ref: 3e08a88389c5794e088fe3336053f3bd85a84163
parent: f28062fe6a762a083797d57ade1a8eba0bd1bb2c
author: Jean-Marc Valin <[email protected]>
date: Mon Mar 3 08:49:20 EST 2008
Only the (rising) overlap part of the window is stored now. No need to hold the zeros and ones (nor even the second half).
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -178,14 +178,10 @@
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++)
{
@@ -192,8 +188,6 @@
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 @@
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 @@
}
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);
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -270,21 +270,15 @@
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;
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -243,7 +243,7 @@
/* 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;*/