Only the (rising) overlap part of the window is stored now. No need to hold the
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Mon, 3 Mar 2008 02:49:20 +0000 (13:49 +1100)
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Mon, 3 Mar 2008 02:49:20 +0000 (13:49 +1100)
zeros and ones (nor even the second half).

libcelt/celt.c
libcelt/modes.c
libcelt/vq.c

index dd46d16..c279d1e 100644 (file)
@@ -178,22 +178,16 @@ static celt_word32_t compute_mdcts(const mdct_lookup *mdct_lookup, celt_word16_t
          int j;
          for (j=0;j<2*N;j++)
             x[j] = in[C*i*N+C*j+c];
-#if 0
-         for (j=0;j<2*N;j++)
-            x[j] = MULT16_32_Q15(window[j],x[j]);
-#else
          for (j=0;j<overlap;j++)
          {
-            x[j+N4] = MULT16_32_Q15(window[j+N4],x[j+N4]);
-            x[2*N-j-N4-1] = MULT16_32_Q15(window[j+N4],x[2*N-j-N4-1]);
+            x[j+N4] = MULT16_32_Q15(window[j],x[j+N4]);
+            x[2*N-j-N4-1] = MULT16_32_Q15(window[j],x[2*N-j-N4-1]);
          }
          for (j=0;j<N4;j++)
          {
             x[j] = 0;
             x[2*N-j-1] = 0;
          }
-         //printf ("%d %d %d %d\n", window[N4-1], window[N4], window[N4+overlap-1], window[N4+overlap]);
-#endif
          for (j=0;j<2*N;j++)
             E += MULT16_16(EXTRACT16(SHR32(x[j],SIG_SHIFT+4)),EXTRACT16(SHR32(x[j],SIG_SHIFT+4)));
          mdct_forward(mdct_lookup, x, tmp);
@@ -225,18 +219,13 @@ static void compute_inv_mdcts(const mdct_lookup *mdct_lookup, celt_word16_t *win
          for (j=0;j<N;j++)
             tmp[j] = X[C*B*j+C*i+c];
          mdct_backward(mdct_lookup, tmp, x);
-#if 0
-         for (j=0;j<2*N;j++)
-            x[j] = MULT16_32_Q15(window[j],x[j]);
-#else
          /* The first and last part would need to be set to zero if we actually
             wanted to use them. */
          for (j=0;j<overlap;j++)
          {
-            x[j+N4] = MULT16_32_Q15(window[j+N4],x[j+N4]);
-            x[2*N-j-N4-1] = MULT16_32_Q15(window[j+N4],x[2*N-j-N4-1]);
+            x[j+N4] = MULT16_32_Q15(window[j],x[j+N4]);
+            x[2*N-j-N4-1] = MULT16_32_Q15(window[j],x[2*N-j-N4-1]);
          }
-#endif
          for (j=0;j<overlap;j++)
             out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c] = 2*(x[N4+j]+mdct_overlap[C*j+c]);
          for (j=0;j<2*N4;j++)
@@ -315,8 +304,8 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
       }
       for (i=0;i<st->overlap;i++)
       {
-         in[C*(i+N4)+c] = MULT16_32_Q15(st->mode->window[i+N4], in[C*(i+N4)+c]);
-         in[C*(B*N+N-i-N4-1)+c] = MULT16_32_Q15(st->mode->window[i+N4], in[C*(B*N+N-i-N4-1)+c]);
+         in[C*(i+N4)+c] = MULT16_32_Q15(st->mode->window[i], in[C*(i+N4)+c]);
+         in[C*(B*N+N-i-N4-1)+c] = MULT16_32_Q15(st->mode->window[i], in[C*(B*N+N-i-N4-1)+c]);
       }
    }
    find_spectral_pitch(st->fft, &st->psy, in, st->out_mem, MAX_PERIOD, (B+1)*N, C, &pitch_index);
index 0753399..7c8c180 100644 (file)
@@ -270,21 +270,15 @@ CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int lookahead,
    N4 = N/4;
    mdct_init(&mode->mdct, 2*N);
 
-   mode->window = (celt_word16_t*)celt_alloc(2*N*sizeof(celt_word16_t));
+   mode->window = (celt_word16_t*)celt_alloc(mode->overlap*sizeof(celt_word16_t));
 
-   for (i=0;i<2*N;i++)
-      mode->window[i] = 0;
 #ifndef FIXED_POINT
    for (i=0;i<mode->overlap;i++)
-      mode->window[N4+i] = mode->window[2*N-N4-i-1] 
-            = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap));
+      mode->window[i] = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap));
 #else
    for (i=0;i<mode->overlap;i++)
-      mode->window[N4+i] = mode->window[2*N-N4-i-1] 
-            = MIN32(32767,32768.*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap)));
+      mode->window[i] = MIN32(32767,32768.*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap)));
 #endif
-   for (i=0;i<N2;i++)
-      mode->window[N-N4+i] = Q15ONE;
 
    mode->marker_start = MODEVALID;
    mode->marker_end = MODEVALID;
index f9b529b..d788396 100644 (file)
@@ -243,7 +243,7 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, cel
                
                /* Compute the gain such that ||p + g*y|| = 1 */
                g = DIV32(SHL32(celt_sqrt(MULT16_16(ROUND(Ryp,14),ROUND(Ryp,14)) + Ryy - MULT16_16(ROUND(Ryy,14),Rpp)) - ROUND(Ryp,14),14),ROUND(Ryy,14));
-               //g *= NORM_SCALING_1;
+               
                /* Knowing that gain, what the error: (x-g*y)^2 
                   (result is negated and we discard x^2 because it's constant) */
                /*score = 2.f*g*Rxy - 1.f*g*g*Ryy*NORM_SCALING_1;*/