static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits) { int n, i, j, k, n2; double tmp_re, tmp_im, s, c; FFTComplex *q; n = 1 << nbits; n2 = n >> 1; for (i = 0; i < n; i++) { tmp_re = 0; tmp_im = 0; q = tab; for (j = 0; j < n; j++) { k = (i * j) & (n - 1); if (k >= n2) { c = -exptab[k - n2].re; s = -exptab[k - n2].im; } else { c = exptab[k].re; s = exptab[k].im; } CMAC(tmp_re, tmp_im, c, s, q->re, q->im); q++; } tabr[i].re = REF_SCALE(tmp_re, nbits); tabr[i].im = REF_SCALE(tmp_im, nbits); } }
/* NOTE: no normalisation by 1 / N is done */ static void mdct_ref(FFTSample *output, FFTSample *input, int nbits) { int i, k, n = 1 << nbits; /* do it by hand */ for (k = 0; k < n / 2; k++) { double s = 0; for (i = 0; i < n; i++) { double a = (2 * M_PI * (2 * i + 1 + n / 2) * (2 * k + 1) / (4 * n)); s += input[i] * cos(a); } output[k] = REF_SCALE(s, nbits - 1); } }
static void imdct_ref(FFTSample *out, FFTSample *in, int nbits) { int i, k, n = 1 << nbits; for (i = 0; i < n; i++) { double sum = 0; for (k = 0; k < n / 2; k++) { int a = (2 * i + 1 + (n / 2)) * (2 * k + 1); double f = cos(M_PI * a / (double) (2 * n)); sum += f * in[k]; } out[i] = REF_SCALE(-sum, nbits - 2); } }