#include <stddef.h>
#include "tx.h"
#include "thread.h"
#include "mem.h"
#include "avassert.h"
Go to the source code of this file.
|
#define | FFT_NAME(x) x |
|
#define | COSTABLE(size) static DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2] |
|
#define | INIT_FF_COS_TABS_FUNC(index, size) |
|
#define | BF(x, y, a, b) |
|
#define | CMUL(dre, dim, are, aim, bre, bim) |
|
#define | CMUL3(c, a, b) CMUL((c).re, (c).im, (a).re, (a).im, (b).re, (b).im) |
|
#define | DECL_FFT5(NAME, D0, D1, D2, D3, D4) |
|
#define | BUTTERFLIES(a0, a1, a2, a3) |
|
#define | BUTTERFLIES_BIG(a0, a1, a2, a3) |
|
#define | TRANSFORM(a0, a1, a2, a3, wre, wim) |
|
#define | TRANSFORM_ZERO(a0, a1, a2, a3) |
|
#define | PASS(name) |
|
#define | BUTTERFLIES BUTTERFLIES_BIG |
|
#define | DECL_FFT(n, n2, n4) |
|
#define | pass pass_big |
|
#define | DECL_COMP_FFT(N) |
|
#define | DECL_COMP_IMDCT(N) |
|
#define | DECL_COMP_MDCT(N) |
|
#define | CHECK_FACTOR(DST, FACTOR, SRC) |
|
|
static FFTSample *const | FFT_NAME (ff_cos_tabs)[18] |
|
| COSTABLE (16) |
|
| COSTABLE (32) |
|
| COSTABLE (64) |
|
| COSTABLE (128) |
|
| COSTABLE (256) |
|
| COSTABLE (512) |
|
| COSTABLE (1024) |
|
| COSTABLE (2048) |
|
| COSTABLE (4096) |
|
| COSTABLE (8192) |
|
| COSTABLE (16384) |
|
| COSTABLE (32768) |
|
| COSTABLE (65536) |
|
| COSTABLE (131072) |
|
static av_cold void | init_ff_cos_tabs (int index) |
|
static av_cold void | ff_init_ff_cos_tabs (int index) |
|
static av_cold void | ff_init_53_tabs (void) |
|
static av_always_inline void | fft3 (FFTComplex *out, FFTComplex *in, ptrdiff_t stride) |
|
static av_always_inline void | fft15 (FFTComplex *out, FFTComplex *in, ptrdiff_t stride) |
|
static void | fft4 (FFTComplex *z) |
|
static void | fft8 (FFTComplex *z) |
|
static void | fft16 (FFTComplex *z) |
|
static void | monolithic_fft (AVTXContext *s, void *_out, void *_in, ptrdiff_t stride) |
|
static void | monolithic_imdct (AVTXContext *s, void *_dst, void *_src, ptrdiff_t stride) |
|
static void | monolithic_mdct (AVTXContext *s, void *_dst, void *_src, ptrdiff_t stride) |
|
static int | mulinv (int n, int m) |
|
static int | gen_compound_mapping (AVTXContext *s, int n, int m, int inv, enum AVTXType type) |
|
static int | split_radix_permutation (int i, int n, int inverse) |
|
static int | get_ptwo_revtab (AVTXContext *s, int m, int inv) |
|
static int | gen_mdct_exptab (AVTXContext *s, int len4, double scale) |
|
av_cold void | av_tx_uninit (AVTXContext **ctx) |
| Frees a context and sets ctx to NULL, does nothing when ctx == NULL. More...
|
|
static int | init_mdct_fft (AVTXContext *s, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags) |
|
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 Currently power of two lengths from 4 to 131072 are supported, along with any length decomposable to a power of two and either 3, 5 or 15. More...
|
|
◆ FFT_NAME
Definition at line 44 of file tx.c.
◆ COSTABLE
Definition at line 46 of file tx.c.
◆ INIT_FF_COS_TABS_FUNC
#define INIT_FF_COS_TABS_FUNC |
( |
|
index, |
|
|
|
size |
|
) |
| |
Value:
{ \
init_ff_cos_tabs(
index); \
}
Definition at line 82 of file tx.c.
◆ BF
#define BF |
( |
|
x, |
|
|
|
y, |
|
|
|
a, |
|
|
|
b |
|
) |
| |
Value:
Definition at line 159 of file tx.c.
◆ CMUL
#define CMUL |
( |
|
dre, |
|
|
|
dim, |
|
|
|
are, |
|
|
|
aim, |
|
|
|
bre, |
|
|
|
bim |
|
) |
| |
Value: do { \
(dre) = (are) * (bre) - (aim) * (bim); \
(
dim) = (are) * (bim) + (aim) * (bre); \
} while (0)
Definition at line 164 of file tx.c.
◆ CMUL3
Definition at line 169 of file tx.c.
◆ DECL_FFT5
#define DECL_FFT5 |
( |
|
NAME, |
|
|
|
D0, |
|
|
|
D1, |
|
|
|
D2, |
|
|
|
D3, |
|
|
|
D4 |
|
) |
| |
Definition at line 195 of file tx.c.
◆ BUTTERFLIES [1/2]
Value:
Definition at line 322 of file tx.c.
◆ BUTTERFLIES_BIG
#define BUTTERFLIES_BIG |
( |
|
a0, |
|
|
|
a1, |
|
|
|
a2, |
|
|
|
a3 |
|
) |
| |
Value: {\
FFTSample r0=
a0.re, i0=
a0.im, r1=
a1.re, i1=
a1.im;\
}
Definition at line 274 of file tx.c.
◆ TRANSFORM
#define TRANSFORM |
( |
|
a0, |
|
|
|
a1, |
|
|
|
a2, |
|
|
|
a3, |
|
|
|
wre, |
|
|
|
wim |
|
) |
| |
Value:
Definition at line 284 of file tx.c.
◆ TRANSFORM_ZERO
#define TRANSFORM_ZERO |
( |
|
a0, |
|
|
|
a1, |
|
|
|
a2, |
|
|
|
a3 |
|
) |
| |
Value:
Definition at line 290 of file tx.c.
◆ PASS
Value:
{\
TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
do {\
z += 2;\
wre += 2;\
wim -= 2;\
TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\
TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
}
Definition at line 299 of file tx.c.
◆ BUTTERFLIES [2/2]
Definition at line 322 of file tx.c.
◆ DECL_FFT
#define DECL_FFT |
( |
|
n, |
|
|
|
n2, |
|
|
|
n4 |
|
) |
| |
Value:
{\
fft##n2(z);\
fft##n4(z+n4*2);\
fft##n4(z+n4*3);\
}
Definition at line 325 of file tx.c.
◆ pass
Definition at line 384 of file tx.c.
◆ DECL_COMP_FFT
#define DECL_COMP_FFT |
( |
|
N | ) |
|
Value:
void *_in, ptrdiff_t
stride) \
{ \
const
int m =
s->m, *in_map =
s->pfatab, *out_map = in_map +
N*m; \
FFTComplex *
out = _out; \
FFTComplex fft##
N##
in[
N]; \
for (
int i = 0;
i < m;
i++) { \
for (
int j = 0; j <
N; j++) \
fft##
N##
in[j] =
in[in_map[
i*
N + j]]; \
fft##
N(
s->tmp +
s->revtab[
i], fft##
N##
in, m); \
out[
i] =
s->tmp[out_map[
i]]; \
}
Definition at line 399 of file tx.c.
◆ DECL_COMP_IMDCT
#define DECL_COMP_IMDCT |
( |
|
N | ) |
|
Definition at line 437 of file tx.c.
◆ DECL_COMP_MDCT
#define DECL_COMP_MDCT |
( |
|
N | ) |
|
Definition at line 479 of file tx.c.
◆ CHECK_FACTOR
#define CHECK_FACTOR |
( |
|
DST, |
|
|
|
FACTOR, |
|
|
|
SRC |
|
) |
| |
Value: if (
DST == 1 && !(
SRC % FACTOR)) { \
DST = FACTOR; \
SRC /= FACTOR; \
}
◆ FFTSample
Definition at line 31 of file tx.c.
◆ FFTComplex
Definition at line 32 of file tx.c.
◆ FFT_NAME()
static FFTSample* const FFT_NAME |
( |
ff_cos_tabs |
| ) |
|
|
static |
◆ COSTABLE() [1/14]
◆ COSTABLE() [2/14]
◆ COSTABLE() [3/14]
◆ COSTABLE() [4/14]
◆ COSTABLE() [5/14]
◆ COSTABLE() [6/14]
◆ COSTABLE() [7/14]
◆ COSTABLE() [8/14]
◆ COSTABLE() [9/14]
◆ COSTABLE() [10/14]
◆ COSTABLE() [11/14]
◆ COSTABLE() [12/14]
◆ COSTABLE() [13/14]
◆ COSTABLE() [14/14]
◆ init_ff_cos_tabs()
Definition at line 66 of file tx.c.
◆ ff_init_ff_cos_tabs()
static av_cold void ff_init_ff_cos_tabs |
( |
int |
index | ) |
|
|
static |
◆ ff_init_53_tabs()
static av_cold void ff_init_53_tabs |
( |
void |
| ) |
|
|
static |
◆ fft3()
◆ fft15()
Definition at line 249 of file tx.c.
◆ fft4()
◆ fft8()
◆ fft16()
Definition at line 363 of file tx.c.
◆ monolithic_fft()
static void monolithic_fft |
( |
AVTXContext * |
s, |
|
|
void * |
_out, |
|
|
void * |
_in, |
|
|
ptrdiff_t |
stride |
|
) |
| |
|
static |
◆ monolithic_imdct()
static void monolithic_imdct |
( |
AVTXContext * |
s, |
|
|
void * |
_dst, |
|
|
void * |
_src, |
|
|
ptrdiff_t |
stride |
|
) |
| |
|
static |
◆ monolithic_mdct()
static void monolithic_mdct |
( |
AVTXContext * |
s, |
|
|
void * |
_dst, |
|
|
void * |
_src, |
|
|
ptrdiff_t |
stride |
|
) |
| |
|
static |
◆ mulinv()
◆ gen_compound_mapping()
◆ split_radix_permutation()
static int split_radix_permutation |
( |
int |
i, |
|
|
int |
n, |
|
|
int |
inverse |
|
) |
| |
|
static |
◆ get_ptwo_revtab()
◆ gen_mdct_exptab()
◆ av_tx_uninit()
Frees a context and sets ctx to NULL, does nothing when ctx == NULL.
Definition at line 698 of file tx.c.
Referenced by av_tx_init().
◆ init_mdct_fft()
◆ av_tx_init()
Initialize a transform context with the given configuration Currently power of two lengths from 4 to 131072 are supported, along with any length decomposable to a power of two and either 3, 5 or 15.
- Parameters
-
ctx | the context to allocate, will be NULL on error |
tx | pointer to the transform function pointer to set |
type | type the type of transform |
inv | whether to do an inverse or a forward transform |
len | the size of the transform in samples |
scale | pointer to the value to scale the output if supported by type |
flags | currently unused |
- Returns
- 0 on success, negative error code on failure
Definition at line 776 of file tx.c.
◆ cos_tabs_init_once
◆ tabs_53_once
◆ ff_53_tabs
◆ fft_dispatch
Initial value:= {
fft4,
fft8,
fft16, fft32, fft64, fft128, fft256, fft512, fft1024,
fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, fft131072
}
Definition at line 394 of file tx.c.
Referenced by init_mdct_fft(), monolithic_fft(), monolithic_imdct(), and monolithic_mdct().
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in