shithub: opus

Download patch

ref: 695ab70027465a774b64159535069a0d3b5eb934
parent: d8dcd244abfa913fa067a3d016b075259b2ea783
author: Jean-Marc Valin <[email protected]>
date: Sun Jun 7 19:54:22 EDT 2009

Minor simplification to the fine energy code

--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -151,14 +151,14 @@
    {
       int q2;
       celt_int16_t frac = 1<<fine_quant[i];
-      celt_word16_t offset = (error[i]+QCONST16(.5f,8))*frac;
+      celt_word16_t offset;
       if (fine_quant[i] <= 0)
          continue;
 #ifdef FIXED_POINT
       /* Has to be without rounding */
-      q2 = offset>>8;
+      q2 = (error[i]+QCONST16(.5f,8))>>(8-fine_quant[i]);
 #else
-      q2 = (int)floor(offset);
+      q2 = (int)floor((error[i]+.5)*frac);
 #endif
       if (q2 > frac-1)
          q2 = frac-1;
@@ -168,7 +168,7 @@
 #else
       offset = (q2+.5f)*(1<<(14-fine_quant[i]))*(1.f/16384) - .5f;
 #endif
-      oldEBands[i] += PSHR32(MULT16_16(DB_SCALING,offset),8);
+      oldEBands[i] += offset;
       /*printf ("%f ", error[i] - offset);*/
    }
    for (i=0;i<m->nbEBands;i++)
@@ -234,7 +234,7 @@
 #else
       offset = (q2+.5f)*(1<<(14-fine_quant[i]))*(1.f/16384) - .5f;
 #endif
-      oldEBands[i] += PSHR32(MULT16_16(DB_SCALING,offset),8);
+      oldEBands[i] += offset;
    }
    for (i=0;i<m->nbEBands;i++)
    {