ref: f4f5dac8baa29773a88e6f18a589450a87dc57ea
parent: bf2d648bbd7f66088c504cc9abdad0ca53a965e4
author: Jean-Marc Valin <[email protected]>
date: Fri May 23 13:27:39 EDT 2008
Doing mid-side stereo when not doing intensity.
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -327,21 +327,28 @@
const int C = CHANNELS(m);
{
int j;
- celt_word16_t left, right;
- celt_word16_t a1, a2;
- celt_word16_t norm;
-#ifdef FIXED_POINT
- int shift = celt_zlog2(MAX32(bank[i*C], bank[i*C+1]))-13;
-#endif
- left = VSHR32(bank[i*C],shift);
- right = VSHR32(bank[i*C+1],shift);
- norm = EPSILON + celt_sqrt(EPSILON+MULT16_16(left,left)+MULT16_16(right,right));
- a1 = DIV32_16(SHL32(EXTEND32(left),14),norm);
- a2 = dir*DIV32_16(SHL32(EXTEND32(right),14),norm);
if (stereo_mode[i] && dir <0)
{
dup_band(X+C*eBands[i], eBands[i+1]-eBands[i]);
} else {
+ celt_word16_t a1, a2;
+ if (stereo_mode[i]==0)
+ {
+ /* Do mid-side when not doing intensity stereo */
+ a1 = QCONST16(.70711f,14);
+ a2 = dir*QCONST16(.70711f,14);
+ } else {
+ celt_word16_t left, right;
+ celt_word16_t norm;
+#ifdef FIXED_POINT
+ int shift = celt_zlog2(MAX32(bank[i*C], bank[i*C+1]))-13;
+#endif
+ left = VSHR32(bank[i*C],shift);
+ right = VSHR32(bank[i*C+1],shift);
+ norm = EPSILON + celt_sqrt(EPSILON+MULT16_16(left,left)+MULT16_16(right,right));
+ a1 = DIV32_16(SHL32(EXTEND32(left),14),norm);
+ a2 = dir*DIV32_16(SHL32(EXTEND32(right),14),norm);
+ }
for (j=eBands[i];j<eBands[i+1];j++)
{
celt_norm_t r, l;
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -322,7 +322,7 @@
for (i=0;i<C*N;i++)
P[i] = 0;
}
- quant_energy(st->mode, bandE, st->oldBandE, 20+nbCompressedBytes*8/5, st->mode->prob, &st->enc);
+ quant_energy(st->mode, bandE, st->oldBandE, 20*C+nbCompressedBytes*8/5, st->mode->prob, &st->enc);
ALLOC(stereo_mode, st->mode->nbEBands, int);
stereo_decision(st->mode, X, stereo_mode, st->mode->nbEBands);
@@ -584,7 +584,7 @@
}
/* Get band energies */
- unquant_energy(st->mode, bandE, st->oldBandE, 20+len*8/5, st->mode->prob, &dec);
+ unquant_energy(st->mode, bandE, st->oldBandE, 20*C+len*8/5, st->mode->prob, &dec);
/* Pitch MDCT */
compute_mdcts(st->mode, st->mode->window, st->out_mem+pitch_index*C, freq);