25static const char *
TAG =
"fftr4 ansi";
43 if (max_fft_size == 0) {
46 if (fft_table_buff != NULL) {
65 if ((pow >= 2) && (pow <= 6)) {
111 int log4N = log2N >> 1;
112 if ((log2N & 0x01) != 0) {
115 float r_temp, i_temp;
116 for (
int i = 0; i <
N; i++) {
125 xx = (xx << 2) + bits2;
130 r_temp =
data[i * 2 + 0];
131 i_temp =
data[i * 2 + 1];
134 data[xx * 2 + 0] = r_temp;
135 data[xx * 2 + 1] = i_temp;
149 int log4N = log2N >> 1;
150 if ((log2N & 0x01) != 0) {
155 int wind_step = table_size / length;
160 length = length >> 2;
161 for (
int j = 0; j <
m; j += 2) {
162 int start_index = j * (length << 1);
165 fc32_t *ptrc1 = ptrc0 + length;
166 fc32_t *ptrc2 = ptrc1 + length;
167 fc32_t *ptrc3 = ptrc2 + length;
173 for (
int k = 0;
k < length;
k++) {
179 bfly[0].
re = in0.
re + in2.
re + in1.
re + in3.
re;
180 bfly[0].
im = in0.
im + in2.
im + in1.
im + in3.
im;
182 bfly[1].
re = in0.
re - in2.
re + in1.
im - in3.
im;
183 bfly[1].
im = in0.
im - in2.
im - in1.
re + in3.
re;
185 bfly[2].
re = in0.
re + in2.
re - in1.
re - in3.
re;
186 bfly[2].
im = in0.
im + in2.
im - in1.
im - in3.
im;
188 bfly[3].
re = in0.
re - in2.
re - in1.
im + in3.
im;
189 bfly[3].
im = in0.
im - in2.
im + in1.
re - in3.
re;
194 ptrc1->
re = bfly[1].
re * winc0->
re + bfly[1].
im * winc0->
im;
195 ptrc1->
im = bfly[1].
im * winc0->
re - bfly[1].
re * winc0->
im;
196 ptrc2->
re = bfly[2].
re * winc1->
re + bfly[2].
im * winc1->
im;
197 ptrc2->
im = bfly[2].
im * winc1->
re - bfly[2].
re * winc1->
im;
198 ptrc3->
re = bfly[3].
re * winc2->
re + bfly[3].
im * winc2->
im;
199 ptrc3->
im = bfly[3].
im * winc2->
re - bfly[3].
re * winc2->
im;
201 winc0 += 1 * wind_step;
202 winc1 += 2 * wind_step;
203 winc2 += 3 * wind_step;
212 wind_step = wind_step << 2;
223 int wind_step = table_size / (
N);
231 float tmp_re = result[0].
re;
232 result[0].
re = tmp_re + result[0].
im;
233 result[0].
im = tmp_re - result[0].
im;
236 for (
int k = 1;
k <=
N / 2 ;
k++ ) {
239 f1k.
re = fpk.
re + fpnk.
re;
240 f1k.
im = fpk.
im - fpnk.
im;
241 f2k.
re = fpk.
re - fpnk.
re;
242 f2k.
im = fpk.
im + fpnk.
im;
244 float c = -table[
k * wind_step + 1];
245 float s = -table[
k * wind_step + 0];
247 tw.
re = c * f2k.
re - s * f2k.
im;
248 tw.
im = s * f2k.
re + c * f2k.
im;
250 result[
k].
re = 0.5 * (f1k.
re + tw.
re);
251 result[
k].
im = 0.5 * (f1k.
im + tw.
im);
252 result[
N -
k].
re = 0.5 * (f1k.
re - tw.
re);
253 result[
N -
k].
im = 0.5 * (tw.
im - f1k.
im);
265 ESP_LOGD(
TAG,
"const uint16_t bitrev4r_table_%i_%s[] = { ",
N, name_ext);
267 int log4N = log2N >> 1;
269 for (
int i = 1; i <
N - 1; i++) {
278 xx = (xx << 2) + bits2;
285 if ((items_count % 8) == 0) {
292 ESP_LOGD(
TAG,
"const uint16_t bitrev4r_table_%i_%s_size = %i;\n",
N, name_ext, items_count);
294 ESP_LOGD(
TAG,
"extern const uint16_t bitrev4r_table_%i_%s[];",
N, name_ext);
295 ESP_LOGD(
TAG,
"extern const uint16_t bitrev4r_table_%i_%s_size;\n",
N, name_ext);
bool dsp_is_power_of_two(int x)
check power of two The function check if the argument is power of 2. The implementation use ANSI C an...
int dsp_power_of_two(int x)
Power of two The function return power of 2 for values 2^N. The implementation use ANSI C and could b...
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
#define ESP_ERR_DSP_UNINITIALIZED
#define ESP_ERR_DSP_INVALID_LENGTH
#define ESP_ERR_DSP_REINITIALIZED
#define dsps_bit_rev_lookup_fc32
#define CONFIG_DSP_MAX_FFT_SIZE
#define dsps_bit_rev4r_fc32
void dsps_fft4r_rev_tables_init_fc32(void)
uint16_t * dsps_fft4r_rev_tables_fc32[]
const uint16_t dsps_fft4r_rev_tables_fc32_size[]
esp_err_t dsps_cplx2real_fc32_ansi_(float *data, int N, float *table, int table_size)
Convert FFT result to complex array for real input data.
esp_err_t dsps_fft4r_init_fc32(float *fft_table_buff, int max_fft_size)
init fft tables
uint16_t * dsps_fft4r_ram_rev_table
int dsps_fft4r_w_table_size
esp_err_t dsps_fft4r_fc32_ansi_(float *data, int length, float *table, int table_size)
complex FFT of radix 4
float * dsps_fft4r_w_table_fc32
uint8_t dsps_fft4r_mem_allocated
esp_err_t dsps_gen_bitrev4r_table(int N, int step, char *name_ext)
esp_err_t dsps_bit_rev4r_direct_fc32_ansi(float *data, int N)
uint8_t dsps_fft4r_initialized
void dsps_fft4r_deinit_fc32()
deinit fft tables
static float data[128 *2]