1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

24 bit DSP fix

This commit is contained in:
f4exb 2018-01-22 02:49:06 +01:00
parent ad219d50cc
commit 732561152b
20 changed files with 362 additions and 515 deletions

View File

@ -188,7 +188,7 @@ endif()
# Compiler flags. # Compiler flags.
if (SAMPLE_24BIT) if (SAMPLE_24BIT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSAMPLE_24BIT") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSDR_SAMPLE_24BIT")
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}")

View File

@ -55,7 +55,11 @@ private:
int m_fcPos; int m_fcPos;
static AirspyThread *m_this; static AirspyThread *m_this;
Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators; #ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
#endif
void run(); void run();
void callback(const qint16* buf, qint32 len); void callback(const qint16* buf, qint32 len);

View File

@ -53,7 +53,11 @@ private:
unsigned int m_log2Decim; unsigned int m_log2Decim;
static AirspyHFThread *m_this; static AirspyHFThread *m_this;
Decimators<qint16, SDR_SAMP_SZ, 16> m_decimators; #ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 16> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 16> m_decimators;
#endif
void run(); void run();
void callback(const qint16* buf, qint32 len); void callback(const qint16* buf, qint32 len);

View File

@ -51,7 +51,11 @@ private:
unsigned int m_log2Decim; unsigned int m_log2Decim;
int m_fcPos; int m_fcPos;
Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators; #ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
#endif
void run(); void run();
void callback(const qint16* buf, qint32 len); void callback(const qint16* buf, qint32 len);

View File

@ -54,7 +54,11 @@ private:
unsigned int m_log2Decim; unsigned int m_log2Decim;
int m_fcPos; int m_fcPos;
Decimators<qint8, SDR_SAMP_SZ, 8> m_decimators; #ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint8, SDR_SAMP_SZ, 8> m_decimators;
#else
Decimators<qint32, qint8, SDR_SAMP_SZ, 8> m_decimators;
#endif
void run(); void run();
void callback(const qint8* buf, qint32 len); void callback(const qint8* buf, qint32 len);

View File

@ -55,7 +55,11 @@ private:
unsigned int m_log2Decim; // soft decimation unsigned int m_log2Decim; // soft decimation
Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators; #ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
#endif
void run(); void run();
void callback(const qint16* buf, qint32 len); void callback(const qint16* buf, qint32 len);

View File

@ -59,7 +59,11 @@ private:
int m_fcPos; int m_fcPos;
float m_phasor; float m_phasor;
Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators; #ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
#endif
void run(); void run();
void convert(const qint16* buf, qint32 len); void convert(const qint16* buf, qint32 len);

View File

@ -52,7 +52,11 @@ private:
unsigned int m_log2Decim; unsigned int m_log2Decim;
int m_fcPos; int m_fcPos;
DecimatorsU<quint8, SDR_SAMP_SZ, 8, 127> m_decimators; #ifdef SDR_SAMPLE_24BIT
DecimatorsU<qint64, quint8, SDR_SAMP_SZ, 8, 127> m_decimators;
#else
DecimatorsU<qint32, quint8, SDR_SAMP_SZ, 8, 127> m_decimators;
#endif
void run(); void run();
void callback(const quint8* buf, qint32 len); void callback(const quint8* buf, qint32 len);

View File

@ -52,7 +52,11 @@ private:
unsigned int m_log2Decim; unsigned int m_log2Decim;
int m_fcPos; int m_fcPos;
Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators; #ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
#endif
void run(); void run();
void callback(const qint16* buf, qint32 len); void callback(const qint16* buf, qint32 len);

View File

@ -85,9 +85,15 @@ private:
bool m_throttleToggle; bool m_throttleToggle;
QMutex m_mutex; QMutex m_mutex;
Decimators<qint16, SDR_SAMP_SZ, 8> m_decimators_8; #ifdef SDR_SAMPLE_24BIT
Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators_12; Decimators<qint64, qint16, SDR_SAMP_SZ, 8> m_decimators_8;
Decimators<qint16, SDR_SAMP_SZ, 16> m_decimators_16; Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators_12;
Decimators<qint64, qint16, SDR_SAMP_SZ, 16> m_decimators_16;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 8> m_decimators_8;
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators_12;
Decimators<qint32, qint16, SDR_SAMP_SZ, 16> m_decimators_16;
#endif
void run(); void run();
void callback(const qint16* buf, qint32 len); void callback(const qint16* buf, qint32 len);

View File

@ -18,7 +18,7 @@
#define INCLUDE_GPL_DSP_DECIMATORS_H_ #define INCLUDE_GPL_DSP_DECIMATORS_H_
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h" #include "dsp/inthalfbandfilterdb.h"
#else #else
#ifdef USE_SSE4_1 #ifdef USE_SSE4_1
@ -192,7 +192,7 @@ struct decimation_shifts<24, 8>
static const uint post64 = 0; static const uint post64 = 0;
}; };
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
class Decimators class Decimators
{ {
public: public:
@ -240,7 +240,7 @@ public:
void decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len); void decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len);
private: private:
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages
@ -266,8 +266,8 @@ private:
#endif #endif
}; };
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
qint32 xreal, yimag; qint32 xreal, yimag;
@ -281,8 +281,8 @@ void Decimators<T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, co
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len)
{ {
qint32 xreal, yimag; qint32 xreal, yimag;
@ -296,10 +296,10 @@ void Decimators<T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, co
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_u(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -317,10 +317,10 @@ void Decimators<T, SdrBits, InputBits>::decimate2_u(SampleVector::iterator* it,
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_u(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -340,10 +340,10 @@ void Decimators<T, SdrBits, InputBits>::decimate2_u(SampleVector::iterator* it,
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -361,10 +361,10 @@ void Decimators<T, SdrBits, InputBits>::decimate2_inf(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -384,10 +384,10 @@ void Decimators<T, SdrBits, InputBits>::decimate2_inf(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -405,10 +405,10 @@ void Decimators<T, SdrBits, InputBits>::decimate2_sup(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -428,10 +428,10 @@ void Decimators<T, SdrBits, InputBits>::decimate2_sup(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -445,10 +445,10 @@ void Decimators<T, SdrBits, InputBits>::decimate4_inf(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate4_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -462,8 +462,8 @@ void Decimators<T, SdrBits, InputBits>::decimate4_inf(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
// Sup (USB): // Sup (USB):
// x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7
@ -471,7 +471,7 @@ void Decimators<T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it
// Inf (LSB): // Inf (LSB):
// x y x y x y x y / x -> 0,-3,-4,7 / y -> 1,2,-5,-6 // 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] // [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
qint32 xreal, yimag; AccuType xreal, yimag;
for (int pos = 0; pos < len - 7; pos += 8) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -485,10 +485,10 @@ void Decimators<T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -502,10 +502,10 @@ void Decimators<T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 15; pos += 8)
{ {
@ -525,10 +525,10 @@ void Decimators<T, SdrBits, InputBits>::decimate8_inf(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate8_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 4)
{ {
@ -548,10 +548,10 @@ void Decimators<T, SdrBits, InputBits>::decimate8_inf(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 15; pos += 8)
{ {
@ -571,10 +571,10 @@ void Decimators<T, SdrBits, InputBits>::decimate8_sup(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate8_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 4)
{ {
@ -594,12 +594,12 @@ void Decimators<T, SdrBits, InputBits>::decimate8_sup(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
// Offset tuning: 4x downsample and rotate, then // Offset tuning: 4x downsample and rotate, then
// downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] // 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; ) for (int pos = 0; pos < len - 31; )
{ {
@ -622,12 +622,12 @@ void Decimators<T, SdrBits, InputBits>::decimate16_inf(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate16_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::decimate16_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len)
{ {
// Offset tuning: 4x downsample and rotate, then // Offset tuning: 4x downsample and rotate, then
// downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] // 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; ) for (int pos = 0; pos < len - 15; )
{ {
@ -650,12 +650,12 @@ void Decimators<T, SdrBits, InputBits>::decimate16_inf(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
// Offset tuning: 4x downsample and rotate, then // Offset tuning: 4x downsample and rotate, then
// downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] // 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; ) for (int pos = 0; pos < len - 31; )
{ {
@ -678,12 +678,12 @@ void Decimators<T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len)
{ {
// Offset tuning: 4x downsample and rotate, then // Offset tuning: 4x downsample and rotate, then
// downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] // 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; ) for (int pos = 0; pos < len - 15; )
{ {
@ -706,10 +706,10 @@ void Decimators<T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 63; )
{ {
@ -737,10 +737,10 @@ void Decimators<T, SdrBits, InputBits>::decimate32_inf(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate32_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 31; )
{ {
@ -768,10 +768,10 @@ void Decimators<T, SdrBits, InputBits>::decimate32_inf(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 63; )
{ {
@ -799,10 +799,10 @@ void Decimators<T, SdrBits, InputBits>::decimate32_sup(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate32_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 31; )
{ {
@ -830,10 +830,10 @@ void Decimators<T, SdrBits, InputBits>::decimate32_sup(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 127; )
{ {
@ -870,10 +870,10 @@ void Decimators<T, SdrBits, InputBits>::decimate64_inf(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate64_inf(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 63; )
{ {
@ -910,10 +910,10 @@ void Decimators<T, SdrBits, InputBits>::decimate64_inf(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 127; )
{ {
@ -950,10 +950,10 @@ void Decimators<T, SdrBits, InputBits>::decimate64_sup(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate64_sup(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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; ) for (int pos = 0; pos < len - 63; )
{ {
@ -990,10 +990,10 @@ void Decimators<T, SdrBits, InputBits>::decimate64_sup(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -1008,14 +1008,15 @@ void Decimators<T, SdrBits, InputBits>::decimate2_cen(SampleVector::iterator* it
(**it).setReal(intbuf[0] >> decimation_shifts<SdrBits, InputBits>::post2); (**it).setReal(intbuf[0] >> decimation_shifts<SdrBits, InputBits>::post2);
(**it).setImag(intbuf[1] >> decimation_shifts<SdrBits, InputBits>::post2); (**it).setImag(intbuf[1] >> decimation_shifts<SdrBits, InputBits>::post2);
++(*it); ++(*it);
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 1; pos += 2)
{ {
@ -1034,10 +1035,10 @@ void Decimators<T, SdrBits, InputBits>::decimate2_cen(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -1069,10 +1070,10 @@ void Decimators<T, SdrBits, InputBits>::decimate4_cen(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate4_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -1104,10 +1105,10 @@ void Decimators<T, SdrBits, InputBits>::decimate4_cen(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 15; pos += 16)
{ {
@ -1164,10 +1165,10 @@ void Decimators<T, SdrBits, InputBits>::decimate8_cen(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate8_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -1224,10 +1225,10 @@ void Decimators<T, SdrBits, InputBits>::decimate8_cen(SampleVector::iterator* it
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 31; pos += 32)
{ {
@ -1333,10 +1334,10 @@ void Decimators<T, SdrBits, InputBits>::decimate16_cen(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate16_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 15; pos += 16)
{ {
@ -1442,10 +1443,10 @@ void Decimators<T, SdrBits, InputBits>::decimate16_cen(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 63; pos += 64)
{ {
@ -1648,10 +1649,10 @@ void Decimators<T, SdrBits, InputBits>::decimate32_cen(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate32_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 31; pos += 32)
{ {
@ -1854,10 +1855,10 @@ void Decimators<T, SdrBits, InputBits>::decimate32_cen(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 127; pos += 128)
{ {
@ -2254,10 +2255,10 @@ void Decimators<T, SdrBits, InputBits>::decimate64_cen(SampleVector::iterator* i
} }
} }
template<typename T, uint SdrBits, uint InputBits> template<typename AccuType, typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) void Decimators<AccuType, T, SdrBits, InputBits>::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) for (int pos = 0; pos < len - 63; pos += 64)
{ {
@ -2654,218 +2655,4 @@ void Decimators<T, SdrBits, InputBits>::decimate64_cen(SampleVector::iterator* i
} }
} }
/*
template<typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
int pos = 0;
while (pos < len - 1)
{
qint32 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre2;
qint32 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::pre2;
pos += 2;
if (m_decimator2.workDecimateCenter(&x0, &y0))
{
(**it).setReal(x0 >> decimation_shifts<SdrBits, InputBits>::post2);
(**it).setImag(y0 >> decimation_shifts<SdrBits, InputBits>::post2);
++(*it);
}
}
}
template<typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
int pos = 0;
while (pos < len - 1)
{
qint32 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre4;
qint32 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::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<SdrBits, InputBits>::post4);
(**it).setImag(y0 >> decimation_shifts<SdrBits, InputBits>::post4);
++(*it);
}
}
}
}
template<typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
int pos = 0;
while (pos < len - 1)
{
qint32 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre8;
qint32 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::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<SdrBits, InputBits>::post8);
(**it).setImag(y2 >> decimation_shifts<SdrBits, InputBits>::post8);
++(*it);
}
}
}
}
}
template<typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
int pos = 0;
while (pos < len - 1)
{
qint32 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre16;
qint32 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::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<SdrBits, InputBits>::post16);
(**it).setImag(y3 >> decimation_shifts<SdrBits, InputBits>::post16);
++(*it);
}
}
}
}
}
}
template<typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
int pos = 0;
while (pos < len - 1)
{
qint32 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre32;
qint32 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::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<SdrBits, InputBits>::post32);
(**it).setImag(y4 >> decimation_shifts<SdrBits, InputBits>::post32);
++(*it);
}
}
}
}
}
}
}
template<typename T, uint SdrBits, uint InputBits>
void Decimators<T, SdrBits, InputBits>::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
int pos = 0;
while (pos < len - 1)
{
qint32 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre64;
qint32 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::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<SdrBits, InputBits>::post64);
(**it).setImag(y5 >> decimation_shifts<SdrBits, InputBits>::post64);
++(*it);
}
}
}
}
}
}
}
}
*/
#endif /* INCLUDE_GPL_DSP_DECIMATORS_H_ */ #endif /* INCLUDE_GPL_DSP_DECIMATORS_H_ */

View File

@ -24,7 +24,7 @@
#define INCLUDE_GPL_DSP_DECIMATORSU_H_ #define INCLUDE_GPL_DSP_DECIMATORSU_H_
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h" #include "dsp/inthalfbandfilterdb.h"
#else #else
#ifdef USE_SSE4_1 #ifdef USE_SSE4_1
@ -180,7 +180,7 @@ struct decimation_shifts<24, 8>
static const uint post64 = 0; static const uint post64 = 0;
}; };
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
class DecimatorsU class DecimatorsU
{ {
public: public:
@ -206,7 +206,7 @@ public:
void decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len); void decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len);
private: private:
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages
@ -232,8 +232,8 @@ private:
#endif #endif
}; };
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::decimate1(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
qint32 xreal, yimag; qint32 xreal, yimag;
@ -247,8 +247,8 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate1(SampleVector::iterator
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
qint32 xreal, yimag; qint32 xreal, yimag;
@ -268,10 +268,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate2_inf(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -289,10 +289,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate2_sup(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -306,8 +306,8 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate4_inf(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
// Sup (USB): // Sup (USB):
// x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7
@ -315,7 +315,7 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate4_sup(SampleVector::iter
// Inf (LSB): // Inf (LSB):
// x y x y x y x y / x -> 0,-3,-4,7 / y -> 1,2,-5,-6 // 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] // [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
qint32 xreal, yimag; AccuType xreal, yimag;
for (int pos = 0; pos < len - 7; pos += 8) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -329,10 +329,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate4_sup(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 15; pos += 8)
{ {
@ -352,10 +352,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate8_inf(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 15; pos += 8)
{ {
@ -375,12 +375,12 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate8_sup(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
// Offset tuning: 4x downsample and rotate, then // Offset tuning: 4x downsample and rotate, then
// downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] // 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; ) for (int pos = 0; pos < len - 31; )
{ {
@ -403,12 +403,12 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate16_inf(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len)
{ {
// Offset tuning: 4x downsample and rotate, then // Offset tuning: 4x downsample and rotate, then
// downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] // 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; ) for (int pos = 0; pos < len - 31; )
{ {
@ -431,10 +431,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate16_sup(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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; ) for (int pos = 0; pos < len - 63; )
{ {
@ -462,10 +462,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate32_inf(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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; ) for (int pos = 0; pos < len - 63; )
{ {
@ -493,10 +493,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate32_sup(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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; ) for (int pos = 0; pos < len - 127; )
{ {
@ -533,10 +533,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate64_inf(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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; ) for (int pos = 0; pos < len - 127; )
{ {
@ -573,10 +573,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate64_sup(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 3; pos += 4)
{ {
@ -595,10 +595,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate2_cen(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 7; pos += 8)
{ {
@ -630,10 +630,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate4_cen(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 15; pos += 16)
{ {
@ -690,10 +690,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate8_cen(SampleVector::iter
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 31; pos += 32)
{ {
@ -799,10 +799,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate16_cen(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 63; pos += 64)
{ {
@ -1005,10 +1005,10 @@ void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate32_cen(SampleVector::ite
} }
} }
template<typename T, uint SdrBits, uint InputBits, int Shift> template<typename AccuType, typename T, uint SdrBits, uint InputBits, int Shift>
void DecimatorsU<T, SdrBits, InputBits, Shift>::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) void DecimatorsU<AccuType, T, SdrBits, InputBits, Shift>::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) for (int pos = 0; pos < len - 127; pos += 128)
{ {

View File

@ -192,7 +192,7 @@ void DownChannelizer::applyConfiguration()
} }
} }
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
DownChannelizer::FilterStage::FilterStage(Mode mode) : DownChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>), m_filter(new IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>),
m_workFunction(0), m_workFunction(0),

View File

@ -23,7 +23,7 @@
#include <QMutex> #include <QMutex>
#include "util/export.h" #include "util/export.h"
#include "util/message.h" #include "util/message.h"
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h" #include "dsp/inthalfbandfilterdb.h"
#else #else
#ifdef USE_SSE4_1 #ifdef USE_SSE4_1
@ -82,7 +82,7 @@ protected:
ModeUpperHalf ModeUpperHalf
}; };
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
typedef bool (IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s); typedef bool (IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter; IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else #else

View File

@ -22,7 +22,7 @@
#include <vector> #include <vector>
#include <QtGlobal> #include <QtGlobal>
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
#define SDR_SAMP_SZ 24 // internal fixed arithmetic sample size #define SDR_SAMP_SZ 24 // internal fixed arithmetic sample size
#define SDR_SCALEF 8388608.0f #define SDR_SCALEF 8388608.0f
#define SDR_SCALED 8388608.0 #define SDR_SCALED 8388608.0

View File

@ -18,7 +18,7 @@
#define INCLUDE_GPL_DSP_INTERPOLATORS_H_ #define INCLUDE_GPL_DSP_INTERPOLATORS_H_
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h" #include "dsp/inthalfbandfilterdb.h"
#else #else
#ifdef USE_SSE4_1 #ifdef USE_SSE4_1
@ -118,7 +118,7 @@ public:
void interpolate64_cen(SampleVector::iterator* it, T* buf, qint32 len); void interpolate64_cen(SampleVector::iterator* it, T* buf, qint32 len);
private: private:
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_FIRST> m_interpolator2; // 1st stages IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_FIRST> m_interpolator2; // 1st stages
IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_SECOND> m_interpolator4; // 2nd stages IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_SECOND> m_interpolator4; // 2nd stages
IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator8; // 3rd stages IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator8; // 3rd stages

View File

@ -146,38 +146,38 @@ public:
} }
} }
bool workDecimateCenter(qint32 *x, qint32 *y) // bool workDecimateCenter(qint32 *x, qint32 *y)
{ // {
// insert sample into ring-buffer // // insert sample into ring-buffer
m_samples[m_ptr][0] = *x; // m_samples[m_ptr][0] = *x;
m_samples[m_ptr][1] = *y; // m_samples[m_ptr][1] = *y;
//
switch(m_state) // switch(m_state)
{ // {
case 0: // case 0:
// advance write-pointer // // advance write-pointer
m_ptr = (m_ptr + HBFIRFilterTraits<HBFilterOrder>::hbOrder) % (HBFIRFilterTraits<HBFilterOrder>::hbOrder + 1); // m_ptr = (m_ptr + HBFIRFilterTraits<HBFilterOrder>::hbOrder) % (HBFIRFilterTraits<HBFilterOrder>::hbOrder + 1);
//
// next state // // next state
m_state = 1; // m_state = 1;
//
// tell caller we don't have a new sample // // tell caller we don't have a new sample
return false; // return false;
//
default: // default:
// save result // // save result
doFIR(x, y); // doFIR(x, y);
//
// advance write-pointer // // advance write-pointer
m_ptr = (m_ptr + HBFIRFilterTraits<HBFilterOrder>::hbOrder) % (HBFIRFilterTraits<HBFilterOrder>::hbOrder + 1); // m_ptr = (m_ptr + HBFIRFilterTraits<HBFilterOrder>::hbOrder) % (HBFIRFilterTraits<HBFilterOrder>::hbOrder + 1);
//
// next state // // next state
m_state = 0; // m_state = 0;
//
// tell caller we have a new sample // // tell caller we have a new sample
return true; // return true;
} // }
} // }
// downsample by 2, return edges of spectrum rotated into center - unused // downsample by 2, return edges of spectrum rotated into center - unused
// bool workDecimateFullRotate(Sample* sample) // bool workDecimateFullRotate(Sample* sample)

View File

@ -35,7 +35,7 @@ public:
bool workDecimateCenter(Sample* sample) bool workDecimateCenter(Sample* sample)
{ {
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sample->real(), (FixReal) sample->imag()); storeSampleFixReal((FixReal) sample->real(), (FixReal) sample->imag());
switch(m_state) switch(m_state)
{ {
@ -67,7 +67,7 @@ public:
{ {
case 0: case 0:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) 0, (FixReal) 0); storeSampleFixReal((FixReal) 0, (FixReal) 0);
// save result // save result
doFIR(SampleOut); doFIR(SampleOut);
// advance write-pointer // advance write-pointer
@ -79,7 +79,7 @@ public:
default: default:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag());
// save result // save result
doFIR(SampleOut); doFIR(SampleOut);
// advance write-pointer // advance write-pointer
@ -125,32 +125,32 @@ public:
} }
} }
bool workDecimateCenter(qint32 *x, qint32 *y) // bool workDecimateCenter(qint32 *x, qint32 *y)
{ // {
// insert sample into ring-buffer // // insert sample into ring-buffer
storeSample32(*x, *y); // storeSample32(*x, *y);
//
switch(m_state) // switch (m_state)
{ // {
case 0: // case 0:
// advance write-pointer // // advance write-pointer
advancePointer(); // advancePointer();
// next state // // next state
m_state = 1; // m_state = 1;
// tell caller we don't have a new sample // // tell caller we don't have a new sample
return false; // return false;
//
default: // default:
// save result // // save result
doFIR(x, y); // doFIR(x, y);
// advance write-pointer // // advance write-pointer
advancePointer(); // advancePointer();
// next state // // next state
m_state = 0; // m_state = 0;
// tell caller we have a new sample // // tell caller we have a new sample
return true; // return true;
} // }
} // }
// downsample by 2, return lower half of original spectrum // downsample by 2, return lower half of original spectrum
bool workDecimateLowerHalf(Sample* sample) bool workDecimateLowerHalf(Sample* sample)
@ -159,7 +159,7 @@ public:
{ {
case 0: case 0:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) -sample->imag(), (FixReal) sample->real()); storeSampleFixReal((FixReal) -sample->imag(), (FixReal) sample->real());
// advance write-pointer // advance write-pointer
advancePointer(); advancePointer();
// next state // next state
@ -169,7 +169,7 @@ public:
case 1: case 1:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) -sample->real(), (FixReal) -sample->imag()); storeSampleFixReal((FixReal) -sample->real(), (FixReal) -sample->imag());
// save result // save result
doFIR(sample); doFIR(sample);
// advance write-pointer // advance write-pointer
@ -181,7 +181,7 @@ public:
case 2: case 2:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sample->imag(), (FixReal) -sample->real()); storeSampleFixReal((FixReal) sample->imag(), (FixReal) -sample->real());
// advance write-pointer // advance write-pointer
advancePointer(); advancePointer();
// next state // next state
@ -191,7 +191,7 @@ public:
default: default:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sample->real(), (FixReal) sample->imag()); storeSampleFixReal((FixReal) sample->real(), (FixReal) sample->imag());
// save result // save result
doFIR(sample); doFIR(sample);
// advance write-pointer // advance write-pointer
@ -279,7 +279,7 @@ public:
{ {
case 0: case 0:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) 0, (FixReal) 0); storeSampleFixReal((FixReal) 0, (FixReal) 0);
// save result // save result
doFIR(&s); doFIR(&s);
@ -297,7 +297,7 @@ public:
case 1: case 1:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag());
// save result // save result
doFIR(&s); doFIR(&s);
@ -315,7 +315,7 @@ public:
case 2: case 2:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) 0, (FixReal) 0); storeSampleFixReal((FixReal) 0, (FixReal) 0);
// save result // save result
doFIR(&s); doFIR(&s);
@ -333,7 +333,7 @@ public:
default: default:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag());
// save result // save result
doFIR(&s); doFIR(&s);
@ -358,7 +358,7 @@ public:
{ {
case 0: case 0:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sample->imag(), (FixReal) -sample->real()); storeSampleFixReal((FixReal) sample->imag(), (FixReal) -sample->real());
// advance write-pointer // advance write-pointer
advancePointer(); advancePointer();
// next state // next state
@ -368,7 +368,7 @@ public:
case 1: case 1:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) -sample->real(), (FixReal) -sample->imag()); storeSampleFixReal((FixReal) -sample->real(), (FixReal) -sample->imag());
// save result // save result
doFIR(sample); doFIR(sample);
// advance write-pointer // advance write-pointer
@ -380,7 +380,7 @@ public:
case 2: case 2:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) -sample->imag(), (FixReal) sample->real()); storeSampleFixReal((FixReal) -sample->imag(), (FixReal) sample->real());
// advance write-pointer // advance write-pointer
advancePointer(); advancePointer();
// next state // next state
@ -390,7 +390,7 @@ public:
default: default:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sample->real(), (FixReal) sample->imag()); storeSampleFixReal((FixReal) sample->real(), (FixReal) sample->imag());
// save result // save result
doFIR(sample); doFIR(sample);
// advance write-pointer // advance write-pointer
@ -478,7 +478,7 @@ public:
{ {
case 0: case 0:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) 0, (FixReal) 0); storeSampleFixReal((FixReal) 0, (FixReal) 0);
// save result // save result
doFIR(&s); doFIR(&s);
@ -496,7 +496,7 @@ public:
case 1: case 1:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag());
// save result // save result
doFIR(&s); doFIR(&s);
@ -514,7 +514,7 @@ public:
case 2: case 2:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) 0, (FixReal) 0); storeSampleFixReal((FixReal) 0, (FixReal) 0);
// save result // save result
doFIR(&s); doFIR(&s);
@ -532,7 +532,7 @@ public:
default: default:
// insert sample into ring-buffer // insert sample into ring-buffer
storeSample((FixReal) sampleIn->real(), (FixReal) sampleIn->imag()); storeSampleFixReal((FixReal) sampleIn->real(), (FixReal) sampleIn->imag());
// save result // save result
doFIR(&s); doFIR(&s);
@ -552,47 +552,47 @@ public:
void myDecimate(const Sample* sample1, Sample* sample2) void myDecimate(const Sample* sample1, Sample* sample2)
{ {
storeSample((FixReal) sample1->real(), (FixReal) sample1->imag()); storeSampleFixReal((FixReal) sample1->real(), (FixReal) sample1->imag());
advancePointer(); advancePointer();
storeSample((FixReal) sample2->real(), (FixReal) sample2->imag()); storeSampleFixReal((FixReal) sample2->real(), (FixReal) sample2->imag());
doFIR(sample2); doFIR(sample2);
advancePointer(); 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(); advancePointer();
storeSample32(*x2, *y2); storeSampleAccu(*x2, *y2);
doFIR(x2, y2); doFIRAccu(x2, y2);
advancePointer(); advancePointer();
} }
/** Simple zero stuffing and filter */ /** Simple zero stuffing and filter */
void myInterpolateZeroStuffing(Sample* sample1, Sample* sample2) void myInterpolateZeroStuffing(Sample* sample1, Sample* sample2)
{ {
storeSample((FixReal) sample1->real(), (FixReal) sample1->imag()); storeSampleFixReal((FixReal) sample1->real(), (FixReal) sample1->imag());
doFIR(sample1); doFIR(sample1);
advancePointer(); advancePointer();
storeSample((FixReal) 0, (FixReal) 0); storeSampleFixReal((FixReal) 0, (FixReal) 0);
doFIR(sample2); doFIR(sample2);
advancePointer(); advancePointer();
} }
/** Simple zero stuffing and filter */ /** Simple zero stuffing and filter */
void myInterpolateZeroStuffing(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2) // void myInterpolateZeroStuffing(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2)
{ // {
storeSample32(*x1, *y1); // storeSampleAccu(*x1, *y1);
doFIR(x1, y1); // doFIR(x1, y1);
advancePointer(); // advancePointer();
//
storeSample32(0, 0); // storeSampleAccu(0, 0);
doFIR(x2, y2); // doFIR(x2, y2);
advancePointer(); // advancePointer();
} // }
/** Optimized upsampler by 2 not calculating FIR with inserted null samples */ /** Optimized upsampler by 2 not calculating FIR with inserted null samples */
void myInterpolate(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2) void myInterpolate(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2)
@ -624,7 +624,7 @@ protected:
int m_size; int m_size;
int m_state; 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][0] = sampleI;
m_samplesDB[m_ptr][1] = sampleQ; m_samplesDB[m_ptr][1] = sampleQ;
@ -632,7 +632,7 @@ protected:
m_samplesDB[m_ptr + m_size][1] = sampleQ; 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][0] = x;
m_samplesDB[m_ptr][1] = y; m_samplesDB[m_ptr][1] = y;
@ -660,8 +660,8 @@ protected:
b += 2; b += 2;
} }
iAcc += ((qint32)m_samplesDB[b-1][0]) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1); iAcc += m_samplesDB[b-1][0] << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
qAcc += ((qint32)m_samplesDB[b-1][1]) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1); qAcc += m_samplesDB[b-1][1] << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
sample->setReal(iAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1)); sample->setReal(iAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1));
sample->setImag(qAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1)); sample->setImag(qAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1));
@ -682,8 +682,30 @@ protected:
b += 2; b += 2;
} }
iAcc += ((qint32)m_samplesDB[b-1][0]) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1); iAcc += m_samplesDB[b-1][0] << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
qAcc += ((qint32)m_samplesDB[b-1][1]) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1); qAcc += m_samplesDB[b-1][1] << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
*x = iAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1); // HB_SHIFT incorrect do not loose the gained bit
*y = qAcc >> (HBFIRFilterTraits<HBFilterOrder>::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<HBFilterOrder>::hbOrder / 4; i++)
{
iAcc += (m_samplesDB[a][0] + m_samplesDB[b][0]) * HBFIRFilterTraits<HBFilterOrder>::hbCoeffs[i];
qAcc += (m_samplesDB[a][1] + m_samplesDB[b][1]) * HBFIRFilterTraits<HBFilterOrder>::hbCoeffs[i];
a -= 2;
b += 2;
}
iAcc += m_samplesDB[b-1][0] << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
qAcc += m_samplesDB[b-1][1] << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
*x = iAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1); // HB_SHIFT incorrect do not loose the gained bit *x = iAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1); // HB_SHIFT incorrect do not loose the gained bit
*y = qAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1); *y = qAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1);

View File

@ -207,7 +207,7 @@ void UpChannelizer::applyConfiguration()
} }
} }
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
UpChannelizer::FilterStage::FilterStage(Mode mode) : UpChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>), m_filter(new IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>),
m_workFunction(0) m_workFunction(0)

View File

@ -23,7 +23,7 @@
#include <QMutex> #include <QMutex>
#include "util/export.h" #include "util/export.h"
#include "util/message.h" #include "util/message.h"
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h" #include "dsp/inthalfbandfilterdb.h"
#else #else
#ifdef USE_SSE4_1 #ifdef USE_SSE4_1
@ -87,7 +87,7 @@ protected:
ModeUpperHalf ModeUpperHalf
}; };
#ifdef SAMPLE_24BIT #ifdef SDR_SAMPLE_24BIT
typedef bool (IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut); typedef bool (IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut);
IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>* m_filter; IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else #else