00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_FFT_H
00023 #define AVCODEC_FFT_H
00024
00025 #include <stdint.h>
00026 #include "config.h"
00027 #include "libavutil/mem.h"
00028 #include "avfft.h"
00029
00030
00031
00032 struct FFTContext {
00033 int nbits;
00034 int inverse;
00035 uint16_t *revtab;
00036 FFTComplex *exptab;
00037 FFTComplex *exptab1;
00038 FFTComplex *tmp_buf;
00039 int mdct_size;
00040 int mdct_bits;
00041
00042 FFTSample *tcos;
00043 FFTSample *tsin;
00044 void (*fft_permute)(struct FFTContext *s, FFTComplex *z);
00045 void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
00046 void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
00047 void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
00048 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
00049 int split_radix;
00050 int permutation;
00051 #define FF_MDCT_PERM_NONE 0
00052 #define FF_MDCT_PERM_INTERLEAVE 1
00053 };
00054
00055 #if CONFIG_HARDCODED_TABLES
00056 #define COSTABLE_CONST const
00057 #define SINTABLE_CONST const
00058 #define SINETABLE_CONST const
00059 #else
00060 #define COSTABLE_CONST
00061 #define SINTABLE_CONST
00062 #define SINETABLE_CONST
00063 #endif
00064
00065 #define COSTABLE(size) \
00066 COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2]
00067 #define SINTABLE(size) \
00068 SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2]
00069 #define SINETABLE(size) \
00070 SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size]
00071 extern COSTABLE(16);
00072 extern COSTABLE(32);
00073 extern COSTABLE(64);
00074 extern COSTABLE(128);
00075 extern COSTABLE(256);
00076 extern COSTABLE(512);
00077 extern COSTABLE(1024);
00078 extern COSTABLE(2048);
00079 extern COSTABLE(4096);
00080 extern COSTABLE(8192);
00081 extern COSTABLE(16384);
00082 extern COSTABLE(32768);
00083 extern COSTABLE(65536);
00084 extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17];
00085
00090 void ff_init_ff_cos_tabs(int index);
00091
00092 extern SINTABLE(16);
00093 extern SINTABLE(32);
00094 extern SINTABLE(64);
00095 extern SINTABLE(128);
00096 extern SINTABLE(256);
00097 extern SINTABLE(512);
00098 extern SINTABLE(1024);
00099 extern SINTABLE(2048);
00100 extern SINTABLE(4096);
00101 extern SINTABLE(8192);
00102 extern SINTABLE(16384);
00103 extern SINTABLE(32768);
00104 extern SINTABLE(65536);
00105
00111 int ff_fft_init(FFTContext *s, int nbits, int inverse);
00112 void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
00113 void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
00114
00115 void ff_fft_init_altivec(FFTContext *s);
00116 void ff_fft_init_mmx(FFTContext *s);
00117 void ff_fft_init_arm(FFTContext *s);
00118
00122 static inline void ff_fft_permute(FFTContext *s, FFTComplex *z)
00123 {
00124 s->fft_permute(s, z);
00125 }
00130 static inline void ff_fft_calc(FFTContext *s, FFTComplex *z)
00131 {
00132 s->fft_calc(s, z);
00133 }
00134 void ff_fft_end(FFTContext *s);
00135
00136
00137
00138 static inline void ff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
00139 {
00140 s->imdct_calc(s, output, input);
00141 }
00142 static inline void ff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
00143 {
00144 s->imdct_half(s, output, input);
00145 }
00146
00147 static inline void ff_mdct_calc(FFTContext *s, FFTSample *output,
00148 const FFTSample *input)
00149 {
00150 s->mdct_calc(s, output, input);
00151 }
00152
00159 void ff_kbd_window_init(float *window, float alpha, int n);
00160
00166 void ff_sine_window_init(float *window, int n);
00167
00171 void ff_init_ff_sine_windows(int index);
00172 extern SINETABLE( 32);
00173 extern SINETABLE( 64);
00174 extern SINETABLE( 128);
00175 extern SINETABLE( 256);
00176 extern SINETABLE( 512);
00177 extern SINETABLE(1024);
00178 extern SINETABLE(2048);
00179 extern SINETABLE(4096);
00180 extern SINETABLE_CONST float * const ff_sine_windows[13];
00181
00182 int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
00183 void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00184 void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00185 void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00186 void ff_mdct_end(FFTContext *s);
00187
00188
00189
00190 struct RDFTContext {
00191 int nbits;
00192 int inverse;
00193 int sign_convention;
00194
00195
00196 const FFTSample *tcos;
00197 SINTABLE_CONST FFTSample *tsin;
00198 FFTContext fft;
00199 void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
00200 };
00201
00207 int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
00208 void ff_rdft_end(RDFTContext *s);
00209
00210 void ff_rdft_init_arm(RDFTContext *s);
00211
00212 static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data)
00213 {
00214 s->rdft_calc(s, data);
00215 }
00216
00217
00218
00219 struct DCTContext {
00220 int nbits;
00221 int inverse;
00222 RDFTContext rdft;
00223 const float *costab;
00224 FFTSample *csc2;
00225 void (*dct_calc)(struct DCTContext *s, FFTSample *data);
00226 };
00227
00236 int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
00237 void ff_dct_calc(DCTContext *s, FFTSample *data);
00238 void ff_dct_end (DCTContext *s);
00239
00240 #endif