Simplifications to the code
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Sat, 3 Oct 2009 13:27:59 +0000 (09:27 -0400)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Sat, 3 Oct 2009 13:27:59 +0000 (09:27 -0400)
libcelt/bands.c
libcelt/celt.c

index a2b02a1..22c4c0d 100644 (file)
@@ -500,7 +500,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
 {
    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 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
       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 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t
 {
    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 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t
       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];
index 2f36b27..a3056f4 100644 (file)
@@ -292,40 +292,25 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig_t * re
       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;