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 *tmp_buf;
00037 int mdct_size;
00038 int mdct_bits;
00039
00040 FFTSample *tcos;
00041 FFTSample *tsin;
00042 void (*fft_permute)(struct FFTContext *s, FFTComplex *z);
00043 void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
00044 void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
00045 void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
00046 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
00047 int fft_permutation;
00048 #define FF_FFT_PERM_DEFAULT 0
00049 #define FF_FFT_PERM_SWAP_LSBS 1
00050 int mdct_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
00113 void ff_fft_init_altivec(FFTContext *s);
00114 void ff_fft_init_mmx(FFTContext *s);
00115 void ff_fft_init_arm(FFTContext *s);
00116 void ff_dct_init_mmx(DCTContext *s);
00117
00121 static inline void ff_fft_permute(FFTContext *s, FFTComplex *z)
00122 {
00123 s->fft_permute(s, z);
00124 }
00129 static inline void ff_fft_calc(FFTContext *s, FFTComplex *z)
00130 {
00131 s->fft_calc(s, z);
00132 }
00133 void ff_fft_end(FFTContext *s);
00134
00135
00136
00137 static inline void ff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
00138 {
00139 s->imdct_calc(s, output, input);
00140 }
00141 static inline void ff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
00142 {
00143 s->imdct_half(s, output, input);
00144 }
00145
00146 static inline void ff_mdct_calc(FFTContext *s, FFTSample *output,
00147 const FFTSample *input)
00148 {
00149 s->mdct_calc(s, output, input);
00150 }
00151
00155 #define FF_KBD_WINDOW_MAX 1024
00156
00163 void ff_kbd_window_init(float *window, float alpha, int n);
00164
00170 void ff_sine_window_init(float *window, int n);
00171
00175 void ff_init_ff_sine_windows(int index);
00176 extern SINETABLE( 32);
00177 extern SINETABLE( 64);
00178 extern SINETABLE( 128);
00179 extern SINETABLE( 256);
00180 extern SINETABLE( 512);
00181 extern SINETABLE(1024);
00182 extern SINETABLE(2048);
00183 extern SINETABLE(4096);
00184 extern SINETABLE_CONST float * const ff_sine_windows[13];
00185
00186 int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
00187 void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00188 void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00189 void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00190 void ff_mdct_end(FFTContext *s);
00191
00192
00193
00194 struct RDFTContext {
00195 int nbits;
00196 int inverse;
00197 int sign_convention;
00198
00199
00200 const FFTSample *tcos;
00201 SINTABLE_CONST FFTSample *tsin;
00202 FFTContext fft;
00203 void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
00204 };
00205
00211 int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
00212 void ff_rdft_end(RDFTContext *s);
00213
00214 void ff_rdft_init_arm(RDFTContext *s);
00215
00216 static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data)
00217 {
00218 s->rdft_calc(s, data);
00219 }
00220
00221
00222
00223 struct DCTContext {
00224 int nbits;
00225 int inverse;
00226 RDFTContext rdft;
00227 const float *costab;
00228 FFTSample *csc2;
00229 void (*dct_calc)(struct DCTContext *s, FFTSample *data);
00230 void (*dct32)(FFTSample *out, const FFTSample *in);
00231 };
00232
00241 int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
00242 void ff_dct_calc(DCTContext *s, FFTSample *data);
00243 void ff_dct_end (DCTContext *s);
00244
00245 #endif