shithub: opus

Download patch

ref: 051e044d1466bfc566d188426abdd6c6d7232ed1
parent: d0aa9f8616bd23868e2581b110eeb8264a58b5f5
author: Timothy B. Terriberry <[email protected]>
date: Sat Jan 8 17:11:46 EST 2011

Fix Jean-Marc's sqrt(0.5) constants.

There were two different ones in use, one with less precision than
 a float, and the other missing a digit in the middle.

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -225,8 +225,8 @@
    for (j=0;j<N;j++)
    {
       celt_norm r, l;
-      l = MULT16_16_Q15(QCONST16(.70711f,15), X[j]);
-      r = MULT16_16_Q15(QCONST16(.70711f,15), Y[j]);
+      l = MULT16_16_Q15(QCONST16(.70710678f,15), X[j]);
+      r = MULT16_16_Q15(QCONST16(.70710678f,15), Y[j]);
       X[j] = l+r;
       Y[j] = r-l;
    }
@@ -459,8 +459,8 @@
       for (j=0;j<N0;j++)
       {
          celt_norm tmp1, tmp2;
-         tmp1 = MULT16_16_Q15(QCONST16(.7070678f,15), X[stride*2*j+i]);
-         tmp2 = MULT16_16_Q15(QCONST16(.7070678f,15), X[stride*(2*j+1)+i]);
+         tmp1 = MULT16_16_Q15(QCONST16(.70710678f,15), X[stride*2*j+i]);
+         tmp2 = MULT16_16_Q15(QCONST16(.70710678f,15), X[stride*(2*j+1)+i]);
          X[stride*2*j+i] = tmp1 + tmp2;
          X[stride*(2*j+1)+i] = tmp1 - tmp2;
       }
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -436,7 +436,7 @@
 static celt_word32 l1_metric(const celt_norm *tmp, int N, int LM, int width)
 {
    int i, j;
-   static const celt_word16 sqrtM_1[4] = {Q15ONE, QCONST16(0.70711f,15), QCONST16(0.5f,15), QCONST16(0.35355f,15)};
+   static const celt_word16 sqrtM_1[4] = {Q15ONE, QCONST16(.70710678f,15), QCONST16(0.5f,15), QCONST16(0.35355339f,15)};
    celt_word32 L1;
    celt_word16 bias;
    L1=0;