Simplified exp_spreading by unifying both directions. Have to admit I don't
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Wed, 13 Feb 2008 06:41:37 +0000 (17:41 +1100)
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Wed, 13 Feb 2008 06:41:37 +0000 (17:41 +1100)
fully understand why that works!

libcelt/bands.c

index 329d7cf..1bb228d 100644 (file)
@@ -43,47 +43,24 @@ static void exp_rotation(float *X, int len, float theta, int dir, int stride, in
    int i, k;
    float c, s;
    c = cos(theta);
-   s = sin(theta);
-   if (dir > 0)
+   s = dir*sin(theta);
+   for (k=0;k<iter;k++)
    {
-      for (k=0;k<iter;k++)
+      for (i=0;i<len-stride;i++)
       {
-         for (i=0;i<len-stride;i++)
-         {
-            float x1, x2;
-            x1 = X[i];
-            x2 = X[i+stride];
-            X[i] = c*x1 - s*x2;
-            X[i+stride] = c*x2 + s*x1;
-         }
-         for (i=len-2*stride-1;i>=0;i--)
-         {
-            float x1, x2;
-            x1 = X[i];
-            x2 = X[i+stride];
-            X[i] = c*x1 - s*x2;
-            X[i+stride] = c*x2 + s*x1;
-         }
+         float x1, x2;
+         x1 = X[i];
+         x2 = X[i+stride];
+         X[i] = c*x1 - s*x2;
+         X[i+stride] = c*x2 + s*x1;
       }
-   } else {
-      for (k=0;k<iter;k++)
+      for (i=len-2*stride-1;i>=0;i--)
       {
-         for (i=0;i<len-2*stride;i++)
-         {
-            float x1, x2;
-            x1 = X[i];
-            x2 = X[i+stride];
-            X[i] = c*x1 + s*x2;
-            X[i+stride] = c*x2 - s*x1;
-         }
-         for (i=len-stride-1;i>=0;i--)
-         {
-            float x1, x2;
-            x1 = X[i];
-            x2 = X[i+stride];
-            X[i] = c*x1 + s*x2;
-            X[i+stride] = c*x2 - s*x1;
-         }
+         float x1, x2;
+         x1 = X[i];
+         x2 = X[i+stride];
+         X[i] = c*x1 - s*x2;
+         X[i+stride] = c*x2 + s*x1;
       }
    }
 }