comparison ac3dec.c @ 7011:77f607fb4e8b libavcodec

get the number of blocks from the ac3 parser and use in the ac3 decoder.
author jbr
date Sat, 07 Jun 2008 22:29:03 +0000
parents 3d84a99ecfa7
children 4156c54aedba
comparison
equal deleted inserted replaced
7010:942e0bd99179 7011:77f607fb4e8b
109 #define CPL_CH 0 109 #define CPL_CH 0
110 110
111 #define AC3_OUTPUT_LFEON 8 111 #define AC3_OUTPUT_LFEON 8
112 112
113 typedef struct { 113 typedef struct {
114 int num_blocks; ///< number of audio blocks
114 int channel_mode; ///< channel mode (acmod) 115 int channel_mode; ///< channel mode (acmod)
115 int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags 116 int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags
116 int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags 117 int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags
117 int dither_all; ///< true if all channels are dithered 118 int dither_all; ///< true if all channels are dithered
118 int cpl_in_use; ///< coupling in use 119 int cpl_in_use; ///< coupling in use
322 s->fbw_channels = s->channels - s->lfe_on; 323 s->fbw_channels = s->channels - s->lfe_on;
323 s->lfe_ch = s->fbw_channels + 1; 324 s->lfe_ch = s->fbw_channels + 1;
324 s->frame_size = hdr.frame_size; 325 s->frame_size = hdr.frame_size;
325 s->center_mix_level = hdr.center_mix_level; 326 s->center_mix_level = hdr.center_mix_level;
326 s->surround_mix_level = hdr.surround_mix_level; 327 s->surround_mix_level = hdr.surround_mix_level;
328 s->num_blocks = hdr.num_blocks;
327 329
328 if(s->lfe_on) { 330 if(s->lfe_on) {
329 s->start_freq[s->lfe_ch] = 0; 331 s->start_freq[s->lfe_ch] = 0;
330 s->end_freq[s->lfe_ch] = 7; 332 s->end_freq[s->lfe_ch] = 7;
331 s->num_exp_groups[s->lfe_ch] = 2; 333 s->num_exp_groups[s->lfe_ch] = 2;
1204 if(s->out_channels < s->channels) 1206 if(s->out_channels < s->channels)
1205 s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; 1207 s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
1206 } 1208 }
1207 1209
1208 /* parse the audio blocks */ 1210 /* parse the audio blocks */
1209 for (blk = 0; blk < NB_BLOCKS; blk++) { 1211 for (blk = 0; blk < s->num_blocks; blk++) {
1210 if (!err && ac3_parse_audio_block(s, blk)) { 1212 if (!err && ac3_parse_audio_block(s, blk)) {
1211 av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); 1213 av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n");
1212 } 1214 }
1213 1215
1214 /* interleave output samples */ 1216 /* interleave output samples */
1215 for (i = 0; i < 256; i++) 1217 for (i = 0; i < 256; i++)
1216 for (ch = 0; ch < s->out_channels; ch++) 1218 for (ch = 0; ch < s->out_channels; ch++)
1217 *(out_samples++) = s->int_output[ch][i]; 1219 *(out_samples++) = s->int_output[ch][i];
1218 } 1220 }
1219 *data_size = NB_BLOCKS * 256 * avctx->channels * sizeof (int16_t); 1221 *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
1220 return s->frame_size; 1222 return s->frame_size;
1221 } 1223 }
1222 1224
1223 /** 1225 /**
1224 * Uninitialize the AC-3 decoder. 1226 * Uninitialize the AC-3 decoder.