Libav 0.7.1
|
00001 /* 00002 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard 00003 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef AVCODEC_FFT_H 00023 #define AVCODEC_FFT_H 00024 00025 #ifndef CONFIG_FFT_FLOAT 00026 #define CONFIG_FFT_FLOAT 1 00027 #endif 00028 00029 #include <stdint.h> 00030 #include "config.h" 00031 #include "libavutil/mem.h" 00032 00033 #if CONFIG_FFT_FLOAT 00034 00035 #include "avfft.h" 00036 00037 #define FFT_NAME(x) x 00038 00039 typedef float FFTDouble; 00040 00041 #else 00042 00043 #define FFT_NAME(x) x ## _fixed 00044 00045 typedef int16_t FFTSample; 00046 typedef int FFTDouble; 00047 00048 typedef struct FFTComplex { 00049 int16_t re, im; 00050 } FFTComplex; 00051 00052 typedef struct FFTContext FFTContext; 00053 00054 #endif /* CONFIG_FFT_FLOAT */ 00055 00056 typedef struct FFTDComplex { 00057 FFTDouble re, im; 00058 } FFTDComplex; 00059 00060 /* FFT computation */ 00061 00062 struct FFTContext { 00063 int nbits; 00064 int inverse; 00065 uint16_t *revtab; 00066 FFTComplex *tmp_buf; 00067 int mdct_size; /* size of MDCT (i.e. number of input data * 2) */ 00068 int mdct_bits; /* n = 2^nbits */ 00069 /* pre/post rotation tables */ 00070 FFTSample *tcos; 00071 FFTSample *tsin; 00075 void (*fft_permute)(struct FFTContext *s, FFTComplex *z); 00080 void (*fft_calc)(struct FFTContext *s, FFTComplex *z); 00081 void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); 00082 void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); 00083 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); 00084 void (*mdct_calcw)(struct FFTContext *s, FFTDouble *output, const FFTSample *input); 00085 int fft_permutation; 00086 #define FF_FFT_PERM_DEFAULT 0 00087 #define FF_FFT_PERM_SWAP_LSBS 1 00088 #define FF_FFT_PERM_AVX 2 00089 int mdct_permutation; 00090 #define FF_MDCT_PERM_NONE 0 00091 #define FF_MDCT_PERM_INTERLEAVE 1 00092 }; 00093 00094 #if CONFIG_HARDCODED_TABLES 00095 #define COSTABLE_CONST const 00096 #else 00097 #define COSTABLE_CONST 00098 #endif 00099 00100 #define COSTABLE(size) \ 00101 COSTABLE_CONST DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2] 00102 00103 extern COSTABLE(16); 00104 extern COSTABLE(32); 00105 extern COSTABLE(64); 00106 extern COSTABLE(128); 00107 extern COSTABLE(256); 00108 extern COSTABLE(512); 00109 extern COSTABLE(1024); 00110 extern COSTABLE(2048); 00111 extern COSTABLE(4096); 00112 extern COSTABLE(8192); 00113 extern COSTABLE(16384); 00114 extern COSTABLE(32768); 00115 extern COSTABLE(65536); 00116 extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[17]; 00117 00118 #define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs) 00119 00124 void ff_init_ff_cos_tabs(int index); 00125 00126 #define ff_fft_init FFT_NAME(ff_fft_init) 00127 #define ff_fft_end FFT_NAME(ff_fft_end) 00128 00134 int ff_fft_init(FFTContext *s, int nbits, int inverse); 00135 00136 #if CONFIG_FFT_FLOAT 00137 void ff_fft_init_altivec(FFTContext *s); 00138 void ff_fft_init_mmx(FFTContext *s); 00139 void ff_fft_init_arm(FFTContext *s); 00140 #else 00141 void ff_fft_fixed_init_arm(FFTContext *s); 00142 #endif 00143 00144 void ff_fft_end(FFTContext *s); 00145 00146 #define ff_mdct_init FFT_NAME(ff_mdct_init) 00147 #define ff_mdct_end FFT_NAME(ff_mdct_end) 00148 00149 int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); 00150 void ff_mdct_end(FFTContext *s); 00151 00152 #endif /* AVCODEC_FFT_H */