Revision 730ba406

View differences:

libavformat/utils.c
1873 1873
                    duration_sum[index]= duration;
1874 1874
                    duration_count[index]=1;
1875 1875
                }else{
1876
                    int factor= av_rescale(duration, duration_count[index], duration_sum[index]);
1876
                    int factor= av_rescale(2*duration, duration_count[index], duration_sum[index]);
1877
                    if(factor==3)
1878
                         duration_count[index] *= 2;
1879
                    factor= av_rescale(duration, duration_count[index], duration_sum[index]);
1877 1880
                    duration_sum[index] += duration;
1878 1881
                    duration_count[index]+= factor;
1879 1882
                }
......
1931 1934
            if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_sample)
1932 1935
                st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
1933 1936

  
1934
            if(duration_count[i] && st->codec->time_base.num*101LL <= st->codec->time_base.den &&
1937
            if(duration_count[i]
1938
               && (st->codec->time_base.num*101LL <= st->codec->time_base.den || st->codec->codec_id == CODEC_ID_MPEG2VIDEO) &&
1939
               //FIXME we should not special case mpeg2, but this needs testing with non mpeg2 ...
1935 1940
               st->time_base.num*duration_sum[i]/duration_count[i]*101LL > st->time_base.den){
1936 1941
                int64_t num, den, error, best_error;
1937 1942

  
......
1946 1951
                        av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, j, 12, INT_MAX);
1947 1952
                    }
1948 1953
                }
1949
                for(j=24; j<=30; j+=6){
1950
                    error= ABS(1001*12*num - 1000*12*j*den);
1954
                for(j=0; j<3; j++){
1955
                    static const int ticks[]= {24,30,60};
1956
                    error= ABS(1001*12*num - 1000*12*den * ticks[j]);
1951 1957
                    if(error < best_error){
1952 1958
                        best_error= error;
1953
                        av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, j*1000, 1001, INT_MAX);
1959
                        av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, ticks[j]*1000, 1001, INT_MAX);
1954 1960
                    }
1955 1961
                }
1956 1962
            }

Also available in: Unified diff