#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. */
/** 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;
};
/** \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);
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,
};
* 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);\
}
/* 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]);
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);
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);
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);
/* 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;\
}
* 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;
/* 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],
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++)
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;