shithub: opus

Download patch

ref: 6ea8baed2d24cc91680c3dac9b57253a093891f3
parent: 3d152a5de419385d21e455f9e15f0b4055dd9060
author: Jean-Marc Valin <[email protected]>
date: Tue Apr 15 04:01:33 EDT 2008

a few loop optimisations.

--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -75,8 +75,10 @@
       }
       if (shift==0)
          return;
-      for (i=0;i<len;i++)
+      i=0;
+      do{
          x[i] = SHR16(x[i], shift);
+      } while (++i<len);
    } else {
       int shift=0;
       if (maxabs == 0)
@@ -89,8 +91,10 @@
       }
       if (shift==0)
          return;
-      for (i=0;i<len;i++)
+      i=0;
+      do{
          x[i] = SHL16(x[i], shift);
+      } while (++i<len);
    }
 }
 #else
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -59,21 +59,21 @@
    /*for (i=0;i<N;i++)
    printf ("%d ", iy[i]);*/
    Rpp = 0;
-   for (i=0;i<N;i++)
+   i=0;
+   do {
       Rpp = MAC16_16(Rpp,P[i],P[i]);
-
-   for (i=0;i<N;i++)
       y[i] = SHL16(iy[i],yshift);
-   
+   } while (++i < N);
+
    Ryp = 0;
    Ryy = 0;
    /* If this doesn't generate a dual MAC (on supported archs), fire the compiler guy */
-   for (i=0;i<N;i++)
-   {
+   i=0;
+   do {
       Ryp = MAC16_16(Ryp, y[i], P[i]);
       Ryy = MAC16_16(Ryy, y[i], y[i]);
-   }
-   
+   } while (++i < N);
+
    /* g = (sqrt(Ryp^2 + Ryy - Rpp*Ryy)-Ryp)/Ryy */
    g = MULT16_32_Q15(
             celt_sqrt(MULT16_16(ROUND16(Ryp,14),ROUND16(Ryp,14)) + Ryy -
@@ -81,8 +81,11 @@
             - ROUND16(Ryp,14),
        celt_rcp(SHR32(Ryy,9)));
 
-   for (i=0;i<N;i++)
+   i=0;
+   do 
       X[i] = P[i] + ROUND16(MULT16_16(y[i], g),11);
+   while (++i < N);
+
    RESTORE_STACK;
 }
 
@@ -92,7 +95,7 @@
    VARDECL(celt_norm_t, y);
    VARDECL(int, iy);
    VARDECL(int, signx);
-   int i, j, is;
+   int j, is;
    celt_word16_t s;
    int pulsesLeft;
    celt_word32_t sum;