Revision 85142724 libavformat/utils.c

View differences:

libavformat/utils.c
2006 2006
    AVStream *st;
2007 2007
    AVPacket pkt1, *pkt;
2008 2008
    int64_t last_dts[MAX_STREAMS];
2009
    int64_t duration_gcd[MAX_STREAMS]={0};
2009 2010
    int duration_count[MAX_STREAMS]={0};
2010 2011
    double (*duration_error)[MAX_STD_TIMEBASES];
2011 2012
    int64_t old_offset = url_ftell(ic->pb);
......
2128 2129
                    duration_error[index][i] += error*error;
2129 2130
                }
2130 2131
                duration_count[index]++;
2132
                // ignore the first 4 values, they might have some random jitter
2133
                if (duration_count[index] > 3)
2134
                    duration_gcd[index] = av_gcd(duration_gcd[index], duration);
2131 2135
            }
2132 2136
            if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
2133 2137
                last_dts[pkt->stream_index]= pkt->dts;
......
2181 2185
            if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample)
2182 2186
                st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
2183 2187

  
2188
            // the check for tb_unreliable() is not completely correct, since this is not about handling
2189
            // a unreliable/inexact time base, but a time base that is finer than necessary, as e.g.
2190
            // ipmovie.c produces.
2191
            if (tb_unreliable(st->codec) && duration_count[i] > 15 && duration_gcd[i] > 1)
2192
                av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * duration_gcd[i], INT_MAX);
2184 2193
            if(duration_count[i]
2185 2194
               && tb_unreliable(st->codec) /*&&
2186 2195
               //FIXME we should not special-case MPEG-2, but this needs testing with non-MPEG-2 ...

Also available in: Unified diff