PlutoSDR input: restored soft decimation

This commit is contained in:
f4exb 2017-09-10 12:27:28 +02:00
parent 97c137197b
commit 6a229bef10
2 changed files with 27 additions and 30 deletions

View File

@ -23,7 +23,7 @@ PlutoSDRInputThread::PlutoSDRInputThread(uint32_t blocksize, DevicePlutoSDRBox*
m_running(false),
m_plutoBox(plutoBox),
m_blockSize(blocksize),
m_convertBuffer(1<<15),
m_convertBuffer(blocksize),
m_sampleFifo(sampleFifo),
m_convertIt(m_convertBuffer.begin()),
m_log2Decim(0),
@ -95,18 +95,21 @@ void PlutoSDRInputThread::run()
is++;
}
m_sampleFifo->write((unsigned char *) m_buf, is*2*sizeof(int16_t));
//m_sampleFifo->write((unsigned char *) m_buf, is*2*sizeof(int16_t));
convert(m_buf, 2 * m_blockSize);
}
m_running = false;
}
// Decimate according to specified log2 (ex: log2=4 => decim=16)
void PlutoSDRInputThread::convert()
void PlutoSDRInputThread::convert(const qint16* buf, qint32 len)
{
SampleVector::iterator it = m_convertBuffer.begin();
if (m_log2Decim == 0)
{
m_decimators.decimate1(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate1(&it, buf, len);
}
else
{
@ -115,22 +118,22 @@ void PlutoSDRInputThread::convert()
switch (m_log2Decim)
{
case 1:
m_decimators.decimate2_inf(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate2_inf(&it, buf, len);
break;
case 2:
m_decimators.decimate4_inf(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate4_inf(&it, buf, len);
break;
case 3:
m_decimators.decimate8_inf(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate8_inf(&it, buf, len);
break;
case 4:
m_decimators.decimate16_inf(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate16_inf(&it, buf, len);
break;
case 5:
m_decimators.decimate32_inf(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate32_inf(&it, buf, len);
break;
case 6:
m_decimators.decimate64_inf(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate64_inf(&it, buf, len);
break;
default:
break;
@ -141,22 +144,22 @@ void PlutoSDRInputThread::convert()
switch (m_log2Decim)
{
case 1:
m_decimators.decimate2_sup(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate2_sup(&it, buf, len);
break;
case 2:
m_decimators.decimate4_sup(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate4_sup(&it, buf, len);
break;
case 3:
m_decimators.decimate8_sup(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate8_sup(&it, buf, len);
break;
case 4:
m_decimators.decimate16_sup(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate16_sup(&it, buf, len);
break;
case 5:
m_decimators.decimate32_sup(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate32_sup(&it, buf, len);
break;
case 6:
m_decimators.decimate64_sup(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate64_sup(&it, buf, len);
break;
default:
break;
@ -167,22 +170,22 @@ void PlutoSDRInputThread::convert()
switch (m_log2Decim)
{
case 1:
m_decimators.decimate2_cen(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate2_cen(&it, buf, len);
break;
case 2:
m_decimators.decimate4_cen(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate4_cen(&it, buf, len);
break;
case 3:
m_decimators.decimate8_cen(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate8_cen(&it, buf, len);
break;
case 4:
m_decimators.decimate16_cen(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate16_cen(&it, buf, len);
break;
case 5:
m_decimators.decimate32_cen(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate32_cen(&it, buf, len);
break;
case 6:
m_decimators.decimate64_cen(&m_convertIt, m_buf, 2*(1<<m_log2Decim));
m_decimators.decimate64_cen(&it, buf, len);
break;
default:
break;
@ -190,12 +193,6 @@ void PlutoSDRInputThread::convert()
}
}
++m_convertIt;
if (m_convertIt == m_convertBuffer.end())
{
m_sampleFifo->write(m_convertBuffer.begin(), m_convertBuffer.end());
m_convertIt = m_convertBuffer.begin();
}
m_sampleFifo->write(m_convertBuffer.begin(), it);
}

View File

@ -61,7 +61,7 @@ private:
Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators;
void run();
void convert();
void convert(const qint16* buf, qint32 len);
};