ref: 4989c1212a5f19c34c5575ec73a44a547e915924
parent: 447e5b8fc631ed40b7ad3715de2f8cfe26580960
author: Jean-Marc Valin <[email protected]>
date: Tue Apr 22 08:18:36 EDT 2008
Moved the windowing from compute_inv_mdcts() to mdct_backward()
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -199,21 +199,21 @@
{
int j;
if (C==1) {
- mdct_backward(lookup, X, x);
+ mdct_backward(lookup, X, x, window, overlap);
} else {
/* De-interleaving the sub-frames */
for (j=0;j<N;j++)
tmp[j] = X[C*j+c];
- mdct_backward(lookup, tmp, x);
+ mdct_backward(lookup, tmp, x, window, overlap);
}
/* 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++)
- out_mem[C*(MAX_PERIOD-N)+C*j+c] = 2*(mdct_overlap[C*j+c]+MULT16_32_Q15(window[j],x[j+N4]));
+ out_mem[C*(MAX_PERIOD-N)+C*j+c] = mdct_overlap[C*j+c]+x[j+N4];
for (j=0;j<overlap;j++)
- mdct_overlap[C*(overlap-j-1)+c] = MULT16_32_Q15(window[j],x[2*N-j-N4-1]);
+ mdct_overlap[C*(overlap-j-1)+c] = x[2*N-j-N4-1];
for (j=0;j<2*N4;j++)
- out_mem[C*(MAX_PERIOD-N)+C*(j+overlap)+c] = 2*x[j+N4+overlap];
+ out_mem[C*(MAX_PERIOD-N)+C*(j+overlap)+c] = x[j+N4+overlap];
}
RESTORE_STACK;
}
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -184,7 +184,7 @@
}
-void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out)
+void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16_t * restrict window, int overlap)
{
int i;
int N, N2, N4;
@@ -208,7 +208,7 @@
*yp++ = S_MUL(*xp2, t[N4]) - S_MUL(*xp1,t[0]);
xp1+=2;
xp2-=2;
- t++;
+ t++;
}
}
@@ -238,8 +238,8 @@
kiss_fft_scalar * restrict yp = out+N4;
for(i = 0; i < N4; i++)
{
- *yp++ =-*fp1;
- *yp++ = *fp2;
+ *yp++ =-*fp1*2;
+ *yp++ = *fp2*2;
fp1 += 2;
fp2 -= 2;
}
@@ -247,14 +247,30 @@
/* Mirror on both sides for TDAC */
{
- const kiss_fft_scalar * restrict xp1 = out+N2-1;
- const kiss_fft_scalar * restrict xp2 = out+N2;
- kiss_fft_scalar * restrict yp1 = out;
- kiss_fft_scalar * restrict yp2 = out+N-1;
- for(i = 0; i < N4; i++)
+ kiss_fft_scalar * restrict xp1 = out+N2-1;
+ kiss_fft_scalar * restrict xp2 = out+N2;
+ kiss_fft_scalar * restrict yp1 = out+N4-overlap/2;
+ kiss_fft_scalar * restrict yp2 = out+N-1-(N4-overlap/2);
+ const celt_word16_t * restrict wp1 = window;
+ const celt_word16_t * restrict wp2 = window+overlap-1;
+ for(i = 0; i< N4-overlap/2; i++)
{
- *yp1++ =-*xp1--;
- *yp2-- = *xp2++;
+ *xp1 = *xp1;
+ *xp2 = *xp2;
+ xp1--;
+ xp2++;
+ }
+ for(; i < N4; i++)
+ {
+ kiss_fft_scalar x1, x2;
+ x1 = *xp1;
+ x2 = *xp2;
+ *yp1++ =-MULT16_32_Q15(*wp1, x1);
+ *yp2-- = MULT16_32_Q15(*wp1, x2);
+ *xp1-- = MULT16_32_Q15(*wp2, x1);
+ *xp2++ = MULT16_32_Q15(*wp2, x2);
+ wp1++;
+ wp2--;
}
}
RESTORE_STACK;
--- a/libcelt/mdct.h
+++ b/libcelt/mdct.h
@@ -46,6 +46,7 @@
#define MDCT_H
#include "kiss_fft.h"
+#include "arch.h"
typedef struct {
int n;
@@ -60,6 +61,6 @@
void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16_t *window, int overlap);
/** Compute a backward MDCT (no scaling) */
-void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out);
+void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16_t * restrict window, int overlap);
#endif
--- a/tests/mdct-test.c
+++ b/tests/mdct-test.c
@@ -99,7 +99,7 @@
if (isinverse)
{
- mdct_backward(&cfg,in,out);
+ mdct_backward(&cfg,in,out, NULL, 0);
check_inv(in,out,nfft,isinverse);
} else {
mdct_forward(&cfg,in,out,NULL, 0);