X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=imdct.c;h=61498f73c8dd0ed656bb665e92480fb110cada12;hp=e2cfe03426eee48092b6973924e7e458a7a4fab3;hb=b6cb7e33fedf463ebb2c5cc0afe2f2a42f694f1e;hpb=44aa9a29ecc951d74a28bd79462cb0f9b628523e diff --git a/imdct.c b/imdct.c index e2cfe034..61498f73 100644 --- a/imdct.c +++ b/imdct.c @@ -29,8 +29,6 @@ typedef float fftsample_t; -#define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) -#define DECLARE_ALIGNED_16(t, v) DECLARE_ALIGNED(16, t, v) #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ struct fft_complex { @@ -42,8 +40,6 @@ struct fft_context { int inverse; uint16_t *revtab; struct fft_complex *exptab; - struct fft_complex *exptab1; /* only used by SSE code */ - struct fft_complex *tmp_buf; }; struct mdct_context { @@ -327,78 +323,29 @@ 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; s->nbits = nbits; n = 1 << nbits; - s->tmp_buf = NULL; s->exptab = para_malloc((n / 2) * sizeof(struct fft_complex)); 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; return 0; } @@ -406,29 +353,6 @@ static void fft_end(struct fft_context *ctx) { freep(&ctx->revtab); freep(&ctx->exptab); - freep(&ctx->exptab1); - freep(&ctx->tmp_buf); -} - -DECLARE_ALIGNED(16, float, ff_sine_128[128]); -DECLARE_ALIGNED(16, float, ff_sine_256[256]); -DECLARE_ALIGNED(16, float, ff_sine_512[512]); -DECLARE_ALIGNED(16, float, ff_sine_1024[1024]); -DECLARE_ALIGNED(16, float, ff_sine_2048[2048]); -DECLARE_ALIGNED(16, float, ff_sine_4096[4096]); - -float *ff_sine_windows[6] = { - ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, - ff_sine_2048, ff_sine_4096 -}; - -// Generate a sine window. -void sine_window_init(float *window, int n) -{ - int i; - - for (i = 0; i < n; i++) - window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); } /**