From a3a066cb6103c21daf8d9a14acc18f12202d7f5b Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Thu, 4 Nov 2010 15:15:54 -0400 Subject: [PATCH] Fixes some stereo issues where the right channel wasn't taken into account --- libcelt/celt.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libcelt/celt.c b/libcelt/celt.c index 091386c2..621141ea 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -454,6 +454,7 @@ static int tf_analysis(const CELTMode *m, celt_word16 *bandLogE, celt_word16 *ol /* FIXME: Should check number of bytes *left* */ if (nbCompressedBytes<15*C) { + *tf_sum = 0; for (i=0;ieBands[i]<eBands[i]<eBands[i]<>LM); best_L1 = L1; /*printf ("%f ", L1);*/ @@ -899,7 +900,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i offsets[i] = 0; /* Dynamic allocation code */ /* Make sure that dynamic allocation can't make us bust the budget */ - if (nbCompressedBytes > 30) + if (nbCompressedBytes > 30 && LM>=1) { int t1, t2; if (LM <= 1) @@ -912,9 +913,14 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i } for (i=1;imode->nbEBands-1;i++) { - if (2*bandLogE[i]-bandLogE[i-1]-bandLogE[i+1] > SHL16(t1,DB_SHIFT)) + celt_word32 d2; + d2 = 2*bandLogE[i]-bandLogE[i-1]-bandLogE[i+1]; + if (C==2) + d2 = HALF32(d2 + 2*bandLogE[i+st->mode->nbEBands]- + bandLogE[i-1+st->mode->nbEBands]-bandLogE[i+1+st->mode->nbEBands]); + if (d2 > SHL16(t1,DB_SHIFT)) offsets[i] += 1; - if (2*bandLogE[i]-bandLogE[i-1]-bandLogE[i+1] > SHL16(t2,DB_SHIFT)) + if (d2 > SHL16(t2,DB_SHIFT)) offsets[i] += 1; } }