diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-02-19 18:20:13 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-02-19 18:40:27 +0100 |
commit | 2969fb43939e74c632559dc865a9ae542ca9eef8 (patch) | |
tree | 94d97c83123333d56e083d7babfd6c10010c450c /libavformat/utils.c | |
parent | 9c070ae03e159f9d8e68fd1001118b514543e622 (diff) | |
download | ffmpeg-2969fb43939e74c632559dc865a9ae542ca9eef8.tar.gz |
avformat/utils: av_guess_frame_rate() favor avg_frame_rate if r_frame_rate has a comparably unlikely value
Fixes Ticket3399
Fixes Ticket2958
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index e859ad21c7..c4d09e99ac 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4325,10 +4325,16 @@ AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *strea AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame) { AVRational fr = st->r_frame_rate; + AVRational codec_fr = av_inv_q(st->codec->time_base); + AVRational avg_fr = st->avg_frame_rate; + + if (avg_fr.num > 0 && avg_fr.den > 0 && fr.num > 0 && fr.den > 0 && + av_q2d(avg_fr) < 70 && av_q2d(fr) > 210) { + fr = avg_fr; + } + if (st->codec->ticks_per_frame > 1) { - AVRational codec_fr = av_inv_q(st->codec->time_base); - AVRational avg_fr = st->avg_frame_rate; codec_fr.den *= st->codec->ticks_per_frame; if ( codec_fr.num > 0 && codec_fr.den > 0 && av_q2d(codec_fr) < av_q2d(fr)*0.7 && fabs(1.0 - av_q2d(av_div_q(avg_fr, fr))) > 0.1) |