From 53bcf6d03c8dcfc2d9ac44c837661a84acec8d48 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 2 Jun 2025 21:45:34 +0200 Subject: [PATCH] imdct: Kill fftsample_t typedef. There is no advantage in not using plain float here. --- imdct.c | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/imdct.c b/imdct.c index ae06c235..25948f10 100644 --- a/imdct.c +++ b/imdct.c @@ -22,14 +22,12 @@ #include "imdct.h" #include "wma.h" -typedef float fftsample_t; - /** Canonical representation of a complex number. */ struct fft_complex { /** Real part. */ - fftsample_t re; + float re; /** Imaginary part. */ - fftsample_t im; + float im; }; /** FFT Lookup table. */ @@ -46,9 +44,9 @@ struct mdct_context { /** n = 2^n bits. */ int nbits; /** Cosine table for pre/post rotation. */ - fftsample_t *tcos; + float *tcos; /** Sine table for pre/post rotation. */ - fftsample_t *tsin; + float *tsin; /** The context for the underlying fast Fourier transform. */ struct fft_context fft; }; @@ -56,7 +54,7 @@ struct mdct_context { /** \cond cosine_tabs */ /* cos(2 * pi * x / n) for 0 <= x <= n / 4, followed by its reverse */ -#define COSINE_TAB(n) static fftsample_t cos_ ## n[n / 2] __a_aligned(16) +#define COSINE_TAB(n) static float cos_ ## n[n / 2] __a_aligned(16) COSINE_TAB(16); COSINE_TAB(32); @@ -72,7 +70,7 @@ COSINE_TAB(16384); COSINE_TAB(32768); COSINE_TAB(65536); -static fftsample_t *cos_tabs[] = { +static float *cos_tabs[] = { cos_16, cos_32, cos_64, cos_128, cos_256, cos_512, cos_1024, cos_2048, cos_4096, cos_8192, cos_16384, cos_32768, cos_65536, }; @@ -113,7 +111,7 @@ __a_const static int split_radix_permutation(int i, int n) * powers of 2. */ #define BUTTERFLIES_BIG(a0, a1, a2, a3) {\ - fftsample_t r0 = a0.re, i0 = a0.im, r1 = a1.re, i1 = a1.im;\ + float r0 = a0.re, i0 = a0.im, r1 = a1.re, i1 = a1.im;\ BF(t3, t5, t5, t1);\ BF(a2.re, a0.re, r0, t5);\ BF(a3.im, a1.im, i1, t3);\ @@ -139,13 +137,13 @@ __a_const static int split_radix_permutation(int i, int n) } /* z[0...8n - 1], w[1...2n - 1] */ -static void pass(struct fft_complex *z, const fftsample_t *wre, unsigned int n) +static void pass(struct fft_complex *z, const float *wre, unsigned int n) { - fftsample_t t1, t2, t3, t4, t5, t6; + float t1, t2, t3, t4, t5, t6; int o1 = 2 * n; int o2 = 4 * n; int o3 = 6 * n; - const fftsample_t *wim = wre + o1; + const float *wim = wre + o1; n--; TRANSFORM_ZERO(z[0], z[o1], z[o2], z[o3]); @@ -173,7 +171,7 @@ static void fft##n(struct fft_complex *z)\ static void fft4(struct fft_complex *z) { - fftsample_t t1, t2, t3, t4, t5, t6, t7, t8; + float t1, t2, t3, t4, t5, t6, t7, t8; BF(t3, t1, z[0].re, z[1].re); BF(t8, t6, z[3].re, z[2].re); @@ -187,7 +185,7 @@ static void fft4(struct fft_complex *z) static void fft8(struct fft_complex *z) { - fftsample_t t1, t2, t3, t4, t5, t6, t7, t8; + float t1, t2, t3, t4, t5, t6, t7, t8; fft4(z); @@ -207,7 +205,7 @@ static void fft8(struct fft_complex *z) static void fft16(struct fft_complex *z) { - fftsample_t t1, t2, t3, t4, t5, t6; + float t1, t2, t3, t4, t5, t6; fft8(z); fft4(z + 8); @@ -241,10 +239,10 @@ static void (*fft_dispatch[]) (struct fft_complex *) = { /* 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);\ + float _are = (are);\ + float _aim = (aim);\ + float _bre = (bre);\ + float _bim = (bim);\ (pre) = _are * _bre - _aim * _bim;\ (pim) = _are * _bim + _aim * _bre;\ } @@ -253,14 +251,14 @@ static void (*fft_dispatch[]) (struct fft_complex *) = { * Compute the middle half of the inverse MDCT, excluding the parts that can be * derived by symmetry. */ -static void imdct_half(struct mdct_context *s, fftsample_t *output, - const fftsample_t *input) +static void imdct_half(struct mdct_context *s, float *output, + const float *input) { int k, n8, n4, n2, n, j; const uint16_t *revtab = s->fft.revtab; - const fftsample_t *tcos = s->tcos; - const fftsample_t *tsin = s->tsin; - const fftsample_t *in1, *in2; + const float *tcos = s->tcos; + const float *tsin = s->tsin; + const float *in1, *in2; struct fft_complex *z = (struct fft_complex *)output; n = 1 << s->nbits; @@ -281,7 +279,7 @@ static void imdct_half(struct mdct_context *s, fftsample_t *output, /* post rotation + reordering */ for (k = 0; k < n8; k++) { - fftsample_t r0, i0, r1, i1; + float r0, i0, r1, i1; CMUL(r0, i1, z[n8 - k - 1].im, z[n8 - k - 1].re, tsin[n8 - k - 1], tcos[n8 - k - 1]); CMUL(r1, i0, z[n8 + k].im, z[n8 + k].re, tsin[n8 + k], @@ -330,7 +328,7 @@ static int fft_init(struct fft_context *s, int nbits) for (j = 4; j <= nbits; j++) { int k = 1 << j; double freq = 2 * M_PI / k; - fftsample_t *tab = cos_tabs[j - 4]; + float *tab = cos_tabs[j - 4]; for (i = 0; i <= k / 4; i++) tab[i] = cos(i * freq); for (i = 1; i < k / 4; i++) @@ -361,8 +359,8 @@ int imdct_init(int nbits, struct mdct_context **result) s->nbits = nbits; s->n = n; n4 = n >> 2; - s->tcos = arr_alloc(n4, sizeof(fftsample_t)); - s->tsin = arr_alloc(n4, sizeof(fftsample_t)); + s->tcos = arr_alloc(n4, sizeof(float)); + s->tsin = arr_alloc(n4, sizeof(float)); for (i = 0; i < n4; i++) { alpha = 2 * M_PI * (i + 1.0 / 8.0) / n; -- 2.39.5