Go to the documentation of this file.
27 #define TYPE_IS(type, x) \
28 (((x) == AV_TX_FLOAT_ ## type) || \
29 ((x) == AV_TX_DOUBLE_ ## type) || \
30 ((x) == AV_TX_INT32_ ## type))
36 for (
int x = 1; x < m; x++)
37 if (((n * x) % m) == 1)
52 for (
int k = 0; k <
s->len; k += sl) {
54 for (
int m = 0; m < d2; m++)
55 for (
int n = 0; n < d1; n++)
56 s->map[k + ((m*d1 + n*d2) % (sl))] = m*d1 + n;
58 for (
int m = 0; m < d2; m++)
59 for (
int n = 0; n < d1; n++)
60 s->map[k + m*d1 + n] = (m*d1 + n*d2) % (sl);
64 for (
int w = 1;
w <= ((sl) >> 1);
w++)
65 FFSWAP(
int,
s->map[k +
w],
s->map[k + sl -
w]);
75 int inv,
int n,
int m)
77 int *in_map, *out_map;
92 out_map =
s->map +
len;
96 for (
int j = 0; j < m; j++) {
97 for (
int i = 0;
i < n;
i++) {
98 in_map[(
i*m + j*n) %
len] = j*n +
i;
99 out_map[(
i*m*m_inv + j*n*n_inv) %
len] =
i*m + j;
103 for (
int j = 0; j < m; j++) {
104 for (
int i = 0;
i < n;
i++) {
105 in_map[j*n +
i] = (
i*m + j*n) %
len;
106 out_map[(
i*m*m_inv + j*n*n_inv) %
len] =
i*m + j;
112 for (
int i = 0;
i < m;
i++) {
113 int *in = &in_map[
i*n + 1];
114 for (
int j = 0; j < ((n - 1) >> 1); j++)
115 FFSWAP(
int, in[j], in[n - j - 2]);
143 for (
int i = 0;
i <
s->len;
i++)
146 for (
int i = 0;
i <
s->len;
i++)
157 int *src_map, out_map_idx = 0;
159 if (!
s->sub || !
s->sub->map)
165 src_map =
s->sub->map;
169 int dst = src_map[
src];
179 for (
int j = 0; j < out_map_idx; j++) {
180 if (dst ==
s->map[j]) {
186 }
while (dst !=
src && !found);
189 s->map[out_map_idx++] =
src;
192 s->map[out_map_idx++] = 0;
198 int is_dual,
int dual_high,
int len,
199 int basis,
int dual_stride,
int inv_lookup)
204 int k1, k2,
stride, even_idx, odd_idx;
206 is_dual = is_dual && dual_stride;
207 dual_high = is_dual & dual_high;
211 odd_idx = even_idx +
len + (is_dual && !dual_high)*
len + dual_high*
len;
213 for (
int i = 0;
i <
len;
i++) {
217 revtab[even_idx++] = k1;
218 revtab[odd_idx++] = k2;
220 revtab[k1] = even_idx++;
221 revtab[k2] = odd_idx++;
233 0, 0,
len >> 0,
basis, dual_stride, inv_lookup);
235 1, 0,
len >> 1,
basis, dual_stride, inv_lookup);
237 1, 1,
len >> 1,
basis, dual_stride, inv_lookup);
242 int basis,
int dual_stride)
251 av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1)));
272 if (
s->cd_self &&
s->cd_self->uninit)
273 s->cd_self->uninit(
s);
286 memset(
s->fn, 0,
sizeof(*
s->fn));
305 int len,
int inv,
const void *
scale)
316 memcpy(_out, _in,
stride);
394 prio += 16*max_factor;
422 while (codelet_list_idx--) {
426 while ((cd = *
list++)) {
429 int factors_product = 1, factors_mod = 0;
456 factors_product *= fl;
457 }
else if (!(fl % cd->
factors[
i])) {
462 factors_product <<=
b;
473 if ((factors_mod < cd->nb_factors) || (
len == factors_product))
476 if (
av_gcd(factors_product, fl) != 1)
480 if ((factors_product < cd->min_len) ||
487 for (
int i = 0;
i < nb_decomp;
i++) {
488 if (factors_product == ld[
i].
len) {
490 if (prio > ld[
i].prio)
499 ld[nb_decomp].
cd = cd;
500 ld[nb_decomp].
len = factors_product;
501 ld[nb_decomp].
len2 = fl;
502 ld[nb_decomp].
prio = prio;
514 for (
int i = 0;
i < nb_decomp;
i++) {
515 if (ld[
i].cd->nb_factors > 1)
532 for (
int i = 1;
i <
s->len;
i++)
533 s->map[
i] =
s->len -
i;
535 for (
int i = 1;
i <
s->len;
i++)
547 const char *sep =
", ";
552 av_bprintf(bp,
"%sunaligned", prev > 1 ? sep :
"");
554 av_bprintf(bp,
"%sinplace", prev > 1 ? sep :
"");
556 av_bprintf(bp,
"%sout_of_place", prev > 1 ? sep :
"");
558 av_bprintf(bp,
"%sfwd_only", prev > 1 ? sep :
"");
560 av_bprintf(bp,
"%sinv_only", prev > 1 ? sep :
"");
562 av_bprintf(bp,
"%spreshuf", prev > 1 ? sep :
"");
564 av_bprintf(bp,
"%simdct_full", prev > 1 ? sep :
"");
566 av_bprintf(bp,
"%sreal_to_real", prev > 1 ? sep :
"");
568 av_bprintf(bp,
"%sreal_to_imaginary", prev > 1 ? sep :
"");
570 av_bprintf(bp,
"%sasm_call", prev > 1 ? sep :
"");
653 for (
int i = 0;
i <= depth;
i++)
658 for (
int i = 0;
i <
s->nb_sub;
i++)
676 int matches = 0, any_flag = 0;
707 return (cd->
nb_factors <= matches) && (any_flag ||
len == 1);
712 int len,
int inv,
const void *
scale)
717 unsigned int cd_matches_size = 0;
719 int nb_cd_matches = 0;
729 uint64_t req_flags =
flags;
750 while (codelet_list_idx--) {
754 while ((cd = *
list++)) {
767 if (((req_flags & cd->
flags) != (req_flags)) ||
768 ((inv_req_mask & cd->
flags) != (req_flags & inv_req_mask)))
786 sizeof(*cd_tmp) * (nb_cd_matches + 1));
793 cd_matches[nb_cd_matches].
cd = cd;
803 inv ?
"inverse" :
"forward");
807 av_bprintf(&bp,
", found %i matches%s", nb_cd_matches,
808 nb_cd_matches ?
":" :
".");
821 for (
int i = 0;
i < nb_cd_matches;
i++) {
836 for (
int i = 0;
i < nb_cd_matches;
i++) {
847 s->cd[
s->nb_sub] = cd;
864 for (
int i = 0;
i <
len;
i++)
875 for (
int i = 0;
i <
len;
i++)
906 const double default_scale_d = 1.0;
907 const float default_scale_f = 1.0f;
918 scale = &default_scale_f;
920 scale = &default_scale_d;
@ AV_TX_REAL_TO_REAL
Perform a real to half-complex RDFT.
#define AV_CPU_FLAG_SSSE3SLOW
SSSE3 supported, but usually not faster.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
static int cmp_decomp(FFTXLenDecomp *a, FFTXLenDecomp *b)
#define AV_CPU_FLAG_SSE3SLOW
SSE3 supported, but usually not faster.
static const FFTXCodelet ff_tx_null_def
static int16_t basis[64][64]
static void print_cd_info(const FFTXCodelet *cd, int prio, int len, int print_prio)
int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv, FFTXCodeletOptions *opts, int basis, int dual_stride)
#define TX_MAX_DECOMPOSITIONS
int ff_tx_gen_inplace_map(AVTXContext *s, int len)
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
#define FF_TX_CPU_FLAGS_ALL
int ff_tx_gen_compound_mapping(AVTXContext *s, FFTXCodeletOptions *opts, int inv, int n, int m)
static void print_type(AVBPrint *bp, enum AVTXType type)
static atomic_int cpu_flags
static int cmp_matches(TXCodeletMatch *a, TXCodeletMatch *b)
static void print_flags(AVBPrint *bp, uint64_t f)
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...
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
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)
#define AV_BPRINT_SIZE_AUTOMATIC
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static av_always_inline float scale(float x, float s)
#define FFDIFFSIGN(x, y)
Comparator.
#define AV_CPU_FLAG_SLOW_GATHER
CPU has slow gathers.
int factors[TX_MAX_FACTORS]
#define FF_ARRAY_ELEMS(a)
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respecively.
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.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FF_TX_FORWARD_ONLY
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
static int split_radix_permutation(int i, int len, int inv)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const int codelet_list_num
@ AV_TX_FULL_IMDCT
Performs a full inverse MDCT rather than leaving out samples that can be derived through symmetry.
@ AV_TX_REAL_TO_IMAGINARY
@ AV_TX_INPLACE
Allows for in-place transformations, where input == output.
int ff_tx_gen_ptwo_revtab(AVTXContext *s, FFTXCodeletOptions *opts)
static void ff_tx_null(AVTXContext *s, void *_out, void *_in, ptrdiff_t stride)
static const int cpu_slow_mask
#define FF_TX_OUT_OF_PLACE
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining list
int(* init)(AVTXContext *s, const struct FFTXCodelet *cd, uint64_t flags, FFTXCodeletOptions *opts, int len, int inv, const void *scale)
@ AV_TX_UNALIGNED
Relaxes alignment requirement for the in and out arrays of av_tx_fn().
static int get_codelet_prio(const FFTXCodelet *cd, int cpu_flags, int len)
void ff_tx_clear_ctx(AVTXContext *s)
static void reset_ctx(AVTXContext *s, int free_sub)
int ff_tx_gen_default_map(AVTXContext *s, FFTXCodeletOptions *opts)
@ AV_TX_FLOAT_DCT_I
Discrete Cosine Transform I.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_CPU_FLAG_AVXSLOW
AVX supported, but slow when using YMM registers (e.g. Bulldozer)
const FFTXCodelet *const ff_tx_codelet_list_float_aarch64[]
#define AV_CPU_FLAG_SSE2SLOW
SSE2 supported, but usually not faster.
const FFTXCodelet *const ff_tx_codelet_list_double_c[]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
static const int cpu_slow_penalties[][2]
#define i(width, name, range_min, range_max)
#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...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define AV_CPU_FLAG_ATOM
Atom processor, some SSSE3 instructions are slower.
av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, uint64_t flags, FFTXCodeletOptions *opts, int len, int inv, const void *scale)
#define FFSWAP(type, a, b)
#define FF_TX_INVERSE_ONLY
void av_bprintf(AVBPrint *buf, const char *fmt,...)
const FFTXCodelet *const ff_tx_codelet_list_float_c[]
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
@ AV_TX_FLOAT_DST_I
Discrete Sine Transform I.
static int check_cd_factors(const FFTXCodelet *cd, int len)
const FFTXCodelet * cd_self
static const int factor[16]
const FFTXCodelet *const ff_tx_codelet_list_float_x86[]
static void print_tx_structure(AVTXContext *s, int depth)
static const FFTXCodelet *const ff_tx_null_list[]
#define flags(name, subs,...)
static av_always_inline int mulinv(int n, int m)
const FFTXCodelet *const ff_tx_codelet_list_int32_c[]
int ff_tx_gen_pfa_input_map(AVTXContext *s, FFTXCodeletOptions *opts, int d1, int d2)
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)
int ff_tx_decompose_length(int dst[TX_MAX_DECOMPOSITIONS], enum AVTXType type, int len, int inv)
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static const FFTXCodelet *const *const codelet_list[]