summaryrefslogtreecommitdiff
path: root/gr-fft/include/gnuradio/fft/fft.h
diff options
context:
space:
mode:
Diffstat (limited to 'gr-fft/include/gnuradio/fft/fft.h')
-rw-r--r--gr-fft/include/gnuradio/fft/fft.h54
1 files changed, 33 insertions, 21 deletions
diff --git a/gr-fft/include/gnuradio/fft/fft.h b/gr-fft/include/gnuradio/fft/fft.h
index d6f52d4c7d..749a5e874c 100644
--- a/gr-fft/include/gnuradio/fft/fft.h
+++ b/gr-fft/include/gnuradio/fft/fft.h
@@ -29,6 +29,7 @@
#include <gnuradio/fft/api.h>
#include <gnuradio/gr_complex.h>
+#include <volk/volk_alloc.hh>
#include <boost/thread.hpp>
namespace gr {
@@ -36,6 +37,7 @@ namespace fft {
/*! \brief Helper function for allocating complex* buffers
+ * TODO: Remove once the single user of this stops using it.
*/
FFT_API gr_complex* malloc_complex(int size);
@@ -48,6 +50,7 @@ FFT_API float* malloc_float(int size);
FFT_API double* malloc_double(int size);
/*! \brief Helper function for freeing fft buffers
+ * TODO: Remove once the single user of this stops using it.
*/
FFT_API void free(void* b);
@@ -71,14 +74,17 @@ public:
*/
class FFT_API fft_complex
{
- int d_fft_size;
+ const int d_fft_size;
int d_nthreads;
- gr_complex* d_inbuf;
- gr_complex* d_outbuf;
+ volk::vector<gr_complex> d_inbuf;
+ volk::vector<gr_complex> d_outbuf;
void* d_plan;
public:
fft_complex(int fft_size, bool forward = true, int nthreads = 1);
+ // Copy disabled due to d_plan.
+ fft_complex(const fft_complex&) = delete;
+ fft_complex& operator=(const fft_complex&) = delete;
virtual ~fft_complex();
/*
@@ -86,11 +92,11 @@ public:
* into which input and output take place. It's done this way in
* order to ensure optimal alignment for SIMD instructions.
*/
- gr_complex* get_inbuf() const { return d_inbuf; }
- gr_complex* get_outbuf() const { return d_outbuf; }
+ gr_complex* get_inbuf() { return d_inbuf.data(); }
+ gr_complex* get_outbuf() { return d_outbuf.data(); }
- int inbuf_length() const { return d_fft_size; }
- int outbuf_length() const { return d_fft_size; }
+ int inbuf_length() const { return d_inbuf.size(); }
+ int outbuf_length() const { return d_outbuf.size(); }
/*!
* Set the number of threads to use for caclulation.
@@ -115,14 +121,17 @@ public:
*/
class FFT_API fft_real_fwd
{
- int d_fft_size;
+ const int d_fft_size;
int d_nthreads;
- float* d_inbuf;
- gr_complex* d_outbuf;
+ volk::vector<float> d_inbuf;
+ volk::vector<gr_complex> d_outbuf;
void* d_plan;
public:
fft_real_fwd(int fft_size, int nthreads = 1);
+ // Copy disabled due to d_plan.
+ fft_real_fwd(const fft_real_fwd&) = delete;
+ fft_real_fwd& operator=(const fft_real_fwd&) = delete;
virtual ~fft_real_fwd();
/*
@@ -130,11 +139,11 @@ public:
* into which input and output take place. It's done this way in
* order to ensure optimal alignment for SIMD instructions.
*/
- float* get_inbuf() const { return d_inbuf; }
- gr_complex* get_outbuf() const { return d_outbuf; }
+ float* get_inbuf() { return d_inbuf.data(); }
+ gr_complex* get_outbuf() { return d_outbuf.data(); }
- int inbuf_length() const { return d_fft_size; }
- int outbuf_length() const { return d_fft_size / 2 + 1; }
+ int inbuf_length() const { return d_inbuf.size(); }
+ int outbuf_length() const { return d_outbuf.size(); }
/*!
* Set the number of threads to use for caclulation.
@@ -159,14 +168,17 @@ public:
*/
class FFT_API fft_real_rev
{
- int d_fft_size;
+ const int d_fft_size;
int d_nthreads;
- gr_complex* d_inbuf;
- float* d_outbuf;
+ volk::vector<gr_complex> d_inbuf;
+ volk::vector<float> d_outbuf;
void* d_plan;
public:
fft_real_rev(int fft_size, int nthreads = 1);
+ // Copy disabled due to d_plan.
+ fft_real_rev(const fft_real_rev&) = delete;
+ fft_real_rev& operator=(const fft_real_rev&) = delete;
virtual ~fft_real_rev();
/*
@@ -174,11 +186,11 @@ public:
* into which input and output take place. It's done this way in
* order to ensure optimal alignment for SIMD instructions.
*/
- gr_complex* get_inbuf() const { return d_inbuf; }
- float* get_outbuf() const { return d_outbuf; }
+ gr_complex* get_inbuf() { return d_inbuf.data(); }
+ float* get_outbuf() { return d_outbuf.data(); }
- int inbuf_length() const { return d_fft_size / 2 + 1; }
- int outbuf_length() const { return d_fft_size; }
+ int inbuf_length() const { return d_inbuf.size(); }
+ int outbuf_length() const { return d_outbuf.size(); }
/*!
* Set the number of threads to use for caclulation.