Commit 45bd0d15 authored by Michael Niedermayer's avatar Michael Niedermayer

lavf: fix fps detection with PAFF H.264

Fixes Ticket1065
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 572781b2
...@@ -743,6 +743,7 @@ typedef struct AVStream { ...@@ -743,6 +743,7 @@ typedef struct AVStream {
int duration_count; int duration_count;
double duration_error[2][2][MAX_STD_TIMEBASES]; double duration_error[2][2][MAX_STD_TIMEBASES];
int64_t codec_info_duration; int64_t codec_info_duration;
int64_t codec_info_duration_fields;
int found_decoder; int found_decoder;
/** /**
......
...@@ -2685,7 +2685,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) ...@@ -2685,7 +2685,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached at %"PRId64"\n", ic->max_analyze_duration, t); av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached at %"PRId64"\n", ic->max_analyze_duration, t);
break; break;
} }
if (pkt->duration) {
st->info->codec_info_duration += pkt->duration; st->info->codec_info_duration += pkt->duration;
st->info->codec_info_duration_fields += st->parser && st->codec->ticks_per_frame==2 ? st->parser->repeat_pict + 1 : 2;
}
} }
#if FF_API_R_FRAME_RATE #if FF_API_R_FRAME_RATE
{ {
...@@ -2796,13 +2799,13 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) ...@@ -2796,13 +2799,13 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
} }
/* estimate average framerate if not set by demuxer */ /* estimate average framerate if not set by demuxer */
if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration) { if (st->info->codec_info_duration_fields && !st->avg_frame_rate.num && st->info->codec_info_duration) {
int best_fps = 0; int best_fps = 0;
double best_error = 0.01; double best_error = 0.01;
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
(st->codec_info_nb_frames-2)*(int64_t)st->time_base.den, st->info->codec_info_duration_fields*(int64_t)st->time_base.den,
st->info->codec_info_duration*(int64_t)st->time_base.num, 60000); st->info->codec_info_duration*2*(int64_t)st->time_base.num, 60000);
/* round guessed framerate to a "standard" framerate if it's /* round guessed framerate to a "standard" framerate if it's
* within 1% of the original estimate*/ * within 1% of the original estimate*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment