shithub: opus

Download patch

ref: 684fb28eba163857fc4bcd5d04f37b9450a8c753
parent: d568303134624dac33d2579e5212ee513db2e1c3
author: Jean-Marc Valin <[email protected]>
date: Tue Apr 15 14:06:59 EDT 2008

oops, forgot to make the gain a 16-bit var

--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -185,7 +185,7 @@
             }
          } while (++j<N); /* Promises we loop at least once */
       } else {
-         celt_word32_t g;
+         celt_word16_t g;
          celt_word32_t best_num = -VERY_LARGE32;
          for (j=0;j<N;j++)
          {
@@ -200,11 +200,11 @@
             Ryp = ROUND16(yp + MULT16_16(s,P[j]), 14);
 
             /* Compute the gain such that ||p + g*y|| = 1 */
-            g = SHR32(MULT16_32_Q15(
+            g = EXTRACT16(SHR32(MULT16_32_Q15(
                          celt_psqrt(MULT16_16(Ryp,Ryp) + 
                                  MULT16_16(Ryy,QCONST16(1.f,14)-Rpp))
                          - Ryp,
-                      celt_rcp(Ryy)),4);
+                      celt_rcp(Ryy)),4));
             /* Knowing that gain, what's the error: (x-g*y)^2 
                (result is negated and we discard x^2 because it's constant) */
             /* score = 2*g*Rxy - g*g*Ryy;*/