shithub: opus

Download patch

ref: 39ffbeec9a168d271087a3e8eb449292708d6a50
parent: 1f589ef1431196a281f4e18af58b11bf6c87e1eb
author: Jean-Marc Valin <[email protected]>
date: Fri Aug 6 03:40:11 EDT 2010

Comments

--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -170,6 +170,7 @@
 #endif
    SAVE_STACK;
 
+   /* When there's no pulse, fill with noise or folded spectrum */
    if (K==0)
    {
       if (lowband != NULL && resynth)
@@ -200,6 +201,7 @@
    if (spread)
       exp_rotation(X, N, 1, B, K);
 
+   /* Get rid of the sign */
    sum = 0;
    j=0; do {
       if (X[j]>0)
@@ -224,6 +226,7 @@
          sum += X[j];
       }  while (++j<N);
 
+      /* If X is too small, just replace it with a pulse at 0 */
 #ifdef FIXED_POINT
       if (sum <= K)
 #else
@@ -289,11 +292,11 @@
          /* 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));
             
-            /* Approximate score: we maximise Rxy/sqrt(Ryy) (we're guaranteed that 
-         Rxy is positive because the sign is pre-computed) */
+         /* Approximate score: we maximise Rxy/sqrt(Ryy) (we're guaranteed that
+            Rxy is positive because the sign is pre-computed) */
          Rxy = MULT16_16_Q15(Rxy,Rxy);
-            /* The idea is to check for num/den >= best_num/best_den, but that way
-         we can do it without any division */
+         /* The idea is to check for num/den >= best_num/best_den, but that way
+            we can do it without any division */
          /* OPT: Make sure to use conditional moves here */
          if (MULT16_16(best_den, Rxy) > MULT16_16(Ryy, best_num))
          {
@@ -318,6 +321,8 @@
       iy[j] += is;
       pulsesLeft -= pulsesAtOnce;
    }
+
+   /* Put the original sign back */
    j=0;
    do {
       X[j] = MULT16_16(signx[j],X[j]);
@@ -326,8 +331,6 @@
    } while (++j<N);
    encode_pulses(iy, N, K, enc);
    
-   /* Recompute the gain in one pass to reduce the encoder-decoder mismatch
-   due to the recursive computation used in quantisation. */
    if (resynth)
    {
       normalise_residual(iy, X, N, K, EXTRACT16(SHR32(yy,2*yshift)));