shithub: opus

Download patch

ref: bbc010c4f3e63661442d35af8877ff5a5cce3903
parent: 3d25e71b407816098a421fe6b30edcd0f5af7ad1
author: Jean-Marc Valin <[email protected]>
date: Fri Oct 15 18:55:35 EDT 2010

Removing yshift from the fixed-point VQ search

--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -173,9 +173,6 @@
    celt_word32 sum;
    celt_word32 xy, yy;
    int N_1; /* Inverse of N, in Q14 format (even for float) */
-#ifdef FIXED_POINT
-   int yshift;
-#endif
    SAVE_STACK;
 
    /* When there's no pulse, fill with noise or folded spectrum */
@@ -203,9 +200,6 @@
       return;
    }
    K = get_pulses(K);
-#ifdef FIXED_POINT
-   yshift = 13-celt_ilog2(K);
-#endif
 
    ALLOC(y, N, celt_norm);
    ALLOC(iy, N, int);
@@ -261,7 +255,7 @@
 #else
          iy[j] = (int)floor(rcp*X[j]);
 #endif
-         y[j] = SHL16(iy[j],yshift);
+         y[j] = iy[j];
          yy = MAC16_16(yy, y[j],y[j]);
          xy = MAC16_16(xy, X[j],y[j]);
          y[j] *= 2;
@@ -277,7 +271,7 @@
 #endif
    if (pulsesLeft > N+3)
    {
-      celt_word16 tmp = SHL16(pulsesLeft, yshift);
+      celt_word16 tmp = pulsesLeft;
       yy = MAC16_16(yy, tmp, tmp);
       yy = MAC16_16(yy, tmp, y[0]);
       iy[0] += pulsesLeft;
@@ -284,7 +278,7 @@
       pulsesLeft=0;
    }
 
-   s = SHL16(1, yshift);
+   s = 1;
    for (i=0;i<pulsesLeft;i++)
    {
       int best_id;
@@ -294,7 +288,7 @@
       int rshift;
 #endif
 #ifdef FIXED_POINT
-      rshift = yshift+1+celt_ilog2(K-pulsesLeft+i+1);
+      rshift = 1+celt_ilog2(K-pulsesLeft+i+1);
 #endif
 
       best_id = 0;
@@ -309,7 +303,7 @@
          /* Temporary sums of the new pulse(s) */
          Rxy = EXTRACT16(SHR32(MAC16_16(xy, s,X[j]),rshift));
          /* We're multiplying y[j] by two so we don't have to do it here */
-         Ryy = EXTRACT16(SHR32(MAC16_16(yy, s,y[j]),rshift));
+         Ryy = MAC16_16(yy, s,y[j]);
             
          /* Approximate score: we maximise Rxy/sqrt(Ryy) (we're guaranteed that
             Rxy is positive because the sign is pre-computed) */
@@ -349,7 +343,7 @@
    
    if (resynth)
    {
-      normalise_residual(iy, X, N, K, EXTRACT16(SHR32(yy,2*yshift)), gain);
+      normalise_residual(iy, X, N, K, yy, gain);
       exp_rotation(X, N, -1, B, K, spread);
    }
    RESTORE_STACK;