Mercurial > libavcodec.hg
comparison ac3dec.c @ 9605:93029f1a4c14 libavcodec
ac3dec: move channel remapping to outside of block loop
author | jbr |
---|---|
date | Tue, 05 May 2009 23:38:12 +0000 |
parents | ba5d9a97ab2f |
children | 31090f08314e |
comparison
equal
deleted
inserted
replaced
9604:b8357dc014b0 | 9605:93029f1a4c14 |
---|---|
1233 int buf_size = avpkt->size; | 1233 int buf_size = avpkt->size; |
1234 AC3DecodeContext *s = avctx->priv_data; | 1234 AC3DecodeContext *s = avctx->priv_data; |
1235 int16_t *out_samples = (int16_t *)data; | 1235 int16_t *out_samples = (int16_t *)data; |
1236 int blk, ch, err; | 1236 int blk, ch, err; |
1237 const uint8_t *channel_map; | 1237 const uint8_t *channel_map; |
1238 const float *output[AC3_MAX_CHANNELS]; | |
1238 | 1239 |
1239 /* initialize the GetBitContext with the start of valid AC-3 Frame */ | 1240 /* initialize the GetBitContext with the start of valid AC-3 Frame */ |
1240 if (s->input_buffer) { | 1241 if (s->input_buffer) { |
1241 /* copy input buffer to decoder context to avoid reading past the end | 1242 /* copy input buffer to decoder context to avoid reading past the end |
1242 of the buffer, which can be caused by a damaged input stream. */ | 1243 of the buffer, which can be caused by a damaged input stream. */ |
1324 s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; | 1325 s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; |
1325 } | 1326 } |
1326 | 1327 |
1327 /* decode the audio blocks */ | 1328 /* decode the audio blocks */ |
1328 channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on]; | 1329 channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on]; |
1330 for (ch = 0; ch < s->out_channels; ch++) | |
1331 output[ch] = s->output[channel_map[ch]]; | |
1329 for (blk = 0; blk < s->num_blocks; blk++) { | 1332 for (blk = 0; blk < s->num_blocks; blk++) { |
1330 const float *output[s->out_channels]; | |
1331 if (!err && decode_audio_block(s, blk)) { | 1333 if (!err && decode_audio_block(s, blk)) { |
1332 av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n"); | 1334 av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n"); |
1333 err = 1; | 1335 err = 1; |
1334 } | 1336 } |
1335 for (ch = 0; ch < s->out_channels; ch++) | |
1336 output[ch] = s->output[channel_map[ch]]; | |
1337 s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels); | 1337 s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels); |
1338 out_samples += 256 * s->out_channels; | 1338 out_samples += 256 * s->out_channels; |
1339 } | 1339 } |
1340 *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t); | 1340 *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t); |
1341 return s->frame_size; | 1341 return s->frame_size; |