comparison mpegaudiodec.c @ 6694:a2319e5d8bd3 libavcodec

use mpeg4audio common code
author bcoudurier
date Sat, 26 Apr 2008 13:56:52 +0000
parents 25413354a79a
children c3182ffe1689
comparison
equal deleted inserted replaced
6693:6f13852a9161 6694:a2319e5d8bd3
2473 return buf_size; 2473 return buf_size;
2474 } 2474 }
2475 #endif /* CONFIG_MP3ADU_DECODER */ 2475 #endif /* CONFIG_MP3ADU_DECODER */
2476 2476
2477 #ifdef CONFIG_MP3ON4_DECODER 2477 #ifdef CONFIG_MP3ON4_DECODER
2478
2479 #include "mpeg4audio.h"
2480
2478 /* Next 3 arrays are indexed by channel config number (passed via codecdata) */ 2481 /* Next 3 arrays are indexed by channel config number (passed via codecdata) */
2479 static const uint8_t mp3Frames[16] = {0,1,1,2,3,3,4,5,2}; /* number of mp3 decoder instances */ 2482 static const uint8_t mp3Frames[16] = {0,1,1,2,3,3,4,5,2}; /* number of mp3 decoder instances */
2480 static const uint8_t mp3Channels[16] = {0,1,2,3,4,5,6,8,4}; /* total output channels */
2481 /* offsets into output buffer, assume output order is FL FR BL BR C LFE */ 2483 /* offsets into output buffer, assume output order is FL FR BL BR C LFE */
2482 static const uint8_t chan_offset[9][5] = { 2484 static const uint8_t chan_offset[9][5] = {
2483 {0}, 2485 {0},
2484 {0}, // C 2486 {0}, // C
2485 {0}, // FLR 2487 {0}, // FLR
2493 2495
2494 2496
2495 static int decode_init_mp3on4(AVCodecContext * avctx) 2497 static int decode_init_mp3on4(AVCodecContext * avctx)
2496 { 2498 {
2497 MP3On4DecodeContext *s = avctx->priv_data; 2499 MP3On4DecodeContext *s = avctx->priv_data;
2500 MPEG4AudioConfig cfg;
2498 int i; 2501 int i;
2499 2502
2500 if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) { 2503 if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) {
2501 av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n"); 2504 av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n");
2502 return -1; 2505 return -1;
2503 } 2506 }
2504 2507
2505 s->chan_cfg = (((unsigned char *)avctx->extradata)[1] >> 3) & 0x0f; 2508 ff_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size);
2506 s->frames = mp3Frames[s->chan_cfg]; 2509 if (!cfg.chan_config || cfg.chan_config > 7) {
2507 if(!s->frames) {
2508 av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n"); 2510 av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
2509 return -1; 2511 return -1;
2510 } 2512 }
2511 avctx->channels = mp3Channels[s->chan_cfg]; 2513 s->chan_cfg = cfg.chan_config;
2514 s->frames = mp3Frames[s->chan_cfg];
2515 avctx->channels = ff_mpeg4audio_channels[s->chan_cfg];
2512 2516
2513 /* Init the first mp3 decoder in standard way, so that all tables get builded 2517 /* Init the first mp3 decoder in standard way, so that all tables get builded
2514 * We replace avctx->priv_data with the context of the first decoder so that 2518 * We replace avctx->priv_data with the context of the first decoder so that
2515 * decode_init() does not have to be changed. 2519 * decode_init() does not have to be changed.
2516 * Other decoders will be initialized here copying data from the first context 2520 * Other decoders will be initialized here copying data from the first context