Mercurial > libavcodec.hg
comparison dca.c @ 12145:9109a7e48d6e libavcodec
Move XCH parameters into context structure.
Patch by Nick Brereton $name AT n$surname DOT net
author | benoit |
---|---|
date | Mon, 12 Jul 2010 09:00:17 +0000 |
parents | 8b28e74de2c0 |
children | 36f7c2d7b3fb |
comparison
equal
deleted
inserted
replaced
12144:846779f6b164 | 12145:9109a7e48d6e |
---|---|
285 const int8_t* channel_order_tab; ///< channel reordering table, lfe and non lfe | 285 const int8_t* channel_order_tab; ///< channel reordering table, lfe and non lfe |
286 GetBitContext gb; | 286 GetBitContext gb; |
287 /* Current position in DCA frame */ | 287 /* Current position in DCA frame */ |
288 int current_subframe; | 288 int current_subframe; |
289 int current_subsubframe; | 289 int current_subsubframe; |
290 | |
291 /* XCh extension information */ | |
292 int xch_present; | |
293 int xch_base_channel; ///< index of first (only) channel containing XCH data | |
290 | 294 |
291 int debug_flag; ///< used for suppressing repeated error messages output | 295 int debug_flag; ///< used for suppressing repeated error messages output |
292 DSPContext dsp; | 296 DSPContext dsp; |
293 FFTContext imdct; | 297 FFTContext imdct; |
294 SynthFilterContext synth; | 298 SynthFilterContext synth; |
1258 int buf_size = avpkt->size; | 1262 int buf_size = avpkt->size; |
1259 | 1263 |
1260 int lfe_samples; | 1264 int lfe_samples; |
1261 int num_core_channels = 0; | 1265 int num_core_channels = 0; |
1262 int i; | 1266 int i; |
1263 int xch_present = 0; | |
1264 int16_t *samples = data; | 1267 int16_t *samples = data; |
1265 DCAContext *s = avctx->priv_data; | 1268 DCAContext *s = avctx->priv_data; |
1266 int channels; | 1269 int channels; |
1267 | 1270 |
1268 | 1271 |
1272 s->xch_present = 0; | |
1269 s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE); | 1273 s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE); |
1270 if (s->dca_buffer_size == -1) { | 1274 if (s->dca_buffer_size == -1) { |
1271 av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); | 1275 av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); |
1272 return -1; | 1276 return -1; |
1273 } | 1277 } |
1295 while(get_bits_left(&s->gb) >= 32) { | 1299 while(get_bits_left(&s->gb) >= 32) { |
1296 uint32_t bits = get_bits_long(&s->gb, 32); | 1300 uint32_t bits = get_bits_long(&s->gb, 32); |
1297 | 1301 |
1298 switch(bits) { | 1302 switch(bits) { |
1299 case 0x5a5a5a5a: { | 1303 case 0x5a5a5a5a: { |
1300 int ext_base_ch = s->prim_channels; | |
1301 int ext_amode, xch_fsize; | 1304 int ext_amode, xch_fsize; |
1305 | |
1306 s->xch_base_channel = s->prim_channels; | |
1302 | 1307 |
1303 /* validate sync word using XCHFSIZE field */ | 1308 /* validate sync word using XCHFSIZE field */ |
1304 xch_fsize = show_bits(&s->gb, 10); | 1309 xch_fsize = show_bits(&s->gb, 10); |
1305 if((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) && | 1310 if((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) && |
1306 (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1)) | 1311 (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1)) |
1316 " supported!\n",ext_amode); | 1321 " supported!\n",ext_amode); |
1317 continue; | 1322 continue; |
1318 } | 1323 } |
1319 | 1324 |
1320 /* much like core primary audio coding header */ | 1325 /* much like core primary audio coding header */ |
1321 dca_parse_audio_coding_header(s, ext_base_ch); | 1326 dca_parse_audio_coding_header(s, s->xch_base_channel); |
1322 | 1327 |
1323 for (i = 0; i < (s->sample_blocks / 8); i++) { | 1328 for (i = 0; i < (s->sample_blocks / 8); i++) { |
1324 dca_decode_block(s, ext_base_ch, i); | 1329 dca_decode_block(s, s->xch_base_channel, i); |
1325 } | 1330 } |
1326 | 1331 |
1327 xch_present = 1; | 1332 s->xch_present = 1; |
1328 break; | 1333 break; |
1329 } | 1334 } |
1330 case 0x1d95f262: | 1335 case 0x1d95f262: |
1331 av_log(avctx, AV_LOG_DEBUG, "Possible X96 extension found at %d bits\n", get_bits_count(&s->gb)); | 1336 av_log(avctx, AV_LOG_DEBUG, "Possible X96 extension found at %d bits\n", get_bits_count(&s->gb)); |
1332 av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", get_bits(&s->gb, 12)+1); | 1337 av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", get_bits(&s->gb, 12)+1); |
1340 channels = s->prim_channels + !!s->lfe; | 1345 channels = s->prim_channels + !!s->lfe; |
1341 | 1346 |
1342 if (s->amode<16) { | 1347 if (s->amode<16) { |
1343 avctx->channel_layout = dca_core_channel_layout[s->amode]; | 1348 avctx->channel_layout = dca_core_channel_layout[s->amode]; |
1344 | 1349 |
1345 if (xch_present && (!avctx->request_channels || | 1350 if (s->xch_present && (!avctx->request_channels || |
1346 avctx->request_channels > num_core_channels)) { | 1351 avctx->request_channels > num_core_channels)) { |
1347 avctx->channel_layout |= CH_BACK_CENTER; | 1352 avctx->channel_layout |= CH_BACK_CENTER; |
1348 if (s->lfe) { | 1353 if (s->lfe) { |
1349 avctx->channel_layout |= CH_LOW_FREQUENCY; | 1354 avctx->channel_layout |= CH_LOW_FREQUENCY; |
1350 s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode]; | 1355 s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode]; |