3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <gcell/gc_declare_proc.h>
23 #include <gcell/spu/libfft.h>
27 * v is really vector complex<float>
30 conjugate_vector(vector float *v, int nelements)
32 vector float k = {1, -1, 1, -1};
34 for (i = 0; i < nelements; i++)
39 gcs_fwd_fft_1d_r2(const gc_job_direct_args_t *input,
40 gc_job_direct_args_t *output __attribute__((unused)),
41 const gc_job_ea_args_t *eaa)
43 vector float *out = (vector float *) eaa->arg[0].ls_addr; // complex
44 vector float *in = (vector float *) eaa->arg[1].ls_addr; // complex
45 vector float *twiddle = (vector float *) eaa->arg[2].ls_addr; // complex
46 vector float *window = (vector float *) eaa->arg[3].ls_addr; // float
48 int log2_fft_length = input->arg[0].u32;
49 int shift = input->arg[1].u32; // non-zero if we should apply fftshift
51 if (eaa->arg[3].get_size){ // apply window
52 // FIXME pointwise multiply in *= window
56 fft_1d_r2(out, in, twiddle, log2_fft_length);
59 // FIXME apply "fftshift" to output data in-place
64 GC_DECLARE_PROC(gcs_fwd_fft_1d_r2, "fwd_fft_1d_r2");
67 gcs_inv_fft_1d_r2(const gc_job_direct_args_t *input,
68 gc_job_direct_args_t *output __attribute__((unused)),
69 const gc_job_ea_args_t *eaa)
71 vector float *out = (vector float *) eaa->arg[0].ls_addr; // complex
72 vector float *in = (vector float *) eaa->arg[1].ls_addr; // complex
73 vector float *twiddle = (vector float *) eaa->arg[2].ls_addr; // complex
74 vector float *window = (vector float *) eaa->arg[3].ls_addr; // float
76 int log2_fft_length = input->arg[0].u32;
77 int shift = input->arg[1].u32; // non-zero if we should apply fftshift
79 if (eaa->arg[3].get_size){ // apply window
80 // FIXME pointwise multiply in *= window
85 // FIXME apply "fftshift" to input data in-place
89 conjugate_vector(in, 1 << (log2_fft_length - 1));
90 fft_1d_r2(out, in, twiddle, log2_fft_length);
91 conjugate_vector(out, 1 << (log2_fft_length - 1));
94 GC_DECLARE_PROC(gcs_inv_fft_1d_r2, "inv_fft_1d_r2");