36 #if !CONFIG_HARDCODED_TABLES
74 if(n <= 2)
return i&1;
84 #if !CONFIG_HARDCODED_TABLES
87 double freq = 2*M_PI/m;
90 tab[i] =
FIX15(cos(i*freq));
97 0, 4, 1, 5, 8, 12, 9, 13, 2, 6, 3, 7, 10, 14, 11, 15
115 int n = 1 << s->
nbits;
117 for (i = 0; i < n; i += 16) {
120 for (k = 0; k < 16; k++)
125 for (k = 0; k < 16; k++) {
127 j = (j & ~7) | ((j >> 1) & 3) | ((j << 2) & 4);
138 if (nbits < 2 || nbits > 16)
170 for(j=4; j<=nbits; j++) {
180 j = (j&~3) | ((j>>1)&1) | ((j<<1)&2);
195 const uint16_t *revtab = s->
revtab;
198 for(j=0;j<np;j++) s->
tmp_buf[revtab[j]] = z[j];
208 #define BUTTERFLIES(a0,a1,a2,a3) {\
210 BF(a2.re, a0.re, a0.re, t5);\
211 BF(a3.im, a1.im, a1.im, t3);\
213 BF(a3.re, a1.re, a1.re, t4);\
214 BF(a2.im, a0.im, a0.im, t6);\
220 #define BUTTERFLIES_BIG(a0,a1,a2,a3) {\
221 FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\
223 BF(a2.re, a0.re, r0, t5);\
224 BF(a3.im, a1.im, i1, t3);\
226 BF(a3.re, a1.re, r1, t4);\
227 BF(a2.im, a0.im, i0, t6);\
230 #define TRANSFORM(a0,a1,a2,a3,wre,wim) {\
231 CMUL(t1, t2, a2.re, a2.im, wre, -wim);\
232 CMUL(t5, t6, a3.re, a3.im, wre, wim);\
233 BUTTERFLIES(a0,a1,a2,a3)\
236 #define TRANSFORM_ZERO(a0,a1,a2,a3) {\
241 BUTTERFLIES(a0,a1,a2,a3)\
246 static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\
248 FFTDouble t1, t2, t3, t4, t5, t6;\
252 const FFTSample *wim = wre+o1;\
255 TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\
256 TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
261 TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\
262 TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
268 #define BUTTERFLIES BUTTERFLIES_BIG
271 #define DECL_FFT(n,n2,n4)\
272 static void fft##n(FFTComplex *z)\
277 pass(z,FFT_NAME(ff_cos_##n),n4/2);\
284 BF(t3, t1, z[0].
re, z[1].re);
285 BF(t8, t6, z[3].re, z[2].re);
286 BF(z[2].re, z[0].re, t1, t6);
287 BF(t4, t2, z[0].
im, z[1].im);
288 BF(t7, t5, z[2].im, z[3].im);
289 BF(z[3].im, z[1].im, t4, t8);
290 BF(z[3].re, z[1].re, t3, t7);
291 BF(z[2].im, z[0].im, t2, t5);
300 BF(t1, z[5].
re, z[4].re, -z[5].re);
301 BF(t2, z[5].
im, z[4].im, -z[5].im);
302 BF(t5, z[7].re, z[6].re, -z[7].re);
303 BF(t6, z[7].im, z[6].im, -z[7].im);
322 TRANSFORM(z[1],z[5],z[9],z[13],cos_16_1,cos_16_3);
323 TRANSFORM(z[3],z[7],z[11],z[15],cos_16_3,cos_16_1);
334 #define pass pass_big
345 fft4,
fft8,
fft16, fft32, fft64, fft128, fft256, fft512, fft1024,
346 fft2048, fft4096, fft8192, fft16384, fft32768, fft65536,
av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
Set up a complex FFT.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int is_second_half_of_fft32(int i, int n)
av_cold void ff_fft_end(FFTContext *s)
void(* mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
static void fft4(FFTComplex *z)
void(* fft_permute)(struct FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling fft_calc().
void ff_fft_init_altivec(FFTContext *s)
COSTABLE_CONST FFTSample *const FFT_NAME(ff_cos_tabs)[]
#define BUTTERFLIES(a0, a1, a2, a3)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
av_cold void ff_fft_init_arm(FFTContext *s)
#define FF_FFT_PERM_DEFAULT
static void ff_fft_calc_c(FFTContext *s, FFTComplex *z)
av_cold void ff_fft_fixed_init_arm(FFTContext *s)
void(* imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
static void(*const fft_dispatch[])(FFTComplex *)
#define TRANSFORM_ZERO(a0, a1, a2, a3)
static av_cold void fft_perm_avx(FFTContext *s)
#define FF_FFT_PERM_SWAP_LSBS
#define DECL_FFT(n, n2, n4)
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
void ff_mdct_calcw_c(FFTContext *s, FFTDouble *output, const FFTSample *input)
#define TRANSFORM(a0, a1, a2, a3, wre, wim)
void(* fft_calc)(struct FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in ff_fft_init().
static void fft16(FFTComplex *z)
static void ff_fft_permute_c(FFTContext *s, FFTComplex *z)
static int split_radix_permutation(int i, int n, int inverse)
static void fft8(FFTComplex *z)
static const struct twinvq_data tab
av_cold void ff_init_ff_cos_tabs(int index)
Initialize the cosine table in ff_cos_tabs[index].
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
static const int avx_tab[]
void(* mdct_calcw)(struct FFTContext *s, FFTDouble *output, const FFTSample *input)
void ff_fft_init_x86(FFTContext *s)