FFmpeg
Data Structures | Typedefs | Enumerations | Functions
tx.h File Reference
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  AVComplexFloat
 
struct  AVComplexDouble
 
struct  AVComplexInt32
 

Typedefs

typedef void(* av_tx_fn) (AVTXContext *s, void *out, void *in, ptrdiff_t stride)
 Function pointer to a function to perform the transform. More...
 

Enumerations

enum  AVTXType {
  AV_TX_FLOAT_FFT = 0, AV_TX_DOUBLE_FFT = 2, AV_TX_INT32_FFT = 4, AV_TX_FLOAT_MDCT = 1,
  AV_TX_DOUBLE_MDCT = 3, AV_TX_INT32_MDCT = 5, AV_TX_FLOAT_RDFT = 6, AV_TX_DOUBLE_RDFT = 7,
  AV_TX_INT32_RDFT = 8, AV_TX_FLOAT_DCT = 9, AV_TX_DOUBLE_DCT = 10, AV_TX_INT32_DCT = 11,
  AV_TX_FLOAT_DCT_I = 12, AV_TX_DOUBLE_DCT_I = 13, AV_TX_INT32_DCT_I = 14, AV_TX_FLOAT_DST_I = 15,
  AV_TX_DOUBLE_DST_I = 16, AV_TX_INT32_DST_I = 17, AV_TX_NB
}
 
enum  AVTXFlags {
  AV_TX_INPLACE = 1ULL << 0, AV_TX_UNALIGNED = 1ULL << 1, AV_TX_FULL_IMDCT = 1ULL << 2, AV_TX_REAL_TO_REAL = 1ULL << 3,
  AV_TX_REAL_TO_IMAGINARY = 1ULL << 4
}
 Flags for av_tx_init() More...
 

Functions

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 not supported. More...
 
void av_tx_uninit (AVTXContext **ctx)
 Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL. More...
 

Typedef Documentation

◆ av_tx_fn

typedef void(* av_tx_fn) (AVTXContext *s, void *out, void *in, ptrdiff_t stride)

Function pointer to a function to perform the transform.

Note
Using a different context than the one allocated during av_tx_init() is not allowed.
Parameters
sthe transform context
outthe output array
inthe input array
stridethe input or output stride in bytes

The out and in arrays must be aligned to the maximum required by the CPU architecture unless the AV_TX_UNALIGNED flag was set in av_tx_init(). The stride must follow the constraints the transform type has specified.

Definition at line 151 of file tx.h.

Enumeration Type Documentation

◆ AVTXType

enum AVTXType
Enumerator
AV_TX_FLOAT_FFT 

Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplexInt32, for each respective variant.

Output is not 1/len normalized. Scaling currently unsupported. The stride parameter must be set to the size of a single sample in bytes.

AV_TX_DOUBLE_FFT 
AV_TX_INT32_FFT 
AV_TX_FLOAT_MDCT 

Standard MDCT with a sample data type of float, double or int32_t, respecively.

For the float and int32 variants, the scale type is 'float', while for the double variant, it's 'double'. If scale is NULL, 1.0 will be used as a default.

Length is the frame size, not the window size (which is 2x frame). For forward transforms, the stride specifies the spacing between each sample in the output array in bytes. The input must be a flat array.

For inverse transforms, the stride specifies the spacing between each sample in the input array in bytes. The output must be a flat array.

NOTE: the inverse transform is half-length, meaning the output will not contain redundant data. This is what most codecs work with. To do a full inverse transform, set the AV_TX_FULL_IMDCT flag on init.

AV_TX_DOUBLE_MDCT 
AV_TX_INT32_MDCT 
AV_TX_FLOAT_RDFT 

Real to complex and complex to real DFTs.

For the float and int32 variants, the scale type is 'float', while for the double variant, it's a 'double'. If scale is NULL, 1.0 will be used as a default.

For forward transforms (R2C), stride must be the spacing between two samples in bytes. For inverse transforms, the stride must be set to the spacing between two complex values in bytes.

The forward transform performs a real-to-complex DFT of N samples to N/2+1 complex values.

The inverse transform performs a complex-to-real DFT of N/2+1 complex values to N real samples. The output is not normalized, but can be made so by setting the scale value to 1.0/len. NOTE: the inverse transform always overwrites the input.

AV_TX_DOUBLE_RDFT 
AV_TX_INT32_RDFT 
AV_TX_FLOAT_DCT 

Real to real (DCT) transforms.

The forward transform is a DCT-II. The inverse transform is a DCT-III.

The input array is always overwritten. DCT-III requires that the input be padded with 2 extra samples. Stride must be set to the spacing between two samples in bytes.

AV_TX_DOUBLE_DCT 
AV_TX_INT32_DCT 
AV_TX_FLOAT_DCT_I 

Discrete Cosine Transform I.

The forward transform is a DCT-I. The inverse transform is a DCT-I multiplied by 2/(N + 1).

The input array is always overwritten.

AV_TX_DOUBLE_DCT_I 
AV_TX_INT32_DCT_I 
AV_TX_FLOAT_DST_I 

Discrete Sine Transform I.

The forward transform is a DST-I. The inverse transform is a DST-I multiplied by 2/(N + 1).

The input array is always overwritten.

AV_TX_DOUBLE_DST_I 
AV_TX_INT32_DST_I 
AV_TX_NB 

Definition at line 39 of file tx.h.

◆ AVTXFlags

enum AVTXFlags

Flags for av_tx_init()

Enumerator
AV_TX_INPLACE 

Allows for in-place transformations, where input == output.

May be unsupported or slower for some transform types.

AV_TX_UNALIGNED 

Relaxes alignment requirement for the in and out arrays of av_tx_fn().

May be slower with certain transform types.

AV_TX_FULL_IMDCT 

Performs a full inverse MDCT rather than leaving out samples that can be derived through symmetry.

Requires an output array of 'len' floats, rather than the usual 'len/2' floats. Ignored for all transforms but inverse MDCTs.

AV_TX_REAL_TO_REAL 

Perform a real to half-complex RDFT.

Only the real, or imaginary coefficients will be output, depending on the flag used. Only available for forward RDFTs. Output array must have enough space to hold N complex values (regular size for a real to complex transform).

AV_TX_REAL_TO_IMAGINARY 

Definition at line 156 of file tx.h.

Function Documentation

◆ av_tx_init()

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 not supported.

Parameters
ctxthe context to allocate, will be NULL on error
txpointer to the transform function pointer to set
typetype the type of transform
invwhether to do an inverse or a forward transform
lenthe size of the transform in samples
scalepointer to the value to scale the output if supported by type
flagsa bitmask of AVTXFlags or 0
Returns
0 on success, negative error code on failure

Definition at line 901 of file tx.c.

Referenced by aac_decode_init(), ac3_decode_init(), ac3_fixed_mdct_init(), ac3_float_mdct_init(), atrac1_decode_init(), atrac3_decode_init(), atrac3p_decode_init(), atrac9_decode_init(), av_dct_init(), av_fft_init(), av_mdct_init(), av_rdft_init(), checkasm_check_synth_filter(), config_eq_output(), config_input(), config_output(), config_props(), convert_coeffs(), decode_init(), dolby_e_init(), dsp_init(), encode_init(), equ_init(), ff_aac_sbr_ctx_init(), ff_celt_init(), ff_dca_core_init(), ff_opus_psy_init(), fir_to_phase(), get_power(), imc_decode_init(), init_cook_mlt(), init_mdct_win(), init_sample_rate(), init_segment(), load_data(), on2avc_decode_init(), opus_encode_init(), qdm2_decode_init(), qdmc_decode_init(), siren_init(), video_audio_display(), vorbis_parse_id_hdr(), wma_decode_init(), wmavoice_decode_init(), and yae_reset().

◆ av_tx_uninit()

void av_tx_uninit ( AVTXContext **  ctx)