shithub: opus

Download patch

ref: 5369578962f59d0613a56a0559e07fba7314c0c2
parent: 884916fb27a60b56a2701d1eb3d9e3fb2430dc72
author: Jean-Marc Valin <[email protected]>
date: Sat Apr 19 08:58:29 EDT 2008

better indexing in exp_rotation()

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -46,6 +46,7 @@
 {
    int i, k;
    celt_word16_t c, s;
+   celt_norm_t *Xptr;
    /* Equivalent to cos(.3) and sin(.3) */
    c = QCONST16(0.95534,15);
    s = dir*QCONST16(0.29552,15);
@@ -53,24 +54,27 @@
    {
       /* We could use MULT16_16_P15 instead of MULT16_16_Q15 for more accuracy, 
          but at this point, I really don't think it's necessary */
+      Xptr = X;
       for (i=0;i<len-stride;i++)
       {
          celt_norm_t x1, x2;
-         x1 = X[i];
-         x2 = X[i+stride];
-         X[i] = MULT16_16_Q15(c,x1) - MULT16_16_Q15(s,x2);
-         X[i+stride] = MULT16_16_Q15(c,x2) + MULT16_16_Q15(s,x1);
+         x1 = Xptr[0];
+         x2 = Xptr[stride];
+         Xptr[stride] = MULT16_16_Q15(c,x2) + MULT16_16_Q15(s,x1);
+         *Xptr++      = MULT16_16_Q15(c,x1) - MULT16_16_Q15(s,x2);
       }
+      Xptr = &X[len-2*stride-1];
       for (i=len-2*stride-1;i>=0;i--)
       {
          celt_norm_t x1, x2;
-         x1 = X[i];
-         x2 = X[i+stride];
-         X[i] = MULT16_16_Q15(c,x1) - MULT16_16_Q15(s,x2);
-         X[i+stride] = MULT16_16_Q15(c,x2) + MULT16_16_Q15(s,x1);
+         x1 = Xptr[0];
+         x2 = Xptr[stride];
+         Xptr[stride] = MULT16_16_Q15(c,x2) + MULT16_16_Q15(s,x1);
+         *Xptr--      = MULT16_16_Q15(c,x1) - MULT16_16_Q15(s,x2);
       }
    }
 }
+
 
 
 const celt_word16_t sqrtC_1[2] = {QCONST16(1.f, 14), QCONST16(1.414214f, 14)};