Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 9896:bbefbca72722 libavcodec
Drop code that attempts to decode frames that are prefixed by junk.
Too often it ends up decoding random data into noise without detecting
it (for example after seeking of some MP3 data with oddly often occurring
startcode emulation).
Fixes issue1154.
author | michael |
---|---|
date | Tue, 30 Jun 2009 03:57:27 +0000 |
parents | 875cd15dfd74 |
children | 67b0747c4192 |
comparison
equal
deleted
inserted
replaced
9895:06e12f9b93d7 | 9896:bbefbca72722 |
---|---|
2253 const uint8_t *buf = avpkt->data; | 2253 const uint8_t *buf = avpkt->data; |
2254 int buf_size = avpkt->size; | 2254 int buf_size = avpkt->size; |
2255 MPADecodeContext *s = avctx->priv_data; | 2255 MPADecodeContext *s = avctx->priv_data; |
2256 uint32_t header; | 2256 uint32_t header; |
2257 int out_size; | 2257 int out_size; |
2258 int skipped = 0; | |
2259 OUT_INT *out_samples = data; | 2258 OUT_INT *out_samples = data; |
2260 | 2259 |
2261 retry: | |
2262 if(buf_size < HEADER_SIZE) | 2260 if(buf_size < HEADER_SIZE) |
2263 return -1; | 2261 return -1; |
2264 | 2262 |
2265 header = AV_RB32(buf); | 2263 header = AV_RB32(buf); |
2266 if(ff_mpa_check_header(header) < 0){ | 2264 if(ff_mpa_check_header(header) < 0){ |
2267 buf++; | 2265 av_log(avctx, AV_LOG_ERROR, "Header missing\n"); |
2268 buf_size--; | 2266 return -1; |
2269 skipped++; | |
2270 av_log(avctx, AV_LOG_ERROR, "Header missing skipping one byte.\n"); | |
2271 goto retry; | |
2272 } | 2267 } |
2273 | 2268 |
2274 if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { | 2269 if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { |
2275 /* free format: prepare to compute frame size */ | 2270 /* free format: prepare to compute frame size */ |
2276 s->frame_size = -1; | 2271 s->frame_size = -1; |
2295 avctx->sample_rate = s->sample_rate; | 2290 avctx->sample_rate = s->sample_rate; |
2296 //FIXME maybe move the other codec info stuff from above here too | 2291 //FIXME maybe move the other codec info stuff from above here too |
2297 }else | 2292 }else |
2298 av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed | 2293 av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed |
2299 s->frame_size = 0; | 2294 s->frame_size = 0; |
2300 return buf_size + skipped; | 2295 return buf_size; |
2301 } | 2296 } |
2302 | 2297 |
2303 static void flush(AVCodecContext *avctx){ | 2298 static void flush(AVCodecContext *avctx){ |
2304 MPADecodeContext *s = avctx->priv_data; | 2299 MPADecodeContext *s = avctx->priv_data; |
2305 memset(s->synth_buf, 0, sizeof(s->synth_buf)); | 2300 memset(s->synth_buf, 0, sizeof(s->synth_buf)); |