Merge commit 'fb722a900fc5cc9e003b9fef25b27ed7fc5547a2'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 10 Oct 2012 11:51:07 +0000 (13:51 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 10 Oct 2012 11:51:07 +0000 (13:51 +0200)
* commit 'fb722a900fc5cc9e003b9fef25b27ed7fc5547a2':
  avconv: remove -same_quant

Conflicts:
Changelog
doc/faq.texi
ffmpeg.c
ffmpeg.h
ffmpeg_opt.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
Changelog
doc/faq.texi
doc/ffmpeg.texi
ffmpeg.c
ffmpeg.h
ffmpeg_opt.c

diff --cc Changelog
+++ b/Changelog
@@@ -1,26 -1,30 +1,27 @@@
  Entries are sorted chronologically from oldest to youngest within each release,
  releases are sorted from youngest to oldest.
  
 -version <next>:
 +version next:
 +
 +- stream disposition information printing in ffprobe
 +- filter for loudness analysis following EBU R128
 +- Opus encoder using libopus
 +- ffprobe -select_streams option
 +- Pinnacle TARGA CineWave YUV16 decoder
 +- TAK demuxer, decoder and parser
 +- DTS-HD demuxer
++- remove -same_quant, it hasn't worked for years
  
 -- XWD encoder and decoder
 -- Support for fragmentation in the mov/mp4 muxer
 -- ISMV (Smooth Streaming) muxer
 -- CDXL demuxer and decoder
 -- Apple ProRes encoder
 -- Sun Rasterfile Encoder
 -- remove libpostproc
 -- ID3v2 attached pictures reading and writing
 -- WMA Lossless decoder
 -- XBM encoder
 -- RealAudio Lossless decoder
 -- ZeroCodec decoder
 -- drop support for avconv without libavfilter
 -- add libavresample audio conversion library
 -- audio filters support in libavfilter and avconv
 -- add fps filter
 -- audio split filter
 -- audio mix filter
 -- avprobe output is now standard INI or JSON. The old format can still
 -  be used with -of old.
 +
 +version 1.0:
 +
 +- INI and flat output in ffprobe
 +- Scene detection in libavfilter
  - Indeo Audio decoder
  - channelsplit audio filter
 +- setnsamples audio filter
 +- atempo filter
 +- ffprobe -show_data option
  - RTMPT protocol support
  - iLBC encoding/decoding via libilbc
  - Microsoft Screen 1 decoder
diff --cc doc/faq.texi
@@@ -294,14 -231,12 +294,14 @@@ Another option is usage of named pipes
  @example
  mkfifo intermediate1.mpg
  mkfifo intermediate2.mpg
 -avconv -i input1.avi -y intermediate1.mpg < /dev/null &
 -avconv -i input2.avi -y intermediate2.mpg < /dev/null &
 +ffmpeg -i input1.avi -qscale:v 1 -y intermediate1.mpg < /dev/null &
 +ffmpeg -i input2.avi -qscale:v 1 -y intermediate2.mpg < /dev/null &
  cat intermediate1.mpg intermediate2.mpg |\
- ffmpeg -f mpeg -i - -qscale:v 2 -c:v mpeg4 -acodec libmp3lame -q:a 4 output.avi
 -avconv -f mpeg -i - -c:v mpeg4 -acodec libmp3lame output.avi
++ffmpeg -f mpeg -i - -c:v mpeg4 -acodec libmp3lame output.avi
  @end example
  
 +@subsection Concatenating using raw audio and video
 +
  Similarly, the yuv4mpegpipe format, and the raw video, raw audio codecs also
  allow concatenation, and the transcoding step is almost lossless.
  When using multiple yuv4mpegpipe(s), the first line needs to be discarded
@@@ -319,15 -253,15 +319,15 @@@ mkfifo temp2.
  mkfifo temp2.v
  mkfifo all.a
  mkfifo all.v
 -avconv -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
 -avconv -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
 -avconv -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
 -@{ avconv -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; @} &
 +ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
 +ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
 +ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
 +@{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; @} &
  cat temp1.a temp2.a > all.a &
  cat temp1.v temp2.v > all.v &
 -avconv -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
 +ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
         -f yuv4mpegpipe -i all.v \
-        -qscale:v 2 -y output.flv
+        -y output.flv
  rm temp[12].[av] all.[av]
  @end example
  
diff --cc doc/ffmpeg.texi
Simple merge
diff --cc ffmpeg.c
+++ b/ffmpeg.c
@@@ -773,8 -513,8 +773,7 @@@ static void do_subtitle_out(AVFormatCon
  
  static void do_video_out(AVFormatContext *s,
                           OutputStream *ost,
--                         AVFrame *in_picture,
-                          float quality)
 -                         int *frame_size)
++                         AVFrame *in_picture)
  {
      int ret, format_video_sync;
      AVPacket pkt;
@@@ -979,95 -661,125 +976,93 @@@ static void do_video_stats(AVFormatCont
  }
  
  /**
 - * Read one frame for lavfi output for ost and encode it.
 + * Get and encode new output from any of the filtergraphs, without causing
 + * activity.
 + *
 + * @return  0 for success, <0 for severe errors
   */
 -static int poll_filter(OutputStream *ost)
 +static int reap_filters(void)
  {
 -    OutputFile    *of = output_files[ost->file_index];
      AVFilterBufferRef *picref;
      AVFrame *filtered_frame = NULL;
 -    int frame_size, ret;
 -
 -    if (!ost->filtered_frame && !(ost->filtered_frame = avcodec_alloc_frame())) {
 -        return AVERROR(ENOMEM);
 -    } else
 -        avcodec_get_frame_defaults(ost->filtered_frame);
 -    filtered_frame = ost->filtered_frame;
 -
 -    if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
 -        !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE))
 -        ret = av_buffersink_read_samples(ost->filter->filter, &picref,
 -                                         ost->st->codec->frame_size);
 -    else
 -        ret = av_buffersink_read(ost->filter->filter, &picref);
 -
 -    if (ret < 0)
 -        return ret;
 -
 -    avfilter_copy_buf_props(filtered_frame, picref);
 -    if (picref->pts != AV_NOPTS_VALUE) {
 -        filtered_frame->pts = av_rescale_q(picref->pts,
 -                                           ost->filter->filter->inputs[0]->time_base,
 -                                           ost->st->codec->time_base) -
 -                              av_rescale_q(of->start_time,
 -                                           AV_TIME_BASE_Q,
 -                                           ost->st->codec->time_base);
 -
 -        if (of->start_time && filtered_frame->pts < 0) {
 -            avfilter_unref_buffer(picref);
 -            return 0;
 -        }
 -    }
 -
 -    switch (ost->filter->filter->inputs[0]->type) {
 -    case AVMEDIA_TYPE_VIDEO:
 -        if (!ost->frame_aspect_ratio)
 -            ost->st->codec->sample_aspect_ratio = picref->video->pixel_aspect;
 -
 -        do_video_out(of->ctx, ost, filtered_frame, &frame_size);
 -        if (vstats_filename && frame_size)
 -            do_video_stats(of->ctx, ost, frame_size);
 -        break;
 -    case AVMEDIA_TYPE_AUDIO:
 -        do_audio_out(of->ctx, ost, filtered_frame);
 -        break;
 -    default:
 -        // TODO support subtitle filters
 -        av_assert0(0);
 -    }
 -
 -    avfilter_unref_buffer(picref);
 -
 -    return 0;
 -}
 -
 -/**
 - * Read as many frames from possible from lavfi and encode them.
 - *
 - * Always read from the active stream with the lowest timestamp. If no frames
 - * are available for it then return EAGAIN and wait for more input. This way we
 - * can use lavfi sources that generate unlimited amount of frames without memory
 - * usage exploding.
 - */
 -static int poll_filters(void)
 -{
 -    int i, j, ret = 0;
 -
 -    while (ret >= 0 && !received_sigterm) {
 -        OutputStream *ost = NULL;
 -        int64_t min_pts = INT64_MAX;
 +    int i;
 +    int64_t frame_pts;
  
 -        /* choose output stream with the lowest timestamp */
 -        for (i = 0; i < nb_output_streams; i++) {
 -            int64_t pts = output_streams[i]->sync_opts;
 +    /* Reap all buffers present in the buffer sinks */
 +    for (i = 0; i < nb_output_streams; i++) {
 +        OutputStream *ost = output_streams[i];
 +        OutputFile    *of = output_files[ost->file_index];
 +        int ret = 0;
  
 -            if (!output_streams[i]->filter || output_streams[i]->finished)
 -                continue;
 +        if (!ost->filter)
 +            continue;
  
 -            pts = av_rescale_q(pts, output_streams[i]->st->codec->time_base,
 -                               AV_TIME_BASE_Q);
 -            if (pts < min_pts) {
 -                min_pts = pts;
 -                ost = output_streams[i];
 +        if (!ost->filtered_frame && !(ost->filtered_frame = avcodec_alloc_frame())) {
 +            return AVERROR(ENOMEM);
 +        } else
 +            avcodec_get_frame_defaults(ost->filtered_frame);
 +        filtered_frame = ost->filtered_frame;
 +
 +        while (1) {
 +            ret = av_buffersink_get_buffer_ref(ost->filter->filter, &picref,
 +                                               AV_BUFFERSINK_FLAG_NO_REQUEST);
 +            if (ret < 0) {
 +                if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
 +                    char buf[256];
 +                    av_strerror(ret, buf, sizeof(buf));
 +                    av_log(NULL, AV_LOG_WARNING,
 +                           "Error in av_buffersink_get_buffer_ref(): %s\n", buf);
 +                }
 +                break;
              }
 -        }
 -
 -        if (!ost)
 -            break;
 -
 -        ret = poll_filter(ost);
 +            frame_pts = AV_NOPTS_VALUE;
 +            if (picref->pts != AV_NOPTS_VALUE) {
 +                filtered_frame->pts = frame_pts = av_rescale_q(picref->pts,
 +                                                ost->filter->filter->inputs[0]->time_base,
 +                                                ost->st->codec->time_base) -
 +                                    av_rescale_q(of->start_time,
 +                                                AV_TIME_BASE_Q,
 +                                                ost->st->codec->time_base);
 +
 +                if (of->start_time && filtered_frame->pts < 0) {
 +                    avfilter_unref_buffer(picref);
 +                    continue;
 +                }
 +            }
 +            //if (ost->source_index >= 0)
 +            //    *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold
  
 -        if (ret == AVERROR_EOF) {
 -            OutputFile *of = output_files[ost->file_index];
  
 -            ost->finished = 1;
 +            switch (ost->filter->filter->inputs[0]->type) {
 +            case AVMEDIA_TYPE_VIDEO:
 +                avfilter_copy_buf_props(filtered_frame, picref);
 +                filtered_frame->pts = frame_pts;
 +                if (!ost->frame_aspect_ratio)
 +                    ost->st->codec->sample_aspect_ratio = picref->video->sample_aspect_ratio;
  
-                 do_video_out(of->ctx, ost, filtered_frame,
-                              same_quant ? ost->last_quality :
-                                           ost->st->codec->global_quality);
 -            if (of->shortest) {
 -                for (j = 0; j < of->ctx->nb_streams; j++)
 -                    output_streams[of->ost_index + j]->finished = 1;
++                do_video_out(of->ctx, ost, filtered_frame);
 +                break;
 +            case AVMEDIA_TYPE_AUDIO:
 +                avfilter_copy_buf_props(filtered_frame, picref);
 +                filtered_frame->pts = frame_pts;
 +                do_audio_out(of->ctx, ost, filtered_frame);
 +                break;
 +            default:
 +                // TODO support subtitle filters
 +                av_assert0(0);
              }
  
 -            ret = 0;
 -        } else if (ret == AVERROR(EAGAIN))
 -            return 0;
 +            avfilter_unref_buffer(picref);
 +        }
      }
  
 -    return ret;
 +    return 0;
  }
  
 -static void print_report(int is_last_report, int64_t timer_start)
 +static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time)
  {
      char buf[1024];
 +    AVBPrint buf_script;
      OutputStream *ost;
      AVFormatContext *oc;
      int64_t total_size;
@@@ -1554,9 -1219,6 +1549,8 @@@ static int decode_video(InputStream *is
      AVFrame *decoded_frame;
      void *buffer_to_free = NULL;
      int i, ret = 0, resample_changed;
-     float quality;
 +    int64_t best_effort_timestamp;
 +    AVRational *frame_sample_aspect;
  
      if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame()))
          return AVERROR(ENOMEM);
          return ret;
      }
  
