X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=imdct.c;h=89ee2dfb4ff8c48e78ad589d8bba0102d33bb153;hp=e3021b45cd0c3522a06b3043bf8a5a1e93056e6a;hb=73e718f38aff8c558e8c1a08ec063dbc5b4cb9c6;hpb=f481eaddec671c3783cc098d65be29ea16ee81b1 diff --git a/imdct.c b/imdct.c index e3021b45..89ee2dfb 100644 --- a/imdct.c +++ b/imdct.c @@ -219,6 +219,7 @@ static void fft16(struct fft_complex *z) TRANSFORM(z[1], z[5], z[9], z[13], ff_cos_16[1], ff_cos_16[3]); TRANSFORM(z[3], z[7], z[11], z[15], ff_cos_16[3], ff_cos_16[1]); } + DECL_FFT(32, 16, 8) DECL_FFT(64, 32, 16) DECL_FFT(128, 64, 32) @@ -233,8 +234,7 @@ DECL_FFT(16384, 8192, 4096) DECL_FFT(32768, 16384, 8192) DECL_FFT(65536, 32768, 16384) -static void (*fft_dispatch[]) (struct fft_complex *) = -{ +static void (*fft_dispatch[]) (struct fft_complex *) = { fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024, fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, }; @@ -247,12 +247,12 @@ static void fft(struct fft_context *s, struct fft_complex *z) /* complex multiplication: p = a * b */ #define CMUL(pre, pim, are, aim, bre, bim) \ {\ - fftsample_t _are = (are);\ - fftsample_t _aim = (aim);\ - fftsample_t _bre = (bre);\ - fftsample_t _bim = (bim);\ - (pre) = _are * _bre - _aim * _bim;\ - (pim) = _are * _bim + _aim * _bre;\ + fftsample_t _are = (are);\ + fftsample_t _aim = (aim);\ + fftsample_t _bre = (bre);\ + fftsample_t _bim = (bim);\ + (pre) = _are * _bre - _aim * _bim;\ + (pim) = _are * _bim + _aim * _bre;\ } /** @@ -327,9 +327,7 @@ void imdct(struct mdct_context *s, float *output, const float *input) static int fft_init(struct fft_context *s, int nbits, int inverse) { - int i, j, m, n; - float alpha, c1, s1, s2; - int split_radix = 1; + int i, j, n; if (nbits < 2 || nbits > 16) return -E_FFT_BAD_PARAMS; @@ -341,66 +339,21 @@ static int fft_init(struct fft_context *s, int nbits, int inverse) s->revtab = para_malloc(n * sizeof(uint16_t)); s->inverse = inverse; - s2 = inverse ? 1.0 : -1.0; - s->exptab1 = NULL; - if (split_radix) { - for (j = 4; j <= nbits; j++) { - int k = 1 << j; - double freq = 2 * M_PI / k; - fftsample_t *tab = ff_cos_tabs[j - 4]; - for (i = 0; i <= k / 4; i++) - tab[i] = cos(i * freq); - for (i = 1; i < k / 4; i++) - tab[k / 2 - i] = tab[i]; - } - for (i = 0; i < n; i++) - s->revtab[-split_radix_permutation( - i, n, s->inverse) & (n - 1)] = i; - s->tmp_buf = para_malloc(n * sizeof(struct fft_complex)); - } else { - int np, nblocks, np2, l; - struct fft_complex *q; - - for (i = 0; i < (n / 2); i++) { - alpha = 2 * M_PI * (float) i / (float) n; - c1 = cos(alpha); - s1 = sin(alpha) * s2; - s->exptab[i].re = c1; - s->exptab[i].im = s1; - } - - np = 1 << nbits; - nblocks = np >> 3; - np2 = np >> 1; - s->exptab1 = para_malloc(np * 2 * sizeof(struct fft_complex)); - q = s->exptab1; - do { - for (l = 0; l < np2; l += 2 * nblocks) { - *q++ = s->exptab[l]; - *q++ = s->exptab[l + nblocks]; - - q->re = -s->exptab[l].im; - q->im = s->exptab[l].re; - q++; - q->re = -s->exptab[l + nblocks].im; - q->im = s->exptab[l + nblocks].re; - q++; - } - nblocks = nblocks >> 1; - } while (nblocks != 0); - freep(&s->exptab); - - /* compute bit reverse table */ - for (i = 0; i < n; i++) { - m = 0; - for (j = 0; j < nbits; j++) { - m |= ((i >> j) & 1) << (nbits - j - 1); - } - s->revtab[i] = m; - } + for (j = 4; j <= nbits; j++) { + int k = 1 << j; + double freq = 2 * M_PI / k; + fftsample_t *tab = ff_cos_tabs[j - 4]; + for (i = 0; i <= k / 4; i++) + tab[i] = cos(i * freq); + for (i = 1; i < k / 4; i++) + tab[k / 2 - i] = tab[i]; } + for (i = 0; i < n; i++) + s->revtab[-split_radix_permutation( + i, n, s->inverse) & (n - 1)] = i; + s->tmp_buf = para_malloc(n * sizeof(struct fft_complex)); return 0; } @@ -442,8 +395,7 @@ int imdct_init(int nbits, int inverse, struct mdct_context **result) double alpha; struct mdct_context *s; - s = para_malloc(sizeof(*s)); - memset(s, 0, sizeof(*s)); + s = para_calloc(sizeof(*s)); n = 1 << nbits; s->nbits = nbits; s->n = n;