Merge commit 'db9d39b4b5e5a3c20aeecf787ddeadd88f4906cf'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Mar 2014 01:04:41 +0000 (02:04 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Mar 2014 01:11:47 +0000 (02:11 +0100)
* commit 'db9d39b4b5e5a3c20aeecf787ddeadd88f4906cf':
  avformat: Report the duration analysis reached

Conflicts:
libavformat/utils.c

See: 8529f9b36b7c1b8f2cb36ba2709983517c4b6458
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/utils.c

@@@ -3208,32 -2391,15 +3208,34 @@@ int avformat_find_stream_info(AVFormatC
              }
              st->info->fps_last_dts     = pkt->dts;
              st->info->fps_last_dts_idx = st->codec_info_nb_frames;
 -
 -            /* check max_analyze_duration */
 -            if (av_rescale_q(pkt->dts - st->info->fps_first_dts, st->time_base,
 -                             AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
 -                av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached\n",
 -                       ic->max_analyze_duration);
 +        }
 +        if (st->codec_info_nb_frames>1) {
 +            int64_t t = 0;
 +            if (st->time_base.den > 0)
 +                t = av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q);
 +            if (st->avg_frame_rate.num > 0)
 +                t = FFMAX(t, av_rescale_q(st->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q));
 +
 +            if (   t == 0
 +                && st->codec_info_nb_frames>30
 +                && st->info->fps_first_dts != AV_NOPTS_VALUE
 +                && st->info->fps_last_dts  != AV_NOPTS_VALUE)
 +                t = FFMAX(t, av_rescale_q(st->info->fps_last_dts - st->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q));
 +
 +            if (t >= ic->max_analyze_duration) {
-                 av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %d reached at %"PRId64" microseconds\n", ic->max_analyze_duration, t);
++                av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %d reached at %"PRId64" microseconds\n",
++                       ic->max_analyze_duration,
++                       t);
                  break;
              }
 +            if (pkt->duration) {
 +                st->info->codec_info_duration        += pkt->duration;
 +                st->info->codec_info_duration_fields += st->parser && st->need_parsing && st->codec->ticks_per_frame ==2 ? st->parser->repeat_pict + 1 : 2;
 +            }
          }
 +#if FF_API_R_FRAME_RATE
 +        ff_rfps_add_frame(ic, st, pkt->dts);
 +#endif
          if (st->parser && st->parser->parser->split && !st->codec->extradata) {
              int i = st->parser->parser->split(st->codec, pkt->data, pkt->size);
              if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {