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

Templatize the accumulator type of integer half-band filters (non SIMD)

This commit is contained in:
f4exb 2018-01-21 19:39:51 +01:00
parent 8cd462a338
commit 08ce7f423b
10 changed files with 58 additions and 58 deletions

View File

@ -154,12 +154,12 @@ private:
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#else #else
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#endif #endif
}; };

View File

@ -138,12 +138,12 @@ private:
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#else #else
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#endif #endif
}; };

View File

@ -215,22 +215,22 @@ DownChannelizer::FilterStage::FilterStage(Mode mode) :
} }
#else #else
DownChannelizer::FilterStage::FilterStage(Mode mode) : DownChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterDB<DOWNCHANNELIZER_HB_FILTER_ORDER>), m_filter(new IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>),
m_workFunction(0), m_workFunction(0),
m_mode(mode), m_mode(mode),
m_sse(false) m_sse(false)
{ {
switch(mode) { switch(mode) {
case ModeCenter: case ModeCenter:
m_workFunction = &IntHalfbandFilterDB<DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateCenter; m_workFunction = &IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateCenter;
break; break;
case ModeLowerHalf: case ModeLowerHalf:
m_workFunction = &IntHalfbandFilterDB<DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateLowerHalf; m_workFunction = &IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateLowerHalf;
break; break;
case ModeUpperHalf: case ModeUpperHalf:
m_workFunction = &IntHalfbandFilterDB<DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateUpperHalf; m_workFunction = &IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateUpperHalf;
break; break;
} }
} }

View File

@ -82,8 +82,8 @@ protected:
typedef bool (IntHalfbandFilterEO1<DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s); typedef bool (IntHalfbandFilterEO1<DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
IntHalfbandFilterEO1<DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter; IntHalfbandFilterEO1<DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else #else
typedef bool (IntHalfbandFilterDB<DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s); typedef bool (IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
IntHalfbandFilterDB<DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter; IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#endif #endif
WorkFunction m_workFunction; WorkFunction m_workFunction;
Mode m_mode; Mode m_mode;

View File

@ -122,12 +122,12 @@ private:
IntHalfbandFilterEO1<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator32; // 5th stages IntHalfbandFilterEO1<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator32; // 5th stages
IntHalfbandFilterEO1<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator64; // 6th stages IntHalfbandFilterEO1<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator64; // 6th stages
#else #else
IntHalfbandFilterDB<INTERPOLATORS_HB_FILTER_ORDER_FIRST> m_interpolator2; // 1st stages IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_FIRST> m_interpolator2; // 1st stages
IntHalfbandFilterDB<INTERPOLATORS_HB_FILTER_ORDER_SECOND> m_interpolator4; // 2nd stages IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_SECOND> m_interpolator4; // 2nd stages
IntHalfbandFilterDB<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator8; // 3rd stages IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator8; // 3rd stages
IntHalfbandFilterDB<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator16; // 4th stages IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator16; // 4th stages
IntHalfbandFilterDB<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator32; // 5th stages IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator32; // 5th stages
IntHalfbandFilterDB<INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator64; // 6th stages IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator64; // 6th stages
#endif #endif
}; };

View File

@ -23,7 +23,7 @@
#include "dsp/hbfiltertraits.h" #include "dsp/hbfiltertraits.h"
#include "util/export.h" #include "util/export.h"
template<uint32_t HBFilterOrder> template<typename AccuType, uint32_t HBFilterOrder>
class SDRANGEL_API IntHalfbandFilter { class SDRANGEL_API IntHalfbandFilter {
public: public:
IntHalfbandFilter() : IntHalfbandFilter() :
@ -748,7 +748,7 @@ public:
} }
protected: protected:
qint32 m_samples[HBFIRFilterTraits<HBFilterOrder>::hbOrder + 1][2]; // Valgrind optim (from qint16) AccuType m_samples[HBFIRFilterTraits<HBFilterOrder>::hbOrder + 1][2]; // Valgrind optim (from qint16)
qint16 m_ptr; qint16 m_ptr;
int m_state; int m_state;
@ -759,8 +759,8 @@ protected:
int b = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 - 2]; //-1 - 1 int b = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 - 2]; //-1 - 1
// go through samples in buffer // go through samples in buffer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {
@ -790,8 +790,8 @@ protected:
qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1; qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1;
// go through samples in buffer // go through samples in buffer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {
@ -811,8 +811,8 @@ protected:
qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1; qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1;
// go through samples in buffer // go through samples in buffer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {
@ -839,8 +839,8 @@ protected:
int b = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 - 2]; //-1 - 1 int b = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 - 2]; //-1 - 1
// go through samples in buffer // go through samples in buffer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {

View File

@ -26,7 +26,7 @@
#include "dsp/hbfiltertraits.h" #include "dsp/hbfiltertraits.h"
#include "util/export.h" #include "util/export.h"
template<uint32_t HBFilterOrder> template<typename AccuType, uint32_t HBFilterOrder>
class SDRANGEL_API IntHalfbandFilterDB { class SDRANGEL_API IntHalfbandFilterDB {
public: public:
IntHalfbandFilterDB(); IntHalfbandFilterDB();
@ -619,7 +619,7 @@ public:
} }
protected: protected:
qint32 m_samplesDB[2*(HBFIRFilterTraits<HBFilterOrder>::hbOrder - 1)][2]; // double buffer technique AccuType m_samplesDB[2*(HBFIRFilterTraits<HBFilterOrder>::hbOrder - 1)][2]; // double buffer technique
int m_ptr; int m_ptr;
int m_size; int m_size;
int m_state; int m_state;
@ -649,8 +649,8 @@ protected:
{ {
int a = m_ptr + m_size; // tip pointer int a = m_ptr + m_size; // tip pointer
int b = m_ptr + 1; // tail pointer int b = m_ptr + 1; // tail pointer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {
@ -671,8 +671,8 @@ protected:
{ {
int a = m_ptr + m_size; // tip pointer int a = m_ptr + m_size; // tip pointer
int b = m_ptr + 1; // tail pointer int b = m_ptr + 1; // tail pointer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {
@ -695,8 +695,8 @@ protected:
qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1; qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1;
// go through samples in buffer // go through samples in buffer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {
@ -716,8 +716,8 @@ protected:
qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1; qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1;
// go through samples in buffer // go through samples in buffer
qint32 iAcc = 0; AccuType iAcc = 0;
qint32 qAcc = 0; AccuType qAcc = 0;
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++) for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
{ {
@ -732,8 +732,8 @@ protected:
} }
}; };
template<uint32_t HBFilterOrder> template<typename AccuType, uint32_t HBFilterOrder>
IntHalfbandFilterDB<HBFilterOrder>::IntHalfbandFilterDB() IntHalfbandFilterDB<AccuType, HBFilterOrder>::IntHalfbandFilterDB()
{ {
m_size = HBFIRFilterTraits<HBFilterOrder>::hbOrder - 1; m_size = HBFIRFilterTraits<HBFilterOrder>::hbOrder - 1;

View File

@ -120,12 +120,12 @@ public:
void decimate64_cen(SampleSinkFifoDoubleBuffered& fifo, const T* buf, qint32 len); void decimate64_cen(SampleSinkFifoDoubleBuffered& fifo, const T* buf, qint32 len);
private: private:
IntHalfbandFilter<32> m_decimator2; // 1st stages IntHalfbandFilter<qint32, 32> m_decimator2; // 1st stages
IntHalfbandFilter<32> m_decimator4; // 2nd stages IntHalfbandFilter<qint32, 32> m_decimator4; // 2nd stages
IntHalfbandFilter<32> m_decimator8; // 3rd stages IntHalfbandFilter<qint32, 32> m_decimator8; // 3rd stages
IntHalfbandFilter<32> m_decimator16; // 4th stages IntHalfbandFilter<qint32, 32> m_decimator16; // 4th stages
IntHalfbandFilter<32> m_decimator32; // 5th stages IntHalfbandFilter<qint32, 32> m_decimator32; // 5th stages
IntHalfbandFilter<32> m_decimator64; // 6th stages IntHalfbandFilter<qint32, 32> m_decimator64; // 6th stages
}; };
template<typename T, uint32_t SdrBits, uint32_t InputBits> template<typename T, uint32_t SdrBits, uint32_t InputBits>

View File

@ -228,20 +228,20 @@ UpChannelizer::FilterStage::FilterStage(Mode mode) :
} }
#else #else
UpChannelizer::FilterStage::FilterStage(Mode mode) : UpChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterDB<UPCHANNELIZER_HB_FILTER_ORDER>), m_filter(new IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>),
m_workFunction(0) m_workFunction(0)
{ {
switch(mode) { switch(mode) {
case ModeCenter: case ModeCenter:
m_workFunction = &IntHalfbandFilterDB<UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateCenter; m_workFunction = &IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateCenter;
break; break;
case ModeLowerHalf: case ModeLowerHalf:
m_workFunction = &IntHalfbandFilterDB<UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateLowerHalf; m_workFunction = &IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateLowerHalf;
break; break;
case ModeUpperHalf: case ModeUpperHalf:
m_workFunction = &IntHalfbandFilterDB<UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateUpperHalf; m_workFunction = &IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateUpperHalf;
break; break;
} }
} }

View File

@ -87,8 +87,8 @@ protected:
typedef bool (IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut); typedef bool (IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut);
IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>* m_filter; IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else #else
typedef bool (IntHalfbandFilterDB<UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut); typedef bool (IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut);
IntHalfbandFilterDB<UPCHANNELIZER_HB_FILTER_ORDER>* m_filter; IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#endif #endif
WorkFunction m_workFunction; WorkFunction m_workFunction;