#include <stdint.h>
#include "config.h"
#include "libavutil/mem.h"
+#include "avfft.h"
/* FFT computation */
-/* NOTE: soon integer code will be added, so you must use the
- FFTSample type */
-typedef float FFTSample;
-
-typedef struct FFTComplex {
- FFTSample re, im;
-} FFTComplex;
-
-typedef struct FFTContext {
+struct FFTContext {
int nbits;
int inverse;
uint16_t *revtab;
- FFTComplex *exptab;
- FFTComplex *exptab1; /* only used by SSE code */
FFTComplex *tmp_buf;
int mdct_size; /* size of MDCT (i.e. number of input data * 2) */
int mdct_bits; /* n = 2^nbits */
void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
- int split_radix;
int permutation;
#define FF_MDCT_PERM_NONE 0
#define FF_MDCT_PERM_INTERLEAVE 1
-} FFTContext;
+};
#if CONFIG_HARDCODED_TABLES
#define COSTABLE_CONST const
extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17];
/**
- * Initializes the cosine table in ff_cos_tabs[index]
+ * Initialize the cosine table in ff_cos_tabs[index]
* \param index index in ff_cos_tabs array of the table to initialize
*/
void ff_init_ff_cos_tabs(int index);
extern SINTABLE(65536);
/**
- * Sets up a complex FFT.
+ * Set up a complex FFT.
* @param nbits log2 of the length of the input array
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
*/
void ff_fft_init_altivec(FFTContext *s);
void ff_fft_init_mmx(FFTContext *s);
void ff_fft_init_arm(FFTContext *s);
+void ff_dct_init_mmx(DCTContext *s);
/**
* Do the permutation needed BEFORE calling ff_fft_calc().
s->mdct_calc(s, output, input);
}
+/**
+ * Maximum window size for ff_kbd_window_init.
+ */
+#define FF_KBD_WINDOW_MAX 1024
+
/**
* Generate a Kaiser-Bessel Derived Window.
* @param window pointer to half window
* @param alpha determines window shape
- * @param n size of half window
+ * @param n size of half window, max FF_KBD_WINDOW_MAX
*/
void ff_kbd_window_init(float *window, float alpha, int n);
/* Real Discrete Fourier Transform */
-enum RDFTransformType {
- RDFT,
- IRDFT,
- RIDFT,
- IRIDFT,
-};
-
-typedef struct {
+struct RDFTContext {
int nbits;
int inverse;
int sign_convention;
const FFTSample *tcos;
SINTABLE_CONST FFTSample *tsin;
FFTContext fft;
-} RDFTContext;
+ void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
+};
/**
- * Sets up a real FFT.
+ * Set up a real FFT.
* @param nbits log2 of the length of the input array
* @param trans the type of transform
*/
int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
-void ff_rdft_calc(RDFTContext *s, FFTSample *data);
void ff_rdft_end(RDFTContext *s);
+void ff_rdft_init_arm(RDFTContext *s);
+
+static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data)
+{
+ s->rdft_calc(s, data);
+}
+
/* Discrete Cosine Transform */
-typedef struct {
+struct DCTContext {
int nbits;
int inverse;
- FFTSample *data;
RDFTContext rdft;
const float *costab;
FFTSample *csc2;
-} DCTContext;
+ void (*dct_calc)(struct DCTContext *s, FFTSample *data);
+ void (*dct32)(FFTSample *out, const FFTSample *in);
+};
/**
- * Sets up (Inverse)DCT.
- * @param nbits log2 of the length of the input array
- * @param inverse >0 forward transform, <0 inverse transform
+ * Set up DCT.
+ * @param nbits size of the input array:
+ * (1 << nbits) for DCT-II, DCT-III and DST-I
+ * (1 << nbits) + 1 for DCT-I
+ *
+ * @note the first element of the input of DST-I is ignored
*/
-int ff_dct_init(DCTContext *s, int nbits, int inverse);
+int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
void ff_dct_calc(DCTContext *s, FFTSample *data);
void ff_dct_end (DCTContext *s);