]> git.sesse.net Git - ffmpeg/blob - libavutil/x86/tx_float_init.c
fate: add tests for JPEG-LS PAL8
[ffmpeg] / libavutil / x86 / tx_float_init.c
1 /*
2  * This file is part of FFmpeg.
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #define TX_FLOAT
20 #include "libavutil/tx_priv.h"
21 #include "libavutil/attributes.h"
22 #include "libavutil/x86/cpu.h"
23
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);
33
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);
36
37 av_cold void ff_tx_init_float_x86(AVTXContext *s, av_tx_fn *tx)
38 {
39     int cpu_flags = av_get_cpu_flags();
40     int gen_revtab = 0, basis, revtab_interleave;
41
42     if (s->flags & AV_TX_UNALIGNED)
43         return;
44
45     if (ff_tx_type_is_mdct(s->type))
46         return;
47
48 #define TXFN(fn, gentab, sr_basis, interleave) \
49     do {                                       \
50         *tx = fn;                              \
51         gen_revtab = gentab;                   \
52         basis = sr_basis;                      \
53         revtab_interleave = interleave;        \
54     } while (0)
55
56     if (s->n == 1) {
57         if (EXTERNAL_SSE2(cpu_flags)) {
58             if (s->m == 4 && s->inv)
59                 TXFN(ff_fft4_inv_float_sse2, 0, 0, 0);
60             else if (s->m == 4)
61                 TXFN(ff_fft4_fwd_float_sse2, 0, 0, 0);
62         }
63
64         if (EXTERNAL_SSE3(cpu_flags)) {
65             if (s->m == 2)
66                 TXFN(ff_fft2_float_sse3, 0, 0, 0);
67             else if (s->m == 8)
68                 TXFN(ff_fft8_float_sse3, 1, 8, 0);
69         }
70
71         if (EXTERNAL_AVX_FAST(cpu_flags)) {
72             if (s->m == 8)
73                 TXFN(ff_fft8_float_avx, 1, 8, 0);
74             else if (s->m == 16)
75                 TXFN(ff_fft16_float_avx, 1, 8, 2);
76 #if ARCH_X86_64
77             else if (s->m == 32)
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);
81 #endif
82         }
83
84         if (EXTERNAL_FMA3_FAST(cpu_flags)) {
85             if (s->m == 16)
86                 TXFN(ff_fft16_float_fma3, 1, 8, 2);
87 #if ARCH_X86_64
88             else if (s->m == 32)
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);
92 #endif
93         }
94     }
95
96     if (gen_revtab)
97         ff_tx_gen_split_radix_parity_revtab(s->revtab, s->m, s->inv, basis,
98                                             revtab_interleave);
99
100 #undef TXFN
101 }