diff --git a/CMakeLists.txt b/CMakeLists.txt index b153e0148..27421bd1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(V4L-MSI "Use Linux Kernel MSI2500 Source." OFF) option(BUILD_TYPE "Build type (RELEASE, RELEASEWITHDBGINFO, DEBUG" RELEASE) option(DEBUG_OUTPUT "Print debug messages" OFF) option(HOST_RPI "Compiling on RPi" OFF) +option(SAMPLE_24BIT "Internal 24 bit DSP" OFF) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) @@ -186,6 +187,9 @@ elseif (${ARCHITECTURE} MATCHES "aarch64") endif() # Compiler flags. +if (SAMPLE_24BIT) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSAMPLE_24BIT") +endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}") ############################################################################## diff --git a/sdrbase/dsp/decimators.h b/sdrbase/dsp/decimators.h index c8bbd27af..e625141af 100644 --- a/sdrbase/dsp/decimators.h +++ b/sdrbase/dsp/decimators.h @@ -18,11 +18,15 @@ #define INCLUDE_GPL_DSP_DECIMATORS_H_ #include "dsp/dsptypes.h" +#ifdef SAMPLE_24BIT +#include "dsp/inthalfbandfilterdb.h" +#else #ifdef USE_SSE4_1 #include "dsp/inthalfbandfiltereo1.h" #else #include "dsp/inthalfbandfilterdb.h" #endif +#endif #define DECIMATORS_HB_FILTER_ORDER 64 @@ -44,6 +48,42 @@ struct decimation_shifts static const uint post64 = 0; }; +template<> +struct decimation_shifts<16, 24> +{ + static const uint pre1 = 0; + static const uint pre2 = 0; + static const uint post2 = 9; + static const uint pre4 = 0; + static const uint post4 = 10; + static const uint pre8 = 0; + static const uint post8 = 11; + static const uint pre16 = 0; + static const uint post16 = 12; + static const uint pre32 = 0; + static const uint post32 = 13; + static const uint pre64 = 0; + static const uint post64 = 14; +}; + +template<> +struct decimation_shifts<24, 24> +{ + static const uint pre1 = 0; + static const uint pre2 = 0; + static const uint post2 = 1; + static const uint pre4 = 0; + static const uint post4 = 2; + static const uint pre8 = 0; + static const uint post8 = 3; + static const uint pre16 = 0; + static const uint post16 = 4; + static const uint pre32 = 0; + static const uint post32 = 5; + static const uint pre64 = 0; + static const uint post64 = 6; +}; + template<> struct decimation_shifts<16, 16> { @@ -62,6 +102,24 @@ struct decimation_shifts<16, 16> static const uint post64 = 6; }; +template<> +struct decimation_shifts<24, 16> +{ + static const uint pre1 = 8; + static const uint pre2 = 7; + static const uint post2 = 0; + static const uint pre4 = 6; + static const uint post4 = 0; + static const uint pre8 = 5; + static const uint post8 = 0; + static const uint pre16 = 4; + static const uint post16 = 0; + static const uint pre32 = 3; + static const uint post32 = 0; + static const uint pre64 = 2; + static const uint post64 = 0; +}; + template<> struct decimation_shifts<16, 12> { @@ -80,6 +138,24 @@ struct decimation_shifts<16, 12> static const uint post64 = 2; }; +template<> +struct decimation_shifts<24, 12> +{ + static const uint pre1 = 12; + static const uint pre2 = 11; + static const uint post2 = 0; + static const uint pre4 = 10; + static const uint post4 = 0; + static const uint pre8 = 9; + static const uint post8 = 0; + static const uint pre16 = 8; + static const uint post16 = 0; + static const uint pre32 = 7; + static const uint post32 = 0; + static const uint pre64 = 6; + static const uint post64 = 0; +}; + template<> struct decimation_shifts<16, 8> { @@ -98,6 +174,24 @@ struct decimation_shifts<16, 8> static const uint post64 = 0; }; +template<> +struct decimation_shifts<24, 8> +{ + static const uint pre1 = 16; + static const uint pre2 = 15; + static const uint post2 = 0; + static const uint pre4 = 14; + static const uint post4 = 0; + static const uint pre8 = 13; + static const uint post8 = 0; + static const uint pre16 = 12; + static const uint post16 = 0; + static const uint pre32 = 11; + static const uint post32 = 0; + static const uint pre64 = 10; + static const uint post64 = 0; +}; + template class Decimators { @@ -146,6 +240,14 @@ public: void decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len); private: +#ifdef SAMPLE_24BIT + IntHalfbandFilterDB m_decimator2; // 1st stages + IntHalfbandFilterDB m_decimator4; // 2nd stages + IntHalfbandFilterDB m_decimator8; // 3rd stages + IntHalfbandFilterDB m_decimator16; // 4th stages + IntHalfbandFilterDB m_decimator32; // 5th stages + IntHalfbandFilterDB m_decimator64; // 6th stages +#else #ifdef USE_SSE4_1 IntHalfbandFilterEO1 m_decimator2; // 1st stages IntHalfbandFilterEO1 m_decimator4; // 2nd stages @@ -161,6 +263,7 @@ private: IntHalfbandFilterDB m_decimator32; // 5th stages IntHalfbandFilterDB m_decimator64; // 6th stages #endif +#endif }; template diff --git a/sdrbase/dsp/decimatorsu.h b/sdrbase/dsp/decimatorsu.h index 2e0b04aaf..fe2e0aa55 100644 --- a/sdrbase/dsp/decimatorsu.h +++ b/sdrbase/dsp/decimatorsu.h @@ -24,11 +24,15 @@ #define INCLUDE_GPL_DSP_DECIMATORSU_H_ #include "dsp/dsptypes.h" +#ifdef SAMPLE_24BIT +#include "dsp/inthalfbandfilterdb.h" +#else #ifdef USE_SSE4_1 #include "dsp/inthalfbandfiltereo1.h" #else #include "dsp/inthalfbandfilterdb.h" #endif +#endif #define DECIMATORS_HB_FILTER_ORDER 64 @@ -50,6 +54,24 @@ struct decimation_shifts static const uint post64 = 0; }; +template<> +struct decimation_shifts<24, 24> +{ + static const uint pre1 = 0; + static const uint pre2 = 0; + static const uint post2 = 1; + static const uint pre4 = 0; + static const uint post4 = 2; + static const uint pre8 = 0; + static const uint post8 = 3; + static const uint pre16 = 0; + static const uint post16 = 4; + static const uint pre32 = 0; + static const uint post32 = 5; + static const uint pre64 = 0; + static const uint post64 = 6; +}; + template<> struct decimation_shifts<16, 16> { @@ -68,6 +90,24 @@ struct decimation_shifts<16, 16> static const uint post64 = 6; }; +template<> +struct decimation_shifts<24, 16> +{ + static const uint pre1 = 8; + static const uint pre2 = 7; + static const uint post2 = 0; + static const uint pre4 = 6; + static const uint post4 = 0; + static const uint pre8 = 5; + static const uint post8 = 0; + static const uint pre16 = 4; + static const uint post16 = 0; + static const uint pre32 = 3; + static const uint post32 = 0; + static const uint pre64 = 2; + static const uint post64 = 0; +}; + template<> struct decimation_shifts<16, 12> { @@ -86,6 +126,24 @@ struct decimation_shifts<16, 12> static const uint post64 = 2; }; +template<> +struct decimation_shifts<24, 12> +{ + static const uint pre1 = 12; + static const uint pre2 = 11; + static const uint post2 = 0; + static const uint pre4 = 10; + static const uint post4 = 0; + static const uint pre8 = 9; + static const uint post8 = 0; + static const uint pre16 = 8; + static const uint post16 = 0; + static const uint pre32 = 7; + static const uint post32 = 0; + static const uint pre64 = 6; + static const uint post64 = 0; +}; + template<> struct decimation_shifts<16, 8> { @@ -104,6 +162,24 @@ struct decimation_shifts<16, 8> static const uint post64 = 0; }; +template<> +struct decimation_shifts<24, 8> +{ + static const uint pre1 = 16; + static const uint pre2 = 15; + static const uint post2 = 0; + static const uint pre4 = 14; + static const uint post4 = 0; + static const uint pre8 = 13; + static const uint post8 = 0; + static const uint pre16 = 12; + static const uint post16 = 0; + static const uint pre32 = 11; + static const uint post32 = 0; + static const uint pre64 = 10; + static const uint post64 = 0; +}; + template class DecimatorsU { @@ -130,6 +206,14 @@ public: void decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len); private: +#ifdef SAMPLE_24BIT + IntHalfbandFilterDB m_decimator2; // 1st stages + IntHalfbandFilterDB m_decimator4; // 2nd stages + IntHalfbandFilterDB m_decimator8; // 3rd stages + IntHalfbandFilterDB m_decimator16; // 4th stages + IntHalfbandFilterDB m_decimator32; // 5th stages + IntHalfbandFilterDB m_decimator64; // 6th stages +#else #ifdef USE_SSE4_1 IntHalfbandFilterEO1 m_decimator2; // 1st stages IntHalfbandFilterEO1 m_decimator4; // 2nd stages @@ -145,6 +229,7 @@ private: IntHalfbandFilterDB m_decimator32; // 5th stages IntHalfbandFilterDB m_decimator64; // 6th stages #endif +#endif }; template diff --git a/sdrbase/dsp/downchannelizer.cpp b/sdrbase/dsp/downchannelizer.cpp index e39b523b8..59d27e41f 100644 --- a/sdrbase/dsp/downchannelizer.cpp +++ b/sdrbase/dsp/downchannelizer.cpp @@ -192,6 +192,28 @@ void DownChannelizer::applyConfiguration() } } +#ifdef SAMPLE_24BIT +DownChannelizer::FilterStage::FilterStage(Mode mode) : + m_filter(new IntHalfbandFilterDB), + m_workFunction(0), + m_mode(mode), + m_sse(false) +{ + switch(mode) { + case ModeCenter: + m_workFunction = &IntHalfbandFilterDB::workDecimateCenter; + break; + + case ModeLowerHalf: + m_workFunction = &IntHalfbandFilterDB::workDecimateLowerHalf; + break; + + case ModeUpperHalf: + m_workFunction = &IntHalfbandFilterDB::workDecimateUpperHalf; + break; + } +} +#else #ifdef USE_SSE4_1 DownChannelizer::FilterStage::FilterStage(Mode mode) : m_filter(new IntHalfbandFilterEO1), @@ -235,7 +257,7 @@ DownChannelizer::FilterStage::FilterStage(Mode mode) : } } #endif - +#endif DownChannelizer::FilterStage::~FilterStage() { delete m_filter; diff --git a/sdrbase/dsp/downchannelizer.h b/sdrbase/dsp/downchannelizer.h index d77c4a402..c770f2948 100644 --- a/sdrbase/dsp/downchannelizer.h +++ b/sdrbase/dsp/downchannelizer.h @@ -23,11 +23,15 @@ #include #include "util/export.h" #include "util/message.h" +#ifdef SAMPLE_24BIT +#include "dsp/inthalfbandfilterdb.h" +#else #ifdef USE_SSE4_1 #include "dsp/inthalfbandfiltereo1.h" #else #include "dsp/inthalfbandfilterdb.h" #endif +#endif #define DOWNCHANNELIZER_HB_FILTER_ORDER 48 @@ -78,12 +82,17 @@ protected: ModeUpperHalf }; +#ifdef SAMPLE_24BIT + typedef bool (IntHalfbandFilterDB::*WorkFunction)(Sample* s); + IntHalfbandFilterDB* m_filter; +#else #ifdef USE_SSE4_1 typedef bool (IntHalfbandFilterEO1::*WorkFunction)(Sample* s); IntHalfbandFilterEO1* m_filter; #else typedef bool (IntHalfbandFilterDB::*WorkFunction)(Sample* s); IntHalfbandFilterDB* m_filter; +#endif #endif WorkFunction m_workFunction; Mode m_mode; diff --git a/sdrbase/dsp/interpolators.h b/sdrbase/dsp/interpolators.h index d64619f40..f565e26a2 100644 --- a/sdrbase/dsp/interpolators.h +++ b/sdrbase/dsp/interpolators.h @@ -18,11 +18,15 @@ #define INCLUDE_GPL_DSP_INTERPOLATORS_H_ #include "dsp/dsptypes.h" +#ifdef SAMPLE_24BIT +#include "dsp/inthalfbandfilterdb.h" +#else #ifdef USE_SSE4_1 #include "dsp/inthalfbandfiltereo1.h" #else #include "dsp/inthalfbandfilterdb.h" #endif +#endif #define INTERPOLATORS_HB_FILTER_ORDER_FIRST 64 #define INTERPOLATORS_HB_FILTER_ORDER_SECOND 32 @@ -114,6 +118,14 @@ public: void interpolate64_cen(SampleVector::iterator* it, T* buf, qint32 len); private: +#ifdef SAMPLE_24BIT + IntHalfbandFilterDB m_interpolator2; // 1st stages + IntHalfbandFilterDB m_interpolator4; // 2nd stages + IntHalfbandFilterDB m_interpolator8; // 3rd stages + IntHalfbandFilterDB m_interpolator16; // 4th stages + IntHalfbandFilterDB m_interpolator32; // 5th stages + IntHalfbandFilterDB m_interpolator64; // 6th stages +#else #ifdef USE_SSE4_1 IntHalfbandFilterEO1 m_interpolator2; // 1st stages IntHalfbandFilterEO1 m_interpolator4; // 2nd stages @@ -129,6 +141,7 @@ private: IntHalfbandFilterDB m_interpolator32; // 5th stages IntHalfbandFilterDB m_interpolator64; // 6th stages #endif +#endif }; template diff --git a/sdrbase/dsp/upchannelizer.cpp b/sdrbase/dsp/upchannelizer.cpp index a59db9ad2..6ae1f045c 100644 --- a/sdrbase/dsp/upchannelizer.cpp +++ b/sdrbase/dsp/upchannelizer.cpp @@ -207,6 +207,26 @@ void UpChannelizer::applyConfiguration() } } +#ifdef SAMPLE_24BIT +UpChannelizer::FilterStage::FilterStage(Mode mode) : + m_filter(new IntHalfbandFilterDB), + m_workFunction(0) +{ + switch(mode) { + case ModeCenter: + m_workFunction = &IntHalfbandFilterDB::workInterpolateCenter; + break; + + case ModeLowerHalf: + m_workFunction = &IntHalfbandFilterDB::workInterpolateLowerHalf; + break; + + case ModeUpperHalf: + m_workFunction = &IntHalfbandFilterDB::workInterpolateUpperHalf; + break; + } +} +#else #ifdef USE_SSE4_1 UpChannelizer::FilterStage::FilterStage(Mode mode) : m_filter(new IntHalfbandFilterEO1), @@ -246,6 +266,7 @@ UpChannelizer::FilterStage::FilterStage(Mode mode) : } } #endif +#endif UpChannelizer::FilterStage::~FilterStage() { diff --git a/sdrbase/dsp/upchannelizer.h b/sdrbase/dsp/upchannelizer.h index 3b15f7a96..fbc0b63da 100644 --- a/sdrbase/dsp/upchannelizer.h +++ b/sdrbase/dsp/upchannelizer.h @@ -23,11 +23,15 @@ #include #include "util/export.h" #include "util/message.h" +#ifdef SAMPLE_24BIT +#include "dsp/inthalfbandfilterdb.h" +#else #ifdef USE_SSE4_1 #include "dsp/inthalfbandfiltereo1.h" #else #include "dsp/inthalfbandfilterdb.h" #endif +#endif #define UPCHANNELIZER_HB_FILTER_ORDER 96 @@ -83,12 +87,17 @@ protected: ModeUpperHalf }; +#ifdef SAMPLE_24BIT + typedef bool (IntHalfbandFilterDB::*WorkFunction)(Sample* sIn, Sample *sOut); + IntHalfbandFilterDB* m_filter; +#else #ifdef USE_SSE4_1 typedef bool (IntHalfbandFilterEO1::*WorkFunction)(Sample* sIn, Sample *sOut); IntHalfbandFilterEO1* m_filter; #else typedef bool (IntHalfbandFilterDB::*WorkFunction)(Sample* sIn, Sample *sOut); IntHalfbandFilterDB* m_filter; +#endif #endif WorkFunction m_workFunction;