summaryrefslogtreecommitdiff
path: root/libavcodec/dca.c
diff options
context:
space:
mode:
authorNick Brereton <nick@nbrereton.net>2010-07-12 09:10:53 +0000
committerBenoit Fouet <benoit.fouet@free.fr>2010-07-12 09:10:53 +0000
commitb12b16c5d35adaba0979a7c2fa76b88e48f5f839 (patch)
tree97d0b8f565f4f8aa98009fa0456242617d6b4e77 /libavcodec/dca.c
parentd0a188501899a5aa613a950354caa9e15cb3ea35 (diff)
downloadffmpeg-b12b16c5d35adaba0979a7c2fa76b88e48f5f839.tar.gz
Fix side channels when XCh extension is present.
Patch by Nick Brereton $name AT n$surname DOT net Originally committed as revision 24210 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/dca.c')
-rw-r--r--libavcodec/dca.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index 073b1c2386..b81094a000 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -1394,6 +1394,20 @@ static int dca_decode_frame(AVCodecContext * avctx,
/* filter to get final output */
for (i = 0; i < (s->sample_blocks / 8); i++) {
dca_filter_channels(s, i);
+
+ /* If this was marked as a DTS-ES stream we need to subtract back- */
+ /* channel from SL & SR to remove matrixed back-channel signal */
+ if((s->source_pcm_res & 1) && s->xch_present) {
+ float* back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256;
+ float* lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256;
+ float* rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256;
+ int j;
+ for(j = 0; j < 256; ++j) {
+ lt_chan[j] -= (back_chan[j] - s->add_bias) * 0.707107f;
+ rt_chan[j] -= (back_chan[j] - s->add_bias) * 0.707107f;
+ }
+ }
+
s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
samples += 256 * channels;
}