Making the MDCT produce interleaved data
This commit is contained in:
parent
dbeb86fd05
commit
a6b4e25628
4 changed files with 19 additions and 22 deletions
|
@ -401,32 +401,24 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * rest
|
||||||
if (C==1 && !shortBlocks)
|
if (C==1 && !shortBlocks)
|
||||||
{
|
{
|
||||||
const int overlap = OVERLAP(mode);
|
const int overlap = OVERLAP(mode);
|
||||||
clt_mdct_forward(&mode->mdct, in, out, mode->window, overlap, mode->maxLM-LM);
|
clt_mdct_forward(&mode->mdct, in, out, mode->window, overlap, mode->maxLM-LM, 1);
|
||||||
} else {
|
} else {
|
||||||
const int overlap = OVERLAP(mode);
|
const int overlap = OVERLAP(mode);
|
||||||
int N = mode->shortMdctSize<<LM;
|
int N = mode->shortMdctSize<<LM;
|
||||||
int B = 1;
|
int B = 1;
|
||||||
int b, c;
|
int b, c;
|
||||||
VARDECL(opus_val32, tmp);
|
|
||||||
SAVE_STACK;
|
|
||||||
if (shortBlocks)
|
if (shortBlocks)
|
||||||
{
|
{
|
||||||
/*lookup = &mode->mdct[0];*/
|
|
||||||
N = mode->shortMdctSize;
|
N = mode->shortMdctSize;
|
||||||
B = shortBlocks;
|
B = shortBlocks;
|
||||||
}
|
}
|
||||||
ALLOC(tmp, N, opus_val32);
|
|
||||||
c=0; do {
|
c=0; do {
|
||||||
for (b=0;b<B;b++)
|
for (b=0;b<B;b++)
|
||||||
{
|
{
|
||||||
int j;
|
/* Interleaving the sub-frames while doing the MDCTs */
|
||||||
clt_mdct_forward(&mode->mdct, in+c*(B*N+overlap)+b*N, tmp, mode->window, overlap, shortBlocks ? mode->maxLM : mode->maxLM-LM);
|
clt_mdct_forward(&mode->mdct, in+c*(B*N+overlap)+b*N, &out[b+c*N*B], mode->window, overlap, shortBlocks ? mode->maxLM : mode->maxLM-LM, B);
|
||||||
/* Interleaving the sub-frames */
|
|
||||||
for (j=0;j<N;j++)
|
|
||||||
out[(j*B+b)+c*N*B] = tmp[j];
|
|
||||||
}
|
}
|
||||||
} while (++c<C);
|
} while (++c<C);
|
||||||
RESTORE_STACK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,8 @@ void clt_mdct_clear(mdct_lookup *l)
|
||||||
|
|
||||||
#endif /* CUSTOM_MODES */
|
#endif /* CUSTOM_MODES */
|
||||||
|
|
||||||
void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 *window, int overlap, int shift)
|
void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out,
|
||||||
|
const opus_val16 *window, int overlap, int shift, int stride)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int N, N2, N4;
|
int N, N2, N4;
|
||||||
|
@ -124,7 +125,7 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
|
||||||
/* 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+(overlap>>1);
|
const kiss_fft_scalar * restrict xp1 = in+(overlap>>1);
|
||||||
const kiss_fft_scalar * restrict xp2 = in+N2-1+(overlap>>1);
|
const kiss_fft_scalar * restrict xp2 = in+N2-1+(overlap>>1);
|
||||||
kiss_fft_scalar * restrict yp = out;
|
kiss_fft_scalar * restrict yp = f;
|
||||||
const opus_val16 * restrict wp1 = window+(overlap>>1);
|
const opus_val16 * restrict wp1 = window+(overlap>>1);
|
||||||
const opus_val16 * restrict wp2 = window+(overlap>>1)-1;
|
const opus_val16 * restrict wp2 = window+(overlap>>1)-1;
|
||||||
for(i=0;i<(overlap>>2);i++)
|
for(i=0;i<(overlap>>2);i++)
|
||||||
|
@ -160,7 +161,7 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
|
||||||
}
|
}
|
||||||
/* Pre-rotation */
|
/* Pre-rotation */
|
||||||
{
|
{
|
||||||
kiss_fft_scalar * restrict yp = out;
|
kiss_fft_scalar * restrict yp = f;
|
||||||
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++)
|
||||||
{
|
{
|
||||||
|
@ -176,14 +177,14 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N/4 complex FFT, down-scales by 4/N */
|
/* N/4 complex FFT, down-scales by 4/N */
|
||||||
opus_fft(l->kfft[shift], (kiss_fft_cpx *)out, (kiss_fft_cpx *)f);
|
opus_fft(l->kfft[shift], (kiss_fft_cpx *)f, (kiss_fft_cpx *)in);
|
||||||
|
|
||||||
/* Post-rotate */
|
/* Post-rotate */
|
||||||
{
|
{
|
||||||
/* 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 fp = f;
|
const kiss_fft_scalar * restrict fp = in;
|
||||||
kiss_fft_scalar * restrict yp1 = out;
|
kiss_fft_scalar * restrict yp1 = out;
|
||||||
kiss_fft_scalar * restrict yp2 = out+N2-1;
|
kiss_fft_scalar * restrict yp2 = out+stride*(N2-1);
|
||||||
const kiss_twiddle_scalar *t = &l->trig[0];
|
const kiss_twiddle_scalar *t = &l->trig[0];
|
||||||
/* 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 */
|
||||||
for(i=0;i<N4;i++)
|
for(i=0;i<N4;i++)
|
||||||
|
@ -195,8 +196,8 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
|
||||||
*yp1 = yr - S_MUL(yi,sine);
|
*yp1 = yr - S_MUL(yi,sine);
|
||||||
*yp2 = yi + S_MUL(yr,sine);;
|
*yp2 = yi + S_MUL(yr,sine);;
|
||||||
fp += 2;
|
fp += 2;
|
||||||
yp1 += 2;
|
yp1 += 2*stride;
|
||||||
yp2 -= 2;
|
yp2 -= 2*stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
|
|
|
@ -56,7 +56,8 @@ int clt_mdct_init(mdct_lookup *l,int N, int maxshift);
|
||||||
void clt_mdct_clear(mdct_lookup *l);
|
void clt_mdct_clear(mdct_lookup *l);
|
||||||
|
|
||||||
/** Compute a forward MDCT and scale by 4/N */
|
/** Compute a forward MDCT and scale by 4/N */
|
||||||
void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const opus_val16 *window, int overlap, int shift);
|
void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out,
|
||||||
|
const opus_val16 *window, int overlap, int shift, int stride);
|
||||||
|
|
||||||
/** 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) */
|
||||||
|
|
|
@ -93,6 +93,7 @@ void test1d(int nfft,int isinverse)
|
||||||
size_t buflen = sizeof(kiss_fft_scalar)*nfft;
|
size_t buflen = sizeof(kiss_fft_scalar)*nfft;
|
||||||
|
|
||||||
kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen);
|
kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen);
|
||||||
|
kiss_fft_scalar * in_copy = (kiss_fft_scalar*)malloc(buflen);
|
||||||
kiss_fft_scalar * out= (kiss_fft_scalar*)malloc(buflen);
|
kiss_fft_scalar * out= (kiss_fft_scalar*)malloc(buflen);
|
||||||
opus_val16 * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2);
|
opus_val16 * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2);
|
||||||
int k;
|
int k;
|
||||||
|
@ -116,6 +117,8 @@ void test1d(int nfft,int isinverse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (k=0;k<nfft;++k)
|
||||||
|
in_copy[k] = in[k];
|
||||||
/*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/
|
/*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/
|
||||||
|
|
||||||
if (isinverse)
|
if (isinverse)
|
||||||
|
@ -125,8 +128,8 @@ void test1d(int nfft,int isinverse)
|
||||||
clt_mdct_backward(&cfg,in,out, window, nfft/2, 0, 1);
|
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, 1);
|
||||||
check(in,out,nfft,isinverse);
|
check(in_copy,out,nfft,isinverse);
|
||||||
}
|
}
|
||||||
/*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/
|
/*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue