Implemented 24 bit internal DSP (with bugs ...)

This commit is contained in:
f4exb 2018-01-21 21:48:36 +01:00
parent 08ce7f423b
commit ad219d50cc
8 changed files with 267 additions and 1 deletions

View File

@ -28,6 +28,7 @@ option(V4L-MSI "Use Linux Kernel MSI2500 Source." OFF)
option(BUILD_TYPE "Build type (RELEASE, RELEASEWITHDBGINFO, DEBUG" RELEASE)
option(DEBUG_OUTPUT "Print debug messages" OFF)
option(HOST_RPI "Compiling on RPi" OFF)
option(SAMPLE_24BIT "Internal 24 bit DSP" OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
@ -186,6 +187,9 @@ elseif (${ARCHITECTURE} MATCHES "aarch64")
endif()
# Compiler flags.
if (SAMPLE_24BIT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSAMPLE_24BIT")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}")
##############################################################################

View File

@ -18,11 +18,15 @@
#define INCLUDE_GPL_DSP_DECIMATORS_H_
#include "dsp/dsptypes.h"
#ifdef SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
#include "dsp/inthalfbandfiltereo1.h"
#else
#include "dsp/inthalfbandfilterdb.h"
#endif
#endif
#define DECIMATORS_HB_FILTER_ORDER 64
@ -44,6 +48,42 @@ struct decimation_shifts
static const uint post64 = 0;
};
template<>
struct decimation_shifts<16, 24>
{
static const uint pre1 = 0;
static const uint pre2 = 0;
static const uint post2 = 9;
static const uint pre4 = 0;
static const uint post4 = 10;
static const uint pre8 = 0;
static const uint post8 = 11;
static const uint pre16 = 0;
static const uint post16 = 12;
static const uint pre32 = 0;
static const uint post32 = 13;
static const uint pre64 = 0;
static const uint post64 = 14;
};
template<>
struct decimation_shifts<24, 24>
{
static const uint pre1 = 0;
static const uint pre2 = 0;
static const uint post2 = 1;
static const uint pre4 = 0;
static const uint post4 = 2;
static const uint pre8 = 0;
static const uint post8 = 3;
static const uint pre16 = 0;
static const uint post16 = 4;
static const uint pre32 = 0;
static const uint post32 = 5;
static const uint pre64 = 0;
static const uint post64 = 6;
};
template<>
struct decimation_shifts<16, 16>
{
@ -62,6 +102,24 @@ struct decimation_shifts<16, 16>
static const uint post64 = 6;
};
template<>
struct decimation_shifts<24, 16>
{
static const uint pre1 = 8;
static const uint pre2 = 7;
static const uint post2 = 0;
static const uint pre4 = 6;
static const uint post4 = 0;
static const uint pre8 = 5;
static const uint post8 = 0;
static const uint pre16 = 4;
static const uint post16 = 0;
static const uint pre32 = 3;
static const uint post32 = 0;
static const uint pre64 = 2;
static const uint post64 = 0;
};
template<>
struct decimation_shifts<16, 12>
{
@ -80,6 +138,24 @@ struct decimation_shifts<16, 12>
static const uint post64 = 2;
};
template<>
struct decimation_shifts<24, 12>
{
static const uint pre1 = 12;
static const uint pre2 = 11;
static const uint post2 = 0;
static const uint pre4 = 10;
static const uint post4 = 0;
static const uint pre8 = 9;
static const uint post8 = 0;
static const uint pre16 = 8;
static const uint post16 = 0;
static const uint pre32 = 7;
static const uint post32 = 0;
static const uint pre64 = 6;
static const uint post64 = 0;
};
template<>
struct decimation_shifts<16, 8>
{
@ -98,6 +174,24 @@ struct decimation_shifts<16, 8>
static const uint post64 = 0;
};
template<>
struct decimation_shifts<24, 8>
{
static const uint pre1 = 16;
static const uint pre2 = 15;
static const uint post2 = 0;
static const uint pre4 = 14;
static const uint post4 = 0;
static const uint pre8 = 13;
static const uint post8 = 0;
static const uint pre16 = 12;
static const uint post16 = 0;
static const uint pre32 = 11;
static const uint post32 = 0;
static const uint pre64 = 10;
static const uint post64 = 0;
};
template<typename T, uint SdrBits, uint InputBits>
class Decimators
{
@ -146,6 +240,14 @@ public:
void decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len);
private:
#ifdef SAMPLE_24BIT
IntHalfbandFilterDB<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_decimator8; // 3rd stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#else
#ifdef USE_SSE4_1
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
@ -161,6 +263,7 @@ private:
IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#endif
#endif
};
template<typename T, uint SdrBits, uint InputBits>

View File

@ -24,11 +24,15 @@
#define INCLUDE_GPL_DSP_DECIMATORSU_H_
#include "dsp/dsptypes.h"
#ifdef SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
#include "dsp/inthalfbandfiltereo1.h"
#else
#include "dsp/inthalfbandfilterdb.h"
#endif
#endif
#define DECIMATORS_HB_FILTER_ORDER 64
@ -50,6 +54,24 @@ struct decimation_shifts
static const uint post64 = 0;
};
template<>
struct decimation_shifts<24, 24>
{
static const uint pre1 = 0;
static const uint pre2 = 0;
static const uint post2 = 1;
static const uint pre4 = 0;
static const uint post4 = 2;
static const uint pre8 = 0;
static const uint post8 = 3;
static const uint pre16 = 0;
static const uint post16 = 4;
static const uint pre32 = 0;
static const uint post32 = 5;
static const uint pre64 = 0;
static const uint post64 = 6;
};
template<>
struct decimation_shifts<16, 16>
{
@ -68,6 +90,24 @@ struct decimation_shifts<16, 16>
static const uint post64 = 6;
};
template<>
struct decimation_shifts<24, 16>
{
static const uint pre1 = 8;
static const uint pre2 = 7;
static const uint post2 = 0;
static const uint pre4 = 6;
static const uint post4 = 0;
static const uint pre8 = 5;
static const uint post8 = 0;
static const uint pre16 = 4;
static const uint post16 = 0;
static const uint pre32 = 3;
static const uint post32 = 0;
static const uint pre64 = 2;
static const uint post64 = 0;
};
template<>
struct decimation_shifts<16, 12>
{
@ -86,6 +126,24 @@ struct decimation_shifts<16, 12>
static const uint post64 = 2;
};
template<>
struct decimation_shifts<24, 12>
{
static const uint pre1 = 12;
static const uint pre2 = 11;
static const uint post2 = 0;
static const uint pre4 = 10;
static const uint post4 = 0;
static const uint pre8 = 9;
static const uint post8 = 0;
static const uint pre16 = 8;
static const uint post16 = 0;
static const uint pre32 = 7;
static const uint post32 = 0;
static const uint pre64 = 6;
static const uint post64 = 0;
};
template<>
struct decimation_shifts<16, 8>
{
@ -104,6 +162,24 @@ struct decimation_shifts<16, 8>
static const uint post64 = 0;
};
template<>
struct decimation_shifts<24, 8>
{
static const uint pre1 = 16;
static const uint pre2 = 15;
static const uint post2 = 0;
static const uint pre4 = 14;
static const uint post4 = 0;
static const uint pre8 = 13;
static const uint post8 = 0;
static const uint pre16 = 12;
static const uint post16 = 0;
static const uint pre32 = 11;
static const uint post32 = 0;
static const uint pre64 = 10;
static const uint post64 = 0;
};
template<typename T, uint SdrBits, uint InputBits, int Shift>
class DecimatorsU
{
@ -130,6 +206,14 @@ public:
void decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len);
private:
#ifdef SAMPLE_24BIT
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_decimator8; // 3rd stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#else
#ifdef USE_SSE4_1
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
@ -145,6 +229,7 @@ private:
IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
IntHalfbandFilterDB<qint32, DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
#endif
#endif
};
template<typename T, uint SdrBits, uint InputBits, int Shift>

View File

