comparison utils.c @ 3575:3f8b95c0cc03 libavformat

Remove old hackish codec probe system.
author michael
date Sat, 12 Jul 2008 20:40:47 +0000
parents 23d0cdbf3308
children 3c57739a071d
comparison
equal deleted inserted replaced
3574:23d0cdbf3308 3575:3f8b95c0cc03
1940 int duration_count[MAX_STREAMS]={0}; 1940 int duration_count[MAX_STREAMS]={0};
1941 double (*duration_error)[MAX_STD_TIMEBASES]; 1941 double (*duration_error)[MAX_STD_TIMEBASES];
1942 offset_t old_offset = url_ftell(ic->pb); 1942 offset_t old_offset = url_ftell(ic->pb);
1943 int64_t codec_info_duration[MAX_STREAMS]={0}; 1943 int64_t codec_info_duration[MAX_STREAMS]={0};
1944 int codec_info_nb_frames[MAX_STREAMS]={0}; 1944 int codec_info_nb_frames[MAX_STREAMS]={0};
1945 AVProbeData probe_data[MAX_STREAMS];
1946 int codec_identified[MAX_STREAMS]={0};
1947 1945
1948 duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error)); 1946 duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error));
1949 if (!duration_error) return AVERROR(ENOMEM); 1947 if (!duration_error) return AVERROR(ENOMEM);
1950 1948
1951 for(i=0;i<ic->nb_streams;i++) { 1949 for(i=0;i<ic->nb_streams;i++) {
1967 1965
1968 for(i=0;i<MAX_STREAMS;i++){ 1966 for(i=0;i<MAX_STREAMS;i++){
1969 last_dts[i]= AV_NOPTS_VALUE; 1967 last_dts[i]= AV_NOPTS_VALUE;
1970 } 1968 }
1971 1969
1972 memset(probe_data, 0, sizeof(probe_data));
1973 count = 0; 1970 count = 0;
1974 read_size = 0; 1971 read_size = 0;
1975 for(;;) { 1972 for(;;) {
1976 /* check if one codec still needs to be handled */ 1973 /* check if one codec still needs to be handled */
1977 for(i=0;i<ic->nb_streams;i++) { 1974 for(i=0;i<ic->nb_streams;i++) {
2054 } 2051 }
2055 duration_count[index]++; 2052 duration_count[index]++;
2056 } 2053 }
2057 if(last == AV_NOPTS_VALUE || duration_count[index]<=1) 2054 if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
2058 last_dts[pkt->stream_index]= pkt->dts; 2055 last_dts[pkt->stream_index]= pkt->dts;
2059
2060 if (st->codec->codec_id == CODEC_ID_NONE) {
2061 AVProbeData *pd = &(probe_data[st->index]);
2062 pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);
2063 memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
2064 pd->buf_size += pkt->size;
2065 memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
2066 }
2067 } 2056 }
2068 if(st->parser && st->parser->parser->split && !st->codec->extradata){ 2057 if(st->parser && st->parser->parser->split && !st->codec->extradata){
2069 int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); 2058 int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
2070 if(i){ 2059 if(i){
2071 st->codec->extradata_size= i; 2060 st->codec->extradata_size= i;
2141 st->r_frame_rate.num = st->time_base.den; 2130 st->r_frame_rate.num = st->time_base.den;
2142 st->r_frame_rate.den = st->time_base.num; 2131 st->r_frame_rate.den = st->time_base.num;
2143 } 2132 }
2144 } 2133 }
2145 }else if(st->codec->codec_type == CODEC_TYPE_AUDIO) { 2134 }else if(st->codec->codec_type == CODEC_TYPE_AUDIO) {
2146 if (st->codec->codec_id == CODEC_ID_NONE && probe_data[st->index].buf_size > 0) {
2147 codec_identified[st->index] = set_codec_from_probe_data(st, &(probe_data[st->index]), 1);
2148 if (codec_identified[st->index]) {
2149 st->need_parsing = AVSTREAM_PARSE_FULL;
2150 }
2151 }
2152 if(!st->codec->bits_per_sample) 2135 if(!st->codec->bits_per_sample)
2153 st->codec->bits_per_sample= av_get_bits_per_sample(st->codec->codec_id); 2136 st->codec->bits_per_sample= av_get_bits_per_sample(st->codec->codec_id);
2154 } 2137 }
2155 } 2138 }
2156 2139
2157 av_estimate_timings(ic, old_offset); 2140 av_estimate_timings(ic, old_offset);
2158
2159 for(i=0;i<ic->nb_streams;i++) {
2160 st = ic->streams[i];
2161 if (codec_identified[st->index])
2162 break;
2163 }
2164 //FIXME this is a mess
2165 if(i!=ic->nb_streams){
2166 av_read_frame_flush(ic);
2167 for(i=0;i<ic->nb_streams;i++) {
2168 st = ic->streams[i];
2169 if (codec_identified[st->index]) {
2170 av_seek_frame(ic, st->index, 0.0, 0);
2171 }
2172 st->cur_dts= st->first_dts;
2173 }
2174 url_fseek(ic->pb, ic->data_offset, SEEK_SET);
2175 }
2176 2141
2177 compute_chapters_end(ic); 2142 compute_chapters_end(ic);
2178 2143
2179 #if 0 2144 #if 0
2180 /* correct DTS for B-frame streams with no timestamps */ 2145 /* correct DTS for B-frame streams with no timestamps */
2200 } 2165 }
2201 } 2166 }
2202 #endif 2167 #endif
2203 2168
2204 av_free(duration_error); 2169 av_free(duration_error);
2205 for(i=0;i<MAX_STREAMS;i++){
2206 av_freep(&(probe_data[i].buf));
2207 }
2208 2170
2209 return ret; 2171 return ret;
2210 } 2172 }
2211 2173
2212 /*******************************************************/ 2174 /*******************************************************/