Mercurial > libavcodec.hg
comparison dca.c @ 12286:91e45d11dd6e libavcodec
Setup correct channel value when downmixing is required.
Patch by Nick Brereton
author | banan |
---|---|
date | Tue, 27 Jul 2010 21:44:09 +0000 |
parents | 6d7a12293959 |
children | 67cb57c918b6 |
comparison
equal
deleted
inserted
replaced
12285:de55a539a2e1 | 12286:91e45d11dd6e |
---|---|
1346 | 1346 |
1347 if (s->amode<16) { | 1347 if (s->amode<16) { |
1348 avctx->channel_layout = dca_core_channel_layout[s->amode]; | 1348 avctx->channel_layout = dca_core_channel_layout[s->amode]; |
1349 | 1349 |
1350 if (s->xch_present && (!avctx->request_channels || | 1350 if (s->xch_present && (!avctx->request_channels || |
1351 avctx->request_channels > num_core_channels)) { | 1351 avctx->request_channels > num_core_channels + !!s->lfe)) { |
1352 avctx->channel_layout |= CH_BACK_CENTER; | 1352 avctx->channel_layout |= CH_BACK_CENTER; |
1353 if (s->lfe) { | 1353 if (s->lfe) { |
1354 avctx->channel_layout |= CH_LOW_FREQUENCY; | 1354 avctx->channel_layout |= CH_LOW_FREQUENCY; |
1355 s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode]; | 1355 s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode]; |
1356 } else { | 1356 } else { |
1357 s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode]; | 1357 s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode]; |
1358 } | 1358 } |
1359 } else { | 1359 } else { |
1360 channels = num_core_channels + !!s->lfe; | |
1361 s->xch_present = 0; /* disable further xch processing */ | |
1360 if (s->lfe) { | 1362 if (s->lfe) { |
1361 avctx->channel_layout |= CH_LOW_FREQUENCY; | 1363 avctx->channel_layout |= CH_LOW_FREQUENCY; |
1362 s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; | 1364 s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; |
1363 } else | 1365 } else |
1364 s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; | 1366 s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; |
1365 } | 1367 } |
1366 | 1368 |
1367 if (s->prim_channels > 0 && | 1369 if (channels > !!s->lfe && |
1368 s->channel_order_tab[s->prim_channels - 1] < 0) | 1370 s->channel_order_tab[channels - 1 - !!s->lfe] < 0) |
1369 return -1; | 1371 return -1; |
1370 | 1372 |
1371 if (avctx->request_channels == 2 && s->prim_channels > 2) { | 1373 if (avctx->request_channels == 2 && s->prim_channels > 2) { |
1372 channels = 2; | 1374 channels = 2; |
1373 s->output = DCA_STEREO; | 1375 s->output = DCA_STEREO; |
1382 /* There is nothing that prevents a dts frame to change channel configuration | 1384 /* There is nothing that prevents a dts frame to change channel configuration |
1383 but FFmpeg doesn't support that so only set the channels if it is previously | 1385 but FFmpeg doesn't support that so only set the channels if it is previously |
1384 unset. Ideally during the first probe for channels the crc should be checked | 1386 unset. Ideally during the first probe for channels the crc should be checked |
1385 and only set avctx->channels when the crc is ok. Right now the decoder could | 1387 and only set avctx->channels when the crc is ok. Right now the decoder could |
1386 set the channels based on a broken first frame.*/ | 1388 set the channels based on a broken first frame.*/ |
1387 if (!avctx->channels) | 1389 avctx->channels = channels; |
1388 avctx->channels = channels; | |
1389 | 1390 |
1390 if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) | 1391 if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) |
1391 return -1; | 1392 return -1; |
1392 *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels; | 1393 *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels; |
1393 | 1394 |