From 732561152b58aac21d49384ced7d2963e6dab989 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 22 Jan 2018 02:49:06 +0100 Subject: [PATCH] 24 bit DSP fix --- CMakeLists.txt | 2 +- plugins/samplesource/airspy/airspythread.h | 6 +- .../samplesource/airspyhf/airspyhfthread.h | 6 +- .../bladerfinput/bladerfinputthread.h | 6 +- .../hackrfinput/hackrfinputthread.h | 6 +- .../limesdrinput/limesdrinputthread.h | 6 +- .../plutosdrinput/plutosdrinputthread.h | 6 +- plugins/samplesource/rtlsdr/rtlsdrthread.h | 6 +- plugins/samplesource/sdrplay/sdrplaythread.h | 6 +- .../testsource/testsourcethread.h | 12 +- sdrbase/dsp/decimators.h | 457 +++++------------- sdrbase/dsp/decimatorsu.h | 116 ++--- sdrbase/dsp/downchannelizer.cpp | 2 +- sdrbase/dsp/downchannelizer.h | 4 +- sdrbase/dsp/dsptypes.h | 2 +- sdrbase/dsp/interpolators.h | 4 +- sdrbase/dsp/inthalfbandfilter.h | 64 +-- sdrbase/dsp/inthalfbandfilterdb.h | 160 +++--- sdrbase/dsp/upchannelizer.cpp | 2 +- sdrbase/dsp/upchannelizer.h | 4 +- 20 files changed, 362 insertions(+), 515 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27421bd1f..2e5b2f1b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,7 +188,7 @@ endif() # Compiler flags. if (SAMPLE_24BIT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSAMPLE_24BIT") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSDR_SAMPLE_24BIT") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}") diff --git a/plugins/samplesource/airspy/airspythread.h b/plugins/samplesource/airspy/airspythread.h index 52fa601e3..a5d62feda 100644 --- a/plugins/samplesource/airspy/airspythread.h +++ b/plugins/samplesource/airspy/airspythread.h @@ -55,7 +55,11 @@ private: int m_fcPos; static AirspyThread *m_this; - Decimators m_decimators; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators; +#else + Decimators m_decimators; +#endif void run(); void callback(const qint16* buf, qint32 len); diff --git a/plugins/samplesource/airspyhf/airspyhfthread.h b/plugins/samplesource/airspyhf/airspyhfthread.h index 0056f5f87..9f22cb6f0 100644 --- a/plugins/samplesource/airspyhf/airspyhfthread.h +++ b/plugins/samplesource/airspyhf/airspyhfthread.h @@ -53,7 +53,11 @@ private: unsigned int m_log2Decim; static AirspyHFThread *m_this; - Decimators m_decimators; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators; +#else + Decimators m_decimators; +#endif void run(); void callback(const qint16* buf, qint32 len); diff --git a/plugins/samplesource/bladerfinput/bladerfinputthread.h b/plugins/samplesource/bladerfinput/bladerfinputthread.h index 4cebd38b9..60e21a2d7 100644 --- a/plugins/samplesource/bladerfinput/bladerfinputthread.h +++ b/plugins/samplesource/bladerfinput/bladerfinputthread.h @@ -51,7 +51,11 @@ private: unsigned int m_log2Decim; int m_fcPos; - Decimators m_decimators; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators; +#else + Decimators m_decimators; +#endif void run(); void callback(const qint16* buf, qint32 len); diff --git a/plugins/samplesource/hackrfinput/hackrfinputthread.h b/plugins/samplesource/hackrfinput/hackrfinputthread.h index 5ef0fb32a..0f07c77df 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputthread.h +++ b/plugins/samplesource/hackrfinput/hackrfinputthread.h @@ -54,7 +54,11 @@ private: unsigned int m_log2Decim; int m_fcPos; - Decimators m_decimators; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators; +#else + Decimators m_decimators; +#endif void run(); void callback(const qint8* buf, qint32 len); diff --git a/plugins/samplesource/limesdrinput/limesdrinputthread.h b/plugins/samplesource/limesdrinput/limesdrinputthread.h index dd5fb3772..d83919c11 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputthread.h +++ b/plugins/samplesource/limesdrinput/limesdrinputthread.h @@ -55,7 +55,11 @@ private: unsigned int m_log2Decim; // soft decimation - Decimators m_decimators; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators; +#else + Decimators m_decimators; +#endif void run(); void callback(const qint16* buf, qint32 len); diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputthread.h b/plugins/samplesource/plutosdrinput/plutosdrinputthread.h index f6373deb2..2e1e94fbe 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputthread.h +++ b/plugins/samplesource/plutosdrinput/plutosdrinputthread.h @@ -59,7 +59,11 @@ private: int m_fcPos; float m_phasor; - Decimators m_decimators; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators; +#else + Decimators m_decimators; +#endif void run(); void convert(const qint16* buf, qint32 len); diff --git a/plugins/samplesource/rtlsdr/rtlsdrthread.h b/plugins/samplesource/rtlsdr/rtlsdrthread.h index 5c4d7ed9f..a3ef61c02 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrthread.h +++ b/plugins/samplesource/rtlsdr/rtlsdrthread.h @@ -52,7 +52,11 @@ private: unsigned int m_log2Decim; int m_fcPos; - DecimatorsU m_decimators; +#ifdef SDR_SAMPLE_24BIT + DecimatorsU m_decimators; +#else + DecimatorsU m_decimators; +#endif void run(); void callback(const quint8* buf, qint32 len); diff --git a/plugins/samplesource/sdrplay/sdrplaythread.h b/plugins/samplesource/sdrplay/sdrplaythread.h index 2882f4a44..d11a11145 100644 --- a/plugins/samplesource/sdrplay/sdrplaythread.h +++ b/plugins/samplesource/sdrplay/sdrplaythread.h @@ -52,7 +52,11 @@ private: unsigned int m_log2Decim; int m_fcPos; - Decimators m_decimators; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators; +#else + Decimators m_decimators; +#endif void run(); void callback(const qint16* buf, qint32 len); diff --git a/plugins/samplesource/testsource/testsourcethread.h b/plugins/samplesource/testsource/testsourcethread.h index d7f237cb6..b1759c90e 100644 --- a/plugins/samplesource/testsource/testsourcethread.h +++ b/plugins/samplesource/testsource/testsourcethread.h @@ -85,9 +85,15 @@ private: bool m_throttleToggle; QMutex m_mutex; - Decimators m_decimators_8; - Decimators m_decimators_12; - Decimators m_decimators_16; +#ifdef SDR_SAMPLE_24BIT + Decimators m_decimators_8; + Decimators m_decimators_12; + Decimators m_decimators_16; +#else + Decimators m_decimators_8; + Decimators m_decimators_12; + Decimators m_decimators_16; +#endif void run(); void callback(const qint16* buf, qint32 len); diff --git a/sdrbase/dsp/decimators.h b/sdrbase/dsp/decimators.h index e625141af..589d08b82 100644 --- a/sdrbase/dsp/decimators.h +++ b/sdrbase/dsp/decimators.h @@ -18,7 +18,7 @@ #define INCLUDE_GPL_DSP_DECIMATORS_H_ #include "dsp/dsptypes.h" -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT #include "dsp/inthalfbandfilterdb.h" #else #ifdef USE_SSE4_1 @@ -192,7 +192,7 @@ struct decimation_shifts<24, 8> static const uint post64 = 0; }; -template +template class Decimators { public: @@ -240,7 +240,7 @@ public: void decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len); private: -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT IntHalfbandFilterDB m_decimator2; // 1st stages IntHalfbandFilterDB m_decimator4; // 2nd stages IntHalfbandFilterDB m_decimator8; // 3rd stages @@ -266,8 +266,8 @@ private: #endif }; -template -void Decimators::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) { qint32 xreal, yimag; @@ -281,8 +281,8 @@ void Decimators::decimate1(SampleVector::iterator* it, co } } -template -void Decimators::decimate1(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate1(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { qint32 xreal, yimag; @@ -296,10 +296,10 @@ void Decimators::decimate1(SampleVector::iterator* it, co } } -template -void Decimators::decimate2_u(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_u(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -317,10 +317,10 @@ void Decimators::decimate2_u(SampleVector::iterator* it, } } -template -void Decimators::decimate2_u(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate2_u(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 3; pos += 4) { @@ -340,10 +340,10 @@ void Decimators::decimate2_u(SampleVector::iterator* it, } } -template -void Decimators::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -361,10 +361,10 @@ void Decimators::decimate2_inf(SampleVector::iterator* it } } -template -void Decimators::decimate2_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate2_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 3; pos += 4) { @@ -384,10 +384,10 @@ void Decimators::decimate2_inf(SampleVector::iterator* it } } -template -void Decimators::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -405,10 +405,10 @@ void Decimators::decimate2_sup(SampleVector::iterator* it } } -template -void Decimators::decimate2_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate2_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 3; pos += 4) { @@ -428,10 +428,10 @@ void Decimators::decimate2_sup(SampleVector::iterator* it } } -template -void Decimators::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -445,10 +445,10 @@ void Decimators::decimate4_inf(SampleVector::iterator* it } } -template -void Decimators::decimate4_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate4_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 3; pos += 4) { @@ -462,8 +462,8 @@ void Decimators::decimate4_inf(SampleVector::iterator* it } } -template -void Decimators::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) { // Sup (USB): // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 @@ -471,7 +471,7 @@ void Decimators::decimate4_sup(SampleVector::iterator* it // Inf (LSB): // x y x y x y x y / x -> 0,-3,-4,7 / y -> 1,2,-5,-6 // [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -485,10 +485,10 @@ void Decimators::decimate4_sup(SampleVector::iterator* it } } -template -void Decimators::decimate4_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate4_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 3; pos += 4) { @@ -502,10 +502,10 @@ void Decimators::decimate4_sup(SampleVector::iterator* it } } -template -void Decimators::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[2], yimag[2]; + AccuType xreal[2], yimag[2]; for (int pos = 0; pos < len - 15; pos += 8) { @@ -525,10 +525,10 @@ void Decimators::decimate8_inf(SampleVector::iterator* it } } -template -void Decimators::decimate8_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate8_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal[2], yimag[2]; + AccuType xreal[2], yimag[2]; for (int pos = 0; pos < len - 7; pos += 4) { @@ -548,10 +548,10 @@ void Decimators::decimate8_inf(SampleVector::iterator* it } } -template -void Decimators::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[2], yimag[2]; + AccuType xreal[2], yimag[2]; for (int pos = 0; pos < len - 15; pos += 8) { @@ -571,10 +571,10 @@ void Decimators::decimate8_sup(SampleVector::iterator* it } } -template -void Decimators::decimate8_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate8_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal[2], yimag[2]; + AccuType xreal[2], yimag[2]; for (int pos = 0; pos < len - 7; pos += 4) { @@ -594,12 +594,12 @@ void Decimators::decimate8_sup(SampleVector::iterator* it } } -template -void Decimators::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) { // Offset tuning: 4x downsample and rotate, then // downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] - qint32 xreal[4], yimag[4]; + AccuType xreal[4], yimag[4]; for (int pos = 0; pos < len - 31; ) { @@ -622,12 +622,12 @@ void Decimators::decimate16_inf(SampleVector::iterator* i } } -template -void Decimators::decimate16_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate16_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { // Offset tuning: 4x downsample and rotate, then // downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] - qint32 xreal[4], yimag[4]; + AccuType xreal[4], yimag[4]; for (int pos = 0; pos < len - 15; ) { @@ -650,12 +650,12 @@ void Decimators::decimate16_inf(SampleVector::iterator* i } } -template -void Decimators::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) { // Offset tuning: 4x downsample and rotate, then // downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] - qint32 xreal[4], yimag[4]; + AccuType xreal[4], yimag[4]; for (int pos = 0; pos < len - 31; ) { @@ -678,12 +678,12 @@ void Decimators::decimate16_sup(SampleVector::iterator* i } } -template -void Decimators::decimate16_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate16_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { // Offset tuning: 4x downsample and rotate, then // downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] - qint32 xreal[4], yimag[4]; + AccuType xreal[4], yimag[4]; for (int pos = 0; pos < len - 15; ) { @@ -706,10 +706,10 @@ void Decimators::decimate16_sup(SampleVector::iterator* i } } -template -void Decimators::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[8], yimag[8]; + AccuType xreal[8], yimag[8]; for (int pos = 0; pos < len - 63; ) { @@ -737,10 +737,10 @@ void Decimators::decimate32_inf(SampleVector::iterator* i } } -template -void Decimators::decimate32_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate32_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal[8], yimag[8]; + AccuType xreal[8], yimag[8]; for (int pos = 0; pos < len - 31; ) { @@ -768,10 +768,10 @@ void Decimators::decimate32_inf(SampleVector::iterator* i } } -template -void Decimators::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[8], yimag[8]; + AccuType xreal[8], yimag[8]; for (int pos = 0; pos < len - 63; ) { @@ -799,10 +799,10 @@ void Decimators::decimate32_sup(SampleVector::iterator* i } } -template -void Decimators::decimate32_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate32_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal[8], yimag[8]; + AccuType xreal[8], yimag[8]; for (int pos = 0; pos < len - 31; ) { @@ -830,10 +830,10 @@ void Decimators::decimate32_sup(SampleVector::iterator* i } } -template -void Decimators::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[16], yimag[16]; + AccuType xreal[16], yimag[16]; for (int pos = 0; pos < len - 127; ) { @@ -870,10 +870,10 @@ void Decimators::decimate64_inf(SampleVector::iterator* i } } -template -void Decimators::decimate64_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate64_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal[16], yimag[16]; + AccuType xreal[16], yimag[16]; for (int pos = 0; pos < len - 63; ) { @@ -910,10 +910,10 @@ void Decimators::decimate64_inf(SampleVector::iterator* i } } -template -void Decimators::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[16], yimag[16]; + AccuType xreal[16], yimag[16]; for (int pos = 0; pos < len - 127; ) { @@ -950,10 +950,10 @@ void Decimators::decimate64_sup(SampleVector::iterator* i } } -template -void Decimators::decimate64_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate64_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 xreal[16], yimag[16]; + AccuType xreal[16], yimag[16]; for (int pos = 0; pos < len - 63; ) { @@ -990,10 +990,10 @@ void Decimators::decimate64_sup(SampleVector::iterator* i } } -template -void Decimators::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[2]; + AccuType intbuf[2]; for (int pos = 0; pos < len - 3; pos += 4) { @@ -1008,14 +1008,15 @@ void Decimators::decimate2_cen(SampleVector::iterator* it (**it).setReal(intbuf[0] >> decimation_shifts::post2); (**it).setImag(intbuf[1] >> decimation_shifts::post2); + ++(*it); } } -template -void Decimators::decimate2_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate2_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 intbuf[2]; + AccuType intbuf[2]; for (int pos = 0; pos < len - 1; pos += 2) { @@ -1034,10 +1035,10 @@ void Decimators::decimate2_cen(SampleVector::iterator* it } } -template -void Decimators::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[4]; + AccuType intbuf[4]; for (int pos = 0; pos < len - 7; pos += 8) { @@ -1069,10 +1070,10 @@ void Decimators::decimate4_cen(SampleVector::iterator* it } } -template -void Decimators::decimate4_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate4_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 intbuf[4]; + AccuType intbuf[4]; for (int pos = 0; pos < len - 3; pos += 4) { @@ -1104,10 +1105,10 @@ void Decimators::decimate4_cen(SampleVector::iterator* it } } -template -void Decimators::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[8]; + AccuType intbuf[8]; for (int pos = 0; pos < len - 15; pos += 16) { @@ -1164,10 +1165,10 @@ void Decimators::decimate8_cen(SampleVector::iterator* it } } -template -void Decimators::decimate8_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate8_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 intbuf[8]; + AccuType intbuf[8]; for (int pos = 0; pos < len - 7; pos += 8) { @@ -1224,10 +1225,10 @@ void Decimators::decimate8_cen(SampleVector::iterator* it } } -template -void Decimators::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[16]; + AccuType intbuf[16]; for (int pos = 0; pos < len - 31; pos += 32) { @@ -1333,10 +1334,10 @@ void Decimators::decimate16_cen(SampleVector::iterator* i } } -template -void Decimators::decimate16_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate16_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 intbuf[16]; + AccuType intbuf[16]; for (int pos = 0; pos < len - 15; pos += 16) { @@ -1442,10 +1443,10 @@ void Decimators::decimate16_cen(SampleVector::iterator* i } } -template -void Decimators::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[32]; + AccuType intbuf[32]; for (int pos = 0; pos < len - 63; pos += 64) { @@ -1648,10 +1649,10 @@ void Decimators::decimate32_cen(SampleVector::iterator* i } } -template -void Decimators::decimate32_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate32_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 intbuf[32]; + AccuType intbuf[32]; for (int pos = 0; pos < len - 31; pos += 32) { @@ -1854,10 +1855,10 @@ void Decimators::decimate32_cen(SampleVector::iterator* i } } -template -void Decimators::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[64]; + AccuType intbuf[64]; for (int pos = 0; pos < len - 127; pos += 128) { @@ -2254,10 +2255,10 @@ void Decimators::decimate64_cen(SampleVector::iterator* i } } -template -void Decimators::decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { - qint32 intbuf[64]; + AccuType intbuf[64]; for (int pos = 0; pos < len - 63; pos += 64) { @@ -2654,218 +2655,4 @@ void Decimators::decimate64_cen(SampleVector::iterator* i } } -/* -template -void Decimators::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) -{ - int pos = 0; - - while (pos < len - 1) - { - qint32 x0 = buf[pos+0] << decimation_shifts::pre2; - qint32 y0 = buf[pos+1] << decimation_shifts::pre2; - pos += 2; - - if (m_decimator2.workDecimateCenter(&x0, &y0)) - { - (**it).setReal(x0 >> decimation_shifts::post2); - (**it).setImag(y0 >> decimation_shifts::post2); - ++(*it); - } - } -} - -template -void Decimators::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) -{ - int pos = 0; - - while (pos < len - 1) - { - qint32 x0 = buf[pos+0] << decimation_shifts::pre4; - qint32 y0 = buf[pos+1] << decimation_shifts::pre4; - pos += 2; - - if (m_decimator2.workDecimateCenter(&x0, &y0)) - { - qint32 x1 = x0; - qint32 y1 = y0; - - if (m_decimator4.workDecimateCenter(&x1, &y1)) - { - (**it).setReal(x0 >> decimation_shifts::post4); - (**it).setImag(y0 >> decimation_shifts::post4); - ++(*it); - } - } - } -} - -template -void Decimators::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) -{ - int pos = 0; - - while (pos < len - 1) - { - qint32 x0 = buf[pos+0] << decimation_shifts::pre8; - qint32 y0 = buf[pos+1] << decimation_shifts::pre8; - pos += 2; - - if (m_decimator2.workDecimateCenter(&x0, &y0)) - { - qint32 x1 = x0; - qint32 y1 = y0; - - if (m_decimator4.workDecimateCenter(&x1, &y1)) - { - qint32 x2 = x1; - qint32 y2 = y1; - - if (m_decimator8.workDecimateCenter(&x2, &y2)) - { - (**it).setReal(x2 >> decimation_shifts::post8); - (**it).setImag(y2 >> decimation_shifts::post8); - ++(*it); - } - } - } - } -} - -template -void Decimators::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) -{ - int pos = 0; - - while (pos < len - 1) - { - qint32 x0 = buf[pos+0] << decimation_shifts::pre16; - qint32 y0 = buf[pos+1] << decimation_shifts::pre16; - pos += 2; - - if (m_decimator2.workDecimateCenter(&x0, &y0)) - { - qint32 x1 = x0; - qint32 y1 = y0; - - if (m_decimator4.workDecimateCenter(&x1, &y1)) - { - qint32 x2 = x1; - qint32 y2 = y1; - - if (m_decimator8.workDecimateCenter(&x2, &y2)) - { - qint32 x3 = x2; - qint32 y3 = y2; - - if (m_decimator16.workDecimateCenter(&x3, &y3)) - { - (**it).setReal(x3 >> decimation_shifts::post16); - (**it).setImag(y3 >> decimation_shifts::post16); - ++(*it); - } - } - } - } - } -} - -template -void Decimators::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) -{ - int pos = 0; - - while (pos < len - 1) - { - qint32 x0 = buf[pos+0] << decimation_shifts::pre32; - qint32 y0 = buf[pos+1] << decimation_shifts::pre32; - pos += 2; - - if (m_decimator2.workDecimateCenter(&x0, &y0)) - { - qint32 x1 = x0; - qint32 y1 = y0; - - if (m_decimator4.workDecimateCenter(&x1, &y1)) - { - qint32 x2 = x1; - qint32 y2 = y1; - - if (m_decimator8.workDecimateCenter(&x2, &y2)) - { - qint32 x3 = x2; - qint32 y3 = y2; - - if (m_decimator16.workDecimateCenter(&x3, &y3)) - { - qint32 x4 = x3; - qint32 y4 = y3; - - if (m_decimator32.workDecimateCenter(&x4, &y4)) - { - (**it).setReal(x4 >> decimation_shifts::post32); - (**it).setImag(y4 >> decimation_shifts::post32); - ++(*it); - } - } - } - } - } - } -} - - -template -void Decimators::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) -{ - int pos = 0; - - while (pos < len - 1) - { - qint32 x0 = buf[pos+0] << decimation_shifts::pre64; - qint32 y0 = buf[pos+1] << decimation_shifts::pre64; - pos += 2; - - if (m_decimator2.workDecimateCenter(&x0, &y0)) - { - qint32 x1 = x0; - qint32 y1 = y0; - - if (m_decimator4.workDecimateCenter(&x1, &y1)) - { - qint32 x2 = x1; - qint32 y2 = y1; - - if (m_decimator8.workDecimateCenter(&x2, &y2)) - { - qint32 x3 = x2; - qint32 y3 = y2; - - if (m_decimator16.workDecimateCenter(&x3, &y3)) - { - qint32 x4 = x3; - qint32 y4 = y3; - - if (m_decimator32.workDecimateCenter(&x4, &y4)) - { - qint32 x5 = x4; - qint32 y5 = y4; - - if (m_decimator64.workDecimateCenter(&x5, &y5)) - { - (**it).setReal(x5 >> decimation_shifts::post64); - (**it).setImag(y5 >> decimation_shifts::post64); - ++(*it); - } - } - } - } - } - } - } -} - - */ - #endif /* INCLUDE_GPL_DSP_DECIMATORS_H_ */ diff --git a/sdrbase/dsp/decimatorsu.h b/sdrbase/dsp/decimatorsu.h index fe2e0aa55..2f028b2f5 100644 --- a/sdrbase/dsp/decimatorsu.h +++ b/sdrbase/dsp/decimatorsu.h @@ -24,7 +24,7 @@ #define INCLUDE_GPL_DSP_DECIMATORSU_H_ #include "dsp/dsptypes.h" -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT #include "dsp/inthalfbandfilterdb.h" #else #ifdef USE_SSE4_1 @@ -180,7 +180,7 @@ struct decimation_shifts<24, 8> static const uint post64 = 0; }; -template +template class DecimatorsU { public: @@ -206,7 +206,7 @@ public: void decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len); private: -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT IntHalfbandFilterDB m_decimator2; // 1st stages IntHalfbandFilterDB m_decimator4; // 2nd stages IntHalfbandFilterDB m_decimator8; // 3rd stages @@ -232,8 +232,8 @@ private: #endif }; -template -void DecimatorsU::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) { qint32 xreal, yimag; @@ -247,8 +247,8 @@ void DecimatorsU::decimate1(SampleVector::iterator } } -template -void DecimatorsU::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) { qint32 xreal, yimag; @@ -268,10 +268,10 @@ void DecimatorsU::decimate2_inf(SampleVector::iter } } -template -void DecimatorsU::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -289,10 +289,10 @@ void DecimatorsU::decimate2_sup(SampleVector::iter } } -template -void DecimatorsU::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -306,8 +306,8 @@ void DecimatorsU::decimate4_inf(SampleVector::iter } } -template -void DecimatorsU::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) { // Sup (USB): // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 @@ -315,7 +315,7 @@ void DecimatorsU::decimate4_sup(SampleVector::iter // Inf (LSB): // x y x y x y x y / x -> 0,-3,-4,7 / y -> 1,2,-5,-6 // [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] - qint32 xreal, yimag; + AccuType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { @@ -329,10 +329,10 @@ void DecimatorsU::decimate4_sup(SampleVector::iter } } -template -void DecimatorsU::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[2], yimag[2]; + AccuType xreal[2], yimag[2]; for (int pos = 0; pos < len - 15; pos += 8) { @@ -352,10 +352,10 @@ void DecimatorsU::decimate8_inf(SampleVector::iter } } -template -void DecimatorsU::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[2], yimag[2]; + AccuType xreal[2], yimag[2]; for (int pos = 0; pos < len - 15; pos += 8) { @@ -375,12 +375,12 @@ void DecimatorsU::decimate8_sup(SampleVector::iter } } -template -void DecimatorsU::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) { // Offset tuning: 4x downsample and rotate, then // downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] - qint32 xreal[4], yimag[4]; + AccuType xreal[4], yimag[4]; for (int pos = 0; pos < len - 31; ) { @@ -403,12 +403,12 @@ void DecimatorsU::decimate16_inf(SampleVector::ite } } -template -void DecimatorsU::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) { // Offset tuning: 4x downsample and rotate, then // downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] - qint32 xreal[4], yimag[4]; + AccuType xreal[4], yimag[4]; for (int pos = 0; pos < len - 31; ) { @@ -431,10 +431,10 @@ void DecimatorsU::decimate16_sup(SampleVector::ite } } -template -void DecimatorsU::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[8], yimag[8]; + AccuType xreal[8], yimag[8]; for (int pos = 0; pos < len - 63; ) { @@ -462,10 +462,10 @@ void DecimatorsU::decimate32_inf(SampleVector::ite } } -template -void DecimatorsU::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[8], yimag[8]; + AccuType xreal[8], yimag[8]; for (int pos = 0; pos < len - 63; ) { @@ -493,10 +493,10 @@ void DecimatorsU::decimate32_sup(SampleVector::ite } } -template -void DecimatorsU::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[16], yimag[16]; + AccuType xreal[16], yimag[16]; for (int pos = 0; pos < len - 127; ) { @@ -533,10 +533,10 @@ void DecimatorsU::decimate64_inf(SampleVector::ite } } -template -void DecimatorsU::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 xreal[16], yimag[16]; + AccuType xreal[16], yimag[16]; for (int pos = 0; pos < len - 127; ) { @@ -573,10 +573,10 @@ void DecimatorsU::decimate64_sup(SampleVector::ite } } -template -void DecimatorsU::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[2]; + AccuType intbuf[2]; for (int pos = 0; pos < len - 3; pos += 4) { @@ -595,10 +595,10 @@ void DecimatorsU::decimate2_cen(SampleVector::iter } } -template -void DecimatorsU::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[4]; + AccuType intbuf[4]; for (int pos = 0; pos < len - 7; pos += 8) { @@ -630,10 +630,10 @@ void DecimatorsU::decimate4_cen(SampleVector::iter } } -template -void DecimatorsU::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[8]; + AccuType intbuf[8]; for (int pos = 0; pos < len - 15; pos += 16) { @@ -690,10 +690,10 @@ void DecimatorsU::decimate8_cen(SampleVector::iter } } -template -void DecimatorsU::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[16]; + AccuType intbuf[16]; for (int pos = 0; pos < len - 31; pos += 32) { @@ -799,10 +799,10 @@ void DecimatorsU::decimate16_cen(SampleVector::ite } } -template -void DecimatorsU::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[32]; + AccuType intbuf[32]; for (int pos = 0; pos < len - 63; pos += 64) { @@ -1005,10 +1005,10 @@ void DecimatorsU::decimate32_cen(SampleVector::ite } } -template -void DecimatorsU::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) { - qint32 intbuf[64]; + AccuType intbuf[64]; for (int pos = 0; pos < len - 127; pos += 128) { diff --git a/sdrbase/dsp/downchannelizer.cpp b/sdrbase/dsp/downchannelizer.cpp index 59d27e41f..8b73f34de 100644 --- a/sdrbase/dsp/downchannelizer.cpp +++ b/sdrbase/dsp/downchannelizer.cpp @@ -192,7 +192,7 @@ void DownChannelizer::applyConfiguration() } } -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT DownChannelizer::FilterStage::FilterStage(Mode mode) : m_filter(new IntHalfbandFilterDB), m_workFunction(0), diff --git a/sdrbase/dsp/downchannelizer.h b/sdrbase/dsp/downchannelizer.h index c770f2948..da9ce6d80 100644 --- a/sdrbase/dsp/downchannelizer.h +++ b/sdrbase/dsp/downchannelizer.h @@ -23,7 +23,7 @@ #include #include "util/export.h" #include "util/message.h" -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT #include "dsp/inthalfbandfilterdb.h" #else #ifdef USE_SSE4_1 @@ -82,7 +82,7 @@ protected: ModeUpperHalf }; -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT typedef bool (IntHalfbandFilterDB::*WorkFunction)(Sample* s); IntHalfbandFilterDB* m_filter; #else diff --git a/sdrbase/dsp/dsptypes.h b/sdrbase/dsp/dsptypes.h index b6462e48d..7300c9dae 100644 --- a/sdrbase/dsp/dsptypes.h +++ b/sdrbase/dsp/dsptypes.h @@ -22,7 +22,7 @@ #include #include -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT #define SDR_SAMP_SZ 24 // internal fixed arithmetic sample size #define SDR_SCALEF 8388608.0f #define SDR_SCALED 8388608.0 diff --git a/sdrbase/dsp/interpolators.h b/sdrbase/dsp/interpolators.h index f565e26a2..0188cfb30 100644 --- a/sdrbase/dsp/interpolators.h +++ b/sdrbase/dsp/interpolators.h @@ -18,7 +18,7 @@ #define INCLUDE_GPL_DSP_INTERPOLATORS_H_ #include "dsp/dsptypes.h" -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT #include "dsp/inthalfbandfilterdb.h" #else #ifdef USE_SSE4_1 @@ -118,7 +118,7 @@ public: void interpolate64_cen(SampleVector::iterator* it, T* buf, qint32 len); private: -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT IntHalfbandFilterDB m_interpolator2; // 1st stages IntHalfbandFilterDB m_interpolator4; // 2nd stages IntHalfbandFilterDB m_interpolator8; // 3rd stages diff --git a/sdrbase/dsp/inthalfbandfilter.h b/sdrbase/dsp/inthalfbandfilter.h index f21f12d87..2a0eec627 100644 --- a/sdrbase/dsp/inthalfbandfilter.h +++ b/sdrbase/dsp/inthalfbandfilter.h @@ -146,38 +146,38 @@ public: } } - bool workDecimateCenter(qint32 *x, qint32 *y) - { - // insert sample into ring-buffer - m_samples[m_ptr][0] = *x; - m_samples[m_ptr][1] = *y; - - switch(m_state) - { - case 0: - // advance write-pointer - m_ptr = (m_ptr + HBFIRFilterTraits::hbOrder) % (HBFIRFilterTraits::hbOrder + 1); - - // next state - m_state = 1; - - // tell caller we don't have a new sample - return false; - - default: - // save result - doFIR(x, y); - - // advance write-pointer - m_ptr = (m_ptr + HBFIRFilterTraits::hbOrder) % (HBFIRFilterTraits::hbOrder + 1); - - // next state - m_state = 0; - - // tell caller we have a new sample - return true; - } - } +// bool workDecimateCenter(qint32 *x, qint32 *y) +// { +// // insert sample into ring-buffer +// m_samples[m_ptr][0] = *x; +// m_samples[m_ptr][1] = *y; +// +// switch(m_state) +// { +// case 0: +// // advance write-pointer +// m_ptr = (m_ptr + HBFIRFilterTraits::hbOrder) % (HBFIRFilterTraits::hbOrder + 1); +// +// // next state +// m_state = 1; +// +// // tell caller we don't have a new sample +// return false; +// +// default: +// // save result +// doFIR(x, y); +// +// // advance write-pointer +// m_ptr = (m_ptr + HBFIRFilterTraits::hbOrder) % (HBFIRFilterTraits::hbOrder + 1); +// +// // next state +// m_state = 0; +// +// // tell caller we have a new sample +// return true; +// } +// } // downsample by 2, return edges of spectrum rotated into center - unused // bool workDecimateFullRotate(Sample* sample) diff --git a/sdrbase/dsp/inthalfbandfilterdb.h b/sdrbase/dsp/inthalfbandfilterdb.h index 4a153edc8..e65dfa59c 100644 --- a/sdrbase/dsp/inthalfbandfilterdb.h +++ b/sdrbase/dsp/inthalfbandfilterdb.h @@ -35,7 +35,7 @@ public: bool workDecimateCenter(Sample* sample) { // insert sample into ring-buffer - storeSample((FixReal) sample->real(), (FixReal) sample->imag()); + storeSampleFixReal((FixReal) sample->real(), (FixReal) sample->imag()); switch(m_state) { @@ -67,7 +67,7 @@ public: { case 0: // insert sample into ring-buffer - storeSample((FixReal) 0, (FixReal) 0); + storeSampleFixReal((FixReal) 0, (FixReal) 0); // save result doFIR(SampleOut); // advance write-pointer @@ -79,7 +79,7 @@ public: default: // insert sample into ring-buffer - storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); + storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); // save result doFIR(SampleOut); // advance write-pointer @@ -125,32 +125,32 @@ public: } } - bool workDecimateCenter(qint32 *x, qint32 *y) - { - // insert sample into ring-buffer - storeSample32(*x, *y); - - switch(m_state) - { - case 0: - // advance write-pointer - advancePointer(); - // next state - m_state = 1; - // tell caller we don't have a new sample - return false; - - default: - // save result - doFIR(x, y); - // advance write-pointer - advancePointer(); - // next state - m_state = 0; - // tell caller we have a new sample - return true; - } - } +// bool workDecimateCenter(qint32 *x, qint32 *y) +// { +// // insert sample into ring-buffer +// storeSample32(*x, *y); +// +// switch (m_state) +// { +// case 0: +// // advance write-pointer +// advancePointer(); +// // next state +// m_state = 1; +// // tell caller we don't have a new sample +// return false; +// +// default: +// // save result +// doFIR(x, y); +// // advance write-pointer +// advancePointer(); +// // next state +// m_state = 0; +// // tell caller we have a new sample +// return true; +// } +// } // downsample by 2, return lower half of original spectrum bool workDecimateLowerHalf(Sample* sample) @@ -159,7 +159,7 @@ public: { case 0: // insert sample into ring-buffer - storeSample((FixReal) -sample->imag(), (FixReal) sample->real()); + storeSampleFixReal((FixReal) -sample->imag(), (FixReal) sample->real()); // advance write-pointer advancePointer(); // next state @@ -169,7 +169,7 @@ public: case 1: // insert sample into ring-buffer - storeSample((FixReal) -sample->real(), (FixReal) -sample->imag()); + storeSampleFixReal((FixReal) -sample->real(), (FixReal) -sample->imag()); // save result doFIR(sample); // advance write-pointer @@ -181,7 +181,7 @@ public: case 2: // insert sample into ring-buffer - storeSample((FixReal) sample->imag(), (FixReal) -sample->real()); + storeSampleFixReal((FixReal) sample->imag(), (FixReal) -sample->real()); // advance write-pointer advancePointer(); // next state @@ -191,7 +191,7 @@ public: default: // insert sample into ring-buffer - storeSample((FixReal) sample->real(), (FixReal) sample->imag()); + storeSampleFixReal((FixReal) sample->real(), (FixReal) sample->imag()); // save result doFIR(sample); // advance write-pointer @@ -279,7 +279,7 @@ public: { case 0: // insert sample into ring-buffer - storeSample((FixReal) 0, (FixReal) 0); + storeSampleFixReal((FixReal) 0, (FixReal) 0); // save result doFIR(&s); @@ -297,7 +297,7 @@ public: case 1: // insert sample into ring-buffer - storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); + storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); // save result doFIR(&s); @@ -315,7 +315,7 @@ public: case 2: // insert sample into ring-buffer - storeSample((FixReal) 0, (FixReal) 0); + storeSampleFixReal((FixReal) 0, (FixReal) 0); // save result doFIR(&s); @@ -333,7 +333,7 @@ public: default: // insert sample into ring-buffer - storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); + storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); // save result doFIR(&s); @@ -358,7 +358,7 @@ public: { case 0: // insert sample into ring-buffer - storeSample((FixReal) sample->imag(), (FixReal) -sample->real()); + storeSampleFixReal((FixReal) sample->imag(), (FixReal) -sample->real()); // advance write-pointer advancePointer(); // next state @@ -368,7 +368,7 @@ public: case 1: // insert sample into ring-buffer - storeSample((FixReal) -sample->real(), (FixReal) -sample->imag()); + storeSampleFixReal((FixReal) -sample->real(), (FixReal) -sample->imag()); // save result doFIR(sample); // advance write-pointer @@ -380,7 +380,7 @@ public: case 2: // insert sample into ring-buffer - storeSample((FixReal) -sample->imag(), (FixReal) sample->real()); + storeSampleFixReal((FixReal) -sample->imag(), (FixReal) sample->real()); // advance write-pointer advancePointer(); // next state @@ -390,7 +390,7 @@ public: default: // insert sample into ring-buffer - storeSample((FixReal) sample->real(), (FixReal) sample->imag()); + storeSampleFixReal((FixReal) sample->real(), (FixReal) sample->imag()); // save result doFIR(sample); // advance write-pointer @@ -478,7 +478,7 @@ public: { case 0: // insert sample into ring-buffer - storeSample((FixReal) 0, (FixReal) 0); + storeSampleFixReal((FixReal) 0, (FixReal) 0); // save result doFIR(&s); @@ -496,7 +496,7 @@ public: case 1: // insert sample into ring-buffer - storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); + storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); // save result doFIR(&s); @@ -514,7 +514,7 @@ public: case 2: // insert sample into ring-buffer - storeSample((FixReal) 0, (FixReal) 0); + storeSampleFixReal((FixReal) 0, (FixReal) 0); // save result doFIR(&s); @@ -532,7 +532,7 @@ public: default: // insert sample into ring-buffer - storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); + storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); // save result doFIR(&s); @@ -552,47 +552,47 @@ public: void myDecimate(const Sample* sample1, Sample* sample2) { - storeSample((FixReal) sample1->real(), (FixReal) sample1->imag()); + storeSampleFixReal((FixReal) sample1->real(), (FixReal) sample1->imag()); advancePointer(); - storeSample((FixReal) sample2->real(), (FixReal) sample2->imag()); + storeSampleFixReal((FixReal) sample2->real(), (FixReal) sample2->imag()); doFIR(sample2); advancePointer(); } - void myDecimate(qint32 x1, qint32 y1, qint32 *x2, qint32 *y2) + void myDecimate(AccuType x1, AccuType y1, AccuType *x2, AccuType *y2) { - storeSample32(x1, y1); + storeSampleAccu(x1, y1); advancePointer(); - storeSample32(*x2, *y2); - doFIR(x2, y2); + storeSampleAccu(*x2, *y2); + doFIRAccu(x2, y2); advancePointer(); } /** Simple zero stuffing and filter */ void myInterpolateZeroStuffing(Sample* sample1, Sample* sample2) { - storeSample((FixReal) sample1->real(), (FixReal) sample1->imag()); + storeSampleFixReal((FixReal) sample1->real(), (FixReal) sample1->imag()); doFIR(sample1); advancePointer(); - storeSample((FixReal) 0, (FixReal) 0); + storeSampleFixReal((FixReal) 0, (FixReal) 0); doFIR(sample2); advancePointer(); } /** Simple zero stuffing and filter */ - void myInterpolateZeroStuffing(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2) - { - storeSample32(*x1, *y1); - doFIR(x1, y1); - advancePointer(); - - storeSample32(0, 0); - doFIR(x2, y2); - advancePointer(); - } +// void myInterpolateZeroStuffing(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2) +// { +// storeSampleAccu(*x1, *y1); +// doFIR(x1, y1); +// advancePointer(); +// +// storeSampleAccu(0, 0); +// doFIR(x2, y2); +// advancePointer(); +// } /** Optimized upsampler by 2 not calculating FIR with inserted null samples */ void myInterpolate(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2) @@ -624,7 +624,7 @@ protected: int m_size; int m_state; - void storeSample(const FixReal& sampleI, const FixReal& sampleQ) + void storeSampleFixReal(const FixReal& sampleI, const FixReal& sampleQ) { m_samplesDB[m_ptr][0] = sampleI; m_samplesDB[m_ptr][1] = sampleQ; @@ -632,7 +632,7 @@ protected: m_samplesDB[m_ptr + m_size][1] = sampleQ; } - void storeSample32(qint32 x, qint32 y) + void storeSampleAccu(AccuType x, AccuType y) { m_samplesDB[m_ptr][0] = x; m_samplesDB[m_ptr][1] = y; @@ -660,8 +660,8 @@ protected: b += 2; } - iAcc += ((qint32)m_samplesDB[b-1][0]) << (HBFIRFilterTraits::hbShift - 1); - qAcc += ((qint32)m_samplesDB[b-1][1]) << (HBFIRFilterTraits::hbShift - 1); + iAcc += m_samplesDB[b-1][0] << (HBFIRFilterTraits::hbShift - 1); + qAcc += m_samplesDB[b-1][1] << (HBFIRFilterTraits::hbShift - 1); sample->setReal(iAcc >> (HBFIRFilterTraits::hbShift -1)); sample->setImag(qAcc >> (HBFIRFilterTraits::hbShift -1)); @@ -682,8 +682,30 @@ protected: b += 2; } - iAcc += ((qint32)m_samplesDB[b-1][0]) << (HBFIRFilterTraits::hbShift - 1); - qAcc += ((qint32)m_samplesDB[b-1][1]) << (HBFIRFilterTraits::hbShift - 1); + iAcc += m_samplesDB[b-1][0] << (HBFIRFilterTraits::hbShift - 1); + qAcc += m_samplesDB[b-1][1] << (HBFIRFilterTraits::hbShift - 1); + + *x = iAcc >> (HBFIRFilterTraits::hbShift -1); // HB_SHIFT incorrect do not loose the gained bit + *y = qAcc >> (HBFIRFilterTraits::hbShift -1); + } + + void doFIRAccu(AccuType *x, AccuType *y) + { + int a = m_ptr + m_size; // tip pointer + int b = m_ptr + 1; // tail pointer + AccuType iAcc = 0; + AccuType qAcc = 0; + + for (int i = 0; i < HBFIRFilterTraits::hbOrder / 4; i++) + { + iAcc += (m_samplesDB[a][0] + m_samplesDB[b][0]) * HBFIRFilterTraits::hbCoeffs[i]; + qAcc += (m_samplesDB[a][1] + m_samplesDB[b][1]) * HBFIRFilterTraits::hbCoeffs[i]; + a -= 2; + b += 2; + } + + iAcc += m_samplesDB[b-1][0] << (HBFIRFilterTraits::hbShift - 1); + qAcc += m_samplesDB[b-1][1] << (HBFIRFilterTraits::hbShift - 1); *x = iAcc >> (HBFIRFilterTraits::hbShift -1); // HB_SHIFT incorrect do not loose the gained bit *y = qAcc >> (HBFIRFilterTraits::hbShift -1); diff --git a/sdrbase/dsp/upchannelizer.cpp b/sdrbase/dsp/upchannelizer.cpp index 6ae1f045c..c2415a186 100644 --- a/sdrbase/dsp/upchannelizer.cpp +++ b/sdrbase/dsp/upchannelizer.cpp @@ -207,7 +207,7 @@ void UpChannelizer::applyConfiguration() } } -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT UpChannelizer::FilterStage::FilterStage(Mode mode) : m_filter(new IntHalfbandFilterDB), m_workFunction(0) diff --git a/sdrbase/dsp/upchannelizer.h b/sdrbase/dsp/upchannelizer.h index fbc0b63da..ee6f5fa35 100644 --- a/sdrbase/dsp/upchannelizer.h +++ b/sdrbase/dsp/upchannelizer.h @@ -23,7 +23,7 @@ #include #include "util/export.h" #include "util/message.h" -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT #include "dsp/inthalfbandfilterdb.h" #else #ifdef USE_SSE4_1 @@ -87,7 +87,7 @@ protected: ModeUpperHalf }; -#ifdef SAMPLE_24BIT +#ifdef SDR_SAMPLE_24BIT typedef bool (IntHalfbandFilterDB::*WorkFunction)(Sample* sIn, Sample *sOut); IntHalfbandFilterDB* m_filter; #else