shithub: opus

Download patch

ref: aa4f58bde99c71ef374a2cd31cf8d7125cfb3861
parent: 40fc679331d4faa5c65a3103efa06201c7e5ce8e
author: Jean-Marc Valin <[email protected]>
date: Sat Oct 3 05:27:59 EDT 2009

Simplifications to the code

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -500,7 +500,7 @@
 {
    int i, j, remaining_bits, balance;
    const celt_int16_t * restrict eBands = m->eBands;
-   celt_norm_t * restrict norm, *X, *Y;
+   celt_norm_t * restrict norm;
    VARDECL(celt_norm_t, _norm);
    int B;
    celt_word16_t mid, side;
@@ -524,6 +524,7 @@
       int imid, iside, itheta;
       int mbits, sbits, delta;
       int qalloc;
+      celt_norm_t * restrict X, * restrict Y;
       
       X = _X+eBands[i];
       Y = X+eBands[m->nbEBands+1];
@@ -792,7 +793,7 @@
 {
    int i, j, remaining_bits, balance;
    const celt_int16_t * restrict eBands = m->eBands;
-   celt_norm_t * restrict norm, *X, *Y;
+   celt_norm_t * restrict norm;
    VARDECL(celt_norm_t, _norm);
    int B;
    celt_word16_t mid, side;
@@ -816,6 +817,7 @@
       int imid, iside, itheta;
       int mbits, sbits, delta;
       int qalloc;
+      celt_norm_t * restrict X, * restrict Y;
       
       X = _X+eBands[i];
       Y = X+eBands[m->nbEBands+1];
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -292,40 +292,25 @@
       const mdct_lookup *lookup = MDCT(mode);
       const int overlap = OVERLAP(mode);
       mdct_forward(lookup, in, out, mode->window, overlap);
-   } else if (!shortBlocks) {
+   } else {
       const mdct_lookup *lookup = MDCT(mode);
       const int overlap = OVERLAP(mode);
-      const int N = FRAMESIZE(mode);
-      int c;
+      int N = FRAMESIZE(mode);
+      int B = 1;
+      int b, c;
       VARDECL(celt_word32_t, x);
       VARDECL(celt_word32_t, tmp);
       SAVE_STACK;
-      ALLOC(x, N+overlap, celt_word32_t);
-      ALLOC(tmp, N, celt_word32_t);
-      for (c=0;c<C;c++)
+      if (shortBlocks)
       {
-         int j;
-         for (j=0;j<N+overlap;j++)
-            x[j] = in[C*j+c];
-         mdct_forward(lookup, x, tmp, mode->window, overlap);
-         /* Interleaving the sub-frames */
-         for (j=0;j<N;j++)
-            out[j+c*N] = tmp[j];
+         lookup = &mode->shortMdct;
+         N = mode->shortMdctSize;
+         B = mode->nbShortMdcts;
       }
-      RESTORE_STACK;
-   } else {
-      const mdct_lookup *lookup = &mode->shortMdct;
-      const int overlap = mode->overlap;
-      const int N = mode->shortMdctSize;
-      int b, c;
-      VARDECL(celt_word32_t, x);
-      VARDECL(celt_word32_t, tmp);
-      SAVE_STACK;
       ALLOC(x, N+overlap, celt_word32_t);
       ALLOC(tmp, N, celt_word32_t);
       for (c=0;c<C;c++)
       {
-         int B = mode->nbShortMdcts;
          for (b=0;b<B;b++)
          {
             int j;