28#define TYPE_IS(type, x) \
29 (((x) == AV_TX_FLOAT_ ## type) || \
30 ((x) == AV_TX_DOUBLE_ ## type) || \
31 ((x) == AV_TX_INT32_ ## type))
37 for (
int x = 1; x < m; x++)
38 if (((n * x) % m) == 1)
53 for (
int k = 0; k <
s->len; k += sl) {
55 for (
int m = 0; m < d2; m++)
56 for (
int n = 0; n < d1; n++)
57 s->map[k + ((m*d1 + n*d2) % (sl))] = m*d1 + n;
59 for (
int m = 0; m < d2; m++)
60 for (
int n = 0; n < d1; n++)
61 s->map[k + m*d1 + n] = (m*d1 + n*d2) % (sl);
65 for (
int w = 1;
w <= ((sl) >> 1);
w++)
66 FFSWAP(
int,
s->map[k +
w],
s->map[k + sl -
w]);
76 int inv,
int n,
int m)
78 int *in_map, *out_map;
93 out_map =
s->map +
len;
97 for (
int j = 0; j < m; j++) {
98 for (
int i = 0;
i < n;
i++) {
99 in_map[(
i*m + j*n) %
len] = j*n +
i;
100 out_map[(
i*m*m_inv + j*n*n_inv) %
len] =
i*m + j;
104 for (
int j = 0; j < m; j++) {
105 for (
int i = 0;
i < n;
i++) {
106 in_map[j*n +
i] = (
i*m + j*n) %
len;
107 out_map[(
i*m*m_inv + j*n*n_inv) %
len] =
i*m + j;
113 for (
int i = 0;
i < m;
i++) {
114 int *in = &in_map[
i*n + 1];
115 for (
int j = 0; j < ((n - 1) >> 1); j++)
116 FFSWAP(
int, in[j], in[n - j - 2]);
144 for (
int i = 0;
i <
s->len;
i++)
147 for (
int i = 0;
i <
s->len;
i++)
158 int *src_map, out_map_idx = 0;
160 if (!
s->sub || !
s->sub->map)
166 src_map =
s->sub->map;
180 for (
int j = 0; j < out_map_idx; j++) {
181 if (
dst ==
s->map[j]) {
187 }
while (
dst !=
src && !found);
190 s->map[out_map_idx++] =
src;
193 s->map[out_map_idx++] = 0;
199 int is_dual,
int dual_high,
int len,
200 int basis,
int dual_stride,
int inv_lookup)
205 int k1, k2,
stride, even_idx, odd_idx;
207 is_dual = is_dual && dual_stride;
208 dual_high = is_dual & dual_high;
212 odd_idx = even_idx +
len + (is_dual && !dual_high)*
len + dual_high*
len;
214 for (
int i = 0;
i <
len;
i++) {
218 revtab[even_idx++] = k1;
219 revtab[odd_idx++] = k2;
221 revtab[k1] = even_idx++;
222 revtab[k2] = odd_idx++;
234 0, 0,
len >> 0,
basis, dual_stride, inv_lookup);
236 1, 0,
len >> 1,
basis, dual_stride, inv_lookup);
238 1, 1,
len >> 1,
basis, dual_stride, inv_lookup);
243 int basis,
int dual_stride)
252 av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1)));
273 if (
s->cd_self &&
s->cd_self->uninit)
274 s->cd_self->uninit(
s);
287 memset(
s->fn, 0,
sizeof(
s->fn));
306 int len,
int inv,
const void *
scale)
317 memcpy(_out, _in,
stride);
395 prio += 16*max_factor;
423 while (codelet_list_idx--) {
427 while ((cd = *list++)) {
430 int factors_product = 1, factors_mod = 0;
457 factors_product *= fl;
458 }
else if (!(fl % cd->
factors[
i])) {
463 factors_product <<=
b;
474 if ((factors_mod < cd->nb_factors) || (
len == factors_product))
477 if (
av_gcd(factors_product, fl) != 1)
481 if ((factors_product < cd->min_len) ||
488 for (
int i = 0;
i < nb_decomp;
i++) {
489 if (factors_product == ld[
i].
len) {
491 if (prio > ld[
i].prio)
500 ld[nb_decomp].
cd = cd;
501 ld[nb_decomp].
len = factors_product;
502 ld[nb_decomp].
len2 = fl;
503 ld[nb_decomp].
prio = prio;
515 for (
int i = 0;
i < nb_decomp;
i++) {
516 if (ld[
i].cd->nb_factors > 1)
533 for (
int i = 1;
i <
s->len;
i++)
534 s->map[
i] =
s->len -
i;
536 for (
int i = 1;
i <
s->len;
i++)
548 const char *sep =
", ";
553 av_bprintf(bp,
"%sunaligned", prev > 1 ? sep :
"");
555 av_bprintf(bp,
"%sinplace", prev > 1 ? sep :
"");
557 av_bprintf(bp,
"%sout_of_place", prev > 1 ? sep :
"");
559 av_bprintf(bp,
"%sfwd_only", prev > 1 ? sep :
"");
561 av_bprintf(bp,
"%sinv_only", prev > 1 ? sep :
"");
563 av_bprintf(bp,
"%spreshuf", prev > 1 ? sep :
"");
565 av_bprintf(bp,
"%simdct_full", prev > 1 ? sep :
"");
567 av_bprintf(bp,
"%sreal_to_real", prev > 1 ? sep :
"");
569 av_bprintf(bp,
"%sreal_to_imaginary", prev > 1 ? sep :
"");
571 av_bprintf(bp,
"%sasm_call", prev > 1 ? sep :
"");
655 for (
int i = 0;
i <= depth;
i++)
660 for (
int i = 0;
i <
s->nb_sub;
i++)
678 int matches = 0, any_flag = 0;
709 return (cd->
nb_factors <= matches) && (any_flag ||
len == 1);
714 int len,
int inv,
const void *
scale)
719 unsigned int cd_matches_size = 0;
721 int nb_cd_matches = 0;
731 uint64_t req_flags =
flags;
752 while (codelet_list_idx--) {
756 while ((cd = *list++)) {
769 if (((req_flags & cd->
flags) != (req_flags)) ||
770 ((inv_req_mask & cd->
flags) != (req_flags & inv_req_mask)))
788 sizeof(*cd_tmp) * (nb_cd_matches + 1));
795 cd_matches[nb_cd_matches].
cd = cd;
805 inv ?
"inverse" :
"forward");
809 av_bprintf(&bp,
", found %i matches%s", nb_cd_matches,
810 nb_cd_matches ?
":" :
".");
823 for (
int i = 0;
i < nb_cd_matches;
i++) {
838 for (
int i = 0;
i < nb_cd_matches;
i++) {
849 s->cd[
s->nb_sub] = cd;
866 for (
int i = 0;
i <
len;
i++)
877 for (
int i = 0;
i <
len;
i++)
908 const double default_scale_d = 1.0;
909 const float default_scale_f = 1.0f;
922 scale = &default_scale_d;
924 scale = &default_scale_f;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFTXCodelet *const ff_tx_codelet_list_float_aarch64[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_AUTOMATIC
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static const int factor[16]
static atomic_int cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
#define AV_CPU_FLAG_SSE3SLOW
SSE3 supported, but usually not faster than regular MMX/SSE (e.g.
#define AV_CPU_FLAG_SSE2SLOW
SSE2 supported, but usually not faster than regular MMX/SSE (e.g.
#define AV_CPU_FLAG_ATOM
Atom processor, some SSSE3 instructions are slower.
#define AV_CPU_FLAG_SSSE3SLOW
SSSE3 supported, but usually not faster.
#define AV_CPU_FLAG_SLOW_GATHER
CPU has slow gathers.
#define AV_CPU_FLAG_AVXSLOW
AVX supported, but slow when using YMM registers (e.g. Bulldozer)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FFSWAP(type, a, b)
#define FFDIFFSIGN(x, y)
Comparator.
Memory handling functions.
static int16_t basis[64][64]
#define AV_QSORT(p, num, type, cmp)
Quicksort This sort is fast, and fully inplace but not stable and it is possible to construct input t...
#define FF_ARRAY_ELEMS(a)
const FFTXCodelet * cd_self
int factors[TX_MAX_FACTORS]
int(* init)(AVTXContext *s, const struct FFTXCodelet *cd, uint64_t flags, FFTXCodeletOptions *opts, int len, int inv, const void *scale)
static AVFormatContext * ctx
static AVDictionary * opts
static av_always_inline int mulinv(int n, int m)
void ff_tx_clear_ctx(AVTXContext *s)
static int cmp_decomp(FFTXLenDecomp *a, FFTXLenDecomp *b)
static av_cold int ff_tx_null_init(AVTXContext *s, const FFTXCodelet *cd, uint64_t flags, FFTXCodeletOptions *opts, int len, int inv, const void *scale)
static void print_flags(AVBPrint *bp, uint64_t f)
static const int cpu_slow_penalties[][2]
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
static void parity_revtab_generator(int *revtab, int n, int inv, int offset, int is_dual, int dual_high, int len, int basis, int dual_stride, int inv_lookup)
static const int codelet_list_num
static const FFTXCodelet *const *const codelet_list[]
int ff_tx_gen_default_map(AVTXContext *s, FFTXCodeletOptions *opts)
static void print_tx_structure(AVTXContext *s, int depth)
int ff_tx_gen_ptwo_revtab(AVTXContext *s, FFTXCodeletOptions *opts)
av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, uint64_t flags, FFTXCodeletOptions *opts, int len, int inv, const void *scale)
static void print_type(AVBPrint *bp, enum AVTXType type)
static void reset_ctx(AVTXContext *s, int free_sub)
static void ff_tx_null(AVTXContext *s, void *_out, void *_in, ptrdiff_t stride)
static int split_radix_permutation(int i, int len, int inv)
static int get_codelet_prio(const FFTXCodelet *cd, int cpu_flags, int len)
static const int cpu_slow_mask
int ff_tx_gen_compound_mapping(AVTXContext *s, FFTXCodeletOptions *opts, int inv, int n, int m)
int ff_tx_decompose_length(int dst[TX_MAX_DECOMPOSITIONS], enum AVTXType type, int len, int inv)
static const FFTXCodelet ff_tx_null_def
static const FFTXCodelet *const ff_tx_null_list[]
int ff_tx_gen_inplace_map(AVTXContext *s, int len)
static int check_cd_factors(const FFTXCodelet *cd, int len)
int ff_tx_gen_pfa_input_map(AVTXContext *s, FFTXCodeletOptions *opts, int d1, int d2)
int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv, FFTXCodeletOptions *opts, int basis, int dual_stride)
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
static int cmp_matches(TXCodeletMatch *a, TXCodeletMatch *b)
static void print_cd_info(const FFTXCodelet *cd, int prio, int len, int print_prio, int log_level)
@ AV_TX_FULL_IMDCT
Performs a full inverse MDCT rather than leaving out samples that can be derived through symmetry.
@ AV_TX_UNALIGNED
Relaxes alignment requirement for the in and out arrays of av_tx_fn().
@ AV_TX_REAL_TO_IMAGINARY
@ AV_TX_REAL_TO_REAL
Perform a real to half-complex RDFT.
@ AV_TX_INPLACE
Allows for in-place transformations, where input == output.
@ AV_TX_FLOAT_DST_I
Discrete Sine Transform I.
@ AV_TX_FLOAT_DCT_I
Discrete Cosine Transform I.
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respectively.
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
#define TX_MAX_DECOMPOSITIONS
#define FF_TX_CPU_FLAGS_ALL
const FFTXCodelet *const ff_tx_codelet_list_float_c[]
#define FF_TX_OUT_OF_PLACE
#define FF_TX_INVERSE_ONLY
#define FF_TX_FORWARD_ONLY
const FFTXCodelet *const ff_tx_codelet_list_double_c[]
const FFTXCodelet *const ff_tx_codelet_list_float_x86[]
const FFTXCodelet *const ff_tx_codelet_list_int32_c[]