ref: 8f02c482ba22074e8200ee89b7986eeb8f2f3b8f
parent: 5c2ac2b75d5742e3e6cd31ef4d783ce43a64f09f
author: Gregory Maxwell <[email protected]>
date: Sat Jan 22 09:57:51 EST 2011
Correct an encoder/decoder mismatch at low volume levels. Relax some low level clamps so that the dynamic range can extend further below the 16bit floor.
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -152,7 +152,7 @@
for (i=0;i<end;i++)
{
int j;
- celt_word32 sum = 1e-10f;
+ celt_word32 sum = 1e-27f;
for (j=M*eBands[i];j<M*eBands[i+1];j++)
sum += X[j+c*N]*X[j+c*N];
bank[i+c*m->nbEBands] = celt_sqrt(sum);
@@ -173,7 +173,7 @@
for (i=0;i<end;i++)
{
int j;
- celt_word16 g = 1.f/(1e-10f+bank[i+c*m->nbEBands]);
+ celt_word16 g = 1.f/(1e-27f+bank[i+c*m->nbEBands]);
for (j=M*eBands[i];j<M*eBands[i+1];j++)
X[j+c*N] = freq[j+c*N]*g;
}
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1378,6 +1378,11 @@
st->prefilter_gain = gain1;
st->prefilter_tapset = prefilter_tapset;
+ /* Clamp the band energy used for prediction */
+ for (i=0;i<C*st->mode->nbEBands;i++)
+ if (oldBandE[i] < -QCONST16(28.f,DB_SHIFT))
+ oldBandE[i] = -QCONST16(28.f,DB_SHIFT);
+
/* In case start or end were to change */
c=0; do
{
@@ -2152,6 +2157,11 @@
st->postfilter_gain = postfilter_gain;
st->postfilter_tapset = postfilter_tapset;
#endif /* ENABLE_POSTFILTER */
+
+ /* Clamp the band energy used for prediction */
+ for (i=0;i<C*st->mode->nbEBands;i++)
+ if (oldBandE[i] < -QCONST16(28.f,DB_SHIFT))
+ oldBandE[i] = -QCONST16(28.f,DB_SHIFT);
/* In case start or end were to change */
c=0; do
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -527,8 +527,6 @@
celt_word16 lg = oldEBands[i+c*m->nbEBands]
+ SHL16((celt_word16)eMeans[i],6);
eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(SHL16(lg,11-DB_SHIFT)),4);
- if (oldEBands[i+c*m->nbEBands] < -QCONST16(14.f,DB_SHIFT))
- oldEBands[i+c*m->nbEBands] = -QCONST16(14.f,DB_SHIFT);
}
} while (++c < C);
}
@@ -542,7 +540,7 @@
do {
for (i=0;i<effEnd;i++)
bandLogE[i+c*m->nbEBands] =
- celt_log2(MAX32(QCONST32(.001f,14),SHL32(bandE[i+c*m->nbEBands],2)))
+ celt_log2(SHL32(bandE[i+c*m->nbEBands],2))
- SHL16((celt_word16)eMeans[i],6);
for (i=effEnd;i<end;i++)
bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT);