I am new to this forum, but have been spending the past few weeks studying the LAME encoder. In particular, I'm looking at the implementation of the psychoacoustic model(s), and as a result have been looking at the compute_ffts(...) function.
Take the function fft_short, for example. Can someone help me understand how the steps in this function actually compute the Fourier Transform? I'm not really sure what the window_s and rv_tbl tables are actually representing, and it is making the whole thing very difficult to follow. If someone is able to maybe break it down and explain it further, I would much appreciate it.
Below is the fft_short function as defined in fft.c:
CODE
#define ms00(f) (window_s[i ] * f(i + k))
#define ms10(f) (window_s[0x7f - i] * f(i + k + 0x80))
#define ms20(f) (window_s[i + 0x40] * f(i + k + 0x40))
#define ms30(f) (window_s[0x3f - i] * f(i + k + 0xc0))
#define ms01(f) (window_s[i + 0x01] * f(i + k + 0x01))
#define ms11(f) (window_s[0x7e - i] * f(i + k + 0x81))
#define ms21(f) (window_s[i + 0x41] * f(i + k + 0x41))
#define ms31(f) (window_s[0x3e - i] * f(i + k + 0xc1))
...
void fft_short(lame_internal_flags * const gfc,
FLOAT x_real[3][BLKSIZE_s], int chn, const sample_t *buffer[2])
{
int i;
int j;
int b;
for (b = 0; b < 3; b++) {
FLOAT *x = &x_real[b][BLKSIZE_s / 2];
short k = (576 / 3) * (b + 1);
j = BLKSIZE_s / 8 - 1;
do {
FLOAT f0,f1,f2,f3, w;
i = rv_tbl[j << 2];
f0 = ms00(ch01); w = ms10(ch01); f1 = f0 - w; f0 = f0 + w;
f2 = ms20(ch01); w = ms30(ch01); f3 = f2 - w; f2 = f2 + w;
x -= 4;
x[0] = f0 + f2;
x[2] = f0 - f2;
x[1] = f1 + f3;
x[3] = f1 - f3;
f0 = ms01(ch01); w = ms11(ch01); f1 = f0 - w; f0 = f0 + w;
f2 = ms21(ch01); w = ms31(ch01); f3 = f2 - w; f2 = f2 + w;
x[BLKSIZE_s / 2 + 0] = f0 + f2;
x[BLKSIZE_s / 2 + 2] = f0 - f2;
x[BLKSIZE_s / 2 + 1] = f1 + f3;
x[BLKSIZE_s / 2 + 3] = f1 - f3;
} while (--j >= 0);
gfc->fft_fht(x, BLKSIZE_s/2);
/* BLKSIZE_s/2 because of 3DNow! ASM routine */
}
}