-     quality = same_quant ? decoded_frame->quality : 0;
 -    decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts,
 -                                           decoded_frame->pkt_dts);
 +    if(ist->top_field_first>=0)
 +        decoded_frame->top_field_first = ist->top_field_first;
 +
 +    best_effort_timestamp= av_frame_get_best_effort_timestamp(decoded_frame);
 +    if(best_effort_timestamp != AV_NOPTS_VALUE)
 +        ist->next_pts = ist->pts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);
 +
 +    if (debug_ts) {
 +        av_log(NULL, AV_LOG_INFO, "decoder -> ist_index:%d type:video "
 +                "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64" best_effort_ts_time:%s keyframe:%d frame_type:%d \n",
 +                ist->st->index, av_ts2str(decoded_frame->pts),
 +                av_ts2timestr(decoded_frame->pts, &ist->st->time_base),
 +                best_effort_timestamp,
 +                av_ts2timestr(best_effort_timestamp, &ist->st->time_base),
 +                decoded_frame->key_frame, decoded_frame->pict_type);
 +    }
 +
      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 < ist->nb_filters; i++) {
 -        if (ist->st->codec->codec->capabilities & CODEC_CAP_DR1) {
 +        int changed =      ist->st->codec->width   != ist->filters[i]->filter->outputs[0]->w
 +                        || ist->st->codec->height  != ist->filters[i]->filter->outputs[0]->h
 +                        || ist->st->codec->pix_fmt != ist->filters[i]->filter->outputs[0]->format;
-         // XXX what an ugly hack
-         if (ist->filters[i]->graph->nb_outputs == 1)
-             ist->filters[i]->graph->outputs[0]->ost->last_quality = quality;
 +
 +        if (!frame_sample_aspect->num)
 +            *frame_sample_aspect = ist->st->sample_aspect_ratio;
 +        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,
diff --cc ffmpeg.h
+++ b/ffmpeg.h
@@@ -377,10 -342,6 +376,9 @@@ extern int debug_ts
  extern int exit_on_error;
  extern int print_stats;
  extern int qp_hist;
- extern int same_quant;
 +extern int stdin_interaction;
 +extern int frame_bits_per_raw_sample;
 +extern AVIOContext *progress_avio;
  
  extern const AVIOInterruptCB int_cb;
  
diff --cc ffmpeg_opt.c
@@@ -83,23 -71,16 +83,22 @@@ int debug_ts          = 0
  int exit_on_error     = 0;
  int print_stats       = 1;
  int qp_hist           = 0;
- int same_quant        = 0;
 +int stdin_interaction = 1;
 +int frame_bits_per_raw_sample = 0;
  
 +
 +static int intra_only         = 0;
  static int file_overwrite     = 0;
 +static int no_file_overwrite  = 0;
  static int video_discard      = 0;
  static int intra_dc_precision = 8;
 -static int using_stdin        = 0;
 +static int do_psnr            = 0;
  static int input_sync;
  
 -void reset_options(OptionsContext *o)
 +void reset_options(OptionsContext *o, int is_input)
  {
      const OptionDef *po = options;
 +    OptionsContext bak= *o;
      int i;
  
      /* all OPT_SPEC and OPT_STRING can be freed in generic way */
@@@ -2390,14 -1968,8 +2389,10 @@@ const OptionDef options[] = 
          "rate control override for specific intervals", "override" },
      { "vcodec",       OPT_VIDEO | HAS_ARG  | OPT_PERFILE,                        { .func_arg = opt_video_codec },
          "force video codec ('copy' to copy stream)", "codec" },
-     { "sameq",        OPT_VIDEO | OPT_BOOL | OPT_EXPERT ,                        { &same_quant },
-         "use same quantizer as source (implies VBR)" },
-     { "same_quant",   OPT_VIDEO | OPT_BOOL | OPT_EXPERT,                         { &same_quant },
-         "use same quantizer as source (implies VBR)" },
 +    { "timecode",     OPT_VIDEO | HAS_ARG | OPT_PERFILE,                         { .func_arg = opt_timecode },
 +        "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
      { "pass",         OPT_VIDEO | HAS_ARG | OPT_SPEC | OPT_INT,                  { .off = OFFSET(pass) },
 -        "select the pass number (1 or 2)", "n" },
 +        "select the pass number (1 to 3)", "n" },
      { "passlogfile",  OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC,  { .off = OFFSET(passlogfiles) },
          "select two pass log file name prefix", "prefix" },
      { "deinterlace",  OPT_VIDEO | OPT_EXPERT ,                                   { .func_arg = opt_deinterlace },