comparison fft.h @ 11392:384d803faff4 libavcodec

Create a public API for FFT family of functions
author mru
date Sun, 07 Mar 2010 21:56:45 +0000
parents 4c7afa50df6f
children 1382cfff33bb
comparison
equal deleted inserted replaced
11391:4c7afa50df6f 11392:384d803faff4
23 #define AVCODEC_FFT_H 23 #define AVCODEC_FFT_H
24 24
25 #include <stdint.h> 25 #include <stdint.h>
26 #include "config.h" 26 #include "config.h"
27 #include "libavutil/mem.h" 27 #include "libavutil/mem.h"
28 #include "avfft.h"
28 29
29 /* FFT computation */ 30 /* FFT computation */
30 31
31 /* NOTE: soon integer code will be added, so you must use the 32 struct FFTContext {
32 FFTSample type */
33 typedef float FFTSample;
34
35 typedef struct FFTComplex {
36 FFTSample re, im;
37 } FFTComplex;
38
39 typedef struct FFTContext {
40 int nbits; 33 int nbits;
41 int inverse; 34 int inverse;
42 uint16_t *revtab; 35 uint16_t *revtab;
43 FFTComplex *exptab; 36 FFTComplex *exptab;
44 FFTComplex *exptab1; /* only used by SSE code */ 37 FFTComplex *exptab1; /* only used by SSE code */
55 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); 48 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
56 int split_radix; 49 int split_radix;
57 int permutation; 50 int permutation;
58 #define FF_MDCT_PERM_NONE 0 51 #define FF_MDCT_PERM_NONE 0
59 #define FF_MDCT_PERM_INTERLEAVE 1 52 #define FF_MDCT_PERM_INTERLEAVE 1
60 } FFTContext; 53 };
61 54
62 #if CONFIG_HARDCODED_TABLES 55 #if CONFIG_HARDCODED_TABLES
63 #define COSTABLE_CONST const 56 #define COSTABLE_CONST const
64 #define SINTABLE_CONST const 57 #define SINTABLE_CONST const
65 #define SINETABLE_CONST const 58 #define SINETABLE_CONST const
192 void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); 185 void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
193 void ff_mdct_end(FFTContext *s); 186 void ff_mdct_end(FFTContext *s);
194 187
195 /* Real Discrete Fourier Transform */ 188 /* Real Discrete Fourier Transform */
196 189
197 enum RDFTransformType { 190 struct RDFTContext {
198 DFT_R2C,
199 IDFT_C2R,
200 IDFT_R2C,
201 DFT_C2R,
202 };
203
204 typedef struct {
205 int nbits; 191 int nbits;
206 int inverse; 192 int inverse;
207 int sign_convention; 193 int sign_convention;
208 194
209 /* pre/post rotation tables */ 195 /* pre/post rotation tables */
210 const FFTSample *tcos; 196 const FFTSample *tcos;
211 SINTABLE_CONST FFTSample *tsin; 197 SINTABLE_CONST FFTSample *tsin;
212 FFTContext fft; 198 FFTContext fft;
213 } RDFTContext; 199 };
214 200
215 /** 201 /**
216 * Sets up a real FFT. 202 * Sets up a real FFT.
217 * @param nbits log2 of the length of the input array 203 * @param nbits log2 of the length of the input array
218 * @param trans the type of transform 204 * @param trans the type of transform
221 void ff_rdft_calc(RDFTContext *s, FFTSample *data); 207 void ff_rdft_calc(RDFTContext *s, FFTSample *data);
222 void ff_rdft_end(RDFTContext *s); 208 void ff_rdft_end(RDFTContext *s);
223 209
224 /* Discrete Cosine Transform */ 210 /* Discrete Cosine Transform */
225 211
226 typedef struct { 212 struct DCTContext {
227 int nbits; 213 int nbits;
228 int inverse; 214 int inverse;
229 FFTSample *data; 215 FFTSample *data;
230 RDFTContext rdft; 216 RDFTContext rdft;
231 const float *costab; 217 const float *costab;
232 FFTSample *csc2; 218 FFTSample *csc2;
233 } DCTContext; 219 };
234 220
235 /** 221 /**
236 * Sets up (Inverse)DCT. 222 * Sets up (Inverse)DCT.
237 * @param nbits log2 of the length of the input array 223 * @param nbits log2 of the length of the input array
238 * @param inverse >0 forward transform, <0 inverse transform 224 * @param inverse >0 forward transform, <0 inverse transform