FFmpeg
Data Structures | Macros | Functions | Variables
fft_template.c File Reference
#include <stdlib.h>
#include <string.h>
#include "libavutil/mathematics.h"
#include "libavutil/thread.h"
#include "fft.h"
#include "fft-internal.h"

Go to the source code of this file.

Data Structures

struct  CosTabsInitOnce
 

Macros

#define INIT_FF_COS_TABS_FUNC(index, size)
 
#define PROCESS_FFT_PERM_SWAP_LSBS(num)
 
#define PROCESS_FFT_PERM_DEFAULT(num)
 
#define SPLIT_RADIX_PERMUTATION(num)
 
#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
 

Functions

 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)
 
av_cold void ff_init_ff_cos_tabs (int index)
 Initialize the cosine table in ff_cos_tabs[index]. More...
 
COSTABLE_CONST FFTSample *const FFT_NAME (ff_cos_tabs)[]
 
static void fft_permute_c (FFTContext *s, FFTComplex *z)
 
static void fft_calc_c (FFTContext *s, FFTComplex *z)
 
static int split_radix_permutation (int i, int n, int inverse)
 
static int is_second_half_of_fft32 (int i, int n)
 
static av_cold void fft_perm_avx (FFTContext *s)
 
av_cold int ff_fft_init (FFTContext *s, int nbits, int inverse)
 Set up a complex FFT. More...
 
av_cold void ff_fft_end (FFTContext *s)
 
static void fft4 (FFTComplex *z)
 
static void fft8 (FFTComplex *z)
 
static void fft16 (FFTComplex *z)
 

Variables

static CosTabsInitOnce cos_tabs_init_once []
 
static const int avx_tab []
 
static void(*const fft_dispatch [])(FFTComplex *)
 

Detailed Description

FFT/IFFT transforms.

Definition in file fft_template.c.

Macro Definition Documentation

◆ INIT_FF_COS_TABS_FUNC

#define INIT_FF_COS_TABS_FUNC (   index,
  size 
)
Value:
static av_cold void init_ff_cos_tabs_ ## size (void)\
{ \
init_ff_cos_tabs(index); \
}

Definition at line 74 of file fft_template.c.

◆ PROCESS_FFT_PERM_SWAP_LSBS

#define PROCESS_FFT_PERM_SWAP_LSBS (   num)
Value:
do {\
for(i = 0; i < n; i++) {\
int k;\
j = i;\
j = (j & ~3) | ((j >> 1) & 1) | ((j << 1) & 2);\
k = -split_radix_permutation(i, n, s->inverse) & (n - 1);\
s->revtab##num[k] = j;\
} \
} while(0);

◆ PROCESS_FFT_PERM_DEFAULT

#define PROCESS_FFT_PERM_DEFAULT (   num)
Value:
do {\
for(i = 0; i < n; i++) {\
int k;\
j = i;\
k = -split_radix_permutation(i, n, s->inverse) & (n - 1);\
s->revtab##num[k] = j;\
} \
} while(0);

◆ SPLIT_RADIX_PERMUTATION

#define SPLIT_RADIX_PERMUTATION (   num)
Value:
do { \
if (s->fft_permutation == FF_FFT_PERM_SWAP_LSBS) {\
PROCESS_FFT_PERM_SWAP_LSBS(num) \
} else {\
PROCESS_FFT_PERM_DEFAULT(num) \
}\
} while(0);

◆ BUTTERFLIES [1/2]

#define BUTTERFLIES (   a0,
  a1,
  a2,
  a3 
)
Value:
{\
BF(t3, t5, t5, t1);\
BF(a2.re, a0.re, a0.re, t5);\
BF(a3.im, a1.im, a1.im, t3);\
BF(t4, t6, t2, t6);\
BF(a3.re, a1.re, a1.re, t4);\
BF(a2.im, a0.im, a0.im, t6);\
}

Definition at line 541 of file fft_template.c.

◆ BUTTERFLIES_BIG

#define BUTTERFLIES_BIG (   a0,
  a1,
  a2,
  a3 
)
Value:
{\
FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\
BF(t3, t5, t5, t1);\
BF(a2.re, a0.re, r0, t5);\
BF(a3.im, a1.im, i1, t3);\
BF(t4, t6, t2, t6);\
BF(a3.re, a1.re, r1, t4);\
BF(a2.im, a0.im, i0, t6);\
}

Definition at line 492 of file fft_template.c.

◆ TRANSFORM

#define TRANSFORM (   a0,
  a1,
  a2,
  a3,
  wre,
  wim 
)
Value:
{\
CMUL(t1, t2, a2.re, a2.im, wre, -wim);\
CMUL(t5, t6, a3.re, a3.im, wre, wim);\
BUTTERFLIES(a0,a1,a2,a3)\
}

Definition at line 502 of file fft_template.c.

◆ TRANSFORM_ZERO

#define TRANSFORM_ZERO (   a0,
  a1,
  a2,
  a3 
)
Value:
{\
t1 = a2.re;\
t2 = a2.im;\
t5 = a3.re;\
t6 = a3.im;\
BUTTERFLIES(a0,a1,a2,a3)\
}

Definition at line 508 of file fft_template.c.

◆ PASS

#define PASS (   name)
Value:
static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\
{\
FFTDouble t1, t2, t3, t4, t5, t6;\
int o1 = 2*n;\
int o2 = 4*n;\
int o3 = 6*n;\
const FFTSample *wim = wre+o1;\
n--;\
TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\
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]);\
} while(--n);\
}

Definition at line 517 of file fft_template.c.

◆ BUTTERFLIES [2/2]

#define BUTTERFLIES   BUTTERFLIES_BIG

Definition at line 541 of file fft_template.c.

◆ DECL_FFT

