Mercurial > libavformat.hg
comparison utils.c @ 1616:dfe8b8bd6833 libavformat
nth try of getting the frame rate detecton working
author | michael |
---|---|
date | Tue, 02 Jan 2007 20:32:01 +0000 |
parents | cab8434bfeab |
children | ad71e733bc20 |
comparison
equal
deleted
inserted
replaced
1615:8e55b4de921c | 1616:dfe8b8bd6833 |
---|---|
1893 if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){ | 1893 if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){ |
1894 double dur= duration * av_q2d(st->time_base); | 1894 double dur= duration * av_q2d(st->time_base); |
1895 | 1895 |
1896 // if(st->codec->codec_type == CODEC_TYPE_VIDEO) | 1896 // if(st->codec->codec_type == CODEC_TYPE_VIDEO) |
1897 // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); | 1897 // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); |
1898 if(duration_count[index] > 0){ | 1898 if(duration_count[index] < 2) |
1899 memset(duration_error, 0, sizeof(duration_error)); | |
1899 for(i=1; i<MAX_STD_TIMEBASES; i++){ | 1900 for(i=1; i<MAX_STD_TIMEBASES; i++){ |
1900 int framerate= get_std_framerate(i); | 1901 int framerate= get_std_framerate(i); |
1901 int ticks= lrintf(dur*framerate/(1001*12)); | 1902 int ticks= lrintf(dur*framerate/(1001*12)); |
1902 double error= dur - ticks*1001*12/(double)framerate; | 1903 double error= dur - ticks*1001*12/(double)framerate; |
1903 duration_error[index][i] += error*error; | 1904 duration_error[index][i] += error*error; |
1904 } | 1905 } |
1905 } | |
1906 duration_count[index]++; | 1906 duration_count[index]++; |
1907 | 1907 |
1908 if(st->codec_info_nb_frames == 0 && 0) | 1908 if(st->codec_info_nb_frames == 0 && 0) |
1909 st->codec_info_duration += duration; | 1909 st->codec_info_duration += duration; |
1910 } | 1910 } |
1958 st = ic->streams[i]; | 1958 st = ic->streams[i]; |
1959 if (st->codec->codec_type == CODEC_TYPE_VIDEO) { | 1959 if (st->codec->codec_type == CODEC_TYPE_VIDEO) { |
1960 if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_sample) | 1960 if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_sample) |
1961 st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); | 1961 st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); |
1962 | 1962 |
1963 if(1 | 1963 if(duration_count[i] |
1964 && (st->codec->time_base.num*101LL <= st->codec->time_base.den || st->codec->codec_id == CODEC_ID_MPEG2VIDEO) /*&& | 1964 && (st->codec->time_base.num*101LL <= st->codec->time_base.den || st->codec->codec_id == CODEC_ID_MPEG2VIDEO) /*&& |
1965 //FIXME we should not special case mpeg2, but this needs testing with non mpeg2 ... | 1965 //FIXME we should not special case mpeg2, but this needs testing with non mpeg2 ... |
1966 st->time_base.num*duration_sum[i]/duration_count[i]*101LL > st->time_base.den*/){ | 1966 st->time_base.num*duration_sum[i]/duration_count[i]*101LL > st->time_base.den*/){ |
1967 double best_error= 2*av_q2d(st->time_base); | 1967 double best_error= 2*av_q2d(st->time_base); |
1968 best_error= best_error*best_error*duration_count[i]*1000*12*30; | 1968 best_error= best_error*best_error*duration_count[i]*1000*12*30; |