Making the IMDCT work on interleaved data

Saves a copy in the decoder
This commit is contained in:
Jean-Marc Valin 2011-08-15 10:01:00 -04:00
parent 1c6c3d17a7
commit dbeb86fd05
4 changed files with 34 additions and 36 deletions

View file

@ -440,17 +440,15 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X
const int C = CHANNELS(_C); const int C = CHANNELS(_C);
const int N = mode->shortMdctSize<<LM; const int N = mode->shortMdctSize<<LM;
const int overlap = OVERLAP(mode); const int overlap = OVERLAP(mode);
c=0; do {
int j;
VARDECL(opus_val32, x); VARDECL(opus_val32, x);
VARDECL(opus_val32, tmp);
int b;
int N2 = N;
int B = 1;
SAVE_STACK; SAVE_STACK;
ALLOC(x, N+overlap, opus_val32); ALLOC(x, N+overlap, opus_val32);
ALLOC(tmp, N, opus_val32); c=0; do {
int j;
int b;
int N2 = N;
int B = 1;
if (shortBlocks) if (shortBlocks)
{ {
@ -462,10 +460,8 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X
for (b=0;b<B;b++) for (b=0;b<B;b++)
{ {
/* De-interleaving the sub-frames */ /* IMDCT on the interleaved the sub-frames */
for (j=0;j<N2;j++) clt_mdct_backward(&mode->mdct, &X[b+c*N2*B], x+N2*b, mode->window, overlap, shortBlocks ? mode->maxLM : mode->maxLM-LM, B);
tmp[j] = X[(j*B+b)+c*N2*B];
clt_mdct_backward(&mode->mdct, tmp, x+N2*b, mode->window, overlap, shortBlocks ? mode->maxLM : mode->maxLM-LM);
} }
for (j=0;j<overlap;j++) for (j=0;j<overlap;j++)
@ -474,8 +470,8 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X
out_mem[c][j] = x[j]; out_mem[c][j] = x[j];
for (j=0;j<overlap;j++) for (j=0;j<overlap;j++)
overlap_mem[c][j] = x[N+j]; overlap_mem[c][j] = x[N+j];
RESTORE_STACK;
} while (++c<C); } while (++c<C);
RESTORE_STACK;
} }
static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int _C, int downsample, const opus_val16 *coef, celt_sig *mem) static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int _C, int downsample, const opus_val16 *coef, celt_sig *mem)

View file

@ -202,7 +202,8 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
RESTORE_STACK; RESTORE_STACK;
} }
void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 * restrict window, int overlap, int shift) void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out,
const opus_val16 * restrict window, int overlap, int shift, int stride)
{ {
int i; int i;
int N, N2, N4; int N, N2, N4;
@ -227,7 +228,7 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala
{ {
/* Temp pointers to make it really clear to the compiler what we're doing */ /* Temp pointers to make it really clear to the compiler what we're doing */
const kiss_fft_scalar * restrict xp1 = in; const kiss_fft_scalar * restrict xp1 = in;
const kiss_fft_scalar * restrict xp2 = in+N2-1; const kiss_fft_scalar * restrict xp2 = in+stride*(N2-1);
kiss_fft_scalar * restrict yp = f2; kiss_fft_scalar * restrict yp = f2;
const kiss_twiddle_scalar *t = &l->trig[0]; const kiss_twiddle_scalar *t = &l->trig[0];
for(i=0;i<N4;i++) for(i=0;i<N4;i++)
@ -238,8 +239,8 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala
/* works because the cos is nearly one */ /* works because the cos is nearly one */
*yp++ = yr - S_MUL(yi,sine); *yp++ = yr - S_MUL(yi,sine);
*yp++ = yi + S_MUL(yr,sine); *yp++ = yi + S_MUL(yr,sine);
xp1+=2; xp1+=2*stride;
xp2-=2; xp2-=2*stride;
} }
} }

View file

@ -60,6 +60,7 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
/** Compute a backward MDCT (no scaling) and performs weighted overlap-add /** Compute a backward MDCT (no scaling) and performs weighted overlap-add
(scales implicitly by 1/2) */ (scales implicitly by 1/2) */
void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const opus_val16 * restrict window, int overlap, int shift); void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out,
const opus_val16 * restrict window, int overlap, int shift, int stride);
#endif #endif

View file

@ -122,7 +122,7 @@ void test1d(int nfft,int isinverse)
{ {
for (k=0;k<nfft;++k) for (k=0;k<nfft;++k)
out[k] = 0; out[k] = 0;
clt_mdct_backward(&cfg,in,out, window, nfft/2, 0); clt_mdct_backward(&cfg,in,out, window, nfft/2, 0, 1);
check_inv(in,out,nfft,isinverse); check_inv(in,out,nfft,isinverse);
} else { } else {
clt_mdct_forward(&cfg,in,out,window, nfft/2, 0); clt_mdct_forward(&cfg,in,out,window, nfft/2, 0);