Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 9 Apr 2012 20:48:20 +0000 (22:48 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 9 Apr 2012 21:02:33 +0000 (23:02 +0200)
* qatar/master:
  avconv: use default alignment for audio buffer
  avcodec: use align == 0 for default alignment in avcodec_fill_audio_frame()
  avutil: use align == 0 for default alignment in audio sample buffer functions
  avutil: allow NULL linesize in av_samples_fill_arrays() and av_samples_alloc()
  avconv: remove OutputStream.picref.
  avconv: only set SAR once on the decoded frame.
  avcodec: validate the channel layout vs. channel count for decoders
  audioconvert: make av_get_channel_layout accept composite names.
  avutil: add av_get_packed_sample_fmt() and av_get_planar_sample_fmt()

Conflicts:
doc/APIchanges
ffmpeg.c
libavcodec/utils.c
libavcodec/version.h
libavutil/audioconvert.c
libavutil/audioconvert.h
libavutil/avutil.h
libavutil/samplefmt.c
libavutil/samplefmt.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
doc/APIchanges
ffmpeg.c
libavcodec/avcodec.h
libavcodec/utils.c
libavcodec/version.h
libavutil/audioconvert.c
libavutil/audioconvert.h
libavutil/avutil.h
libavutil/samplefmt.c
libavutil/samplefmt.h

diff --cc doc/APIchanges
@@@ -13,33 -12,14 +13,36 @@@ libavutil:   2011-04-1
  
  API changes, most recent first:
  
 -2012-xx-xx - xxxxxxx - lavu 51.26.0 - audioconvert.h
 -  Add av_get_default_channel_layout()
 +2012-03-26 - a67d9cf - lavfi 2.66.100
 +  Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
 +
+ 2012-xx-xx - xxxxxxx - lavu 51.27.0 - samplefmt.h
+   Add av_get_packed_sample_fmt() and av_get_planar_sample_fmt()
 +2012-03-21 - b75c67d - lavu 51.43.100
 +  Add bprint.h for bprint API.
 +
 +2012-02-21 - 9cbf17e - lavc 54.4.100
 +  Add av_get_pcm_codec() function.
 +
 +2012-02-16 - 560b224 - libswr 0.7.100
 +  Add swr_set_matrix() function.
 +
 +2012-02-09 - c28e7af - lavu 51.39.100
 +  Add a new installed header libavutil/timestamp.h with timestamp
 +  utilities.
 +
 +2012-02-06 - 70ffda3 - lavu 51.38.100
 +  Add av_parse_ratio() function to parseutils.h.
  
 -2012-03-06 - 4d851f8 - lavu 51.25.0 - cpu.h
 -  Add av_set_cpu_flags_mask().
 +2012-02-06 - 70ffda3 - lavu 51.38.100
 +  Add AV_LOG_MAX_OFFSET macro to log.h.
 +
 +2012-02-02 - 0eaa123 - lavu 51.37.100
 +  Add public timecode helpers.
 +
 +2012-01-24 - 0c3577b - lavfi 2.60.100
 +  Add avfilter_graph_dump.
  
  2012-03-05 - lavc 54.8.0
    6699d07 Add av_get_exact_bits_per_sample()
diff --cc ffmpeg.c
+++ b/ffmpeg.c
@@@ -268,11 -241,8 +268,10 @@@ typedef struct OutputStream 
      AVFifoBuffer *fifo;     /* for compression: one audio fifo per codec */
      FILE *logfile;
  
 +    SwrContext *swr;
 +
      AVFilterContext *output_video_filter;
      AVFilterContext *input_video_filter;
-     AVFilterBufferRef *picref;
      char *avfilter;
      AVFilterGraph *graph;
  
@@@ -2073,76 -1905,87 +2072,80 @@@ static int transcode_video(InputStream 
          /* no picture yet */
          return ret;
      }
 -    decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts,
 -                                           decoded_frame->pkt_dts);
 +
 +    best_effort_timestamp= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "best_effort_timestamp");
 +    if(*best_effort_timestamp != AV_NOPTS_VALUE)
 +        ist->next_pts = ist->pts = decoded_frame->pts = *best_effort_timestamp;
 +
      pkt->size = 0;
 +
      pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free);
  
 +    frame_sample_aspect= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "sample_aspect_ratio");
 +    for(i=0;i<nb_output_streams;i++) {
 +        OutputStream *ost = ost = &output_streams[i];
 +        if(check_output_constraints(ist, ost) && ost->encoding_needed){
 +            int changed =    ist->st->codec->width   != ost->input_video_filter->outputs[0]->w
 +                          || ist->st->codec->height  != ost->input_video_filter->outputs[0]->h
 +                          || ist->st->codec->pix_fmt != ost->input_video_filter->outputs[0]->format;
 +            if (!frame_sample_aspect->num)
 +                *frame_sample_aspect = ist->st->sample_aspect_ratio;
 +            decoded_frame->pts = ist->pts;
 +            if (ist->dr1 && decoded_frame->type==FF_BUFFER_TYPE_USER && !changed) {
 +                FrameBuffer      *buf = decoded_frame->opaque;
 +                AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays(
 +                                            decoded_frame->data, decoded_frame->linesize,
 +                                            AV_PERM_READ | AV_PERM_PRESERVE,
 +                                            ist->st->codec->width, ist->st->codec->height,
 +                                            ist->st->codec->pix_fmt);
 +
 +                avfilter_copy_frame_props(fb, decoded_frame);
 +                fb->buf->priv           = buf;
 +                fb->buf->free           = filter_release_buffer;
 +
 +                buf->refcount++;
 +                av_buffersrc_buffer(ost->input_video_filter, fb);
 +            } else
 +            if((av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE)) < 0){
 +                av_log(NULL, AV_LOG_FATAL, "Failed to inject frame into filter network\n");
 +                exit_program(1);
 +            }
 +        }
 +    }
 +
      rate_emu_sleep(ist);
  
