FFmpeg
tx_float_init.c
Go to the documentation of this file.
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_avx2(AVTXContext *s, void *out, void *in, ptrdiff_t stride);
36 
38 {
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 
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))
81 #endif
82  }
83 
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 #endif
91  }
92 
93 #if ARCH_X86_64
95  if (s->m >= 64 && s->m <= 131072 && !(s->flags & AV_TX_INPLACE))
97  }
98 #endif
99  }
100 
101  if (gen_revtab)
102  ff_tx_gen_split_radix_parity_revtab(s->revtab, s->m, s->inv, basis,
103  revtab_interleave);
104 
105 #undef TXFN
106 }
stride
int stride
Definition: mace.c:144
cpu.h
out
FILE * out
Definition: movenc.c:54
AVTXContext
Definition: tx_priv.h:110
basis
static int16_t basis[64][64]
Definition: mpegvideo_enc.c:4133
EXTERNAL_AVX2_FAST
#define EXTERNAL_AVX2_FAST(flags)
Definition: cpu.h:79
ff_tx_init_float_x86
av_cold void ff_tx_init_float_x86(AVTXContext *s, av_tx_fn *tx)
Definition: tx_float_init.c:37
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:98
ff_split_radix_fft_float_avx
void ff_split_radix_fft_float_avx(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
cpu_flags
static atomic_int cpu_flags
Definition: cpu.c:50
ff_tx_gen_split_radix_parity_revtab
void ff_tx_gen_split_radix_parity_revtab(int *revtab, int len, int inv, int basis, int dual_stride)
Definition: tx.c:202
av_cold
#define av_cold
Definition: attributes.h:90
av_tx_fn
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:102
s
#define s(width, name)
Definition: cbs_vp9.c:257
ff_fft16_float_avx
void ff_fft16_float_avx(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
EXTERNAL_AVX_FAST
#define EXTERNAL_AVX_FAST(flags)
Definition: cpu.h:71
ff_fft2_float_sse3
void ff_fft2_float_sse3(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
TXFN
#define TXFN(fn, gentab, sr_basis, interleave)
EXTERNAL_SSE3
#define EXTERNAL_SSE3(flags)
Definition: cpu.h:62
AV_TX_INPLACE
@ AV_TX_INPLACE
Performs an in-place transformation on the input.
Definition: tx.h:113
AV_TX_UNALIGNED
@ AV_TX_UNALIGNED
Relaxes alignment requirement for the in and out arrays of av_tx_fn().
Definition: tx.h:119
ff_fft16_float_fma3
void ff_fft16_float_fma3(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
attributes.h
ff_tx_type_is_mdct
int ff_tx_type_is_mdct(enum AVTXType type)
Definition: tx.c:21
EXTERNAL_SSE2
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:59
ff_fft4_fwd_float_sse2
void ff_fft4_fwd_float_sse2(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
EXTERNAL_FMA3_FAST
#define EXTERNAL_FMA3_FAST(flags)
Definition: cpu.h:75
ff_fft4_inv_float_sse2
void ff_fft4_inv_float_sse2(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
tx_priv.h
ff_fft8_float_avx
void ff_fft8_float_avx(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
ff_fft8_float_sse3
void ff_fft8_float_sse3(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
ff_fft32_float_fma3
void ff_fft32_float_fma3(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
ff_fft32_float_avx
void ff_fft32_float_avx(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
ff_split_radix_fft_float_avx2
void ff_split_radix_fft_float_avx2(AVTXContext *s, void *out, void *in, ptrdiff_t stride)