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 permutation;
00048 #define FF_MDCT_PERM_NONE 0
00049 #define FF_MDCT_PERM_INTERLEAVE 1
00050 };
00051
00052 #if CONFIG_HARDCODED_TABLES
00053 #define COSTABLE_CONST const
00054 #define SINTABLE_CONST const
00055 #define SINETABLE_CONST const
00056 #else
00057 #define COSTABLE_CONST
00058 #define SINTABLE_CONST
00059 #define SINETABLE_CONST
00060 #endif
00061
00062 #define COSTABLE(size) \
00063 COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2]
00064 #define SINTABLE(size) \
00065 SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2]
00066 #define SINETABLE(size) \
00067 SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size]
00068 extern COSTABLE(16);
00069 extern COSTABLE(32);
00070 extern COSTABLE(64);
00071 extern COSTABLE(128);
00072 extern COSTABLE(256);
00073 extern COSTABLE(512);
00074 extern COSTABLE(1024);
00075 extern COSTABLE(2048);
00076 extern COSTABLE(4096);
00077 extern COSTABLE(8192);
00078 extern COSTABLE(16384);
00079 extern COSTABLE(32768);
00080 extern COSTABLE(65536);
00081 extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17];
00082
00087 void ff_init_ff_cos_tabs(int index);
00088
00089 extern SINTABLE(16);
00090 extern SINTABLE(32);
00091 extern SINTABLE(64);
00092 extern SINTABLE(128);
00093 extern SINTABLE(256);
00094 extern SINTABLE(512);
00095 extern SINTABLE(1024);
00096 extern SINTABLE(2048);
00097 extern SINTABLE(4096);
00098 extern SINTABLE(8192);
00099 extern SINTABLE(16384);
00100 extern SINTABLE(32768);
00101 extern SINTABLE(65536);
00102
00108 int ff_fft_init(FFTContext *s, int nbits, int inverse);
00109 void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
00110 void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
00111
00112 void ff_fft_init_altivec(FFTContext *s);
00113 void ff_fft_init_mmx(FFTContext *s);
00114 void ff_fft_init_arm(FFTContext *s);
00115 void ff_dct_init_mmx(DCTContext *s);
00116
00120 static inline void ff_fft_permute(FFTContext *s, FFTComplex *z)
00121 {
00122 s->fft_permute(s, z);
00123 }
00128 static inline void ff_fft_calc(FFTContext *s, FFTComplex *z)
00129 {
00130 s->fft_calc(s, z);
00131 }
00132 void ff_fft_end(FFTContext *s);
00133
00134
00135
00136 static inline void ff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
00137 {
00138 s->imdct_calc(s, output, input);
00139 }
00140 static inline void ff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
00141 {
00142 s->imdct_half(s, output, input);
00143 }
00144
00145 static inline void ff_mdct_calc(FFTContext *s, FFTSample *output,
00146 const FFTSample *input)
00147 {
00148 s->mdct_calc(s, output, input);
00149 }
00150
00154 #define FF_KBD_WINDOW_MAX 1024
00155
00162 void ff_kbd_window_init(float *window, float alpha, int n);
00163
00169 void ff_sine_window_init(float *window, int n);
00170
00174 void ff_init_ff_sine_windows(int index);
00175 extern SINETABLE( 32);
00176 extern SINETABLE( 64);
00177 extern SINETABLE( 128);
00178 extern SINETABLE( 256);
00179 extern SINETABLE( 512);
00180 extern SINETABLE(1024);
00181 extern SINETABLE(2048);
00182 extern SINETABLE(4096);
00183 extern SINETABLE_CONST float * const ff_sine_windows[13];
00184
00185 int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
00186 void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00187 void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00188 void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
00189 void ff_mdct_end(FFTContext *s);
00190
00191
00192
00193 struct RDFTContext {
00194 int nbits;
00195 int inverse;
00196 int sign_convention;
00197
00198
00199 const FFTSample *tcos;
00200 SINTABLE_CONST FFTSample *tsin;
00201 FFTContext fft;
00202 void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
00203 };
00204
00210 int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
00211 void ff_rdft_end(RDFTContext *s);
00212
00213 void ff_rdft_init_arm(RDFTContext *s);
00214
00215 static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data)
00216 {
00217 s->rdft_calc(s, data);
00218 }
00219
00220
00221
00222 struct DCTContext {
00223 int nbits;
00224 int inverse;
00225 RDFTContext rdft;
00226 const float *costab;
00227 FFTSample *csc2;
00228 void (*dct_calc)(struct DCTContext *s, FFTSample *data);
00229 void (*dct32)(FFTSample *out, const FFTSample *in);
00230 };
00231
00240 int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
00241 void ff_dct_calc(DCTContext *s, FFTSample *data);
00242 void ff_dct_end (DCTContext *s);
00243
00244 #endif