36 # define RSCALE(x, y) ((x) + (y))
39 # define RSCALE(x, y) ((int)((x) + (unsigned)(y) + 32) >> 6)
41 # define RSCALE(x, y) ((int)((x) + (unsigned)(y)) >> 1)
54 memset(s, 0,
sizeof(*s));
81 theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
82 scale = sqrt(fabs(scale));
84 alpha = 2 *
M_PI * (i + theta) / n;
86 s->
tcos[i*tstep] =
lrint(-cos(alpha) * 2147483648.0);
87 s->
tsin[i*tstep] =
lrint(-sin(alpha) * 2147483648.0);
89 s->
tcos[i*tstep] =
FIX15(-cos(alpha) * scale);
90 s->
tsin[i*tstep] =
FIX15(-sin(alpha) * scale);
107 int k, n8, n4, n2,
n, j;
108 const uint16_t *revtab = s->
revtab;
121 in2 = input + n2 - 1;
122 for(k = 0; k < n4; k++) {
124 CMUL(z[j].
re, z[j].
im, *in2, *in1, tcos[k], tsin[k]);
131 for(k = 0; k < n8; k++) {
133 CMUL(r0, i1, z[n8-k-1].
im, z[n8-k-1].
re, tsin[n8-k-1], tcos[n8-k-1]);
134 CMUL(r1, i0, z[n8+k ].
im, z[n8+k ].
re, tsin[n8+k ], tcos[n8+k ]);
156 for(k = 0; k < n4; k++) {
157 output[k] = -output[n2-k-1];
158 output[n-k-1] = output[n2+k];
169 int i, j,
n, n8, n4, n2, n3;
171 const uint16_t *revtab = s->
revtab;
184 re =
RSCALE(-input[2*i+n3], - input[n3-1-2*i]);
185 im =
RSCALE(-input[n4+2*i], + input[n4-1-2*i]);
187 CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
189 re =
RSCALE( input[2*i] , - input[n2-1-2*i]);
190 im =
RSCALE(-input[n2+2*i], - input[ n-1-2*i]);
192 CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
200 CMUL(i1, r0, x[n8-i-1].re, x[n8-i-1].im, -tsin[n8-i-1], -tcos[n8-i-1]);
201 CMUL(i0, r1, x[n8+i ].re, x[n8+i ].im, -tsin[n8+i ], -tcos[n8+i ]);
static float alpha(float a)
av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
init MDCT or IMDCT computation.
void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
Compute the middle half of the inverse MDCT of size N = 2^nbits, thus excluding the parts that can be...
#define CMUL(dre, dim, are, aim, bre, bim)
void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
Compute MDCT of size N = 2^nbits.
av_cold void ff_mdct_end(FFTContext *s)
Replacements for frequently missing libm functions.
common internal and external API header
void(* fft_calc)(struct FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in ff_fft_init().
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
#define av_malloc_array(a, b)
enum mdct_permutation_type mdct_permutation
void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input)
Compute inverse MDCT of size N = 2^nbits.