2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "libavutil/tx_priv.h"
21 #include "libavutil/attributes.h"
22 #include "libavutil/x86/cpu.h"
24 void ff_fft2_float_sse3 (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
25 void ff_fft4_inv_float_sse2 (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
26 void ff_fft4_fwd_float_sse2 (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
27 void ff_fft8_float_sse3 (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
28 void ff_fft8_float_avx (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
29 void ff_fft16_float_avx (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
30 void ff_fft16_float_fma3 (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
31 void ff_fft32_float_avx (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
32 void ff_fft32_float_fma3 (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
34 void ff_split_radix_fft_float_avx (AVTXContext *s, void *out, void *in, ptrdiff_t stride);
35 void ff_split_radix_fft_float_fma3(AVTXContext *s, void *out, void *in, ptrdiff_t stride);
37 av_cold void ff_tx_init_float_x86(AVTXContext *s, av_tx_fn *tx)
39 int cpu_flags = av_get_cpu_flags();
40 int gen_revtab = 0, basis, revtab_interleave;
42 if (s->flags & AV_TX_UNALIGNED)
45 if (ff_tx_type_is_mdct(s->type))
48 #define TXFN(fn, gentab, sr_basis, interleave) \
51 gen_revtab = gentab; \
53 revtab_interleave = interleave; \
57 if (EXTERNAL_SSE2(cpu_flags)) {
58 if (s->m == 4 && s->inv)
59 TXFN(ff_fft4_inv_float_sse2, 0, 0, 0);
61 TXFN(ff_fft4_fwd_float_sse2, 0, 0, 0);
64 if (EXTERNAL_SSE3(cpu_flags)) {
66 TXFN(ff_fft2_float_sse3, 0, 0, 0);
68 TXFN(ff_fft8_float_sse3, 1, 8, 0);
71 if (EXTERNAL_AVX_FAST(cpu_flags)) {
73 TXFN(ff_fft8_float_avx, 1, 8, 0);
75 TXFN(ff_fft16_float_avx, 1, 8, 2);
78 TXFN(ff_fft32_float_avx, 1, 8, 2);
79 else if (s->m >= 64 && s->m <= 131072 && !(s->flags & AV_TX_INPLACE))
80 TXFN(ff_split_radix_fft_float_avx, 1, 8, 2);
84 if (EXTERNAL_FMA3_FAST(cpu_flags)) {
86 TXFN(ff_fft16_float_fma3, 1, 8, 2);
89 TXFN(ff_fft32_float_fma3, 1, 8, 2);
90 else if (s->m >= 64 && s->m <= 131072 && !(s->flags & AV_TX_INPLACE))
91 TXFN(ff_split_radix_fft_float_fma3, 1, 8, 2);
97 ff_tx_gen_split_radix_parity_revtab(s->revtab, s->m, s->inv, basis,