#endif
}
+static const int avx_tab[] = {
+ 0, 4, 1, 5, 8, 12, 9, 13, 2, 6, 3, 7, 10, 14, 11, 15
+};
+
+static int is_second_half_of_fft32(int i, int n)
+{
+ if (n <= 32)
+ return i >= 16;
+ else if (i < n/2)
+ return is_second_half_of_fft32(i, n/2);
+ else if (i < 3*n/4)
+ return is_second_half_of_fft32(i - n/2, n/4);
+ else
+ return is_second_half_of_fft32(i - 3*n/4, n/4);
+}
+
+static av_cold void fft_perm_avx(FFTContext *s)
+{
+ int i;
+ int n = 1 << s->nbits;
+
+ for (i = 0; i < n; i += 16) {
+ int k;
+ if (is_second_half_of_fft32(i, n)) {
+ for (k = 0; k < 16; k++)
+ s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] =
+ i + avx_tab[k];
+
+ } else {
+ for (k = 0; k < 16; k++) {
+ int j = i + k;
+ j = (j & ~7) | ((j >> 1) & 3) | ((j << 2) & 4);
+ s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] = j;
+ }
+ }
+ }
+}
+
av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
{
int i, j, n;
#if CONFIG_FFT_FLOAT
if (ARCH_ARM) ff_fft_init_arm(s);
if (HAVE_ALTIVEC) ff_fft_init_altivec(s);
- if (HAVE_MMX) ff_fft_init_mmx(s);
+ if (ARCH_X86) ff_fft_init_x86(s);
+ if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc;
+#else
+ if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c;
+ if (ARCH_ARM) ff_fft_fixed_init_arm(s);
#endif
for(j=4; j<=nbits; j++) {
ff_init_ff_cos_tabs(j);
}
- for(i=0; i<n; i++) {
- int j = i;
- if (s->fft_permutation == FF_FFT_PERM_SWAP_LSBS)
- j = (j&~3) | ((j>>1)&1) | ((j<<1)&2);
- s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = j;
+
+ if (s->fft_permutation == FF_FFT_PERM_AVX) {
+ fft_perm_avx(s);
+ } else {
+ for(i=0; i<n; i++) {
+ int j = i;
+ if (s->fft_permutation == FF_FFT_PERM_SWAP_LSBS)
+ j = (j&~3) | ((j>>1)&1) | ((j<<1)&2);
+ s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = j;
+ }
}
return 0;
static void fft8(FFTComplex *z)
{
- FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
+ FFTDouble t1, t2, t3, t4, t5, t6;
fft4(z);
BF(t1, z[5].re, z[4].re, -z[5].re);
BF(t2, z[5].im, z[4].im, -z[5].im);
- BF(t3, z[7].re, z[6].re, -z[7].re);
- BF(t4, z[7].im, z[6].im, -z[7].im);
- BF(t8, t1, t3, t1);
- BF(t7, t2, t2, t4);
- BF(z[4].re, z[0].re, z[0].re, t1);
- BF(z[4].im, z[0].im, z[0].im, t2);
- BF(z[6].re, z[2].re, z[2].re, t7);
- BF(z[6].im, z[2].im, z[2].im, t8);
+ BF(t5, z[7].re, z[6].re, -z[7].re);
+ BF(t6, z[7].im, z[6].im, -z[7].im);
+ BUTTERFLIES(z[0],z[2],z[4],z[6]);
TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf);
}
{
fft_dispatch[s->nbits-2](z);
}
-