aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dca.c
diff options
context:
space:
mode:
authorNick Brereton <nick@nbrereton.net>2012-07-12 13:49:23 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-07-16 16:05:25 +0200
commit73154feec1c34d3e6443ba9c24b49af3748accaa (patch)
tree5f916f867a8e307efae93a31426471902cfbf381 /libavcodec/dca.c
parentac9389a6633dd4bb355f7c0419bd0af7da22e308 (diff)
downloadffmpeg-73154feec1c34d3e6443ba9c24b49af3748accaa.tar.gz
Fix ordering of XXCH downmix coefficients.
Reviewed-by: Benjamin Larsson <benjamin@southpole.se> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dca.c')
-rw-r--r--libavcodec/dca.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index 41d4905307..7682d50e98 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -540,6 +540,18 @@ static inline void get_array(GetBitContext *gb, int *dst, int len, int bits)
*dst++ = get_bits(gb, bits);
}
+static inline int dca_xxch2index(DCAContext *s, int xxch_ch)
+{
+ int i, base, mask;
+
+ /* locate channel set containing the channel */
+ for (i = -1, base = 0, mask = (s->xxch_core_spkmask & ~DCA_XXCH_LFE1);
+ i <= s->xxch_chset && !(mask & xxch_ch); mask = s->xxch_spk_masks[++i])
+ base += av_popcount(mask);
+
+ return base + av_popcount(mask & (xxch_ch - 1));
+}
+
static int dca_parse_audio_coding_header(DCAContext *s, int base_channel,
int xxch)
{
@@ -595,8 +607,7 @@ static int dca_parse_audio_coding_header(DCAContext *s, int base_channel,
coeff = get_bits(&s->gb, 7);
sign = (coeff & 64) ? 1.0 : -1.0;
mag = dca_downmix_scale_factors[(coeff & 63) << 2];
- ichan = av_popcount((acc_mask & ~DCA_XXCH_LFE1)
- & ((1 << i) - 1));
+ ichan = dca_xxch2index(s, 1 << i);
s->xxch_dmix_coeff[j][ichan] = sign * mag * scale_factor;
}
}