some index work (simplifications for dumb compilers) on IMDCT

This commit is contained in:
Jean-Marc Valin 2008-04-10 18:54:02 +10:00
parent 6d3289c718
commit c1a4c2ec44

View file

@ -167,37 +167,62 @@ void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *
ALLOC(f, N2, kiss_fft_scalar); ALLOC(f, N2, kiss_fft_scalar);
/* Pre-rotate */ /* Pre-rotate */
for(i=0;i<N4;i++)
{ {
out[2*i] = -S_MUL(in[N2-2*i-1], l->trig[i]) - S_MUL(in[2*i],l->trig[i+N4]); /* Temp pointers to make it really clear to the compiler what we're doing */
out[2*i+1] = S_MUL(in[N2-2*i-1], l->trig[i+N4]) - S_MUL(in[2*i],l->trig[i]); const kiss_fft_scalar * restrict xp1 = in;
const kiss_fft_scalar * restrict xp2 = in+N2-1;
kiss_fft_scalar * restrict yp = out;
for(i=0;i<N4;i++)
{
*yp++ = -S_MUL(*xp2, l->trig[i]) - S_MUL(*xp1,l->trig[i+N4]);
*yp++ = S_MUL(*xp2, l->trig[i+N4]) - S_MUL(*xp1,l->trig[i]);
xp1+=2;
xp2-=2;
}
} }
/* Inverse N/4 complex FFT. This one should *not* downscale even in fixed-point */ /* Inverse N/4 complex FFT. This one should *not* downscale even in fixed-point */
cpx32_ifft(l->kfft, out, f, N4); cpx32_ifft(l->kfft, out, f, N4);
/* Post-rotate */ /* Post-rotate */
for(i=0;i<N4;i++)
{ {
kiss_fft_scalar re, im; kiss_fft_scalar * restrict fp = f;
re = f[2*i]; for(i=0;i<N4;i++)
im = f[2*i+1]; {
/* We'd scale up by 2 here, but instead it's done when mixing the windows */ kiss_fft_scalar re, im;
f[2*i] = S_MUL(re,l->trig[i]) + S_MUL(im,l->trig[i+N4]); re = fp[0];
f[2*i+1] = S_MUL(im,l->trig[i]) - S_MUL(re,l->trig[i+N4]); im = fp[1];
/* We'd scale up by 2 here, but instead it's done when mixing the windows */
fp[0] = S_MUL(re,l->trig[i]) + S_MUL(im,l->trig[i+N4]);
fp[1] = S_MUL(im,l->trig[i]) - S_MUL(re,l->trig[i+N4]);
fp += 2;
}
} }
/* De-shuffle the components for the middle of the window only */ /* De-shuffle the components for the middle of the window only */
for(i = 0; i < N4; i++)
{ {
out[N4+2*i] =-f[2*i]; const kiss_fft_scalar * restrict fp1 = f;
out[N4+2*i+1] = f[N2-2*i-1]; const kiss_fft_scalar * restrict fp2 = f+N2-1;
kiss_fft_scalar * restrict yp = out+N4;
for(i = 0; i < N4; i++)
{
*yp++ =-*fp1;
*yp++ = *fp2;
fp1 += 2;
fp2 -= 2;
}
} }
/* Mirror on both sides for TDAC */ /* Mirror on both sides for TDAC */
for(i = 0; i < N4; i++)
{ {
out[i] =-out[N2-i-1]; const kiss_fft_scalar * restrict xp1 = out+N2-1;
out[N-i-1] = out[N2+i]; 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++)
{
*yp1++ =-*xp1--;
*yp2-- = *xp2++;
}
} }
RESTORE_STACK; RESTORE_STACK;
} }