ref: 83c26e713c004fea99eaa98a8062ac5a86817eb9
parent: 7a56741b2ee901fbf6cafd6c8fe1e1c63ff7709e
author: Jean-Marc Valin <[email protected]>
date: Sun Jun 14 05:19:51 EDT 2009
Now storing the band energies in de-interleaved format when doing stereo
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -74,11 +74,11 @@
} while (++j<eBands[i+1]);
/* We're adding one here to make damn sure we never end up with a pitch vector that's
larger than unity norm */
- bank[i*C+c] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift);
+ bank[i+c*m->nbEBands] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift);
} else {
- bank[i*C+c] = EPSILON;
+ bank[i+c*m->nbEBands] = EPSILON;
}
- /*printf ("%f ", bank[i*C+c]);*/
+ /*printf ("%f ", bank[i+c*m->nbEBands]);*/
}
}
/*printf ("\n");*/
@@ -96,8 +96,8 @@
celt_word16_t g;
int j,shift;
celt_word16_t E;
- shift = celt_zlog2(bank[i*C+c])-13;
- E = VSHR32(bank[i*C+c], shift);
+ shift = celt_zlog2(bank[i+c*m->nbEBands])-13;
+ E = VSHR32(bank[i+c*m->nbEBands], shift);
g = EXTRACT16(celt_rcp(SHL32(E,3)));
j=eBands[i]; do {
X[j*C+c] = MULT16_16_Q15(VSHR32(freq[j*C+c],shift-1),g);
@@ -121,8 +121,8 @@
celt_word32_t sum = 1e-10;
for (j=eBands[i];j<eBands[i+1];j++)
sum += X[j*C+c]*X[j*C+c];
- bank[i*C+c] = sqrt(sum);
- /*printf ("%f ", bank[i*C+c]);*/
+ bank[i+c*m->nbEBands] = sqrt(sum);
+ /*printf ("%f ", bank[i+c*m->nbEBands]);*/
}
}
/*printf ("\n");*/
@@ -142,8 +142,8 @@
celt_word32_t sum = 1e-10;
for (j=eBands[i];j<eBands[i+1];j++)
sum += X[j*C+c]*X[j*C+c]*tonality[j];
- bank[i*C+c] = sqrt(sum);
- /*printf ("%f ", bank[i*C+c]);*/
+ bank[i+c*m->nbEBands] = sqrt(sum);
+ /*printf ("%f ", bank[i+c*m->nbEBands]);*/
}
}
/*printf ("\n");*/
@@ -161,7 +161,7 @@
for (i=0;i<m->nbEBands;i++)
{
int j;
- celt_word16_t g = 1.f/(1e-10+bank[i*C+c]);
+ celt_word16_t g = 1.f/(1e-10+bank[i+c*m->nbEBands]);
for (j=eBands[i];j<eBands[i+1];j++)
X[j*C+c] = freq[j*C+c]*g;
}
@@ -198,7 +198,7 @@
for (i=0;i<m->nbEBands;i++)
{
int j;
- celt_word32_t g = SHR32(bank[i*C+c],1);
+ celt_word32_t g = SHR32(bank[i+c*m->nbEBands],1);
j=eBands[i]; do {
freq[j*C+c] = SHL32(MULT16_32_Q15(X[j*C+c], g),2);
} while (++j<eBands[i+1]);
@@ -305,10 +305,10 @@
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;
+ int shift = celt_zlog2(MAX32(bank[i], bank[i+m->nbEBands]))-13;
#endif
- left = VSHR32(bank[i*C],shift);
- right = VSHR32(bank[i*C+1],shift);
+ left = VSHR32(bank[i],shift);
+ right = VSHR32(bank[i+m->nbEBands],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);
@@ -339,10 +339,10 @@
celt_word16_t a1, a2;
int j;
#ifdef FIXED_POINT
- int shift = celt_zlog2(MAX32(bank[i*C], bank[i*C+1]))-13;
+ int shift = celt_zlog2(MAX32(bank[i], bank[i+m->nbEBands]))-13;
#endif
- left = VSHR32(bank[i*C],shift);
- right = VSHR32(bank[i*C+1],shift);
+ left = VSHR32(bank[i],shift);
+ right = VSHR32(bank[i+m->nbEBands],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);
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -763,9 +763,14 @@
compute_band_energies(st->mode, freq, bandEp);
normalise_bands(st->mode, freq, P, bandEp);
pitch_power = bandEp[0]+bandEp[1]+bandEp[2];
- /* Check if we can safely use the pitch (i.e. effective gain
- isn't too high) */
curr_power = bandE[0]+bandE[1]+bandE[2];
+ if (C>1)
+ {
+ pitch_power += bandEp[0+st->mode->nbEBands]+bandEp[1+st->mode->nbEBands]+bandEp[2+st->mode->nbEBands];
+ curr_power += bandE[0+st->mode->nbEBands]+bandE[1+st->mode->nbEBands]+bandE[2+st->mode->nbEBands];
+ }
+ /* Check if we can safely use the pitch (i.e. effective gain
+ isn't too high) */
if ((MULT16_32_Q15(QCONST16(.1f, 15),curr_power) + QCONST32(10.f,ENER_SHIFT) < pitch_power))
{
/* Pitch prediction */
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -311,7 +311,7 @@
SAVE_STACK;
ALLOC(E, m->nbEBands, celt_word16_t);
for (i=0;i<m->nbEBands;i++)
- E[i] = eBands[C*i+c];
+ E[i] = eBands[i+c*m->nbEBands];
coarse_needed=quant_coarse_energy_mono(m, E, oldEBands+c*m->nbEBands, budget/C, intra, prob, error+c*m->nbEBands, enc);
maxBudget=IMAX(maxBudget,coarse_needed);
RESTORE_STACK;
@@ -339,7 +339,7 @@
SAVE_STACK;
quant_fine_energy_mono(m, E, oldEBands+c*m->nbEBands, error+c*m->nbEBands, fine_quant, enc);
for (i=0;i<m->nbEBands;i++)
- eBands[C*i+c] = E[i];
+ eBands[i+c*m->nbEBands] = E[i];
RESTORE_STACK;
}
}
@@ -364,7 +364,7 @@
SAVE_STACK;
quant_energy_finalise_mono(m, E, oldEBands+c*m->nbEBands, error+c*m->nbEBands, fine_quant, fine_priority, bits_left/C, enc);
for (i=0;i<m->nbEBands;i++)
- eBands[C*i+c] = E[i];
+ eBands[i+c*m->nbEBands] = E[i];
RESTORE_STACK;
}
}
@@ -412,7 +412,7 @@
int i;
unquant_fine_energy_mono(m, E, oldEBands+c*m->nbEBands, fine_quant, dec);
for (i=0;i<m->nbEBands;i++)
- eBands[C*i+c] = E[i];
+ eBands[i+c*m->nbEBands] = E[i];
}
RESTORE_STACK;
}
@@ -438,7 +438,7 @@
int i;
unquant_energy_finalise_mono(m, E, oldEBands+c*m->nbEBands, fine_quant, fine_priority, bits_left/C, dec);
for (i=0;i<m->nbEBands;i++)
- eBands[C*i+c] = E[i];
+ eBands[i+c*m->nbEBands] = E[i];
}
RESTORE_STACK;
}