Commit 2969fb43 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/utils: av_guess_frame_rate() favor avg_frame_rate if r_frame_rate has...

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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 9c070ae0
......@@ -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)
......
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