diff options
-rw-r--r-- | include-gpl/dsp/fftsengine.h | 29 | ||||
-rw-r--r-- | sdrbase/dsp/fftengine.cpp | 8 | ||||
-rw-r--r-- | sdrbase/dsp/fftsengine.cpp | 46 |
3 files changed, 82 insertions, 1 deletions
diff --git a/include-gpl/dsp/fftsengine.h b/include-gpl/dsp/fftsengine.h new file mode 100644 index 0000000..50dd8e6 --- /dev/null +++ b/include-gpl/dsp/fftsengine.h @@ -0,0 +1,29 @@ +#ifndef INCLUDE_FFTSEngine_H +#define INCLUDE_FFTSEngine_H + +#include <QMutex> +#include <ffts/ffts.h> +#include <list> +#include "dsp/fftengine.h" + +class FFTSEngine : public FFTEngine { +public: + FFTSEngine(); + ~FFTSEngine(); + + void configure(int n, bool inverse); + void transform(); + + Complex* in(); + Complex* out(); + +protected: + void allocate(int n); + ffts_plan_t* m_currentplan; + void *imem; + void *iptr; + void *omem; + void *optr; +}; + +#endif // INCLUDE_FFTSEngine_H diff --git a/sdrbase/dsp/fftengine.cpp b/sdrbase/dsp/fftengine.cpp index fe431b1..bc93380 100644 --- a/sdrbase/dsp/fftengine.cpp +++ b/sdrbase/dsp/fftengine.cpp @@ -5,6 +5,9 @@ #ifdef USE_FFTW #include "dsp/fftwengine.h" #endif // USE_FFTW +#ifdef USE_FFTS +#include "dsp/fftsengine.h" +#endif // USE_FFTS FFTEngine::~FFTEngine() { @@ -20,7 +23,10 @@ FFTEngine* FFTEngine::create() qDebug("FFT: using KissFFT engine"); return new KissEngine; #endif // USE_KISSFFT - +#ifdef USE_FFTS + qDebug("FFT: using FFTS engine"); + return new FFTSEngine; +#endif // USE_FFTS qCritical("FFT: no engine built"); return NULL; } diff --git a/sdrbase/dsp/fftsengine.cpp b/sdrbase/dsp/fftsengine.cpp new file mode 100644 index 0000000..e719065 --- /dev/null +++ b/sdrbase/dsp/fftsengine.cpp @@ -0,0 +1,46 @@ +#include <QTime> +#include "dsp/fftsengine.h" + +FFTSEngine::FFTSEngine() : + m_currentplan(ffts_init_1d(1024, 1)) +{ + allocate(4096); +} + +FFTSEngine::~FFTSEngine() +{ + ffts_free(m_currentplan); + free(imem); + free(omem); +} + +void FFTSEngine::allocate(int n) +{ + imem = malloc(n*4*2+15); + iptr = (void*)(((unsigned long)imem+15) & (unsigned long)(~ 0x0F)); + omem = malloc(n*4*2+15); + optr = (void*)(((unsigned long)omem+15) & (unsigned long)(~ 0x0F)); +} + +void FFTSEngine::configure(int n, bool inverse) +{ + ffts_free(m_currentplan); + m_currentplan = ffts_init_1d(n, 1); +} + +void FFTSEngine::transform() +{ + ffts_execute(m_currentplan, iptr, optr); +} + + +Complex* FFTSEngine::in() +{ + return reinterpret_cast<Complex*>(iptr); +} + +Complex* FFTSEngine::out() +{ + return reinterpret_cast<Complex*>(optr); +} + |