mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
Deep redesign: do decimation chain fully on 32 bit signed integers
This commit is contained in:
parent
a559035e22
commit
107efd3691
@ -101,7 +101,7 @@ private:
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal, yimag;
|
||||
qint32 xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < len; pos += 2)
|
||||
{
|
||||
@ -116,7 +116,7 @@ void Decimators<T, SdrBits, InputBits>::decimate1(SampleVector::iterator* it, co
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate2_u(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal, yimag;
|
||||
qint32 xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < len - 7; pos += 8)
|
||||
{
|
||||
@ -137,7 +137,7 @@ void Decimators<T, SdrBits, InputBits>::decimate2_u(SampleVector::iterator* it,
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal, yimag;
|
||||
qint32 xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < len - 7; pos += 8)
|
||||
{
|
||||
@ -158,7 +158,7 @@ void Decimators<T, SdrBits, InputBits>::decimate2_inf(SampleVector::iterator* it
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal, yimag;
|
||||
qint32 xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < len - 7; pos += 8)
|
||||
{
|
||||
@ -183,8 +183,8 @@ void Decimators<T, SdrBits, InputBits>::decimate2_cen(SampleVector::iterator* it
|
||||
|
||||
while (pos < len - 3)
|
||||
{
|
||||
qint16 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre2;
|
||||
qint16 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::pre2;
|
||||
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))
|
||||
@ -203,14 +203,14 @@ void Decimators<T, SdrBits, InputBits>::decimate4_cen(SampleVector::iterator* it
|
||||
|
||||
while (pos < len)
|
||||
{
|
||||
qint16 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre4;
|
||||
qint16 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::pre4;
|
||||
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))
|
||||
{
|
||||
qint16 x1 = x0;
|
||||
qint16 y1 = y0;
|
||||
qint32 x1 = x0;
|
||||
qint32 y1 = y0;
|
||||
|
||||
if (m_decimator4.workDecimateCenter(&x1, &y1))
|
||||
{
|
||||
@ -229,19 +229,19 @@ void Decimators<T, SdrBits, InputBits>::decimate8_cen(SampleVector::iterator* it
|
||||
|
||||
while (pos < len)
|
||||
{
|
||||
qint16 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre8;
|
||||
qint16 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::pre8;
|
||||
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))
|
||||
{
|
||||
qint16 x1 = x0;
|
||||
qint16 y1 = y0;
|
||||
qint32 x1 = x0;
|
||||
qint32 y1 = y0;
|
||||
|
||||
if (m_decimator4.workDecimateCenter(&x1, &y1))
|
||||
{
|
||||
qint16 x2 = x1;
|
||||
qint16 y2 = y1;
|
||||
qint32 x2 = x1;
|
||||
qint32 y2 = y1;
|
||||
|
||||
if (m_decimator8.workDecimateCenter(&x2, &y2))
|
||||
{
|
||||
@ -261,24 +261,24 @@ void Decimators<T, SdrBits, InputBits>::decimate16_cen(SampleVector::iterator* i
|
||||
|
||||
while (pos < len)
|
||||
{
|
||||
qint16 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre16;
|
||||
qint16 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::pre16;
|
||||
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))
|
||||
{
|
||||
qint16 x1 = x0;
|
||||
qint16 y1 = y0;
|
||||
qint32 x1 = x0;
|
||||
qint32 y1 = y0;
|
||||
|
||||
if (m_decimator4.workDecimateCenter(&x1, &y1))
|
||||
{
|
||||
qint16 x2 = x1;
|
||||
qint16 y2 = y1;
|
||||
qint32 x2 = x1;
|
||||
qint32 y2 = y1;
|
||||
|
||||
if (m_decimator8.workDecimateCenter(&x2, &y2))
|
||||
{
|
||||
qint16 x3 = x2;
|
||||
qint16 y3 = y2;
|
||||
qint32 x3 = x2;
|
||||
qint32 y3 = y2;
|
||||
|
||||
if (m_decimator16.workDecimateCenter(&x3, &y3))
|
||||
{
|
||||
@ -299,29 +299,29 @@ void Decimators<T, SdrBits, InputBits>::decimate32_cen(SampleVector::iterator* i
|
||||
|
||||
while (pos < len)
|
||||
{
|
||||
qint16 x0 = buf[pos+0] << decimation_shifts<SdrBits, InputBits>::pre32;
|
||||
qint16 y0 = buf[pos+1] << decimation_shifts<SdrBits, InputBits>::pre32;
|
||||
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))
|
||||
{
|
||||
qint16 x1 = x0;
|
||||
qint16 y1 = y0;
|
||||
qint32 x1 = x0;
|
||||
qint32 y1 = y0;
|
||||
|
||||
if (m_decimator4.workDecimateCenter(&x1, &y1))
|
||||
{
|
||||
qint16 x2 = x1;
|
||||
qint16 y2 = y1;
|
||||
qint32 x2 = x1;
|
||||
qint32 y2 = y1;
|
||||
|
||||
if (m_decimator8.workDecimateCenter(&x2, &y2))
|
||||
{
|
||||
qint16 x3 = x2;
|
||||
qint16 y3 = y2;
|
||||
qint32 x3 = x2;
|
||||
qint32 y3 = y2;
|
||||
|
||||
if (m_decimator16.workDecimateCenter(&x3, &y3))
|
||||
{
|
||||
qint16 x4 = x3;
|
||||
qint16 y4 = y3;
|
||||
qint32 x4 = x3;
|
||||
qint32 y4 = y3;
|
||||
|
||||
if (m_decimator32.workDecimateCenter(&x4, &y4))
|
||||
{
|
||||
@ -339,7 +339,7 @@ void Decimators<T, SdrBits, InputBits>::decimate32_cen(SampleVector::iterator* i
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal, yimag;
|
||||
qint32 xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < len - 7; pos += 8)
|
||||
{
|
||||
@ -362,7 +362,7 @@ void Decimators<T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it
|
||||
// Inf (LSB):
|
||||
// x y x y x y x y / x -> 0,-3,-4,7 / y -> 1,2,-5,-6
|
||||
// [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
|
||||
qint16 xreal, yimag;
|
||||
qint32 xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < len - 7; pos += 8)
|
||||
{
|
||||
@ -379,7 +379,7 @@ void Decimators<T, SdrBits, InputBits>::decimate4_sup(SampleVector::iterator* it
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal[2], yimag[2];
|
||||
qint32 xreal[2], yimag[2];
|
||||
|
||||
for (int pos = 0; pos < len - 15; pos += 8)
|
||||
{
|
||||
@ -402,7 +402,7 @@ void Decimators<T, SdrBits, InputBits>::decimate8_inf(SampleVector::iterator* it
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal[2], yimag[2];
|
||||
qint32 xreal[2], yimag[2];
|
||||
|
||||
for (int pos = 0; pos < len - 15; pos += 8)
|
||||
{
|
||||
@ -427,7 +427,7 @@ void Decimators<T, SdrBits, InputBits>::decimate16_inf(SampleVector::iterator* i
|
||||
{
|
||||
// Offset tuning: 4x downsample and rotate, then
|
||||
// downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
|
||||
qint16 xreal[4], yimag[4];
|
||||
qint32 xreal[4], yimag[4];
|
||||
|
||||
for (int pos = 0; pos < len - 31; )
|
||||
{
|
||||
@ -455,7 +455,7 @@ void Decimators<T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* i
|
||||
{
|
||||
// Offset tuning: 4x downsample and rotate, then
|
||||
// downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7]
|
||||
qint16 xreal[4], yimag[4];
|
||||
qint32 xreal[4], yimag[4];
|
||||
|
||||
for (int pos = 0; pos < len - 31; )
|
||||
{
|
||||
@ -481,7 +481,7 @@ void Decimators<T, SdrBits, InputBits>::decimate16_sup(SampleVector::iterator* i
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal[8], yimag[8];
|
||||
qint32 xreal[8], yimag[8];
|
||||
|
||||
for (int pos = 0; pos < len - 63; )
|
||||
{
|
||||
@ -512,7 +512,7 @@ void Decimators<T, SdrBits, InputBits>::decimate32_inf(SampleVector::iterator* i
|
||||
template<typename T, uint SdrBits, uint InputBits>
|
||||
void Decimators<T, SdrBits, InputBits>::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal[8], yimag[8];
|
||||
qint32 xreal[8], yimag[8];
|
||||
|
||||
for (int pos = 0; pos < len - 63; )
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool workDecimateCenter(qint16 *x, qint16 *y)
|
||||
bool workDecimateCenter(qint32 *x, qint32 *y)
|
||||
{
|
||||
// insert sample into ring-buffer
|
||||
m_samples[m_ptr][0] = *x;
|
||||
@ -277,7 +277,7 @@ public:
|
||||
m_ptr = mod33[m_ptr + 2 - 1];
|
||||
}
|
||||
|
||||
void myDecimate(qint16 x1, qint16 y1, qint16 *x2, qint16 *y2)
|
||||
void myDecimate(qint32 x1, qint32 y1, qint32 *x2, qint32 *y2)
|
||||
{
|
||||
static const qint16 mod33[38] = { 31,32,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
|
||||
20,21,22,23,24,25,26,27,28,29,30,31,32,0,1,2};
|
||||
@ -385,7 +385,7 @@ protected:
|
||||
sample->setImag(qAcc >> HB_SHIFT);
|
||||
}
|
||||
|
||||
void doFIR(qint16 *x, qint16 *y)
|
||||
void doFIR(qint32 *x, qint32 *y)
|
||||
{
|
||||
// coefficents
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user