@ -192,6 +192,28 @@ void DownChannelizer::applyConfiguration()
}
}
#ifdef SAMPLE_24BIT
DownChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>),
m_workFunction(0),
m_mode(mode),
m_sse(false)
{
switch(mode) {
case ModeCenter:
m_workFunction = &IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateCenter;
break;
case ModeLowerHalf:
m_workFunction = &IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateLowerHalf;
break;
case ModeUpperHalf:
m_workFunction = &IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::workDecimateUpperHalf;
break;
}
}
#else
#ifdef USE_SSE4_1
DownChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterEO1<DOWNCHANNELIZER_HB_FILTER_ORDER>),
@ -235,7 +257,7 @@ DownChannelizer::FilterStage::FilterStage(Mode mode) :
}
}
#endif
#endif
DownChannelizer::FilterStage::~FilterStage()
{
delete m_filter;

View File

@ -23,11 +23,15 @@
#include <QMutex>
#include "util/export.h"
#include "util/message.h"
#ifdef SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
#include "dsp/inthalfbandfiltereo1.h"
#else
#include "dsp/inthalfbandfilterdb.h"
#endif
#endif
#define DOWNCHANNELIZER_HB_FILTER_ORDER 48
@ -78,12 +82,17 @@ protected:
ModeUpperHalf
};
#ifdef SAMPLE_24BIT
typedef bool (IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else
#ifdef USE_SSE4_1
typedef bool (IntHalfbandFilterEO1<DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
IntHalfbandFilterEO1<DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else
typedef bool (IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
IntHalfbandFilterDB<qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#endif
#endif
WorkFunction m_workFunction;
Mode m_mode;

View File

@ -18,11 +18,15 @@
#define INCLUDE_GPL_DSP_INTERPOLATORS_H_
#include "dsp/dsptypes.h"
#ifdef SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
#include "dsp/inthalfbandfiltereo1.h"
#else
#include "dsp/inthalfbandfilterdb.h"
#endif
#endif
#define INTERPOLATORS_HB_FILTER_ORDER_FIRST 64
#define INTERPOLATORS_HB_FILTER_ORDER_SECOND 32
@ -114,6 +118,14 @@ public:
void interpolate64_cen(SampleVector::iterator* it, T* buf, qint32 len);
private:
#ifdef SAMPLE_24BIT
IntHalfbandFilterDB<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_NEXT> m_interpolator8; // 3rd stages
IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator16; // 4th stages
IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator32; // 5th stages
IntHalfbandFilterDB<qint64, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator64; // 6th stages
#else
#ifdef USE_SSE4_1
IntHalfbandFilterEO1<INTERPOLATORS_HB_FILTER_ORDER_FIRST> m_interpolator2; // 1st stages
IntHalfbandFilterEO1<INTERPOLATORS_HB_FILTER_ORDER_SECOND> m_interpolator4; // 2nd stages
@ -129,6 +141,7 @@ private:
IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator32; // 5th stages
IntHalfbandFilterDB<qint32, INTERPOLATORS_HB_FILTER_ORDER_NEXT> m_interpolator64; // 6th stages
#endif
#endif
};
template<typename T, uint SdrBits, uint OutputBits>

View File

@ -207,6 +207,26 @@ void UpChannelizer::applyConfiguration()
}
}
#ifdef SAMPLE_24BIT
UpChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>),
m_workFunction(0)
{
switch(mode) {
case ModeCenter:
m_workFunction = &IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateCenter;
break;
case ModeLowerHalf:
m_workFunction = &IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateLowerHalf;
break;
case ModeUpperHalf:
m_workFunction = &IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>::workInterpolateUpperHalf;
break;
}
}
#else
#ifdef USE_SSE4_1
UpChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>),
@ -246,6 +266,7 @@ UpChannelizer::FilterStage::FilterStage(Mode mode) :
}
}
#endif
#endif
UpChannelizer::FilterStage::~FilterStage()
{

View File

@ -23,11 +23,15 @@
#include <QMutex>
#include "util/export.h"
#include "util/message.h"
#ifdef SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
#include "dsp/inthalfbandfiltereo1.h"
#else
#include "dsp/inthalfbandfilterdb.h"
#endif
#endif
#define UPCHANNELIZER_HB_FILTER_ORDER 96
@ -83,12 +87,17 @@ protected:
ModeUpperHalf
};
#ifdef SAMPLE_24BIT
typedef bool (IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut);
IntHalfbandFilterDB<qint64, UPCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else
#ifdef USE_SSE4_1
typedef bool (IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut);
IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else
typedef bool (IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut);
IntHalfbandFilterDB<qint32, UPCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#endif
#endif
WorkFunction m_workFunction;