+     if (ist->st->sample_aspect_ratio.num)
+         decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
      for (i = 0; i < nb_output_streams; i++) {
          OutputStream *ost = &output_streams[i];
 -        int frame_size, resample_changed;
  
          if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
              continue;
  
 -        resample_changed = ost->resample_width   != decoded_frame->width  ||
 -                           ost->resample_height  != decoded_frame->height ||
 -                           ost->resample_pix_fmt != decoded_frame->format;
 -        if (resample_changed) {
 -            av_log(NULL, AV_LOG_INFO,
 -                    "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
 -                    ist->file_index, ist->st->index,
 -                    ost->resample_width,  ost->resample_height,  av_get_pix_fmt_name(ost->resample_pix_fmt),
 -                    decoded_frame->width, decoded_frame->height, av_get_pix_fmt_name(decoded_frame->format));
 -
 -            avfilter_graph_free(&ost->graph);
 -            if (configure_video_filters(ist, ost)) {
 -                av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n");
 -                exit_program(1);
 -            }
 -
 -            ost->resample_width   = decoded_frame->width;
 -            ost->resample_height  = decoded_frame->height;
 -            ost->resample_pix_fmt = decoded_frame->format;
 -        }
 -
 -        if (ist->st->codec->codec->capabilities & CODEC_CAP_DR1) {
 -            FrameBuffer      *buf = decoded_frame->opaque;
 -            AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays(
 -                                        decoded_frame->data, decoded_frame->linesize,
 -                                        AV_PERM_READ | AV_PERM_PRESERVE,
 -                                        ist->st->codec->width, ist->st->codec->height,
 -                                        ist->st->codec->pix_fmt);
 -
 -            avfilter_copy_frame_props(fb, decoded_frame);
 -            fb->buf->priv           = buf;
 -            fb->buf->free           = filter_release_buffer;
 -
 -            buf->refcount++;
 -            av_buffersrc_buffer(ost->input_video_filter, fb);
 -        } else
 -            av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame,
 -                                     decoded_frame->pts, decoded_frame->sample_aspect_ratio);
 -
 -        if (!ist->filtered_frame && !(ist->filtered_frame = avcodec_alloc_frame())) {
 -            ret = AVERROR(ENOMEM);
 -            goto fail;
 -        } else
 -            avcodec_get_frame_defaults(ist->filtered_frame);
 -        filtered_frame = ist->filtered_frame;
 -
 -        frame_available = avfilter_poll_frame(ost->output_video_filter->inputs[0]);
 -        while (frame_available) {
 +        while (av_buffersink_poll_frame(ost->output_video_filter)) {
 +            AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;
 +            AVFrame *filtered_frame;
+             AVFilterBufferRef *picref;
 -            AVRational ist_pts_tb;
 -            if ((ret = get_filtered_video_frame(ost->output_video_filter,
 -                                                filtered_frame, &picref,
 -                                                &ist_pts_tb)) < 0)
 +
-             if (av_buffersink_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0){
++            if (av_buffersink_get_buffer_ref(ost->output_video_filter, &picref, 0) < 0){
 +                av_log(NULL, AV_LOG_WARNING, "AV Filter told us it has a frame available but failed to output one\n");
 +                goto cont;
 +            }
 +            if (!ist->filtered_frame && !(ist->filtered_frame = avcodec_alloc_frame())) {
 +                ret = AVERROR(ENOMEM);
                  goto fail;
-             avfilter_fill_frame_from_video_buffer_ref(filtered_frame, ost->picref);
-             filtered_frame->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
 +            }
 +            filtered_frame = ist->filtered_frame;
 +            *filtered_frame= *decoded_frame; //for me_threshold
++            avfilter_fill_frame_from_video_buffer_ref(filtered_frame, picref);
+             filtered_frame->pts = av_rescale_q(picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
              if (!ost->frame_aspect_ratio)
-                 ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
 -                ost->st->codec->sample_aspect_ratio = picref->video->pixel_aspect;
 -
 -            do_video_out(output_files[ost->file_index].ctx, ost, filtered_frame, &frame_size,
 -                         same_quant ? quality : ost->st->codec->global_quality);
 -            if (vstats_filename && frame_size)
 -                do_video_stats(output_files[ost->file_index].ctx, ost, frame_size);
 -            frame_available = ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);
++                ost->st->codec->sample_aspect_ratio = picref->video->sample_aspect_ratio;
 +            do_video_out(output_files[ost->file_index].ctx, ost, ist, filtered_frame);
 +            cont:
-             avfilter_unref_buffer(ost->picref);
+             avfilter_unref_buffer(picref);
          }
      }
  
Simple merge
@@@ -913,10 -811,14 +913,18 @@@ int attribute_align_arg avcodec_open2(A
          }
      }
  
