Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 6698:06f422f73ade libavcodec
correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
author | bcoudurier |
---|---|
date | Sat, 26 Apr 2008 14:18:29 +0000 |
parents | 1310a89b0dcd |
children | 99cf02b8f831 |
comparison
equal
deleted
inserted
replaced
6697:1310a89b0dcd | 6698:06f422f73ade |
---|---|
60 * Context for MP3On4 decoder | 60 * Context for MP3On4 decoder |
61 */ | 61 */ |
62 typedef struct MP3On4DecodeContext { | 62 typedef struct MP3On4DecodeContext { |
63 int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) | 63 int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) |
64 int chan_cfg; ///< channel config number | 64 int chan_cfg; ///< channel config number |
65 int syncword; ///< syncword patch | |
65 MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance | 66 MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance |
66 } MP3On4DecodeContext; | 67 } MP3On4DecodeContext; |
67 | 68 |
68 /* layer 3 "granule" */ | 69 /* layer 3 "granule" */ |
69 typedef struct GranuleDef { | 70 typedef struct GranuleDef { |
2511 } | 2512 } |
2512 s->chan_cfg = cfg.chan_config; | 2513 s->chan_cfg = cfg.chan_config; |
2513 s->frames = mp3Frames[s->chan_cfg]; | 2514 s->frames = mp3Frames[s->chan_cfg]; |
2514 avctx->channels = ff_mpeg4audio_channels[s->chan_cfg]; | 2515 avctx->channels = ff_mpeg4audio_channels[s->chan_cfg]; |
2515 | 2516 |
2517 if (cfg.sample_rate < 16000) | |
2518 s->syncword = 0xffe00000; | |
2519 else | |
2520 s->syncword = 0xfff00000; | |
2521 | |
2516 /* Init the first mp3 decoder in standard way, so that all tables get builded | 2522 /* Init the first mp3 decoder in standard way, so that all tables get builded |
2517 * We replace avctx->priv_data with the context of the first decoder so that | 2523 * We replace avctx->priv_data with the context of the first decoder so that |
2518 * decode_init() does not have to be changed. | 2524 * decode_init() does not have to be changed. |
2519 * Other decoders will be initialized here copying data from the first context | 2525 * Other decoders will be initialized here copying data from the first context |
2520 */ | 2526 */ |
2584 fsize = AV_RB16(buf) >> 4; | 2590 fsize = AV_RB16(buf) >> 4; |
2585 fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); | 2591 fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); |
2586 m = s->mp3decctx[fr]; | 2592 m = s->mp3decctx[fr]; |
2587 assert (m != NULL); | 2593 assert (m != NULL); |
2588 | 2594 |
2589 // Get header | 2595 header = (AV_RB32(buf) & 0x000fffff) | s->syncword; // patch header |
2590 header = AV_RB32(buf) | 0xfff00000; | |
2591 | 2596 |
2592 if (ff_mpa_check_header(header) < 0) { // Bad header, discard block | 2597 if (ff_mpa_check_header(header) < 0) { // Bad header, discard block |
2593 *data_size = 0; | 2598 *data_size = 0; |
2594 return buf_size; | 2599 return buf_size; |
2595 } | 2600 } |