#define DECL_FFT (   n,
  n2,
  n4 
)
Value:
static void fft##n(FFTComplex *z)\
{\
fft##n2(z);\
fft##n4(z+n4*2);\
fft##n4(z+n4*3);\
pass(z,FFT_NAME(ff_cos_##n),n4/2);\
}

Definition at line 545 of file fft_template.c.

◆ pass

#define pass   pass_big

Definition at line 608 of file fft_template.c.

Function Documentation

◆ COSTABLE() [1/14]

COSTABLE ( 16  )

◆ COSTABLE() [2/14]

COSTABLE ( 32  )

◆ COSTABLE() [3/14]

COSTABLE ( 64  )

◆ COSTABLE() [4/14]

COSTABLE ( 128  )

◆ COSTABLE() [5/14]

COSTABLE ( 256  )

◆ COSTABLE() [6/14]

COSTABLE ( 512  )

◆ COSTABLE() [7/14]

COSTABLE ( 1024  )

◆ COSTABLE() [8/14]

COSTABLE ( 2048  )

◆ COSTABLE() [9/14]

COSTABLE ( 4096  )

◆ COSTABLE() [10/14]

COSTABLE ( 8192  )

◆ COSTABLE() [11/14]

COSTABLE ( 16384  )

◆ COSTABLE() [12/14]

COSTABLE ( 32768  )

◆ COSTABLE() [13/14]

COSTABLE ( 65536  )

◆ COSTABLE() [14/14]

COSTABLE ( 131072  )

◆ init_ff_cos_tabs()

static av_cold void init_ff_cos_tabs ( int  index)
static

Definition at line 57 of file fft_template.c.

◆ ff_init_ff_cos_tabs()

av_cold void ff_init_ff_cos_tabs ( int  index)

Initialize the cosine table in ff_cos_tabs[index].

Parameters
indexindex in ff_cos_tabs array of the table to initialize

Definition at line 116 of file fft_template.c.

Referenced by ff_fft_init().

◆ FFT_NAME()

COSTABLE_CONST FFTSample* const FFT_NAME ( ff_cos_tabs  )

Referenced by fft16(), and init_ff_cos_tabs().

◆ fft_permute_c()

static void fft_permute_c ( FFTContext s,
FFTComplex z 
)
static

Definition at line 298 of file fft_template.c.

Referenced by ff_fft_init().

◆ fft_calc_c()

static void fft_calc_c ( FFTContext s,
FFTComplex z 
)
static

Definition at line 624 of file fft_template.c.

Referenced by ff_fft_init().

◆ split_radix_permutation()

static int split_radix_permutation ( int  i,
int  n,
int  inverse 
)
static

Definition at line 144 of file fft_template.c.

Referenced by fft_perm_avx().

◆ is_second_half_of_fft32()

static int is_second_half_of_fft32 ( int  i,
int  n 
)
static

Definition at line 160 of file fft_template.c.

Referenced by fft_perm_avx().

◆ fft_perm_avx()

static av_cold void fft_perm_avx ( FFTContext s)
static

Definition at line 172 of file fft_template.c.

Referenced by ff_fft_init().

◆ ff_fft_init()

av_cold int ff_fft_init ( FFTContext s,
int  nbits,
int  inverse 
)

Set up a complex FFT.

Parameters
nbitslog2 of the length of the input array
inverseif 0 perform the forward transform, if 1 perform the inverse

Definition at line 194 of file fft_template.c.

◆ ff_fft_end()

av_cold void ff_fft_end ( FFTContext s)

Definition at line 313 of file fft_template.c.

◆ fft4()

static void fft4 ( FFTComplex z)
static

Definition at line 554 of file fft_template.c.

Referenced by fft16(), and fft8().

◆ fft8()

static void fft8 ( FFTComplex z)
static

Definition at line 568 of file fft_template.c.

Referenced by fft16().

◆ fft16()

static void fft16 ( FFTComplex z)
static

Definition at line 584 of file fft_template.c.

Variable Documentation

◆ cos_tabs_init_once

CosTabsInitOnce cos_tabs_init_once[]
static
Initial value:
= {
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ init_ff_cos_tabs_16, AV_ONCE_INIT },
{ init_ff_cos_tabs_32, AV_ONCE_INIT },
{ init_ff_cos_tabs_64, AV_ONCE_INIT },
{ init_ff_cos_tabs_128, AV_ONCE_INIT },
{ init_ff_cos_tabs_256, AV_ONCE_INIT },
{ init_ff_cos_tabs_512, AV_ONCE_INIT },
{ init_ff_cos_tabs_1024, AV_ONCE_INIT },
{ init_ff_cos_tabs_2048, AV_ONCE_INIT },
{ init_ff_cos_tabs_4096, AV_ONCE_INIT },
{ init_ff_cos_tabs_8192, AV_ONCE_INIT },
{ init_ff_cos_tabs_16384, AV_ONCE_INIT },
{ init_ff_cos_tabs_32768, AV_ONCE_INIT },
{ init_ff_cos_tabs_65536, AV_ONCE_INIT },
{ init_ff_cos_tabs_131072, AV_ONCE_INIT },
}

Definition at line 95 of file fft_template.c.

Referenced by ff_init_ff_cos_tabs().

◆ avx_tab

const int avx_tab[]
static
Initial value:
= {
0, 4, 1, 5, 8, 12, 9, 13, 2, 6, 3, 7, 10, 14, 11, 15
}

Definition at line 156 of file fft_template.c.

Referenced by fft_perm_avx().

◆ fft_dispatch

void(* const fft_dispatch[])(FFTComplex *)
static
Initial value:
= {
fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024,
fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, fft131072
}

Definition at line 619 of file fft_template.c.

Referenced by fft_calc_c().

fft16
static void fft16(FFTComplex *z)
Definition: fft_template.c:584
name
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 default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
split_radix_permutation
static int split_radix_permutation(int i, int n, int inverse)
Definition: fft_template.c:144
t1
#define t1
Definition: regdef.h:29
FF_FFT_PERM_SWAP_LSBS
@ FF_FFT_PERM_SWAP_LSBS
Definition: fft.h:66
a1
#define a1
Definition: regdef.h:47
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:177
NULL
#define NULL
Definition: coverity.c:32
t5
#define t5
Definition: regdef.h:33
t6
#define t6
Definition: regdef.h:34
FFTSample
float FFTSample
Definition: avfft.h:35
index
int index
Definition: gxfenc.c:89
size
int size
Definition: twinvq_data.h:10344
a0
#define a0
Definition: regdef.h:46
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
t4
#define t4
Definition: regdef.h:32
t3
#define t3
Definition: regdef.h:31
a2
#define a2
Definition: regdef.h:48
t2
#define t2
Definition: regdef.h:30
fft4
static void fft4(FFTComplex *z)
Definition: fft_template.c:554
FFT_NAME
COSTABLE_CONST FFTSample *const FFT_NAME(ff_cos_tabs)[]
TRANSFORM_ZERO
#define TRANSFORM_ZERO(a0, a1, a2, a3)
Definition: fft_template.c:508
fft8
static void fft8(FFTComplex *z)
Definition: fft_template.c:568
a3
#define a3
Definition: regdef.h:49
FFTComplex
Definition: avfft.h:37