shithub: opus

Download patch

ref: e995c31f443b1a03ca0fcc80c6cff28d522c25c1
parent: 2fa8affdc5134327592c473ce9f429f94cd403f5
author: Jean-Marc Valin <[email protected]>
date: Tue Feb 26 08:48:16 EST 2008

Put the channel count outside of the energy calculation. Increased the allowed
range for the mono encoder.

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -84,7 +84,7 @@
          float sum = 1e-10;
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
             sum += SIG_SCALING_1*SIG_SCALING_1*X[j*C+c]*X[j*C+c];
-         bank[i*C+c] = sqrt(C*sum);
+         bank[i*C+c] = sqrt(sum);
          /*printf ("%f ", bank[i*C+c]);*/
       }
    }
@@ -103,7 +103,7 @@
       for (i=0;i<m->nbEBands;i++)
       {
          int j;
-         float g = 1.f/(1e-10+bank[i*C+c]);
+         float g = 1.f/(1e-10+bank[i*C+c]*sqrt(C));
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
             X[j*C+c] = NORM_SCALING*SIG_SCALING_1*freq[j*C+c]*g;
       }
@@ -133,7 +133,7 @@
       for (i=0;i<m->nbEBands;i++)
       {
          int j;
-         float g = bank[i*C+c];
+         float g = sqrt(C)*bank[i*C+c];
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
             freq[j*C+c] = NORM_SCALING_1*SIG_SCALING*X[j*C+c] * g;
       }
--- a/tools/celtenc.c
+++ b/tools/celtenc.c
@@ -438,10 +438,10 @@
    {
       if (bitrate < 0)
          bitrate = 64;
-      if (bitrate < 40)
-         bitrate = 40;
-      if (bitrate > 80)
-         bitrate = 80;
+      if (bitrate < 32)
+         bitrate = 32;
+      if (bitrate > 110)
+         bitrate = 110;
    }
    else if (chan == 2)
    {