-     if (av_codec_is_decoder(avctx->codec) && !avctx->bit_rate)
-         avctx->bit_rate = get_bit_rate(avctx);
 +    ret=0;
++
+     if (av_codec_is_decoder(avctx->codec)) {
++        if (!avctx->bit_rate)
++            avctx->bit_rate = get_bit_rate(avctx);
+         /* validate channel layout from the decoder */
+         if (avctx->channel_layout &&
+             av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
+             av_log(avctx, AV_LOG_WARNING, "channel layout does not match number of channels\n");
+             avctx->channel_layout = 0;
+         }
+     }
  end:
      entangled_thread_counter--;
  
@@@ -21,8 -21,8 +21,8 @@@
  #define AVCODEC_VERSION_H
  
  #define LIBAVCODEC_VERSION_MAJOR 54
 -#define LIBAVCODEC_VERSION_MINOR 11
 -#define LIBAVCODEC_VERSION_MICRO  1
 +#define LIBAVCODEC_VERSION_MINOR  14
- #define LIBAVCODEC_VERSION_MICRO 100
++#define LIBAVCODEC_VERSION_MICRO 101
  
  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                 LIBAVCODEC_VERSION_MINOR, \
@@@ -74,13 -75,12 +74,12 @@@ static const struct 
      { "4.0",         4,  AV_CH_LAYOUT_4POINT0 },
      { "quad",        4,  AV_CH_LAYOUT_QUAD },
      { "quad(side)",  4,  AV_CH_LAYOUT_2_2 },
 -    { "4.1",         5,  AV_CH_LAYOUT_4POINT1 },
 -    { "5.0",         5,  AV_CH_LAYOUT_5POINT0 },
 +    { "3.1",         4,  AV_CH_LAYOUT_3POINT1 },
      { "5.0",         5,  AV_CH_LAYOUT_5POINT0_BACK },
 -    { "5.1",         6,  AV_CH_LAYOUT_5POINT1 },
 +    { "5.0(side)",   5,  AV_CH_LAYOUT_5POINT0 },
 +    { "4.1",         5,  AV_CH_LAYOUT_4POINT1 },
      { "5.1",         6,  AV_CH_LAYOUT_5POINT1_BACK },
