Mercurial > libavformat.hg
comparison utils.c @ 1569:d440e6a53bae libavformat
the next r_frame_rate try ...
discard first duration
accumulate remaining durations
add 15000/1001 and 12000/1001
author | michael |
---|---|
date | Tue, 12 Dec 2006 14:07:46 +0000 |
parents | e2fcff5c3d7d |
children | cffb8f8e1ed6 |
comparison
equal
deleted
inserted
replaced
1568:04aa1ab71309 | 1569:d440e6a53bae |
---|---|
1758 #define MAX_READ_SIZE 5000000 | 1758 #define MAX_READ_SIZE 5000000 |
1759 | 1759 |
1760 /* maximum duration until we stop analysing the stream */ | 1760 /* maximum duration until we stop analysing the stream */ |
1761 #define MAX_STREAM_DURATION ((int)(AV_TIME_BASE * 3.0)) | 1761 #define MAX_STREAM_DURATION ((int)(AV_TIME_BASE * 3.0)) |
1762 | 1762 |
1763 #define MAX_STD_TIMEBASES (60*12+3) | 1763 #define MAX_STD_TIMEBASES (60*12+5) |
1764 static int get_std_framerate(int i){ | 1764 static int get_std_framerate(int i){ |
1765 if(i<60*12) return i*1001; | 1765 if(i<60*12) return i*1001; |
1766 else return ((int[]){24,30,60})[i-60*12]*1000*12; | 1766 else return ((int[]){24,30,60,12,15})[i-60*12]*1000*12; |
1767 } | 1767 } |
1768 | 1768 |
1769 /** | 1769 /** |
1770 * Read the beginning of a media file to get stream information. This | 1770 * Read the beginning of a media file to get stream information. This |
1771 * is useful for file formats with no headers such as MPEG. This | 1771 * is useful for file formats with no headers such as MPEG. This |
1892 if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){ | 1892 if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){ |
1893 double dur= duration * av_q2d(st->time_base); | 1893 double dur= duration * av_q2d(st->time_base); |
1894 | 1894 |
1895 // if(st->codec->codec_type == CODEC_TYPE_VIDEO) | 1895 // if(st->codec->codec_type == CODEC_TYPE_VIDEO) |
1896 // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); | 1896 // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); |
1897 if(duration_count[index] > 0){ | |
1897 for(i=1; i<MAX_STD_TIMEBASES; i++){ | 1898 for(i=1; i<MAX_STD_TIMEBASES; i++){ |
1898 int framerate= get_std_framerate(i); | 1899 int framerate= get_std_framerate(i); |
1899 int ticks= lrintf(dur*framerate/(1001*12)); | 1900 int ticks= lrintf(dur*framerate/(1001*12)); |
1900 double error= dur - ticks*1001*12/(double)framerate; | 1901 double error= dur - ticks*1001*12/(double)framerate; |
1901 duration_error[index][i] += error*error; | 1902 duration_error[index][i] += error*error; |
1902 } | 1903 } |
1904 } | |
1903 duration_count[index]++; | 1905 duration_count[index]++; |
1904 | 1906 |
1905 if(st->codec_info_nb_frames == 0 && 0) | 1907 if(st->codec_info_nb_frames == 0 && 0) |
1906 st->codec_info_duration += duration; | 1908 st->codec_info_duration += duration; |
1907 } | 1909 } |
1908 last_dts[pkt->stream_index]= pkt->dts; | 1910 if(last == AV_NOPTS_VALUE || duration_count[index]<=1) |
1911 last_dts[pkt->stream_index]= pkt->dts; | |
1909 } | 1912 } |
1910 if(st->parser && st->parser->parser->split && !st->codec->extradata){ | 1913 if(st->parser && st->parser->parser->split && !st->codec->extradata){ |
1911 int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); | 1914 int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); |
1912 if(i){ | 1915 if(i){ |
1913 st->codec->extradata_size= i; | 1916 st->codec->extradata_size= i; |