Correct an encoder/decoder mismatch at low volume levels. Relax some low level clamps...
authorGregory Maxwell <greg@xiph.org>
Sat, 22 Jan 2011 19:57:51 +0000 (14:57 -0500)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Sun, 23 Jan 2011 00:50:36 +0000 (19:50 -0500)
libcelt/bands.c
libcelt/celt.c
libcelt/quant_bands.c

index 45680fd..4c96b30 100644 (file)
@@ -152,7 +152,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank
       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 @@ void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_nor
       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;
       }
index 913d4e4..99ce919 100644 (file)
@@ -1378,6 +1378,11 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
    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
    {
@@ -2153,6 +2158,11 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
    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
    {
index 937692f..effa183 100644 (file)
@@ -527,8 +527,6 @@ void log2Amp(const CELTMode *m, int start, int end,
          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 @@ void amp2Log2(const CELTMode *m, int effEnd, int end,
    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);