- //     { "5.1+downmix", 8,  AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
 +    { "5.1(side)",   6,  AV_CH_LAYOUT_5POINT1 },
      { "6.0",         6,  AV_CH_LAYOUT_6POINT0 },
      { "6.0(front)",  6,  AV_CH_LAYOUT_6POINT0_FRONT },
      { "hexagonal",   6,  AV_CH_LAYOUT_HEXAGONAL },
      { "7.0(front)",  7,  AV_CH_LAYOUT_7POINT0_FRONT },
      { "7.1",         8,  AV_CH_LAYOUT_7POINT1 },
      { "7.1(wide)",   8,  AV_CH_LAYOUT_7POINT1_WIDE },
- //     { "7.1+downmix", 10, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
 -    { "7.1(wide)",   8,  AV_CH_LAYOUT_7POINT1_WIDE_BACK },
      { "octagonal",   8,  AV_CH_LAYOUT_OCTAGONAL },
      { "downmix",     2,  AV_CH_LAYOUT_STEREO_DOWNMIX, },
 -    { 0 }
  };
  
  static uint64_t get_channel_layout_single(const char *name, int name_len)
Simple merge
   */
  
  #define LIBAVUTIL_VERSION_MAJOR 51
- #define LIBAVUTIL_VERSION_MINOR 45
 -#define LIBAVUTIL_VERSION_MINOR 27
 -#define LIBAVUTIL_VERSION_MICRO  2
++#define LIBAVUTIL_VERSION_MINOR 46
 +#define LIBAVUTIL_VERSION_MICRO 100
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                 LIBAVUTIL_VERSION_MINOR, \
@@@ -60,15 -60,24 +60,33 @@@ enum AVSampleFormat av_get_sample_fmt(c
      return AV_SAMPLE_FMT_NONE;
  }
  
 +enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar)
 +{
 +    if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
 +        return AV_SAMPLE_FMT_NONE;
 +    if (sample_fmt_info[sample_fmt].planar == planar)
 +        return sample_fmt;
 +    return sample_fmt_info[sample_fmt].altform;
 +}
 +
+ enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
+ {
+     if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
+         return AV_SAMPLE_FMT_NONE;
+     if (sample_fmt_info[sample_fmt].planar)
+         return sample_fmt_info[sample_fmt].altform;
+     return sample_fmt;
+ }
+ enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
+ {
+     if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
+         return AV_SAMPLE_FMT_NONE;
+     if (sample_fmt_info[sample_fmt].planar)
+         return sample_fmt;
+     return sample_fmt_info[sample_fmt].altform;
+ }
  char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt)
  {
      /* print header */
@@@ -54,14 -54,28 +54,36 @@@ const char *av_get_sample_fmt_name(enu
  enum AVSampleFormat av_get_sample_fmt(const char *name);
  
  /**
 + * Return the planar<->packed alternative form of the given sample format, or
 + * AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the
 + * requested planar/packed format, the format returned is the same as the
 + * input.
 + */
 +enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar);
 +
 +/**
+  * Get the packed alternative form of the given sample format.
+  *
+  * If the passed sample_fmt is already in packed format, the format returned is
+  * the same as the input.
+  *
+  * @return  the packed alternative form of the given sample format or
+             AV_SAMPLE_FMT_NONE on error.
+  */
+ enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt);
+ /**
+  * Get the planar alternative form of the given sample format.
+  *
+  * If the passed sample_fmt is already in planar format, the format returned is
+  * the same as the input.
+  *
+  * @return  the planar alternative form of the given sample format or
+             AV_SAMPLE_FMT_NONE on error.
+  */
+ enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt);
+ /**
   * Generate a string corresponding to the sample format with
   * sample_fmt, or a header if sample_fmt is negative.
   *