add FFTS to cmake and fix some codingstyle issues
This commit is contained in:
parent
34fb4e9973
commit
4dfb984431
|
@ -19,6 +19,7 @@ find_package(OpenGL REQUIRED)
|
|||
find_package(PkgConfig)
|
||||
|
||||
find_package(FFTW3F)
|
||||
find_package(FFTS)
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
@ -183,29 +184,42 @@ set(sdrbase_RESOURCES
|
|||
sdrbase/resources/res.qrc
|
||||
)
|
||||
|
||||
if(FFTW3F_FOUND)
|
||||
if(LIBFFTS_FOUND)
|
||||
set(sdrbase_SOURCES
|
||||
${sdrbase_SOURCES}
|
||||
sdrbase/dsp/fftwengine.cpp
|
||||
sdrbase/dsp/fftsengine.cpp
|
||||
)
|
||||
set(sdrbase_HEADERS
|
||||
${sdrbase_HEADERS}
|
||||
include-gpl/dsp/fftwengine.h
|
||||
include-gpl/dsp/fftsengine.h
|
||||
)
|
||||
add_definitions(-DUSE_FFTW)
|
||||
include_directories(${FFTW3F_INCLUDE_DIRS})
|
||||
else(FFTW3F_FOUND)
|
||||
set(sdrbase_SOURCES
|
||||
${sdrbase_SOURCES}
|
||||
sdrbase/dsp/kissengine.cpp
|
||||
include/dsp/kissfft.h
|
||||
)
|
||||
set(sdrbase_HEADERS
|
||||
${sdrbase_HEADERS}
|
||||
include-gpl/dsp/kissengine.h
|
||||
)
|
||||
add_definitions(-DUSE_KISSFFT)
|
||||
endif(FFTW3F_FOUND)
|
||||
add_definitions(-DUSE_FFTS)
|
||||
include_directories(${LIBFFTS_INCLUDE_DIR})
|
||||
else(LIBFFTS_FOUND)
|
||||
if(FFTW3F_FOUND)
|
||||
set(sdrbase_SOURCES
|
||||
${sdrbase_SOURCES}
|
||||
sdrbase/dsp/fftwengine.cpp
|
||||
)
|
||||
set(sdrbase_HEADERS
|
||||
${sdrbase_HEADERS}
|
||||
include-gpl/dsp/fftwengine.h
|
||||
)
|
||||
add_definitions(-DUSE_FFTW)
|
||||
include_directories(${FFTW3F_INCLUDE_DIRS})
|
||||
else(FFTW3F_FOUND)
|
||||
set(sdrbase_SOURCES
|
||||
${sdrbase_SOURCES}
|
||||
sdrbase/dsp/kissengine.cpp
|
||||
include/dsp/kissfft.h
|
||||
)
|
||||
set(sdrbase_HEADERS
|
||||
${sdrbase_HEADERS}
|
||||
include-gpl/dsp/kissengine.h
|
||||
)
|
||||
add_definitions(-DUSE_KISSFFT)
|
||||
endif(FFTW3F_FOUND)
|
||||
endif(LIBFFTS_FOUND)
|
||||
|
||||
#include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
|
@ -231,9 +245,13 @@ target_link_libraries(sdrbase
|
|||
${LIBUSB_LIBRARIES}
|
||||
)
|
||||
|
||||
if(FFTW3F_FOUND)
|
||||
target_link_libraries(sdrbase ${FFTW3F_LIBRARIES})
|
||||
endif(FFTW3F_FOUND)
|
||||
if(LIBFFTS_FOUND)
|
||||
target_link_libraries(sdrbase ${LIBFFTS_LIBRARIES})
|
||||
else(LIBFFTS_FOUND)
|
||||
if(FFTW3F_FOUND)
|
||||
target_link_libraries(sdrbase ${FFTW3F_LIBRARIES})
|
||||
endif(FFTW3F_FOUND)
|
||||
endif(LIBFFTS_FOUND)
|
||||
|
||||
set_target_properties(sdrbase PROPERTIES DEFINE_SYMBOL "sdrangelove_EXPORTS")
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
if(NOT LIBFFTS_FOUND)
|
||||
pkg_check_modules (LIBFFTS_PKG ffts)
|
||||
|
||||
find_path(LIBFFTS_INCLUDE_DIR NAMES ffts.h
|
||||
PATHS
|
||||
${LIBFFTS_PKG_INCLUDE_DIRS}
|
||||
/usr/include/ffts
|
||||
/usr/local/include/ffts
|
||||
)
|
||||
find_library(LIBFFTS_LIBRARIES NAMES ffts
|
||||
PATHS
|
||||
${LIBFFTS_PKG_LIBRARY_DIRS}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
)
|
||||
|
||||
if(LIBFFTS_INCLUDE_DIR AND LIBFFTS_LIBRARIES)
|
||||
set(LIBFFTS_FOUND TRUE CACHE INTERNAL "libffts found")
|
||||
message(STATUS "Found libffts: ${LIBFFTS_INCLUDE_DIR}, ${LIBFFTS_LIBRARIES}")
|
||||
else(LIBFFTS_INCLUDE_DIR AND LIBFFTS_LIBRARIES)
|
||||
set(LIBFFTS_FOUND FALSE CACHE INTERNAL "libffts found")
|
||||
message(STATUS "libffts not found.")
|
||||
endif(LIBFFTS_INCLUDE_DIR AND LIBFFTS_LIBRARIES)
|
||||
|
||||
mark_as_advanced(LIBFFTS_INCLUDE_DIR LIBFFTS_LIBRARIES)
|
||||
|
||||
endif(NOT LIBFFTS_FOUND)
|
|
@ -1,15 +1,13 @@
|
|||
#ifndef INCLUDE_FFTSEngine_H
|
||||
#define INCLUDE_FFTSEngine_H
|
||||
#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();
|
||||
FFTSEngine();
|
||||
~FFTSEngine();
|
||||
|
||||
void configure(int n, bool inverse);
|
||||
void transform();
|
||||
|
@ -18,12 +16,12 @@ public:
|
|||
Complex* out();
|
||||
|
||||
protected:
|
||||
void allocate(int n);
|
||||
ffts_plan_t* m_currentplan;
|
||||
void *imem;
|
||||
void *iptr;
|
||||
void *omem;
|
||||
void *optr;
|
||||
void allocate(int n);
|
||||
ffts_plan_t* m_currentplan;
|
||||
void* m_imem;
|
||||
void* m_iptr;
|
||||
void* m_omem;
|
||||
void* m_optr;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FFTSEngine_H
|
||||
#endif // INCLUDE_FFTSENGINE_H
|
||||
|
|
|
@ -2,45 +2,43 @@
|
|||
#include "dsp/fftsengine.h"
|
||||
|
||||
FFTSEngine::FFTSEngine() :
|
||||
m_currentplan(ffts_init_1d(1024, 1))
|
||||
m_currentplan(ffts_init_1d(1024, -1))
|
||||
{
|
||||
allocate(4096);
|
||||
allocate(8192);
|
||||
}
|
||||
|
||||
FFTSEngine::~FFTSEngine()
|
||||
{
|
||||
ffts_free(m_currentplan);
|
||||
free(imem);
|
||||
free(omem);
|
||||
ffts_free(m_currentplan);
|
||||
free(m_imem);
|
||||
free(m_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));
|
||||
m_imem = malloc(n * sizeof(Real) * 2 + 15);
|
||||
m_iptr = (void*)(((unsigned long)m_imem + 15) & (unsigned long)(~0x0f));
|
||||
m_omem = malloc(n * sizeof(Real) * 2 + 15);
|
||||
m_optr = (void*)(((unsigned long)m_omem + 15) & (unsigned long)(~0x0f));
|
||||
}
|
||||
|
||||
void FFTSEngine::configure(int n, bool inverse)
|
||||
{
|
||||
ffts_free(m_currentplan);
|
||||
m_currentplan = ffts_init_1d(n, 1);
|
||||
ffts_free(m_currentplan);
|
||||
m_currentplan = ffts_init_1d(n, inverse ? 1 : -1);
|
||||
}
|
||||
|
||||
void FFTSEngine::transform()
|
||||
{
|
||||
ffts_execute(m_currentplan, iptr, optr);
|
||||
ffts_execute(m_currentplan, m_iptr, m_optr);
|
||||
}
|
||||
|
||||
|
||||
Complex* FFTSEngine::in()
|
||||
{
|
||||
return reinterpret_cast<Complex*>(iptr);
|
||||
return reinterpret_cast<Complex*>(m_iptr);
|
||||
}
|
||||
|
||||
Complex* FFTSEngine::out()
|
||||
{
|
||||
return reinterpret_cast<Complex*>(optr);
|
||||
return reinterpret_cast<Complex*>(m_optr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue