From cc5d614f670e0eaf2fb84b5cdc0c8ab1948b2e3b Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 21 Jun 2020 11:46:08 +0200 Subject: [PATCH] IQ swap: initial implementation in plugins --- plugins/samplesource/airspy/airspyinput.cpp | 24 +- .../samplesource/airspy/airspysettings.cpp | 3 + plugins/samplesource/airspy/airspysettings.h | 1 + plugins/samplesource/airspy/airspythread.cpp | 145 ++- plugins/samplesource/airspy/airspythread.h | 8 +- .../samplesource/airspyhf/airspyhfinput.cpp | 22 +- .../airspyhf/airspyhfsettings.cpp | 3 + .../samplesource/airspyhf/airspyhfsettings.h | 1 + .../samplesource/airspyhf/airspyhfthread.cpp | 62 +- .../samplesource/airspyhf/airspyhfthread.h | 8 +- .../bladerf1input/bladerf1input.cpp | 20 +- .../bladerf1input/bladerf1inputsettings.cpp | 3 + .../bladerf1input/bladerf1inputsettings.h | 1 + .../bladerf1input/bladerf1inputthread.cpp | 143 ++- .../bladerf1input/bladerf1inputthread.h | 8 +- .../bladerf2input/bladerf2input.cpp | 25 +- .../bladerf2input/bladerf2inputsettings.cpp | 3 + .../bladerf2input/bladerf2inputsettings.h | 1 + .../bladerf2input/bladerf2inputthread.cpp | 157 ++- .../bladerf2input/bladerf2inputthread.h | 8 +- plugins/samplesource/fcdpro/fcdproinput.cpp | 20 +- .../samplesource/fcdpro/fcdprosettings.cpp | 3 + plugins/samplesource/fcdpro/fcdprosettings.h | 1 + plugins/samplesource/fcdpro/fcdprothread.cpp | 144 ++- plugins/samplesource/fcdpro/fcdprothread.h | 9 +- .../fcdproplus/fcdproplusinput.cpp | 20 +- .../fcdproplus/fcdproplussettings.cpp | 4 + .../fcdproplus/fcdproplussettings.h | 1 + .../fcdproplus/fcdproplusthread.cpp | 144 ++- .../fcdproplus/fcdproplusthread.h | 8 +- .../samplesource/hackrfinput/hackrfinput.cpp | 25 +- .../hackrfinput/hackrfinputsettings.cpp | 3 + .../hackrfinput/hackrfinputsettings.h | 1 + .../hackrfinput/hackrfinputthread.cpp | 145 ++- .../hackrfinput/hackrfinputthread.h | 8 +- .../limesdrinput/limesdrinput.cpp | 15 +- .../limesdrinput/limesdrinputsettings.cpp | 3 + .../limesdrinput/limesdrinputsettings.h | 1 + .../limesdrinput/limesdrinputthread.cpp | 58 +- .../limesdrinput/limesdrinputthread.h | 8 +- plugins/samplesource/perseus/perseusinput.cpp | 18 +- .../samplesource/perseus/perseussettings.cpp | 3 + .../samplesource/perseus/perseussettings.h | 1 + .../samplesource/perseus/perseusthread.cpp | 43 +- plugins/samplesource/perseus/perseusthread.h | 11 +- .../plutosdrinput/plutosdrinput.cpp | 20 +- .../plutosdrinput/plutosdrinputsettings.cpp | 3 + .../plutosdrinput/plutosdrinputsettings.h | 1 + .../plutosdrinput/plutosdrinputthread.cpp | 142 +- .../plutosdrinput/plutosdrinputthread.h | 9 +- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 21 +- .../samplesource/rtlsdr/rtlsdrsettings.cpp | 3 + plugins/samplesource/rtlsdr/rtlsdrsettings.h | 1 + plugins/samplesource/rtlsdr/rtlsdrthread.cpp | 148 ++- plugins/samplesource/rtlsdr/rtlsdrthread.h | 8 +- plugins/samplesource/sdrplay/sdrplayinput.cpp | 23 +- .../samplesource/sdrplay/sdrplaysettings.cpp | 3 + .../samplesource/sdrplay/sdrplaysettings.h | 1 + .../samplesource/sdrplay/sdrplaythread.cpp | 148 ++- plugins/samplesource/sdrplay/sdrplaythread.h | 8 +- .../soapysdrinput/soapysdrinput.cpp | 26 +- .../soapysdrinput/soapysdrinputsettings.cpp | 3 + .../soapysdrinput/soapysdrinputsettings.h | 1 + .../soapysdrinput/soapysdrinputthread.cpp | 626 +++++++-- .../soapysdrinput/soapysdrinputthread.h | 32 +- .../testsource/testsourcethread.h | 6 +- plugins/samplesource/xtrxinput/xtrxinput.cpp | 27 +- .../xtrxinput/xtrxinputsettings.cpp | 3 + .../xtrxinput/xtrxinputsettings.h | 1 + .../xtrxinput/xtrxinputthread.cpp | 85 +- .../samplesource/xtrxinput/xtrxinputthread.h | 8 +- sdrbase/dsp/decimators.h | 198 +-- sdrbase/dsp/decimatorsff.cpp | 1144 ++--------------- sdrbase/dsp/decimatorsff.h | 1088 +++++++++++++++- sdrbase/dsp/decimatorsfi.cpp | 1143 ++-------------- sdrbase/dsp/decimatorsfi.h | 1088 +++++++++++++++- sdrbase/dsp/decimatorsif.h | 126 +- sdrbase/dsp/decimatorsu.h | 106 +- sdrbase/dsp/downchannelizer.cpp | 16 +- sdrbase/dsp/downchannelizer.h | 8 +- sdrbase/dsp/inthalfbandfiltereo.h | 34 +- sdrbase/dsp/inthalfbandfiltereof.h | 22 +- sdrbench/mainbench.h | 8 +- 83 files changed, 4846 insertions(+), 2835 deletions(-) diff --git a/plugins/samplesource/airspy/airspyinput.cpp b/plugins/samplesource/airspy/airspyinput.cpp index c2645e7e1..0c3ac675c 100644 --- a/plugins/samplesource/airspy/airspyinput.cpp +++ b/plugins/samplesource/airspy/airspyinput.cpp @@ -50,8 +50,8 @@ const qint64 AirspyInput::loHighLimitFreq = 1900000000L; AirspyInput::AirspyInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), - m_dev(0), - m_airspyThread(0), + m_dev(nullptr), + m_airspyThread(nullptr), m_deviceDescription("Airspy"), m_running(false) { @@ -181,6 +181,7 @@ bool AirspyInput::start() m_airspyThread = new AirspyThread(m_dev, &m_sampleFifo); m_airspyThread->setSamplerate(m_sampleRates[m_settings.m_devSampleRateIndex]); m_airspyThread->setLog2Decimation(m_settings.m_log2Decim); + m_airspyThread->setIQOrder(m_settings.m_iqOrder); m_airspyThread->setFcPos((int) m_settings.m_fcPos); m_airspyThread->startWork(); @@ -213,11 +214,11 @@ void AirspyInput::stop() qDebug("AirspyInput::stop"); QMutexLocker mutexLocker(&m_mutex); - if (m_airspyThread != 0) + if (m_airspyThread) { m_airspyThread->stopWork(); delete m_airspyThread; - m_airspyThread = 0; + m_airspyThread = nullptr; } m_running = false; @@ -401,7 +402,7 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force) { qCritical("AirspyInput::applySettings: could not set sample rate index %u (%d S/s): %s", settings.m_devSampleRateIndex, m_sampleRates[settings.m_devSampleRateIndex], airspy_error_name(rc)); } - else if (m_airspyThread != 0) + else if (m_airspyThread) { qDebug("AirspyInput::applySettings: sample rate set to index: %u (%d S/s)", settings.m_devSampleRateIndex, m_sampleRates[settings.m_devSampleRateIndex]); m_airspyThread->setSamplerate(m_sampleRates[settings.m_devSampleRateIndex]); @@ -414,13 +415,22 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force) reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_airspyThread != 0) + if (m_airspyThread) { m_airspyThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "AirspyInput: set decimation to " << (1<setIQOrder(settings.m_iqOrder); + } + } + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { reverseAPIKeys.append("centerFrequency"); } @@ -462,7 +472,7 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force) if ((m_settings.m_fcPos != settings.m_fcPos) || force) { - if (m_airspyThread != 0) + if (m_airspyThread) { m_airspyThread->setFcPos((int) settings.m_fcPos); qDebug() << "AirspyInput: set fc pos (enum) to " << (int) settings.m_fcPos; diff --git a/plugins/samplesource/airspy/airspysettings.cpp b/plugins/samplesource/airspy/airspysettings.cpp index 50d28e35f..9669114f1 100644 --- a/plugins/samplesource/airspy/airspysettings.cpp +++ b/plugins/samplesource/airspy/airspysettings.cpp @@ -41,6 +41,7 @@ void AirspySettings::resetToDefaults() m_iqCorrection = false; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -70,6 +71,7 @@ QByteArray AirspySettings::serialize() const s.writeString(16, m_reverseAPIAddress); s.writeU32(17, m_reverseAPIPort); s.writeU32(18, m_reverseAPIDeviceIndex); + s.writeBool(19, m_iqOrder); return s.final(); } @@ -116,6 +118,7 @@ bool AirspySettings::deserialize(const QByteArray& data) d.readU32(18, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(19, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/airspy/airspysettings.h b/plugins/samplesource/airspy/airspysettings.h index 33847cee4..89c9cd68e 100644 --- a/plugins/samplesource/airspy/airspysettings.h +++ b/plugins/samplesource/airspy/airspysettings.h @@ -42,6 +42,7 @@ struct AirspySettings { bool m_iqCorrection; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/airspy/airspythread.cpp b/plugins/samplesource/airspy/airspythread.cpp index ce9bb2a6c..26c5c4f98 100644 --- a/plugins/samplesource/airspy/airspythread.cpp +++ b/plugins/samplesource/airspy/airspythread.cpp @@ -33,7 +33,8 @@ AirspyThread::AirspyThread(struct airspy_device* dev, SampleSinkFifo* sampleFifo m_sampleFifo(sampleFifo), m_samplerate(10), m_log2Decim(0), - m_fcPos(0) + m_fcPos(0), + m_iqOrder(true) { m_this = this; std::fill(m_buf, m_buf + 2*AIRSPY_BLOCKSIZE, 0); @@ -112,13 +113,13 @@ void AirspyThread::run() } // Decimate according to specified log2 (ex: log2=4 => decim=16) -void AirspyThread::callback(const qint16* buf, qint32 len) +void AirspyThread::callbackIQ(const qint16* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); } else { @@ -127,22 +128,22 @@ void AirspyThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, buf, len); + m_decimatorsIQ.decimate2_inf(&it, buf, len); break; case 2: - m_decimators.decimate4_inf(&it, buf, len); + m_decimatorsIQ.decimate4_inf(&it, buf, len); break; case 3: - m_decimators.decimate8_inf(&it, buf, len); + m_decimatorsIQ.decimate8_inf(&it, buf, len); break; case 4: - m_decimators.decimate16_inf(&it, buf, len); + m_decimatorsIQ.decimate16_inf(&it, buf, len); break; case 5: - m_decimators.decimate32_inf(&it, buf, len); + m_decimatorsIQ.decimate32_inf(&it, buf, len); break; case 6: - m_decimators.decimate64_inf(&it, buf, len); + m_decimatorsIQ.decimate64_inf(&it, buf, len); break; default: break; @@ -153,22 +154,22 @@ void AirspyThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, buf, len); + m_decimatorsIQ.decimate2_sup(&it, buf, len); break; case 2: - m_decimators.decimate4_sup(&it, buf, len); + m_decimatorsIQ.decimate4_sup(&it, buf, len); break; case 3: - m_decimators.decimate8_sup(&it, buf, len); + m_decimatorsIQ.decimate8_sup(&it, buf, len); break; case 4: - m_decimators.decimate16_sup(&it, buf, len); + m_decimatorsIQ.decimate16_sup(&it, buf, len); break; case 5: - m_decimators.decimate32_sup(&it, buf, len); + m_decimatorsIQ.decimate32_sup(&it, buf, len); break; case 6: - m_decimators.decimate64_sup(&it, buf, len); + m_decimatorsIQ.decimate64_sup(&it, buf, len); break; default: break; @@ -179,22 +180,22 @@ void AirspyThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); break; default: break; @@ -205,10 +206,108 @@ void AirspyThread::callback(const qint16* buf, qint32 len) m_sampleFifo->write(m_convertBuffer.begin(), it); } +void AirspyThread::callbackQI(const qint16* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + if (m_fcPos == 0) // Infra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_inf(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_inf(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_inf(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_inf(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_sup(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_sup(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_sup(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_sup(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 2) // Center + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} int AirspyThread::rx_callback(airspy_transfer_t* transfer) { qint32 bytes_to_write = transfer->sample_count * sizeof(qint16); - m_this->callback((qint16 *) transfer->samples, bytes_to_write); - return 0; + + if (m_this->m_iqOrder) { + m_this->callbackIQ((qint16 *) transfer->samples, bytes_to_write); + } else { + m_this->callbackQI((qint16 *) transfer->samples, bytes_to_write); + } + + return 0; } diff --git a/plugins/samplesource/airspy/airspythread.h b/plugins/samplesource/airspy/airspythread.h index e202f9881..c86b2f978 100644 --- a/plugins/samplesource/airspy/airspythread.h +++ b/plugins/samplesource/airspy/airspythread.h @@ -40,6 +40,7 @@ public: void setSamplerate(uint32_t samplerate); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -54,12 +55,15 @@ private: int m_samplerate; unsigned int m_log2Decim; int m_fcPos; + bool m_iqOrder; static AirspyThread *m_this; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; void run(); - void callback(const qint16* buf, qint32 len); + void callbackIQ(const qint16* buf, qint32 len); + void callbackQI(const qint16* buf, qint32 len); static int rx_callback(airspy_transfer_t* transfer); }; diff --git a/plugins/samplesource/airspyhf/airspyhfinput.cpp b/plugins/samplesource/airspyhf/airspyhfinput.cpp index c8d67dcf4..9d182e5c2 100644 --- a/plugins/samplesource/airspyhf/airspyhfinput.cpp +++ b/plugins/samplesource/airspyhf/airspyhfinput.cpp @@ -53,7 +53,7 @@ AirspyHFInput::AirspyHFInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), m_dev(0), - m_airspyHFThread(0), + m_airspyHFThread(nullptr), m_deviceDescription("AirspyHF"), m_running(false) { @@ -181,6 +181,7 @@ bool AirspyHFInput::start() } m_airspyHFThread->setLog2Decimation(m_settings.m_log2Decim); + m_airspyHFThread->setIQOrder(m_settings.m_iqOrder); m_airspyHFThread->startWork(); mutexLocker.unlock(); @@ -210,11 +211,11 @@ void AirspyHFInput::stop() qDebug("AirspyHFInput::stop"); QMutexLocker mutexLocker(&m_mutex); - if (m_airspyHFThread != 0) + if (m_airspyHFThread) { m_airspyHFThread->stopWork(); delete m_airspyHFThread; - m_airspyHFThread = 0; + m_airspyHFThread = nullptr; } m_running = false; @@ -445,7 +446,7 @@ bool AirspyHFInput::applySettings(const AirspyHFSettings& settings, bool force) { qCritical("AirspyHFInput::applySettings: could not set sample rate index %u (%d S/s)", sampleRateIndex, m_sampleRates[sampleRateIndex]); } - else if (m_airspyHFThread != 0) + else if (m_airspyHFThread) { qDebug("AirspyHFInput::applySettings: sample rate set to index: %u (%d S/s)", sampleRateIndex, m_sampleRates[sampleRateIndex]); m_airspyHFThread->setSamplerate(m_sampleRates[sampleRateIndex]); @@ -458,13 +459,22 @@ bool AirspyHFInput::applySettings(const AirspyHFSettings& settings, bool force) reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_airspyHFThread != 0) + if (m_airspyHFThread) { m_airspyHFThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "AirspyInput: set decimation to " << (1<setIQOrder(settings.m_iqOrder); + } + } + if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) { reverseAPIKeys.append("LOppmTenths"); @@ -477,7 +487,7 @@ bool AirspyHFInput::applySettings(const AirspyHFSettings& settings, bool force) { qCritical("AirspyHFInput::applySettings: could not set LO ppm correction to %f", settings.m_LOppmTenths / 10.0f); } - else if (m_airspyHFThread != 0) + else if (m_airspyHFThread) { qDebug("AirspyHFInput::applySettings: LO ppm correction set to %f", settings.m_LOppmTenths / 10.0f); } diff --git a/plugins/samplesource/airspyhf/airspyhfsettings.cpp b/plugins/samplesource/airspyhf/airspyhfsettings.cpp index 4160b1465..33e8e7d69 100644 --- a/plugins/samplesource/airspyhf/airspyhfsettings.cpp +++ b/plugins/samplesource/airspyhf/airspyhfsettings.cpp @@ -33,6 +33,7 @@ void AirspyHFSettings::resetToDefaults() m_log2Decim = 0; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_bandIndex = 0; m_fileRecordName = ""; m_useReverseAPI = false; @@ -69,6 +70,7 @@ QByteArray AirspyHFSettings::serialize() const s.writeU32(18, m_attenuatorSteps); s.writeBool(19, m_dcBlock); s.writeBool(20, m_iqCorrection); + s.writeBool(21, m_iqOrder); return s.final(); } @@ -115,6 +117,7 @@ bool AirspyHFSettings::deserialize(const QByteArray& data) d.readU32(18, &m_attenuatorSteps, 0); d.readBool(19, &m_dcBlock, false); d.readBool(20, &m_iqCorrection, false); + d.readBool(21, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/airspyhf/airspyhfsettings.h b/plugins/samplesource/airspyhf/airspyhfsettings.h index 3ce2d7d3a..dd121cbf9 100644 --- a/plugins/samplesource/airspyhf/airspyhfsettings.h +++ b/plugins/samplesource/airspyhf/airspyhfsettings.h @@ -28,6 +28,7 @@ struct AirspyHFSettings quint32 m_log2Decim; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; quint32 m_bandIndex; QString m_fileRecordName; bool m_useReverseAPI; diff --git a/plugins/samplesource/airspyhf/airspyhfthread.cpp b/plugins/samplesource/airspyhf/airspyhfthread.cpp index 50fed72b4..f9dd48a8a 100644 --- a/plugins/samplesource/airspyhf/airspyhfthread.cpp +++ b/plugins/samplesource/airspyhf/airspyhfthread.cpp @@ -31,7 +31,8 @@ AirspyHFThread::AirspyHFThread(airspyhf_device_t* dev, SampleSinkFifo* sampleFif m_convertBuffer(AIRSPYHF_BLOCKSIZE), m_sampleFifo(sampleFifo), m_samplerate(10), - m_log2Decim(0) + m_log2Decim(0), + m_iqOrder(true) { memset((char*) m_buf, 0, 2*AIRSPYHF_BLOCKSIZE*sizeof(qint16)); m_this = this; @@ -102,32 +103,32 @@ void AirspyHFThread::run() } // Decimate according to specified log2 (ex: log2=4 => decim=16) -void AirspyHFThread::callback(const float* buf, qint32 len) +void AirspyHFThread::callbackIQ(const float* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); switch (m_log2Decim) { case 0: - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); break; case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); break; default: break; @@ -136,10 +137,49 @@ void AirspyHFThread::callback(const float* buf, qint32 len) m_sampleFifo->write(m_convertBuffer.begin(), it); } +void AirspyHFThread::callbackQI(const float* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + switch (m_log2Decim) + { + case 0: + m_decimatorsQI.decimate1(&it, buf, len); + break; + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} int AirspyHFThread::rx_callback(airspyhf_transfer_t* transfer) { qint32 nbIAndQ = transfer->sample_count * 2; - m_this->callback((float *) transfer->samples, nbIAndQ); - return 0; + + if (m_this->m_iqOrder) { + m_this->callbackIQ((float *) transfer->samples, nbIAndQ); + } else { + m_this->callbackQI((float *) transfer->samples, nbIAndQ); + } + + return 0; } diff --git a/plugins/samplesource/airspyhf/airspyhfthread.h b/plugins/samplesource/airspyhf/airspyhfthread.h index b8e88775d..b9c9d734d 100644 --- a/plugins/samplesource/airspyhf/airspyhfthread.h +++ b/plugins/samplesource/airspyhf/airspyhfthread.h @@ -39,6 +39,7 @@ public: void stopWork(); void setSamplerate(uint32_t samplerate); void setLog2Decimation(unsigned int log2_decim); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -52,12 +53,15 @@ private: int m_samplerate; unsigned int m_log2Decim; + bool m_iqOrder; static AirspyHFThread *m_this; - DecimatorsFI m_decimators; + DecimatorsFI m_decimatorsIQ; + DecimatorsFI m_decimatorsQI; void run(); - void callback(const float* buf, qint32 len); + void callbackIQ(const float* buf, qint32 len); + void callbackQI(const float* buf, qint32 len); static int rx_callback(airspyhf_transfer_t* transfer); }; diff --git a/plugins/samplesource/bladerf1input/bladerf1input.cpp b/plugins/samplesource/bladerf1input/bladerf1input.cpp index 7a538d0c6..122e4bac2 100644 --- a/plugins/samplesource/bladerf1input/bladerf1input.cpp +++ b/plugins/samplesource/bladerf1input/bladerf1input.cpp @@ -46,7 +46,7 @@ Bladerf1Input::Bladerf1Input(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), m_dev(0), - m_bladerfThread(0), + m_bladerfThread(nullptr), m_deviceDescription("BladeRFInput"), m_running(false) { @@ -163,6 +163,7 @@ bool Bladerf1Input::start() m_bladerfThread = new Bladerf1InputThread(m_dev, &m_sampleFifo); m_bladerfThread->setLog2Decimation(m_settings.m_log2Decim); m_bladerfThread->setFcPos((int) m_settings.m_fcPos); + m_bladerfThread->setIQOrder(m_settings.m_iqOrder); m_bladerfThread->startWork(); @@ -206,11 +207,11 @@ void Bladerf1Input::stop() { // QMutexLocker mutexLocker(&m_mutex); - if(m_bladerfThread != 0) + if(m_bladerfThread) { m_bladerfThread->stopWork(); delete m_bladerfThread; - m_bladerfThread = 0; + m_bladerfThread = nullptr; } m_running = false; @@ -514,7 +515,7 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, bool fo { reverseAPIKeys.append("fcPos"); - if (m_bladerfThread != 0) + if (m_bladerfThread) { m_bladerfThread->setFcPos((int) settings.m_fcPos); qDebug() << "BladerfInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos; @@ -526,13 +527,22 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, bool fo reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_bladerfThread != 0) + if (m_bladerfThread) { m_bladerfThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "BladerfInput::applySettings: set decimation to " << (1<setIQOrder(settings.m_iqOrder); + } + } + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { reverseAPIKeys.append("centerFrequency"); } diff --git a/plugins/samplesource/bladerf1input/bladerf1inputsettings.cpp b/plugins/samplesource/bladerf1input/bladerf1inputsettings.cpp index 499b72f4e..6745b693e 100644 --- a/plugins/samplesource/bladerf1input/bladerf1inputsettings.cpp +++ b/plugins/samplesource/bladerf1input/bladerf1inputsettings.cpp @@ -41,6 +41,7 @@ void BladeRF1InputSettings::resetToDefaults() m_xb200Filter = BLADERF_XB200_AUTO_1DB; m_dcBlock = false; m_iqCorrection = false; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -68,6 +69,7 @@ QByteArray BladeRF1InputSettings::serialize() const s.writeString(14, m_reverseAPIAddress); s.writeU32(15, m_reverseAPIPort); s.writeU32(16, m_reverseAPIDeviceIndex); + s.writeBool(17, m_iqOrder); return s.final(); } @@ -114,6 +116,7 @@ bool BladeRF1InputSettings::deserialize(const QByteArray& data) d.readU32(16, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(17, &m_iqOrder); return true; } diff --git a/plugins/samplesource/bladerf1input/bladerf1inputsettings.h b/plugins/samplesource/bladerf1input/bladerf1inputsettings.h index 2e07945d1..32ab4ba33 100644 --- a/plugins/samplesource/bladerf1input/bladerf1inputsettings.h +++ b/plugins/samplesource/bladerf1input/bladerf1inputsettings.h @@ -42,6 +42,7 @@ struct BladeRF1InputSettings { bladerf_xb200_filter m_xb200Filter; bool m_dcBlock; bool m_iqCorrection; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/bladerf1input/bladerf1inputthread.cpp b/plugins/samplesource/bladerf1input/bladerf1inputthread.cpp index 13624a7ce..602d09e66 100644 --- a/plugins/samplesource/bladerf1input/bladerf1inputthread.cpp +++ b/plugins/samplesource/bladerf1input/bladerf1inputthread.cpp @@ -31,7 +31,8 @@ Bladerf1InputThread::Bladerf1InputThread(struct bladerf* dev, SampleSinkFifo* sa m_convertBuffer(BLADERF_BLOCKSIZE), m_sampleFifo(sampleFifo), m_log2Decim(0), - m_fcPos(0) + m_fcPos(0), + m_iqOrder(true) { std::fill(m_buf, m_buf + 2*BLADERF_BLOCKSIZE, 0); } @@ -79,20 +80,24 @@ void Bladerf1InputThread::run() break; } - callback(m_buf, 2 * BLADERF_BLOCKSIZE); + if (m_iqOrder) { + callbackIQ(m_buf, 2 * BLADERF_BLOCKSIZE); + } else { + callbackQI(m_buf, 2 * BLADERF_BLOCKSIZE); + } } m_running = false; } // Decimate according to specified log2 (ex: log2=4 => decim=16) -void Bladerf1InputThread::callback(const qint16* buf, qint32 len) +void Bladerf1InputThread::callbackIQ(const qint16* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); } else { @@ -101,22 +106,22 @@ void Bladerf1InputThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, buf, len); + m_decimatorsIQ.decimate2_inf(&it, buf, len); break; case 2: - m_decimators.decimate4_inf(&it, buf, len); + m_decimatorsIQ.decimate4_inf(&it, buf, len); break; case 3: - m_decimators.decimate8_inf(&it, buf, len); + m_decimatorsIQ.decimate8_inf(&it, buf, len); break; case 4: - m_decimators.decimate16_inf(&it, buf, len); + m_decimatorsIQ.decimate16_inf(&it, buf, len); break; case 5: - m_decimators.decimate32_inf(&it, buf, len); + m_decimatorsIQ.decimate32_inf(&it, buf, len); break; case 6: - m_decimators.decimate64_inf(&it, buf, len); + m_decimatorsIQ.decimate64_inf(&it, buf, len); break; default: break; @@ -127,22 +132,22 @@ void Bladerf1InputThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, buf, len); + m_decimatorsIQ.decimate2_sup(&it, buf, len); break; case 2: - m_decimators.decimate4_sup(&it, buf, len); + m_decimatorsIQ.decimate4_sup(&it, buf, len); break; case 3: - m_decimators.decimate8_sup(&it, buf, len); + m_decimatorsIQ.decimate8_sup(&it, buf, len); break; case 4: - m_decimators.decimate16_sup(&it, buf, len); + m_decimatorsIQ.decimate16_sup(&it, buf, len); break; case 5: - m_decimators.decimate32_sup(&it, buf, len); + m_decimatorsIQ.decimate32_sup(&it, buf, len); break; case 6: - m_decimators.decimate64_sup(&it, buf, len); + m_decimatorsIQ.decimate64_sup(&it, buf, len); break; default: break; @@ -153,22 +158,116 @@ void Bladerf1InputThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} + +void Bladerf1InputThread::callbackQI(const qint16* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + if (m_fcPos == 0) // Infra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_inf(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_inf(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_inf(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_inf(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_sup(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_sup(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_sup(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_sup(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 2) // Center + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); break; default: break; diff --git a/plugins/samplesource/bladerf1input/bladerf1inputthread.h b/plugins/samplesource/bladerf1input/bladerf1inputthread.h index 98e0a0a2d..5b0fd029d 100644 --- a/plugins/samplesource/bladerf1input/bladerf1inputthread.h +++ b/plugins/samplesource/bladerf1input/bladerf1inputthread.h @@ -38,6 +38,7 @@ public: void stopWork(); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -51,11 +52,14 @@ private: unsigned int m_log2Decim; int m_fcPos; + bool m_iqOrder; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; void run(); - void callback(const qint16* buf, qint32 len); + void callbackIQ(const qint16* buf, qint32 len); + void callbackQI(const qint16* buf, qint32 len); }; #endif // INCLUDE_BLADERFINPUTTHREAD_H diff --git a/plugins/samplesource/bladerf2input/bladerf2input.cpp b/plugins/samplesource/bladerf2input/bladerf2input.cpp index 605c83fe2..fdb9f681f 100644 --- a/plugins/samplesource/bladerf2input/bladerf2input.cpp +++ b/plugins/samplesource/bladerf2input/bladerf2input.cpp @@ -50,7 +50,7 @@ BladeRF2Input::BladeRF2Input(DeviceAPI *deviceAPI) : m_settings(), m_deviceDescription("BladeRF2Input"), m_running(false), - m_thread(0) + m_thread(nullptr) { openDevice(); @@ -209,7 +209,7 @@ void BladeRF2Input::init() BladeRF2InputThread *BladeRF2Input::findThread() { - if (m_thread == 0) // this does not own the thread + if (!m_thread) // this does not own the thread { BladeRF2InputThread *bladerf2InputThread = 0; @@ -251,7 +251,7 @@ void BladeRF2Input::moveThreadToBuddy() if (buddySource) { buddySource->setThread(m_thread); - m_thread = 0; // zero for others + m_thread = nullptr; // zero for others } } } @@ -323,6 +323,7 @@ bool BladeRF2Input::start() delete bladerf2InputThread; bladerf2InputThread = new BladeRF2InputThread(m_deviceShared.m_dev->getDev(), requestedChannel+1); m_thread = bladerf2InputThread; // take ownership + bladerf2InputThread->setIQOrder(m_settings.m_iqOrder); for (int i = 0; i < nbOriginalChannels; i++) // restore original FIFO references { @@ -423,7 +424,7 @@ void BladeRF2Input::stop() qDebug("BladeRF2Input::stop: SI mode. Just stop and delete the thread"); bladerf2InputThread->stopWork(); delete bladerf2InputThread; - m_thread = 0; + m_thread = nullptr; // remove old thread address from buddies (reset in all buddies) const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); @@ -453,7 +454,7 @@ void BladeRF2Input::stop() } delete bladerf2InputThread; - m_thread = 0; + m_thread = nullptr; if (stillActiveFIFO) { @@ -844,7 +845,7 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo reverseAPIKeys.append("fcPos"); BladeRF2InputThread *inputThread = findThread(); - if (inputThread != 0) + if (inputThread) { inputThread->setFcPos(requestedChannel, (int) settings.m_fcPos); qDebug() << "BladeRF2Input::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos; @@ -857,13 +858,23 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo forwardChangeOwnDSP = true; BladeRF2InputThread *inputThread = findThread(); - if (inputThread != 0) + if (inputThread) { inputThread->setLog2Decimation(requestedChannel, settings.m_log2Decim); qDebug() << "BladeRF2Input::applySettings: set decimation to " << (1<setIQOrder(settings.m_iqOrder); + } + } + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { reverseAPIKeys.append("centerFrequency"); } diff --git a/plugins/samplesource/bladerf2input/bladerf2inputsettings.cpp b/plugins/samplesource/bladerf2input/bladerf2inputsettings.cpp index 036e55aa5..f0be32a49 100644 --- a/plugins/samplesource/bladerf2input/bladerf2inputsettings.cpp +++ b/plugins/samplesource/bladerf2input/bladerf2inputsettings.cpp @@ -39,6 +39,7 @@ void BladeRF2InputSettings::resetToDefaults() m_iqCorrection = false; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -66,6 +67,7 @@ QByteArray BladeRF2InputSettings::serialize() const s.writeString(14, m_reverseAPIAddress); s.writeU32(15, m_reverseAPIPort); s.writeU32(16, m_reverseAPIDeviceIndex); + s.writeBool(17, m_iqOrder); return s.final(); } @@ -110,6 +112,7 @@ bool BladeRF2InputSettings::deserialize(const QByteArray& data) d.readU32(16, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(17, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/bladerf2input/bladerf2inputsettings.h b/plugins/samplesource/bladerf2input/bladerf2inputsettings.h index ac96337cd..facb025e1 100644 --- a/plugins/samplesource/bladerf2input/bladerf2inputsettings.h +++ b/plugins/samplesource/bladerf2input/bladerf2inputsettings.h @@ -41,6 +41,7 @@ struct BladeRF2InputSettings { bool m_iqCorrection; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/bladerf2input/bladerf2inputthread.cpp b/plugins/samplesource/bladerf2input/bladerf2inputthread.cpp index ec5dbf815..6f1d78300 100644 --- a/plugins/samplesource/bladerf2input/bladerf2inputthread.cpp +++ b/plugins/samplesource/bladerf2input/bladerf2inputthread.cpp @@ -23,7 +23,8 @@ BladeRF2InputThread::BladeRF2InputThread(struct bladerf* dev, unsigned int nbRxC QThread(parent), m_running(false), m_dev(dev), - m_nbChannels(nbRxChannels) + m_nbChannels(nbRxChannels), + m_iqOrder(true) { qDebug("BladeRF2InputThread::BladeRF2InputThread"); m_channels = new Channel[nbRxChannels]; @@ -105,10 +106,17 @@ void BladeRF2InputThread::run() break; } - if (m_nbChannels > 1) { + if (m_nbChannels > 1) + { callbackMI(m_buf, DeviceBladeRF2::blockSize); - } else { - callbackSI(m_buf, 2*DeviceBladeRF2::blockSize); + } + else + { + if (m_iqOrder) { + callbackSIIQ(m_buf, 2*DeviceBladeRF2::blockSize); + } else { + callbackSIQI(m_buf, 2*DeviceBladeRF2::blockSize); + } } } qDebug("BladeRF2InputThread::run: stop running loop"); @@ -198,19 +206,24 @@ void BladeRF2InputThread::callbackMI(const qint16* buf, qint32 samplesPerChannel for (unsigned int channel = 0; channel < m_nbChannels; channel++) { - if (m_channels[channel].m_sampleFifo) { - callbackSI(&buf[2*samplesPerChannel*channel], 2*samplesPerChannel, channel); + if (m_channels[channel].m_sampleFifo) + { + if (m_iqOrder) { + callbackSIIQ(&buf[2*samplesPerChannel*channel], 2*samplesPerChannel, channel); + } else { + callbackSIQI(&buf[2*samplesPerChannel*channel], 2*samplesPerChannel, channel); + } } } } -void BladeRF2InputThread::callbackSI(const qint16* buf, qint32 len, unsigned int channel) +void BladeRF2InputThread::callbackSIIQ(const qint16* buf, qint32 len, unsigned int channel) { SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); if (m_channels[channel].m_log2Decim == 0) { - m_channels[channel].m_decimators.decimate1(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate1(&it, buf, len); } else { @@ -219,22 +232,22 @@ void BladeRF2InputThread::callbackSI(const qint16* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators.decimate2_inf(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate2_inf(&it, buf, len); break; case 2: - m_channels[channel].m_decimators.decimate4_inf(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate4_inf(&it, buf, len); break; case 3: - m_channels[channel].m_decimators.decimate8_inf(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate8_inf(&it, buf, len); break; case 4: - m_channels[channel].m_decimators.decimate16_inf(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate16_inf(&it, buf, len); break; case 5: - m_channels[channel].m_decimators.decimate32_inf(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate32_inf(&it, buf, len); break; case 6: - m_channels[channel].m_decimators.decimate64_inf(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate64_inf(&it, buf, len); break; default: break; @@ -245,22 +258,22 @@ void BladeRF2InputThread::callbackSI(const qint16* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators.decimate2_sup(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate2_sup(&it, buf, len); break; case 2: - m_channels[channel].m_decimators.decimate4_sup(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate4_sup(&it, buf, len); break; case 3: - m_channels[channel].m_decimators.decimate8_sup(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate8_sup(&it, buf, len); break; case 4: - m_channels[channel].m_decimators.decimate16_sup(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate16_sup(&it, buf, len); break; case 5: - m_channels[channel].m_decimators.decimate32_sup(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate32_sup(&it, buf, len); break; case 6: - m_channels[channel].m_decimators.decimate64_sup(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate64_sup(&it, buf, len); break; default: break; @@ -271,22 +284,22 @@ void BladeRF2InputThread::callbackSI(const qint16* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators.decimate2_cen(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_channels[channel].m_decimators.decimate4_cen(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_channels[channel].m_decimators.decimate8_cen(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_channels[channel].m_decimators.decimate16_cen(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_channels[channel].m_decimators.decimate32_cen(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_channels[channel].m_decimators.decimate64_cen(&it, buf, len); + m_channels[channel].m_decimatorsIQ.decimate64_cen(&it, buf, len); break; default: break; @@ -297,3 +310,95 @@ void BladeRF2InputThread::callbackSI(const qint16* buf, qint32 len, unsigned int m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); } +void BladeRF2InputThread::callbackSIQI(const qint16* buf, qint32 len, unsigned int channel) +{ + SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); + + if (m_channels[channel].m_log2Decim == 0) + { + m_channels[channel].m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + if (m_channels[channel].m_fcPos == 0) // Infra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsQI.decimate4_inf(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsQI.decimate8_inf(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsQI.decimate16_inf(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsQI.decimate32_inf(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsQI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 1) // Supra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsQI.decimate4_sup(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsQI.decimate8_sup(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsQI.decimate16_sup(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsQI.decimate32_sup(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsQI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 2) // Center + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsQI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); +} diff --git a/plugins/samplesource/bladerf2input/bladerf2inputthread.h b/plugins/samplesource/bladerf2input/bladerf2inputthread.h index cfae9320c..211c7f60e 100644 --- a/plugins/samplesource/bladerf2input/bladerf2inputthread.h +++ b/plugins/samplesource/bladerf2input/bladerf2inputthread.h @@ -51,6 +51,7 @@ public: int getFcPos(unsigned int channel) const; void setFifo(unsigned int channel, SampleSinkFifo *sampleFifo); SampleSinkFifo *getFifo(unsigned int channel); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: struct Channel @@ -59,7 +60,8 @@ private: SampleSinkFifo* m_sampleFifo; unsigned int m_log2Decim; int m_fcPos; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; Channel() : m_sampleFifo(0), @@ -79,10 +81,12 @@ private: Channel *m_channels; //!< Array of channels dynamically allocated for the given number of Rx channels qint16 *m_buf; //!< Full buffer for SISO or MIMO operation unsigned int m_nbChannels; + bool m_iqOrder; void run(); unsigned int getNbFifos(); - void callbackSI(const qint16* buf, qint32 len, unsigned int channel = 0); + void callbackSIIQ(const qint16* buf, qint32 len, unsigned int channel = 0); + void callbackSIQI(const qint16* buf, qint32 len, unsigned int channel = 0); void callbackMI(const qint16* buf, qint32 samplesPerChannel); }; diff --git a/plugins/samplesource/fcdpro/fcdproinput.cpp b/plugins/samplesource/fcdpro/fcdproinput.cpp index f43549c4d..b53f1e1c1 100644 --- a/plugins/samplesource/fcdpro/fcdproinput.cpp +++ b/plugins/samplesource/fcdpro/fcdproinput.cpp @@ -45,7 +45,7 @@ FCDProInput::FCDProInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_dev(0), m_settings(), - m_FCDThread(0), + m_FCDThread(nullptr), m_deviceDescription(fcd_traits::displayedName), m_running(false) { @@ -138,6 +138,9 @@ bool FCDProInput::start() } m_FCDThread = new FCDProThread(&m_sampleFifo, &m_fcdFIFO); + m_FCDThread->setLog2Decimation(m_settings.m_log2Decim); + m_FCDThread->setFcPos(m_settings.m_fcPos); + m_FCDThread->setIQOrder(m_settings.m_iqOrder); m_FCDThread->startWork(); // mutexLocker.unlock(); @@ -374,7 +377,7 @@ void FCDProInput::applySettings(const FCDProSettings& settings, bool force) reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_FCDThread != 0) + if (m_FCDThread) { m_FCDThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "FCDProInput::applySettings: set decimation to " << (1<setFcPos((int) settings.m_fcPos); } qDebug() << "FCDProInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos; } + if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) + { + reverseAPIKeys.append("iqOrder"); + + if (m_FCDThread) { + m_FCDThread->setIQOrder((int) settings.m_iqOrder); + } + + qDebug() << "FCDProInput::applySettings: set IQ order to %s" << (settings.m_iqOrder ? "IQ" : "QI"); + } + if ((m_settings.m_lnaGainIndex != settings.m_lnaGainIndex) || force) { reverseAPIKeys.append("lnaGainIndex"); diff --git a/plugins/samplesource/fcdpro/fcdprosettings.cpp b/plugins/samplesource/fcdpro/fcdprosettings.cpp index 64d2ca4ab..4340f554e 100644 --- a/plugins/samplesource/fcdpro/fcdprosettings.cpp +++ b/plugins/samplesource/fcdpro/fcdprosettings.cpp @@ -50,6 +50,7 @@ void FCDProSettings::resetToDefaults() m_fcPos = FC_POS_CENTER; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -88,6 +89,7 @@ QByteArray FCDProSettings::serialize() const s.writeString(25, m_reverseAPIAddress); s.writeU32(26, m_reverseAPIPort); s.writeU32(27, m_reverseAPIDeviceIndex); + s.writeBool(28, m_iqOrder); return s.final(); } @@ -143,6 +145,7 @@ bool FCDProSettings::deserialize(const QByteArray& data) d.readU32(27, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(28, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/fcdpro/fcdprosettings.h b/plugins/samplesource/fcdpro/fcdprosettings.h index a4d1b4843..27a0151ba 100644 --- a/plugins/samplesource/fcdpro/fcdprosettings.h +++ b/plugins/samplesource/fcdpro/fcdprosettings.h @@ -51,6 +51,7 @@ struct FCDProSettings { bool m_iqCorrection; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/fcdpro/fcdprothread.cpp b/plugins/samplesource/fcdpro/fcdprothread.cpp index 72f605725..b31bdd5df 100644 --- a/plugins/samplesource/fcdpro/fcdprothread.cpp +++ b/plugins/samplesource/fcdpro/fcdprothread.cpp @@ -34,7 +34,8 @@ FCDProThread::FCDProThread(SampleSinkFifo* sampleFifo, AudioFifo *fcdFIFO, QObje m_log2Decim(0), m_fcPos(2), m_convertBuffer(fcd_traits::convBufSize), // nb samples - m_sampleFifo(sampleFifo) + m_sampleFifo(sampleFifo), + m_iqOrder(true) { start(); } @@ -80,7 +81,12 @@ void FCDProThread::run() while (m_running) { - work(fcd_traits::convBufSize); + if (m_iqOrder) { + workIQ(fcd_traits::convBufSize); + } else { + workQI(fcd_traits::convBufSize); + } + std::this_thread::sleep_for(std::chrono::microseconds(200)); } @@ -88,14 +94,14 @@ void FCDProThread::run() m_running = false; } -void FCDProThread::work(unsigned int n_items) +void FCDProThread::workIQ(unsigned int n_items) { uint32_t nbRead = m_fcdFIFO->read((unsigned char *) m_buf, n_items); // number of samples SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate1(&it, m_buf, 2*nbRead); } else { @@ -104,22 +110,22 @@ void FCDProThread::work(unsigned int n_items) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate2_inf(&it, m_buf, 2*nbRead); break; case 2: - m_decimators.decimate4_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate4_inf(&it, m_buf, 2*nbRead); break; case 3: - m_decimators.decimate8_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate8_inf(&it, m_buf, 2*nbRead); break; case 4: - m_decimators.decimate16_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate16_inf(&it, m_buf, 2*nbRead); break; case 5: - m_decimators.decimate32_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate32_inf(&it, m_buf, 2*nbRead); break; case 6: - m_decimators.decimate64_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate64_inf(&it, m_buf, 2*nbRead); break; default: break; @@ -130,22 +136,22 @@ void FCDProThread::work(unsigned int n_items) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate2_sup(&it, m_buf, 2*nbRead); break; case 2: - m_decimators.decimate4_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate4_sup(&it, m_buf, 2*nbRead); break; case 3: - m_decimators.decimate8_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate8_sup(&it, m_buf, 2*nbRead); break; case 4: - m_decimators.decimate16_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate16_sup(&it, m_buf, 2*nbRead); break; case 5: - m_decimators.decimate32_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate32_sup(&it, m_buf, 2*nbRead); break; case 6: - m_decimators.decimate64_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate64_sup(&it, m_buf, 2*nbRead); break; default: break; @@ -156,22 +162,116 @@ void FCDProThread::work(unsigned int n_items) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate2_cen(&it, m_buf, 2*nbRead); break; case 2: - m_decimators.decimate4_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate4_cen(&it, m_buf, 2*nbRead); break; case 3: - m_decimators.decimate8_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate8_cen(&it, m_buf, 2*nbRead); break; case 4: - m_decimators.decimate16_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate16_cen(&it, m_buf, 2*nbRead); break; case 5: - m_decimators.decimate32_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate32_cen(&it, m_buf, 2*nbRead); break; case 6: - m_decimators.decimate64_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate64_cen(&it, m_buf, 2*nbRead); + break; + default: + break; + } + } + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} + +void FCDProThread::workQI(unsigned int n_items) +{ + uint32_t nbRead = m_fcdFIFO->read((unsigned char *) m_buf, n_items); // number of samples + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, m_buf, 2*nbRead); + } + else + { + if (m_fcPos == 0) // Infradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, m_buf, 2*nbRead); + break; + case 2: + m_decimatorsQI.decimate4_inf(&it, m_buf, 2*nbRead); + break; + case 3: + m_decimatorsQI.decimate8_inf(&it, m_buf, 2*nbRead); + break; + case 4: + m_decimatorsQI.decimate16_inf(&it, m_buf, 2*nbRead); + break; + case 5: + m_decimatorsQI.decimate32_inf(&it, m_buf, 2*nbRead); + break; + case 6: + m_decimatorsQI.decimate64_inf(&it, m_buf, 2*nbRead); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, m_buf, 2*nbRead); + break; + case 2: + m_decimatorsQI.decimate4_sup(&it, m_buf, 2*nbRead); + break; + case 3: + m_decimatorsQI.decimate8_sup(&it, m_buf, 2*nbRead); + break; + case 4: + m_decimatorsQI.decimate16_sup(&it, m_buf, 2*nbRead); + break; + case 5: + m_decimatorsQI.decimate32_sup(&it, m_buf, 2*nbRead); + break; + case 6: + m_decimatorsQI.decimate64_sup(&it, m_buf, 2*nbRead); + break; + default: + break; + } + } + else // Centered + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, m_buf, 2*nbRead); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, m_buf, 2*nbRead); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, m_buf, 2*nbRead); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, m_buf, 2*nbRead); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, m_buf, 2*nbRead); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, m_buf, 2*nbRead); break; default: break; diff --git a/plugins/samplesource/fcdpro/fcdprothread.h b/plugins/samplesource/fcdpro/fcdprothread.h index 39daa270e..61ae8e749 100644 --- a/plugins/samplesource/fcdpro/fcdprothread.h +++ b/plugins/samplesource/fcdpro/fcdprothread.h @@ -39,6 +39,7 @@ public: void stopWork(); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: AudioFifo* m_fcdFIFO; @@ -48,14 +49,18 @@ private: bool m_running; unsigned int m_log2Decim; int m_fcPos; + bool m_iqOrder; qint16 m_buf[fcd_traits::convBufSize*2]; // stereo (I, Q) SampleVector m_convertBuffer; SampleSinkFifo* m_sampleFifo; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; + void run(); - void work(unsigned int n_items); + void workIQ(unsigned int n_items); + void workQI(unsigned int n_items); }; #endif // INCLUDE_FCDPROTHREAD_H diff --git a/plugins/samplesource/fcdproplus/fcdproplusinput.cpp b/plugins/samplesource/fcdproplus/fcdproplusinput.cpp index bbe3131e7..4b02b7c49 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusinput.cpp +++ b/plugins/samplesource/fcdproplus/fcdproplusinput.cpp @@ -45,7 +45,7 @@ FCDProPlusInput::FCDProPlusInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_dev(0), m_settings(), - m_FCDThread(0), + m_FCDThread(nullptr), m_deviceDescription(fcd_traits::displayedName), m_running(false) { @@ -140,6 +140,9 @@ bool FCDProPlusInput::start() } m_FCDThread = new FCDProPlusThread(&m_sampleFifo, &m_fcdFIFO); + m_FCDThread->setLog2Decimation(m_settings.m_log2Decim); + m_FCDThread->setFcPos(m_settings.m_fcPos); + m_FCDThread->setIQOrder(m_settings.m_iqOrder); m_FCDThread->startWork(); // mutexLocker.unlock(); @@ -375,7 +378,7 @@ void FCDProPlusInput::applySettings(const FCDProPlusSettings& settings, bool for reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_FCDThread != 0) + if (m_FCDThread) { m_FCDThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "FCDProPlusInput::applySettings: set decimation to " << (1<setFcPos((int) settings.m_fcPos); } qDebug() << "FCDProPlusInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos; } + if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) + { + reverseAPIKeys.append("iqOrder"); + + if (m_FCDThread) { + m_FCDThread->setIQOrder((int) settings.m_iqOrder); + } + + qDebug() << "FCDProPlusInput::applySettings: set IQ order to %s" << (settings.m_iqOrder ? "IQ" : "QI"); + } + if ((m_settings.m_lnaGain != settings.m_lnaGain) || force) { reverseAPIKeys.append("lnaGain"); diff --git a/plugins/samplesource/fcdproplus/fcdproplussettings.cpp b/plugins/samplesource/fcdproplus/fcdproplussettings.cpp index b1081b9e8..c01a3c666 100644 --- a/plugins/samplesource/fcdproplus/fcdproplussettings.cpp +++ b/plugins/samplesource/fcdproplus/fcdproplussettings.cpp @@ -41,6 +41,7 @@ void FCDProPlusSettings::resetToDefaults() m_iqImbalance = false; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -69,6 +70,7 @@ QByteArray FCDProPlusSettings::serialize() const s.writeString(15, m_reverseAPIAddress); s.writeU32(16, m_reverseAPIPort); s.writeU32(17, m_reverseAPIDeviceIndex); + s.writeBool(18, m_iqOrder); return s.final(); } @@ -114,6 +116,8 @@ bool FCDProPlusSettings::deserialize(const QByteArray& data) d.readU32(17, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(18, &m_iqOrder, true); + return true; } else diff --git a/plugins/samplesource/fcdproplus/fcdproplussettings.h b/plugins/samplesource/fcdproplus/fcdproplussettings.h index d56995f82..99b9be155 100644 --- a/plugins/samplesource/fcdproplus/fcdproplussettings.h +++ b/plugins/samplesource/fcdproplus/fcdproplussettings.h @@ -42,6 +42,7 @@ struct FCDProPlusSettings { bool m_iqImbalance; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/fcdproplus/fcdproplusthread.cpp b/plugins/samplesource/fcdproplus/fcdproplusthread.cpp index 49a4ff67a..64989ce6e 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusthread.cpp +++ b/plugins/samplesource/fcdproplus/fcdproplusthread.cpp @@ -33,7 +33,8 @@ FCDProPlusThread::FCDProPlusThread(SampleSinkFifo* sampleFifo, AudioFifo *fcdFIF m_log2Decim(0), m_fcPos(2), m_convertBuffer(fcd_traits::convBufSize), // nb samples - m_sampleFifo(sampleFifo) + m_sampleFifo(sampleFifo), + m_iqOrder(true) { start(); } @@ -79,7 +80,12 @@ void FCDProPlusThread::run() while (m_running) { - work(fcd_traits::convBufSize); + if (m_iqOrder) { + workIQ(fcd_traits::convBufSize); + } else { + workQI(fcd_traits::convBufSize); + } + std::this_thread::sleep_for(std::chrono::microseconds(100)); } @@ -87,14 +93,14 @@ void FCDProPlusThread::run() m_running = false; } -void FCDProPlusThread::work(unsigned int n_items) +void FCDProPlusThread::workIQ(unsigned int n_items) { uint32_t nbRead = m_fcdFIFO->read((unsigned char *) m_buf, n_items); // number of samples SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate1(&it, m_buf, 2*nbRead); } else { @@ -103,22 +109,22 @@ void FCDProPlusThread::work(unsigned int n_items) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate2_inf(&it, m_buf, 2*nbRead); break; case 2: - m_decimators.decimate4_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate4_inf(&it, m_buf, 2*nbRead); break; case 3: - m_decimators.decimate8_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate8_inf(&it, m_buf, 2*nbRead); break; case 4: - m_decimators.decimate16_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate16_inf(&it, m_buf, 2*nbRead); break; case 5: - m_decimators.decimate32_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate32_inf(&it, m_buf, 2*nbRead); break; case 6: - m_decimators.decimate64_inf(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate64_inf(&it, m_buf, 2*nbRead); break; default: break; @@ -129,22 +135,22 @@ void FCDProPlusThread::work(unsigned int n_items) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate2_sup(&it, m_buf, 2*nbRead); break; case 2: - m_decimators.decimate4_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate4_sup(&it, m_buf, 2*nbRead); break; case 3: - m_decimators.decimate8_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate8_sup(&it, m_buf, 2*nbRead); break; case 4: - m_decimators.decimate16_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate16_sup(&it, m_buf, 2*nbRead); break; case 5: - m_decimators.decimate32_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate32_sup(&it, m_buf, 2*nbRead); break; case 6: - m_decimators.decimate64_sup(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate64_sup(&it, m_buf, 2*nbRead); break; default: break; @@ -155,22 +161,116 @@ void FCDProPlusThread::work(unsigned int n_items) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate2_cen(&it, m_buf, 2*nbRead); break; case 2: - m_decimators.decimate4_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate4_cen(&it, m_buf, 2*nbRead); break; case 3: - m_decimators.decimate8_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate8_cen(&it, m_buf, 2*nbRead); break; case 4: - m_decimators.decimate16_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate16_cen(&it, m_buf, 2*nbRead); break; case 5: - m_decimators.decimate32_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate32_cen(&it, m_buf, 2*nbRead); break; case 6: - m_decimators.decimate64_cen(&it, m_buf, 2*nbRead); + m_decimatorsIQ.decimate64_cen(&it, m_buf, 2*nbRead); + break; + default: + break; + } + } + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} + +void FCDProPlusThread::workQI(unsigned int n_items) +{ + uint32_t nbRead = m_fcdFIFO->read((unsigned char *) m_buf, n_items); // number of samples + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, m_buf, 2*nbRead); + } + else + { + if (m_fcPos == 0) // Infradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, m_buf, 2*nbRead); + break; + case 2: + m_decimatorsQI.decimate4_inf(&it, m_buf, 2*nbRead); + break; + case 3: + m_decimatorsQI.decimate8_inf(&it, m_buf, 2*nbRead); + break; + case 4: + m_decimatorsQI.decimate16_inf(&it, m_buf, 2*nbRead); + break; + case 5: + m_decimatorsQI.decimate32_inf(&it, m_buf, 2*nbRead); + break; + case 6: + m_decimatorsQI.decimate64_inf(&it, m_buf, 2*nbRead); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, m_buf, 2*nbRead); + break; + case 2: + m_decimatorsQI.decimate4_sup(&it, m_buf, 2*nbRead); + break; + case 3: + m_decimatorsQI.decimate8_sup(&it, m_buf, 2*nbRead); + break; + case 4: + m_decimatorsQI.decimate16_sup(&it, m_buf, 2*nbRead); + break; + case 5: + m_decimatorsQI.decimate32_sup(&it, m_buf, 2*nbRead); + break; + case 6: + m_decimatorsQI.decimate64_sup(&it, m_buf, 2*nbRead); + break; + default: + break; + } + } + else // Centered + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, m_buf, 2*nbRead); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, m_buf, 2*nbRead); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, m_buf, 2*nbRead); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, m_buf, 2*nbRead); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, m_buf, 2*nbRead); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, m_buf, 2*nbRead); break; default: break; diff --git a/plugins/samplesource/fcdproplus/fcdproplusthread.h b/plugins/samplesource/fcdproplus/fcdproplusthread.h index faea5d178..4c00be307 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusthread.h +++ b/plugins/samplesource/fcdproplus/fcdproplusthread.h @@ -40,6 +40,7 @@ public: void stopWork(); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: AudioFifo* m_fcdFIFO; @@ -49,13 +50,16 @@ private: bool m_running; unsigned int m_log2Decim; int m_fcPos; + bool m_iqOrder; qint16 m_buf[fcd_traits::convBufSize*2]; // stereo (I, Q) SampleVector m_convertBuffer; SampleSinkFifo* m_sampleFifo; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; void run(); - void work(unsigned int n_items); + void workIQ(unsigned int n_items); + void workQI(unsigned int n_items); }; #endif // INCLUDE_FCDTHREAD_H diff --git a/plugins/samplesource/hackrfinput/hackrfinput.cpp b/plugins/samplesource/hackrfinput/hackrfinput.cpp index 80d1c0ff7..bcfec0213 100644 --- a/plugins/samplesource/hackrfinput/hackrfinput.cpp +++ b/plugins/samplesource/hackrfinput/hackrfinput.cpp @@ -46,8 +46,8 @@ MESSAGE_CLASS_DEFINITION(HackRFInput::MsgStartStop, Message) HackRFInput::HackRFInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), - m_dev(0), - m_hackRFThread(0), + m_dev(nullptr), + m_hackRFThread(nullptr), m_deviceDescription("HackRF"), m_running(false) { @@ -155,7 +155,7 @@ bool HackRFInput::start() m_hackRFThread->setSamplerate(m_settings.m_devSampleRate); m_hackRFThread->setLog2Decimation(m_settings.m_log2Decim); m_hackRFThread->setFcPos((int) m_settings.m_fcPos); - + m_hackRFThread->setIQOrder(m_settings.m_iqOrder); m_hackRFThread->startWork(); qDebug("HackRFInput::startInput: started"); @@ -186,11 +186,11 @@ void HackRFInput::stop() qDebug("HackRFInput::stop"); // QMutexLocker mutexLocker(&m_mutex); - if (m_hackRFThread != 0) + if (m_hackRFThread) { m_hackRFThread->stopWork(); delete m_hackRFThread; - m_hackRFThread = 0; + m_hackRFThread = nullptr; } m_running = false; @@ -402,7 +402,7 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) } else { - if (m_hackRFThread != 0) + if (m_hackRFThread) { qDebug("HackRFInput::applySettings: sample rate set to %llu S/s", settings.m_devSampleRate); m_hackRFThread->setSamplerate(settings.m_devSampleRate); @@ -416,13 +416,22 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_hackRFThread != 0) + if (m_hackRFThread) { m_hackRFThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "HackRFInput: set decimation to " << (1<setIQOrder(settings.m_iqOrder); + } + } + if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)) { reverseAPIKeys.append("centerFrequency"); } @@ -470,7 +479,7 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) if ((m_settings.m_fcPos != settings.m_fcPos) || force) { - if (m_hackRFThread != 0) + if (m_hackRFThread) { m_hackRFThread->setFcPos((int) settings.m_fcPos); qDebug() << "HackRFInput: set fc pos (enum) to " << (int) settings.m_fcPos; diff --git a/plugins/samplesource/hackrfinput/hackrfinputsettings.cpp b/plugins/samplesource/hackrfinput/hackrfinputsettings.cpp index 2d9e27af8..986274306 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputsettings.cpp +++ b/plugins/samplesource/hackrfinput/hackrfinputsettings.cpp @@ -43,6 +43,7 @@ void HackRFInputSettings::resetToDefaults() m_fileRecordName = ""; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; m_reverseAPIPort = 8888; @@ -70,6 +71,7 @@ QByteArray HackRFInputSettings::serialize() const s.writeU32(17, m_reverseAPIDeviceIndex); s.writeBool(18, m_transverterMode); s.writeS64(19, m_transverterDeltaFrequency); + s.writeBool(20, m_iqOrder); return s.final(); } @@ -115,6 +117,7 @@ bool HackRFInputSettings::deserialize(const QByteArray& data) m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; d.readBool(18, &m_transverterMode, false); d.readS64(19, &m_transverterDeltaFrequency, 0); + d.readBool(20, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/hackrfinput/hackrfinputsettings.h b/plugins/samplesource/hackrfinput/hackrfinputsettings.h index 008acaf5b..2d8b9eab8 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputsettings.h +++ b/plugins/samplesource/hackrfinput/hackrfinputsettings.h @@ -43,6 +43,7 @@ struct HackRFInputSettings { QString m_fileRecordName; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; bool m_useReverseAPI; QString m_reverseAPIAddress; uint16_t m_reverseAPIPort; diff --git a/plugins/samplesource/hackrfinput/hackrfinputthread.cpp b/plugins/samplesource/hackrfinput/hackrfinputthread.cpp index cfbe78fb9..1039a1c94 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputthread.cpp +++ b/plugins/samplesource/hackrfinput/hackrfinputthread.cpp @@ -31,7 +31,8 @@ HackRFInputThread::HackRFInputThread(hackrf_device* dev, SampleSinkFifo* sampleF m_sampleFifo(sampleFifo), m_samplerate(10), m_log2Decim(0), - m_fcPos(0) + m_fcPos(0), + m_iqOrder(true) { std::fill(m_buf, m_buf + 2*HACKRF_BLOCKSIZE, 0); } @@ -122,13 +123,13 @@ void HackRFInputThread::run() } // Decimate according to specified log2 (ex: log2=4 => decim=16) -void HackRFInputThread::callback(const qint8* buf, qint32 len) +void HackRFInputThread::callbackIQ(const qint8* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); } else { @@ -137,22 +138,22 @@ void HackRFInputThread::callback(const qint8* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, buf, len); + m_decimatorsIQ.decimate2_inf(&it, buf, len); break; case 2: - m_decimators.decimate4_inf_txsync(&it, buf, len); + m_decimatorsIQ.decimate4_inf_txsync(&it, buf, len); break; case 3: - m_decimators.decimate8_inf_txsync(&it, buf, len); + m_decimatorsIQ.decimate8_inf_txsync(&it, buf, len); break; case 4: - m_decimators.decimate16_inf_txsync(&it, buf, len); + m_decimatorsIQ.decimate16_inf_txsync(&it, buf, len); break; case 5: - m_decimators.decimate32_inf_txsync(&it, buf, len); + m_decimatorsIQ.decimate32_inf_txsync(&it, buf, len); break; case 6: - m_decimators.decimate64_inf_txsync(&it, buf, len); + m_decimatorsIQ.decimate64_inf_txsync(&it, buf, len); break; default: break; @@ -163,22 +164,22 @@ void HackRFInputThread::callback(const qint8* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, buf, len); + m_decimatorsIQ.decimate2_sup(&it, buf, len); break; case 2: - m_decimators.decimate4_sup_txsync(&it, buf, len); + m_decimatorsIQ.decimate4_sup_txsync(&it, buf, len); break; case 3: - m_decimators.decimate8_sup_txsync(&it, buf, len); + m_decimatorsIQ.decimate8_sup_txsync(&it, buf, len); break; case 4: - m_decimators.decimate16_sup_txsync(&it, buf, len); + m_decimatorsIQ.decimate16_sup_txsync(&it, buf, len); break; case 5: - m_decimators.decimate32_sup_txsync(&it, buf, len); + m_decimatorsIQ.decimate32_sup_txsync(&it, buf, len); break; case 6: - m_decimators.decimate64_sup_txsync(&it, buf, len); + m_decimatorsIQ.decimate64_sup_txsync(&it, buf, len); break; default: break; @@ -189,22 +190,22 @@ void HackRFInputThread::callback(const qint8* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); break; default: break; @@ -215,11 +216,109 @@ void HackRFInputThread::callback(const qint8* buf, qint32 len) m_sampleFifo->write(m_convertBuffer.begin(), it); } +void HackRFInputThread::callbackQI(const qint8* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + if (m_fcPos == 0) // Infra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_inf_txsync(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_inf_txsync(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_inf_txsync(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_inf_txsync(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_inf_txsync(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_sup_txsync(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_sup_txsync(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_sup_txsync(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_sup_txsync(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_sup_txsync(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 2) // Center + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} int HackRFInputThread::rx_callback(hackrf_transfer* transfer) { HackRFInputThread *thread = (HackRFInputThread *) transfer->rx_ctx; qint32 bytes_to_write = transfer->valid_length; - thread->callback((qint8 *) transfer->buffer, bytes_to_write); - return 0; + + if (thread->m_iqOrder) { + thread->callbackIQ((qint8 *) transfer->buffer, bytes_to_write); + } else { + thread->callbackQI((qint8 *) transfer->buffer, bytes_to_write); + } + + return 0; } diff --git a/plugins/samplesource/hackrfinput/hackrfinputthread.h b/plugins/samplesource/hackrfinput/hackrfinputthread.h index 21ed22a9b..1c9163d1b 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputthread.h +++ b/plugins/samplesource/hackrfinput/hackrfinputthread.h @@ -40,6 +40,7 @@ public: void setSamplerate(uint32_t samplerate); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -54,11 +55,14 @@ private: int m_samplerate; unsigned int m_log2Decim; int m_fcPos; + bool m_iqOrder; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; void run(); - void callback(const qint8* buf, qint32 len); + void callbackIQ(const qint8* buf, qint32 len); + void callbackQI(const qint8* buf, qint32 len); static int rx_callback(hackrf_transfer* transfer); }; diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index c9fcb5455..d648b226d 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -53,7 +53,7 @@ MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgStartStop, Message) LimeSDRInput::LimeSDRInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), - m_limeSDRInputThread(0), + m_limeSDRInputThread(nullptr), m_deviceDescription("LimeSDRInput"), m_running(false), m_channelAcquired(false) @@ -422,7 +422,7 @@ bool LimeSDRInput::start() applySettings(m_settings, true); m_limeSDRInputThread->setLog2Decimation(m_settings.m_log2SoftDecim); - + m_limeSDRInputThread->setIQOrder(m_settings.m_iqOrder); m_limeSDRInputThread->startWork(); m_deviceShared.m_thread = m_limeSDRInputThread; @@ -439,7 +439,7 @@ void LimeSDRInput::stop() { m_limeSDRInputThread->stopWork(); delete m_limeSDRInputThread; - m_limeSDRInputThread = 0; + m_limeSDRInputThread = nullptr; } m_deviceShared.m_thread = 0; @@ -1096,6 +1096,15 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc } } + if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) + { + reverseAPIKeys.append("iqOrder"); + + if (m_limeSDRInputThread) { + m_limeSDRInputThread->setIQOrder(settings.m_iqOrder); + } + } + if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) { reverseAPIKeys.append("antennaPath"); diff --git a/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp b/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp index c7ad85493..9ac720d8c 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp @@ -46,6 +46,7 @@ void LimeSDRInputSettings::resetToDefaults() m_extClockFreq = 10000000; // 10 MHz m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_fileRecordName = ""; m_gpioDir = 0; m_gpioPins = 0; @@ -85,6 +86,7 @@ QByteArray LimeSDRInputSettings::serialize() const s.writeString(25, m_reverseAPIAddress); s.writeU32(26, m_reverseAPIPort); s.writeU32(27, m_reverseAPIDeviceIndex); + s.writeBool(28, m_iqOrder); return s.final(); } @@ -141,6 +143,7 @@ bool LimeSDRInputSettings::deserialize(const QByteArray& data) d.readU32(27, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(28, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/limesdrinput/limesdrinputsettings.h b/plugins/samplesource/limesdrinput/limesdrinputsettings.h index 36779dc8c..765a6b23c 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputsettings.h +++ b/plugins/samplesource/limesdrinput/limesdrinputsettings.h @@ -66,6 +66,7 @@ struct LimeSDRInputSettings uint32_t m_extClockFreq; //!< Frequency (Hz) of external clock source bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; QString m_fileRecordName; uint8_t m_gpioDir; //!< GPIO pin direction LSB first; 0 input, 1 output uint8_t m_gpioPins; //!< GPIO pins to write; LSB first diff --git a/plugins/samplesource/limesdrinput/limesdrinputthread.cpp b/plugins/samplesource/limesdrinput/limesdrinputthread.cpp index 79f19f4d9..1730899dd 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputthread.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinputthread.cpp @@ -27,7 +27,8 @@ LimeSDRInputThread::LimeSDRInputThread(lms_stream_t* stream, SampleSinkFifo* sam m_stream(stream), m_convertBuffer(DeviceLimeSDR::blockSize), m_sampleFifo(sampleFifo), - m_log2Decim(0) + m_log2Decim(0), + m_iqOrder(true) { std::fill(m_buf, m_buf + 2*DeviceLimeSDR::blockSize, 0); } @@ -94,39 +95,43 @@ void LimeSDRInputThread::run() break; } - callback(m_buf, 2 * res); + if (m_iqOrder) { + callbackIQ(m_buf, 2 * res); + } else { + callbackQI(m_buf, 2 * res); + } } m_running = false; } // Decimate according to specified log2 (ex: log2=4 => decim=16) -void LimeSDRInputThread::callback(const qint16* buf, qint32 len) +void LimeSDRInputThread::callbackIQ(const qint16* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); switch (m_log2Decim) { case 0: - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); break; case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); break; default: break; @@ -135,3 +140,36 @@ void LimeSDRInputThread::callback(const qint16* buf, qint32 len) m_sampleFifo->write(m_convertBuffer.begin(), it); } +void LimeSDRInputThread::callbackQI(const qint16* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + switch (m_log2Decim) + { + case 0: + m_decimatorsQI.decimate1(&it, buf, len); + break; + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} diff --git a/plugins/samplesource/limesdrinput/limesdrinputthread.h b/plugins/samplesource/limesdrinput/limesdrinputthread.h index 1ea9a7d1d..29b7a1cdc 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputthread.h +++ b/plugins/samplesource/limesdrinput/limesdrinputthread.h @@ -42,6 +42,7 @@ public: virtual void setDeviceSampleRate(int sampleRate) { (void) sampleRate; } virtual bool isRunning() { return m_running; } void setLog2Decimation(unsigned int log2_decim); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -54,11 +55,14 @@ private: SampleSinkFifo* m_sampleFifo; unsigned int m_log2Decim; // soft decimation + bool m_iqOrder; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; void run(); - void callback(const qint16* buf, qint32 len); + void callbackIQ(const qint16* buf, qint32 len); + void callbackQI(const qint16* buf, qint32 len); }; diff --git a/plugins/samplesource/perseus/perseusinput.cpp b/plugins/samplesource/perseus/perseusinput.cpp index ab66e35b0..88f9db279 100644 --- a/plugins/samplesource/perseus/perseusinput.cpp +++ b/plugins/samplesource/perseus/perseusinput.cpp @@ -44,7 +44,7 @@ PerseusInput::PerseusInput(DeviceAPI *deviceAPI) : m_fileSink(0), m_deviceDescription("PerseusInput"), m_running(false), - m_perseusThread(0), + m_perseusThread(nullptr), m_perseusDescriptor(0) { openDevice(); @@ -86,6 +86,7 @@ bool PerseusInput::start() applySettings(m_settings, true); + m_perseusThread->setIQOrder(m_settings.m_iqOrder); m_perseusThread->setLog2Decimation(m_settings.m_log2Decim); m_perseusThread->startWork(); @@ -96,11 +97,11 @@ bool PerseusInput::start() void PerseusInput::stop() { - if (m_perseusThread != 0) + if (m_perseusThread) { m_perseusThread->stopWork(); delete m_perseusThread; - m_perseusThread = 0; + m_perseusThread = nullptr; } m_running = false; @@ -341,13 +342,22 @@ bool PerseusInput::applySettings(const PerseusSettings& settings, bool force) reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_perseusThread != 0) + if (m_perseusThread) { m_perseusThread->setLog2Decimation(settings.m_log2Decim); qDebug("PerseusInput: set decimation to %d", (1<setIQOrder(settings.m_iqOrder); + } + } + if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)) { reverseAPIKeys.append("centerFrequency"); } diff --git a/plugins/samplesource/perseus/perseussettings.cpp b/plugins/samplesource/perseus/perseussettings.cpp index 8c7ca75bd..0013d8736 100644 --- a/plugins/samplesource/perseus/perseussettings.cpp +++ b/plugins/samplesource/perseus/perseussettings.cpp @@ -32,6 +32,7 @@ void PerseusSettings::resetToDefaults() m_log2Decim = 0; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_adcDither = false; m_adcPreamp = false; m_wideBand = false; @@ -60,6 +61,7 @@ QByteArray PerseusSettings::serialize() const s.writeString(11, m_reverseAPIAddress); s.writeU32(12, m_reverseAPIPort); s.writeU32(13, m_reverseAPIDeviceIndex); + s.writeBool(14, m_iqOrder); return s.final(); } @@ -107,6 +109,7 @@ bool PerseusSettings::deserialize(const QByteArray& data) d.readU32(13, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(14, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/perseus/perseussettings.h b/plugins/samplesource/perseus/perseussettings.h index e407ae4eb..df0476529 100644 --- a/plugins/samplesource/perseus/perseussettings.h +++ b/plugins/samplesource/perseus/perseussettings.h @@ -38,6 +38,7 @@ struct PerseusSettings quint32 m_log2Decim; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; bool m_adcDither; bool m_adcPreamp; bool m_wideBand; diff --git a/plugins/samplesource/perseus/perseusthread.cpp b/plugins/samplesource/perseus/perseusthread.cpp index 903109352..4cec02b9b 100644 --- a/plugins/samplesource/perseus/perseusthread.cpp +++ b/plugins/samplesource/perseus/perseusthread.cpp @@ -27,7 +27,8 @@ PerseusThread::PerseusThread(perseus_descr* dev, SampleSinkFifo* sampleFifo, QOb m_dev(dev), m_convertBuffer(PERSEUS_NBSAMPLES), m_sampleFifo(sampleFifo), - m_log2Decim(0) + m_log2Decim(0), + m_iqOrder(true) { m_this = this; std::fill(m_buf, m_buf + 2*PERSEUS_NBSAMPLES, 0); @@ -90,20 +91,42 @@ void PerseusThread::run() m_running = false; } -void PerseusThread::callback(const uint8_t* buf, qint32 len) +void PerseusThread::callbackIQ(const uint8_t* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); switch (m_log2Decim) { case 0: - m_decimators32.decimate1(&it, (TripleByteLE*) buf, len); + m_decimators32IQ.decimate1(&it, (TripleByteLE*) buf, len); break; case 1: - m_decimators64.decimate2_cen(&it, (TripleByteLE*) buf, len); + m_decimators64IQ.decimate2_cen(&it, (TripleByteLE*) buf, len); break; case 2: - m_decimators64.decimate4_cen(&it, (TripleByteLE*) buf, len); + m_decimators64IQ.decimate4_cen(&it, (TripleByteLE*) buf, len); + break; + default: + break; + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} + +void PerseusThread::callbackQI(const uint8_t* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + switch (m_log2Decim) + { + case 0: + m_decimators32QI.decimate1(&it, (TripleByteLE*) buf, len); + break; + case 1: + m_decimators64QI.decimate2_cen(&it, (TripleByteLE*) buf, len); + break; + case 2: + m_decimators64QI.decimate4_cen(&it, (TripleByteLE*) buf, len); break; default: break; @@ -116,7 +139,13 @@ int PerseusThread::rx_callback(void *buf, int buf_size, void *extra) { (void) extra; qint32 nbIAndQ = buf_size / 3; // 3 bytes per I or Q - m_this->callback((uint8_t*) buf, nbIAndQ); - return 0; + + if (m_this->m_iqOrder) { + m_this->callbackIQ((uint8_t*) buf, nbIAndQ); + } else { + m_this->callbackQI((uint8_t*) buf, nbIAndQ); + } + + return 0; } diff --git a/plugins/samplesource/perseus/perseusthread.h b/plugins/samplesource/perseus/perseusthread.h index d7cd7f070..5e36cc53d 100644 --- a/plugins/samplesource/perseus/perseusthread.h +++ b/plugins/samplesource/perseus/perseusthread.h @@ -39,6 +39,7 @@ public: void startWork(); void stopWork(); void setLog2Decimation(unsigned int log2_decim); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -51,13 +52,17 @@ private: SampleSinkFifo* m_sampleFifo; unsigned int m_log2Decim; + bool m_iqOrder; static PerseusThread *m_this; - Decimators, SDR_RX_SAMP_SZ, 24> m_decimators32; // for no decimation (accumulator is int32) - Decimators, SDR_RX_SAMP_SZ, 24> m_decimators64; // for actual decimation (accumulator is int64) + Decimators, SDR_RX_SAMP_SZ, 24, true> m_decimators32IQ; // for no decimation (accumulator is int32) + Decimators, SDR_RX_SAMP_SZ, 24, true> m_decimators64IQ; // for actual decimation (accumulator is int64) + Decimators, SDR_RX_SAMP_SZ, 24, false> m_decimators32QI; // for no decimation (accumulator is int32) + Decimators, SDR_RX_SAMP_SZ, 24, false> m_decimators64QI; // for actual decimation (accumulator is int64) void run(); - void callback(const uint8_t* buf, qint32 len); // inner call back + void callbackIQ(const uint8_t* buf, qint32 len); // inner call back + void callbackQI(const uint8_t* buf, qint32 len); static int rx_callback(void *buf, int buf_size, void *extra); // call back from Perseus }; diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp index 1bcb1704e..f072043d9 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp @@ -48,7 +48,7 @@ PlutoSDRInput::PlutoSDRInput(DeviceAPI *deviceAPI) : m_deviceDescription("PlutoSDRInput"), m_running(false), m_plutoRxBuffer(0), - m_plutoSDRInputThread(0) + m_plutoSDRInputThread(nullptr) { m_deviceSampleRates.m_addaConnvRate = 0; m_deviceSampleRates.m_bbRateHz = 0; @@ -115,6 +115,7 @@ bool PlutoSDRInput::start() applySettings(m_settings, true); m_plutoSDRInputThread->setLog2Decimation(m_settings.m_log2Decim); + m_plutoSDRInputThread->setIQOrder(m_settings.m_iqOrder); m_plutoSDRInputThread->startWork(); m_deviceShared.m_thread = m_plutoSDRInputThread; @@ -125,14 +126,14 @@ bool PlutoSDRInput::start() void PlutoSDRInput::stop() { - if (m_plutoSDRInputThread != 0) + if (m_plutoSDRInputThread) { m_plutoSDRInputThread->stopWork(); delete m_plutoSDRInputThread; - m_plutoSDRInputThread = 0; + m_plutoSDRInputThread = nullptr; } - m_deviceShared.m_thread = 0; + m_deviceShared.m_thread = nullptr; m_running = false; } @@ -585,7 +586,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) { - if (m_plutoSDRInputThread != 0) + if (m_plutoSDRInputThread) { m_plutoSDRInputThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "PlutoSDRInput::applySettings: set soft decimation to " << (1<setIQOrder(settings.m_iqOrder); + } + } + if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) { plutoBox->setLOPPMTenths(settings.m_LOppmTenths); @@ -625,7 +633,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo if ((m_settings.m_fcPos != settings.m_fcPos) || force) { - if (m_plutoSDRInputThread != 0) + if (m_plutoSDRInputThread) { m_plutoSDRInputThread->setFcPos(settings.m_fcPos); qDebug() << "PlutoSDRInput::applySettings: set fcPos to " << settings.m_fcPos; diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputsettings.cpp b/plugins/samplesource/plutosdrinput/plutosdrinputsettings.cpp index c238be8b6..b336c5af8 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputsettings.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinputsettings.cpp @@ -48,6 +48,7 @@ void PlutoSDRInputSettings::resetToDefaults() m_gainMode = GAIN_MANUAL; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -82,6 +83,7 @@ QByteArray PlutoSDRInputSettings::serialize() const s.writeBool(22, m_hwBBDCBlock); s.writeBool(23, m_hwRFDCBlock); s.writeBool(24, m_hwIQCorrection); + s.writeBool(25, m_iqOrder); return s.final(); } @@ -153,6 +155,7 @@ bool PlutoSDRInputSettings::deserialize(const QByteArray& data) d.readBool(22, &m_hwBBDCBlock, true); d.readBool(23, &m_hwRFDCBlock, true); d.readBool(24, &m_hwIQCorrection, true); + d.readBool(25, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputsettings.h b/plugins/samplesource/plutosdrinput/plutosdrinputsettings.h index 34143ad9f..776223c1d 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputsettings.h +++ b/plugins/samplesource/plutosdrinput/plutosdrinputsettings.h @@ -78,6 +78,7 @@ struct PlutoSDRInputSettings { GainMode m_gainMode; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputthread.cpp b/plugins/samplesource/plutosdrinput/plutosdrinputthread.cpp index fa6ec87ba..74c5ecfba 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputthread.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinputthread.cpp @@ -31,7 +31,8 @@ PlutoSDRInputThread::PlutoSDRInputThread(uint32_t blocksizeSamples, DevicePlutoS m_sampleFifo(sampleFifo), m_log2Decim(0), m_fcPos(PlutoSDRInputSettings::FC_POS_CENTER), - m_phasor(0) + m_phasor(0), + m_iqOrder(true) { m_buf = new qint16[blocksizeSamples*2]; // (I,Q) -> 2 * int16_t m_bufConv = new qint16[blocksizeSamples*2]; // (I,Q) -> 2 * int16_t @@ -139,21 +140,24 @@ void PlutoSDRInputThread::run() ihs++; } - //m_sampleFifo->write((unsigned char *) m_buf, ihs*sizeof(int16_t)); - convert(m_buf, 2*m_blockSizeSamples); // size given in number of int16_t (I and Q interleaved) + if (m_iqOrder) { + convertIQ(m_buf, 2*m_blockSizeSamples); // size given in number of int16_t (I and Q interleaved) + } else { + convertQI(m_buf, 2*m_blockSizeSamples); + } } m_running = false; } // Decimate according to specified log2 (ex: log2=4 => decim=16) -void PlutoSDRInputThread::convert(const qint16* buf, qint32 len) +void PlutoSDRInputThread::convertIQ(const qint16* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); } else { @@ -162,22 +166,22 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, buf, len); + m_decimatorsIQ.decimate2_inf(&it, buf, len); break; case 2: - m_decimators.decimate4_inf(&it, buf, len); + m_decimatorsIQ.decimate4_inf(&it, buf, len); break; case 3: - m_decimators.decimate8_inf(&it, buf, len); + m_decimatorsIQ.decimate8_inf(&it, buf, len); break; case 4: - m_decimators.decimate16_inf(&it, buf, len); + m_decimatorsIQ.decimate16_inf(&it, buf, len); break; case 5: - m_decimators.decimate32_inf(&it, buf, len); + m_decimatorsIQ.decimate32_inf(&it, buf, len); break; case 6: - m_decimators.decimate64_inf(&it, buf, len); + m_decimatorsIQ.decimate64_inf(&it, buf, len); break; default: break; @@ -188,22 +192,22 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, buf, len); + m_decimatorsIQ.decimate2_sup(&it, buf, len); break; case 2: - m_decimators.decimate4_sup(&it, buf, len); + m_decimatorsIQ.decimate4_sup(&it, buf, len); break; case 3: - m_decimators.decimate8_sup(&it, buf, len); + m_decimatorsIQ.decimate8_sup(&it, buf, len); break; case 4: - m_decimators.decimate16_sup(&it, buf, len); + m_decimatorsIQ.decimate16_sup(&it, buf, len); break; case 5: - m_decimators.decimate32_sup(&it, buf, len); + m_decimatorsIQ.decimate32_sup(&it, buf, len); break; case 6: - m_decimators.decimate64_sup(&it, buf, len); + m_decimatorsIQ.decimate64_sup(&it, buf, len); break; default: break; @@ -214,22 +218,22 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); break; default: break; @@ -240,3 +244,95 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len) m_sampleFifo->write(m_convertBuffer.begin(), it); } +void PlutoSDRInputThread::convertQI(const qint16* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + if (m_fcPos == 0) // Infra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_inf(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_inf(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_inf(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_inf(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supra + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_sup(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_sup(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_sup(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_sup(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 2) // Center + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); +} diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputthread.h b/plugins/samplesource/plutosdrinput/plutosdrinputthread.h index 1e02bf578..010add1c0 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputthread.h +++ b/plugins/samplesource/plutosdrinput/plutosdrinputthread.h @@ -42,6 +42,7 @@ public: virtual bool isRunning() { return m_running; } void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -59,12 +60,14 @@ private: unsigned int m_log2Decim; // soft decimation int m_fcPos; float m_phasor; + bool m_iqOrder; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; void run(); - void convert(const qint16* buf, qint32 len); - + void convertIQ(const qint16* buf, qint32 len); + void convertQI(const qint16* buf, qint32 len); }; diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index 71552fc94..1e2d9c9c9 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -54,7 +54,7 @@ RTLSDRInput::RTLSDRInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), m_dev(0), - m_rtlSDRThread(0), + m_rtlSDRThread(nullptr), m_deviceDescription(), m_running(false) { @@ -207,7 +207,7 @@ bool RTLSDRInput::start() m_rtlSDRThread->setSamplerate(m_settings.m_devSampleRate); m_rtlSDRThread->setLog2Decimation(m_settings.m_log2Decim); m_rtlSDRThread->setFcPos((int) m_settings.m_fcPos); - + m_rtlSDRThread->setIQOrder(m_settings.m_iqOrder); m_rtlSDRThread->startWork(); mutexLocker.unlock(); @@ -233,11 +233,11 @@ void RTLSDRInput::stop() { QMutexLocker mutexLocker(&m_mutex); - if (m_rtlSDRThread != 0) + if (m_rtlSDRThread) { m_rtlSDRThread->stopWork(); delete m_rtlSDRThread; - m_rtlSDRThread = 0; + m_rtlSDRThread = nullptr; } m_running = false; @@ -434,7 +434,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force) reverseAPIKeys.append("log2Decim"); forwardChange = true; - if (m_rtlSDRThread != 0) { + if (m_rtlSDRThread) { m_rtlSDRThread->setLog2Decimation(settings.m_log2Decim); } @@ -445,7 +445,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force) { reverseAPIKeys.append("fcPos"); - if (m_rtlSDRThread != 0) { + if (m_rtlSDRThread) { m_rtlSDRThread->setFcPos((int) settings.m_fcPos); } @@ -465,6 +465,15 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force) reverseAPIKeys.append("transverterDeltaFrequency"); } + if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) + { + reverseAPIKeys.append("iqOrder"); + + if (m_rtlSDRThread) { + m_rtlSDRThread->setIQOrder(settings.m_iqOrder); + } + } + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || (m_settings.m_fcPos != settings.m_fcPos) || (m_settings.m_log2Decim != settings.m_log2Decim) diff --git a/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp b/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp index 92180eeab..c1dc27102 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp @@ -38,6 +38,7 @@ void RTLSDRSettings::resetToDefaults() m_agc = false; m_noModMode = false; m_transverterMode = false; + m_iqOrder = true; m_transverterDeltaFrequency = 0; m_rfBandwidth = 2500 * 1000; // Hz m_fileRecordName = ""; @@ -70,6 +71,7 @@ QByteArray RTLSDRSettings::serialize() const s.writeString(17, m_reverseAPIAddress); s.writeU32(18, m_reverseAPIPort); s.writeU32(19, m_reverseAPIDeviceIndex); + s.writeBool(20, m_iqOrder); return s.final(); } @@ -116,6 +118,7 @@ bool RTLSDRSettings::deserialize(const QByteArray& data) d.readU32(19, &utmp, 0); m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp; + d.readBool(20, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/rtlsdr/rtlsdrsettings.h b/plugins/samplesource/rtlsdr/rtlsdrsettings.h index d74932369..beac7cb37 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrsettings.h +++ b/plugins/samplesource/rtlsdr/rtlsdrsettings.h @@ -39,6 +39,7 @@ struct RTLSDRSettings { bool m_agc; bool m_noModMode; bool m_transverterMode; + bool m_iqOrder; qint64 m_transverterDeltaFrequency; quint32 m_rfBandwidth; //!< RF filter bandwidth in Hz QString m_fileRecordName; diff --git a/plugins/samplesource/rtlsdr/rtlsdrthread.cpp b/plugins/samplesource/rtlsdr/rtlsdrthread.cpp index c7b3138c1..6ff2c6b2e 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrthread.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrthread.cpp @@ -32,7 +32,8 @@ RTLSDRThread::RTLSDRThread(rtlsdr_dev_t* dev, SampleSinkFifo* sampleFifo, QObjec m_sampleFifo(sampleFifo), m_samplerate(288000), m_log2Decim(4), - m_fcPos(0) + m_fcPos(0), + m_iqOrder(true) { } @@ -89,13 +90,13 @@ void RTLSDRThread::run() } // Decimate according to specified log2 (ex: log2=4 => decim=16) -void RTLSDRThread::callback(const quint8* buf, qint32 len) +void RTLSDRThread::callbackIQ(const quint8* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); } else { @@ -104,22 +105,22 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, buf, len); + m_decimatorsIQ.decimate2_inf(&it, buf, len); break; case 2: - m_decimators.decimate4_inf(&it, buf, len); + m_decimatorsIQ.decimate4_inf(&it, buf, len); break; case 3: - m_decimators.decimate8_inf(&it, buf, len); + m_decimatorsIQ.decimate8_inf(&it, buf, len); break; case 4: - m_decimators.decimate16_inf(&it, buf, len); + m_decimatorsIQ.decimate16_inf(&it, buf, len); break; case 5: - m_decimators.decimate32_inf(&it, buf, len); + m_decimatorsIQ.decimate32_inf(&it, buf, len); break; case 6: - m_decimators.decimate64_inf(&it, buf, len); + m_decimatorsIQ.decimate64_inf(&it, buf, len); break; default: break; @@ -130,22 +131,22 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, buf, len); + m_decimatorsIQ.decimate2_sup(&it, buf, len); break; case 2: - m_decimators.decimate4_sup(&it, buf, len); + m_decimatorsIQ.decimate4_sup(&it, buf, len); break; case 3: - m_decimators.decimate8_sup(&it, buf, len); + m_decimatorsIQ.decimate8_sup(&it, buf, len); break; case 4: - m_decimators.decimate16_sup(&it, buf, len); + m_decimatorsIQ.decimate16_sup(&it, buf, len); break; case 5: - m_decimators.decimate32_sup(&it, buf, len); + m_decimatorsIQ.decimate32_sup(&it, buf, len); break; case 6: - m_decimators.decimate64_sup(&it, buf, len); + m_decimatorsIQ.decimate64_sup(&it, buf, len); break; default: break; @@ -156,22 +157,118 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); + + if(!m_running) + rtlsdr_cancel_async(m_dev); +} + +void RTLSDRThread::callbackQI(const quint8* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + if (m_fcPos == 0) // Infradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_inf(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_inf(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_inf(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_inf(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_sup(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_sup(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_sup(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_sup(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else // Centered + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); break; default: break; @@ -187,7 +284,12 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len) void RTLSDRThread::callbackHelper(unsigned char* buf, uint32_t len, void* ctx) { - RTLSDRThread* thread = (RTLSDRThread*)ctx; - thread->callback(buf, len); + RTLSDRThread* thread = (RTLSDRThread*) ctx; + + if (thread->m_iqOrder) { + thread->callbackIQ(buf, len); + } else { + thread->callbackQI(buf, len); + } } diff --git a/plugins/samplesource/rtlsdr/rtlsdrthread.h b/plugins/samplesource/rtlsdr/rtlsdrthread.h index a22b5407c..5ba6d7949 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrthread.h +++ b/plugins/samplesource/rtlsdr/rtlsdrthread.h @@ -39,6 +39,7 @@ public: void setSamplerate(int samplerate); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -52,11 +53,14 @@ private: int m_samplerate; unsigned int m_log2Decim; int m_fcPos; + bool m_iqOrder; - DecimatorsU m_decimators; + DecimatorsU m_decimatorsIQ; + DecimatorsU m_decimatorsQI; void run(); - void callback(const quint8* buf, qint32 len); + void callbackIQ(const quint8* buf, qint32 len); + void callbackQI(const quint8* buf, qint32 len); static void callbackHelper(unsigned char* buf, uint32_t len, void* ctx); }; diff --git a/plugins/samplesource/sdrplay/sdrplayinput.cpp b/plugins/samplesource/sdrplay/sdrplayinput.cpp index 297f625c7..6dabfc862 100644 --- a/plugins/samplesource/sdrplay/sdrplayinput.cpp +++ b/plugins/samplesource/sdrplay/sdrplayinput.cpp @@ -49,7 +49,7 @@ SDRPlayInput::SDRPlayInput(DeviceAPI *deviceAPI) : m_variant(SDRPlayUndef), m_settings(), m_dev(0), - m_sdrPlayThread(0), + m_sdrPlayThread(nullptr), m_deviceDescription("SDRPlay"), m_devNumber(0), m_running(false) @@ -185,7 +185,7 @@ bool SDRPlayInput::start() m_sdrPlayThread = new SDRPlayThread(m_dev, &m_sampleFifo); m_sdrPlayThread->setLog2Decimation(m_settings.m_log2Decim); m_sdrPlayThread->setFcPos((int) m_settings.m_fcPos); - + m_sdrPlayThread->setIQOrder(m_settings.m_iqOrder); m_sdrPlayThread->startWork(); // mutexLocker.unlock(); @@ -216,11 +216,11 @@ void SDRPlayInput::stop() { // QMutexLocker mutexLocker(&m_mutex); - if(m_sdrPlayThread != 0) + if(m_sdrPlayThread) { m_sdrPlayThread->stopWork(); delete m_sdrPlayThread; - m_sdrPlayThread = 0; + m_sdrPlayThread = nullptr; } m_running = false; @@ -524,7 +524,7 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh { reverseAPIKeys.append("log2Decim"); - if (m_sdrPlayThread != 0) + if (m_sdrPlayThread) { m_sdrPlayThread->setLog2Decimation(settings.m_log2Decim); qDebug() << "SDRPlayInput::applySettings: set decimation to " << (1<setFcPos((int) settings.m_fcPos); qDebug() << "SDRPlayInput: set fc pos (enum) to " << (int) settings.m_fcPos; } } + if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) + { + reverseAPIKeys.append("iqOrder"); + + if (m_sdrPlayThread) + { + m_sdrPlayThread->setIQOrder((int) settings.m_iqOrder); + qDebug() << "SDRPlayInput: set IQ order to " << (settings.m_iqOrder ? "IQ" : "QI"); + } + } + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { reverseAPIKeys.append("centerFrequency"); } diff --git a/plugins/samplesource/sdrplay/sdrplaysettings.cpp b/plugins/samplesource/sdrplay/sdrplaysettings.cpp index b9fb26355..8405e90d7 100644 --- a/plugins/samplesource/sdrplay/sdrplaysettings.cpp +++ b/plugins/samplesource/sdrplay/sdrplaysettings.cpp @@ -42,6 +42,7 @@ void SDRPlaySettings::resetToDefaults() m_lnaOn = false; m_mixerAmpOn = false; m_basebandGain = 29; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -71,6 +72,7 @@ QByteArray SDRPlaySettings::serialize() const s.writeString(16, m_reverseAPIAddress); s.writeU32(17, m_reverseAPIPort); s.writeU32(18, m_reverseAPIDeviceIndex); + s.writeBool(19, m_iqOrder); return s.final(); } @@ -117,6 +119,7 @@ bool SDRPlaySettings::deserialize(const QByteArray& data) d.readU32(18, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(19, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/sdrplay/sdrplaysettings.h b/plugins/samplesource/sdrplay/sdrplaysettings.h index 6693aceb0..7966cd88c 100644 --- a/plugins/samplesource/sdrplay/sdrplaysettings.h +++ b/plugins/samplesource/sdrplay/sdrplaysettings.h @@ -45,6 +45,7 @@ struct SDRPlaySettings { bool m_lnaOn; bool m_mixerAmpOn; int m_basebandGain; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/sdrplay/sdrplaythread.cpp b/plugins/samplesource/sdrplay/sdrplaythread.cpp index 8ee8c7fb0..55f3b513b 100644 --- a/plugins/samplesource/sdrplay/sdrplaythread.cpp +++ b/plugins/samplesource/sdrplay/sdrplaythread.cpp @@ -28,7 +28,8 @@ SDRPlayThread::SDRPlayThread(mirisdr_dev_t* dev, SampleSinkFifo* sampleFifo, QOb m_sampleFifo(sampleFifo), m_samplerate(288000), m_log2Decim(0), - m_fcPos(0) + m_fcPos(0), + m_iqOrder(true) { } @@ -89,16 +90,22 @@ void SDRPlayThread::run() void SDRPlayThread::callbackHelper(unsigned char* buf, uint32_t len, void* ctx) { SDRPlayThread* thread = (SDRPlayThread*) ctx; - thread->callback((const qint16*) buf, len/2); + + if (thread->m_iqOrder) { + thread->callbackIQ((const qint16*) buf, len/2); + } else { + thread->callbackQI((const qint16*) buf, len/2); + } + } -void SDRPlayThread::callback(const qint16* buf, qint32 len) +void SDRPlayThread::callbackIQ(const qint16* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); if (m_log2Decim == 0) { - m_decimators.decimate1(&it, buf, len); + m_decimatorsIQ.decimate1(&it, buf, len); } else { @@ -107,22 +114,22 @@ void SDRPlayThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_inf(&it, buf, len); + m_decimatorsIQ.decimate2_inf(&it, buf, len); break; case 2: - m_decimators.decimate4_inf(&it, buf, len); + m_decimatorsIQ.decimate4_inf(&it, buf, len); break; case 3: - m_decimators.decimate8_inf(&it, buf, len); + m_decimatorsIQ.decimate8_inf(&it, buf, len); break; case 4: - m_decimators.decimate16_inf(&it, buf, len); + m_decimatorsIQ.decimate16_inf(&it, buf, len); break; case 5: - m_decimators.decimate32_inf(&it, buf, len); + m_decimatorsIQ.decimate32_inf(&it, buf, len); break; case 6: - m_decimators.decimate64_inf(&it, buf, len); + m_decimatorsIQ.decimate64_inf(&it, buf, len); break; default: break; @@ -133,22 +140,22 @@ void SDRPlayThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_sup(&it, buf, len); + m_decimatorsIQ.decimate2_sup(&it, buf, len); break; case 2: - m_decimators.decimate4_sup(&it, buf, len); + m_decimatorsIQ.decimate4_sup(&it, buf, len); break; case 3: - m_decimators.decimate8_sup(&it, buf, len); + m_decimatorsIQ.decimate8_sup(&it, buf, len); break; case 4: - m_decimators.decimate16_sup(&it, buf, len); + m_decimatorsIQ.decimate16_sup(&it, buf, len); break; case 5: - m_decimators.decimate32_sup(&it, buf, len); + m_decimatorsIQ.decimate32_sup(&it, buf, len); break; case 6: - m_decimators.decimate64_sup(&it, buf, len); + m_decimatorsIQ.decimate64_sup(&it, buf, len); break; default: break; @@ -159,22 +166,22 @@ void SDRPlayThread::callback(const qint16* buf, qint32 len) switch (m_log2Decim) { case 1: - m_decimators.decimate2_cen(&it, buf, len); + m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_decimators.decimate4_cen(&it, buf, len); + m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_decimators.decimate8_cen(&it, buf, len); + m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_decimators.decimate16_cen(&it, buf, len); + m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_decimators.decimate32_cen(&it, buf, len); + m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_decimators.decimate64_cen(&it, buf, len); + m_decimatorsIQ.decimate64_cen(&it, buf, len); break; default: break; @@ -190,3 +197,100 @@ void SDRPlayThread::callback(const qint16* buf, qint32 len) } } +void SDRPlayThread::callbackQI(const qint16* buf, qint32 len) +{ + SampleVector::iterator it = m_convertBuffer.begin(); + + if (m_log2Decim == 0) + { + m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + if (m_fcPos == 0) // Infradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_inf(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_inf(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_inf(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_inf(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_fcPos == 1) // Supradyne + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_sup(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_sup(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_sup(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_sup(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else // Centered + { + switch (m_log2Decim) + { + case 1: + m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_decimatorsQI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_sampleFifo->write(m_convertBuffer.begin(), it); + + if(!m_running) + { + mirisdr_cancel_async(m_dev); + } +} diff --git a/plugins/samplesource/sdrplay/sdrplaythread.h b/plugins/samplesource/sdrplay/sdrplaythread.h index 8c0c45deb..dcb00d9ba 100644 --- a/plugins/samplesource/sdrplay/sdrplaythread.h +++ b/plugins/samplesource/sdrplay/sdrplaythread.h @@ -39,6 +39,7 @@ public: void setSamplerate(int samplerate); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: QMutex m_startWaitMutex; @@ -52,11 +53,14 @@ private: int m_samplerate; unsigned int m_log2Decim; int m_fcPos; + bool m_iqOrder; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; void run(); - void callback(const qint16* buf, qint32 len); + void callbackIQ(const qint16* buf, qint32 len); + void callbackQI(const qint16* buf, qint32 len); static void callbackHelper(unsigned char* buf, uint32_t len, void* ctx); }; diff --git a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp index 71d8e3911..3e52630b0 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp +++ b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp @@ -48,7 +48,7 @@ SoapySDRInput::SoapySDRInput(DeviceAPI *deviceAPI) : m_settings(), m_deviceDescription("SoapySDRInput"), m_running(false), - m_thread(0) + m_thread(nullptr) { openDevice(); initGainSettings(m_settings); @@ -395,7 +395,7 @@ void SoapySDRInput::init() SoapySDRInputThread *SoapySDRInput::findThread() { - if (m_thread == 0) // this does not own the thread + if (!m_thread) // this does not own the thread { SoapySDRInputThread *soapySDRInputThread = 0; @@ -437,7 +437,7 @@ void SoapySDRInput::moveThreadToBuddy() if (buddySource) { buddySource->setThread(m_thread); - m_thread = 0; // zero for others + m_thread = nullptr; // zero for others } } } @@ -604,7 +604,7 @@ void SoapySDRInput::stop() qDebug("SoapySDRInput::stop: SI mode. Just stop and delete the thread"); soapySDRInputThread->stopWork(); delete soapySDRInputThread; - m_thread = 0; + m_thread = nullptr; // remove old thread address from buddies (reset in all buddies) const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); @@ -636,7 +636,7 @@ void SoapySDRInput::stop() } delete soapySDRInputThread; - m_thread = 0; + m_thread = nullptr; if (highestActiveChannelIndex >= 0) // there is at least one channel still active { @@ -975,7 +975,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo { reverseAPIKeys.append("fcPos"); - if (inputThread != 0) + if (inputThread) { inputThread->setFcPos(requestedChannel, (int) settings.m_fcPos); qDebug() << "SoapySDRInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos; @@ -988,13 +988,25 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo forwardChangeOwnDSP = true; SoapySDRInputThread *inputThread = findThread(); - if (inputThread != 0) + if (inputThread) { inputThread->setLog2Decimation(requestedChannel, settings.m_log2Decim); qDebug() << "SoapySDRInput::applySettings: set decimation to " << (1<setIQOrder(settings.m_iqOrder); + qDebug() << "SoapySDRInput::applySettings: set IQ order to " << (settings.m_iqOrder ? "IQ" : "QI"); + } + } + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { reverseAPIKeys.append("centerFrequency"); } diff --git a/plugins/samplesource/soapysdrinput/soapysdrinputsettings.cpp b/plugins/samplesource/soapysdrinput/soapysdrinputsettings.cpp index 87b48b737..bc5eb524d 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinputsettings.cpp +++ b/plugins/samplesource/soapysdrinput/soapysdrinputsettings.cpp @@ -37,6 +37,7 @@ void SoapySDRInputSettings::resetToDefaults() m_softIQCorrection = false; m_transverterMode = false; m_transverterDeltaFrequency = 0; + m_iqOrder = true; m_fileRecordName = ""; m_antenna = "NONE"; m_bandwidth = 1000000; @@ -82,6 +83,7 @@ QByteArray SoapySDRInputSettings::serialize() const s.writeString(24, m_reverseAPIAddress); s.writeU32(25, m_reverseAPIPort); s.writeU32(26, m_reverseAPIDeviceIndex); + s.writeBool(27, m_iqOrder); return s.final(); } @@ -144,6 +146,7 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data) d.readU32(26, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(27, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h b/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h index 85e7de580..b971a22cb 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h +++ b/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h @@ -39,6 +39,7 @@ struct SoapySDRInputSettings { bool m_softIQCorrection; bool m_transverterMode; qint64 m_transverterDeltaFrequency; + bool m_iqOrder; QString m_fileRecordName; QString m_antenna; quint32 m_bandwidth; diff --git a/plugins/samplesource/soapysdrinput/soapysdrinputthread.cpp b/plugins/samplesource/soapysdrinput/soapysdrinputthread.cpp index c9c6b885f..5c58301c6 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinputthread.cpp +++ b/plugins/samplesource/soapysdrinput/soapysdrinputthread.cpp @@ -32,7 +32,8 @@ SoapySDRInputThread::SoapySDRInputThread(SoapySDR::Device* dev, unsigned int nbR m_dev(dev), m_sampleRate(0), m_nbChannels(nbRxChannels), - m_decimatorType(DecimatorFloat) + m_decimatorType(DecimatorFloat), + m_iqOrder(true) { qDebug("SoapySDRInputThread::SoapySDRInputThread"); m_channels = new Channel[nbRxChannels]; @@ -155,28 +156,57 @@ void SoapySDRInputThread::run() break; } - if (m_nbChannels > 1) + if (m_iqOrder) { - callbackMI(buffs, numElems*2); // size given in number of I or Q samples (2 items per sample) + if (m_nbChannels > 1) + { + callbackMIIQ(buffs, numElems*2); // size given in number of I or Q samples (2 items per sample) + } + else + { + switch (m_decimatorType) + { + case Decimator8: + callbackSI8IQ((const qint8*) buffs[0], numElems*2); + break; + case Decimator12: + callbackSI12IQ((const qint16*) buffs[0], numElems*2); + break; + case Decimator16: + callbackSI16IQ((const qint16*) buffs[0], numElems*2); + break; + case DecimatorFloat: + default: + callbackSIFIQ((const float*) buffs[0], numElems*2); + } + } } else { - switch (m_decimatorType) + if (m_nbChannels > 1) { - case Decimator8: - callbackSI8((const qint8*) buffs[0], numElems*2); - break; - case Decimator12: - callbackSI12((const qint16*) buffs[0], numElems*2); - break; - case Decimator16: - callbackSI16((const qint16*) buffs[0], numElems*2); - break; - case DecimatorFloat: - default: - callbackSIF((const float*) buffs[0], numElems*2); + callbackMIQI(buffs, numElems*2); // size given in number of I or Q samples (2 items per sample) + } + else + { + switch (m_decimatorType) + { + case Decimator8: + callbackSI8QI((const qint8*) buffs[0], numElems*2); + break; + case Decimator12: + callbackSI12QI((const qint16*) buffs[0], numElems*2); + break; + case Decimator16: + callbackSI16QI((const qint16*) buffs[0], numElems*2); + break; + case DecimatorFloat: + default: + callbackSIFQI((const float*) buffs[0], numElems*2); + } } } + } qDebug("SoapySDRInputThread::run: stop running loop"); @@ -253,35 +283,57 @@ SampleSinkFifo *SoapySDRInputThread::getFifo(unsigned int channel) } } -void SoapySDRInputThread::callbackMI(std::vector& buffs, qint32 samplesPerChannel) +void SoapySDRInputThread::callbackMIIQ(std::vector& buffs, qint32 samplesPerChannel) { for(unsigned int ichan = 0; ichan < m_nbChannels; ichan++) { switch (m_decimatorType) { case Decimator8: - callbackSI8((const qint8*) buffs[ichan], samplesPerChannel, ichan); + callbackSI8IQ((const qint8*) buffs[ichan], samplesPerChannel, ichan); break; case Decimator12: - callbackSI12((const qint16*) buffs[ichan], samplesPerChannel, ichan); + callbackSI12IQ((const qint16*) buffs[ichan], samplesPerChannel, ichan); break; case Decimator16: - callbackSI16((const qint16*) buffs[ichan], samplesPerChannel, ichan); + callbackSI16IQ((const qint16*) buffs[ichan], samplesPerChannel, ichan); break; case DecimatorFloat: default: - callbackSIF((const float*) buffs[ichan], samplesPerChannel, ichan); + callbackSIFIQ((const float*) buffs[ichan], samplesPerChannel, ichan); } } } -void SoapySDRInputThread::callbackSI8(const qint8* buf, qint32 len, unsigned int channel) +void SoapySDRInputThread::callbackMIQI(std::vector& buffs, qint32 samplesPerChannel) +{ + for(unsigned int ichan = 0; ichan < m_nbChannels; ichan++) + { + switch (m_decimatorType) + { + case Decimator8: + callbackSI8QI((const qint8*) buffs[ichan], samplesPerChannel, ichan); + break; + case Decimator12: + callbackSI12QI((const qint16*) buffs[ichan], samplesPerChannel, ichan); + break; + case Decimator16: + callbackSI16QI((const qint16*) buffs[ichan], samplesPerChannel, ichan); + break; + case DecimatorFloat: + default: + callbackSIFQI((const float*) buffs[ichan], samplesPerChannel, ichan); + } + } +} + +void SoapySDRInputThread::callbackSI8IQ(const qint8* buf, qint32 len, unsigned int channel) { SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); if (m_channels[channel].m_log2Decim == 0) { - m_channels[channel].m_decimators8.decimate1(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate1(&it, buf, len); } else { @@ -290,22 +342,22 @@ void SoapySDRInputThread::callbackSI8(const qint8* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators8.decimate2_inf(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate2_inf(&it, buf, len); break; case 2: - m_channels[channel].m_decimators8.decimate4_inf(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate4_inf(&it, buf, len); break; case 3: - m_channels[channel].m_decimators8.decimate8_inf(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate8_inf(&it, buf, len); break; case 4: - m_channels[channel].m_decimators8.decimate16_inf(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate16_inf(&it, buf, len); break; case 5: - m_channels[channel].m_decimators8.decimate32_inf(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate32_inf(&it, buf, len); break; case 6: - m_channels[channel].m_decimators8.decimate64_inf(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate64_inf(&it, buf, len); break; default: break; @@ -316,22 +368,22 @@ void SoapySDRInputThread::callbackSI8(const qint8* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators8.decimate2_sup(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate2_sup(&it, buf, len); break; case 2: - m_channels[channel].m_decimators8.decimate4_sup(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate4_sup(&it, buf, len); break; case 3: - m_channels[channel].m_decimators8.decimate8_sup(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate8_sup(&it, buf, len); break; case 4: - m_channels[channel].m_decimators8.decimate16_sup(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate16_sup(&it, buf, len); break; case 5: - m_channels[channel].m_decimators8.decimate32_sup(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate32_sup(&it, buf, len); break; case 6: - m_channels[channel].m_decimators8.decimate64_sup(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate64_sup(&it, buf, len); break; default: break; @@ -342,22 +394,22 @@ void SoapySDRInputThread::callbackSI8(const qint8* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators8.decimate2_cen(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate2_cen(&it, buf, len); break; case 2: - m_channels[channel].m_decimators8.decimate4_cen(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate4_cen(&it, buf, len); break; case 3: - m_channels[channel].m_decimators8.decimate8_cen(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate8_cen(&it, buf, len); break; case 4: - m_channels[channel].m_decimators8.decimate16_cen(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate16_cen(&it, buf, len); break; case 5: - m_channels[channel].m_decimators8.decimate32_cen(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate32_cen(&it, buf, len); break; case 6: - m_channels[channel].m_decimators8.decimate64_cen(&it, buf, len); + m_channels[channel].m_decimators8IQ.decimate64_cen(&it, buf, len); break; default: break; @@ -368,13 +420,13 @@ void SoapySDRInputThread::callbackSI8(const qint8* buf, qint32 len, unsigned int m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); } -void SoapySDRInputThread::callbackSI12(const qint16* buf, qint32 len, unsigned int channel) +void SoapySDRInputThread::callbackSI8QI(const qint8* buf, qint32 len, unsigned int channel) { SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); if (m_channels[channel].m_log2Decim == 0) { - m_channels[channel].m_decimators12.decimate1(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate1(&it, buf, len); } else { @@ -383,22 +435,22 @@ void SoapySDRInputThread::callbackSI12(const qint16* buf, qint32 len, unsigned i switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators12.decimate2_inf(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate2_inf(&it, buf, len); break; case 2: - m_channels[channel].m_decimators12.decimate4_inf(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate4_inf(&it, buf, len); break; case 3: - m_channels[channel].m_decimators12.decimate8_inf(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate8_inf(&it, buf, len); break; case 4: - m_channels[channel].m_decimators12.decimate16_inf(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate16_inf(&it, buf, len); break; case 5: - m_channels[channel].m_decimators12.decimate32_inf(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate32_inf(&it, buf, len); break; case 6: - m_channels[channel].m_decimators12.decimate64_inf(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate64_inf(&it, buf, len); break; default: break; @@ -409,22 +461,22 @@ void SoapySDRInputThread::callbackSI12(const qint16* buf, qint32 len, unsigned i switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators12.decimate2_sup(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate2_sup(&it, buf, len); break; case 2: - m_channels[channel].m_decimators12.decimate4_sup(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate4_sup(&it, buf, len); break; case 3: - m_channels[channel].m_decimators12.decimate8_sup(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate8_sup(&it, buf, len); break; case 4: - m_channels[channel].m_decimators12.decimate16_sup(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate16_sup(&it, buf, len); break; case 5: - m_channels[channel].m_decimators12.decimate32_sup(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate32_sup(&it, buf, len); break; case 6: - m_channels[channel].m_decimators12.decimate64_sup(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate64_sup(&it, buf, len); break; default: break; @@ -435,22 +487,22 @@ void SoapySDRInputThread::callbackSI12(const qint16* buf, qint32 len, unsigned i switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators12.decimate2_cen(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate2_cen(&it, buf, len); break; case 2: - m_channels[channel].m_decimators12.decimate4_cen(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate4_cen(&it, buf, len); break; case 3: - m_channels[channel].m_decimators12.decimate8_cen(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate8_cen(&it, buf, len); break; case 4: - m_channels[channel].m_decimators12.decimate16_cen(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate16_cen(&it, buf, len); break; case 5: - m_channels[channel].m_decimators12.decimate32_cen(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate32_cen(&it, buf, len); break; case 6: - m_channels[channel].m_decimators12.decimate64_cen(&it, buf, len); + m_channels[channel].m_decimators8QI.decimate64_cen(&it, buf, len); break; default: break; @@ -461,13 +513,13 @@ void SoapySDRInputThread::callbackSI12(const qint16* buf, qint32 len, unsigned i m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); } -void SoapySDRInputThread::callbackSI16(const qint16* buf, qint32 len, unsigned int channel) +void SoapySDRInputThread::callbackSI12IQ(const qint16* buf, qint32 len, unsigned int channel) { SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); if (m_channels[channel].m_log2Decim == 0) { - m_channels[channel].m_decimators16.decimate1(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate1(&it, buf, len); } else { @@ -476,22 +528,22 @@ void SoapySDRInputThread::callbackSI16(const qint16* buf, qint32 len, unsigned i switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators16.decimate2_inf(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate2_inf(&it, buf, len); break; case 2: - m_channels[channel].m_decimators16.decimate4_inf(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate4_inf(&it, buf, len); break; case 3: - m_channels[channel].m_decimators16.decimate8_inf(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate8_inf(&it, buf, len); break; case 4: - m_channels[channel].m_decimators16.decimate16_inf(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate16_inf(&it, buf, len); break; case 5: - m_channels[channel].m_decimators16.decimate32_inf(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate32_inf(&it, buf, len); break; case 6: - m_channels[channel].m_decimators16.decimate64_inf(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate64_inf(&it, buf, len); break; default: break; @@ -502,22 +554,22 @@ void SoapySDRInputThread::callbackSI16(const qint16* buf, qint32 len, unsigned i switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators16.decimate2_sup(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate2_sup(&it, buf, len); break; case 2: - m_channels[channel].m_decimators16.decimate4_sup(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate4_sup(&it, buf, len); break; case 3: - m_channels[channel].m_decimators16.decimate8_sup(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate8_sup(&it, buf, len); break; case 4: - m_channels[channel].m_decimators16.decimate16_sup(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate16_sup(&it, buf, len); break; case 5: - m_channels[channel].m_decimators16.decimate32_sup(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate32_sup(&it, buf, len); break; case 6: - m_channels[channel].m_decimators16.decimate64_sup(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate64_sup(&it, buf, len); break; default: break; @@ -528,22 +580,22 @@ void SoapySDRInputThread::callbackSI16(const qint16* buf, qint32 len, unsigned i switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimators16.decimate2_cen(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate2_cen(&it, buf, len); break; case 2: - m_channels[channel].m_decimators16.decimate4_cen(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate4_cen(&it, buf, len); break; case 3: - m_channels[channel].m_decimators16.decimate8_cen(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate8_cen(&it, buf, len); break; case 4: - m_channels[channel].m_decimators16.decimate16_cen(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate16_cen(&it, buf, len); break; case 5: - m_channels[channel].m_decimators16.decimate32_cen(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate32_cen(&it, buf, len); break; case 6: - m_channels[channel].m_decimators16.decimate64_cen(&it, buf, len); + m_channels[channel].m_decimators12IQ.decimate64_cen(&it, buf, len); break; default: break; @@ -554,13 +606,13 @@ void SoapySDRInputThread::callbackSI16(const qint16* buf, qint32 len, unsigned i m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); } -void SoapySDRInputThread::callbackSIF(const float* buf, qint32 len, unsigned int channel) +void SoapySDRInputThread::callbackSI12QI(const qint16* buf, qint32 len, unsigned int channel) { SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); if (m_channels[channel].m_log2Decim == 0) { - m_channels[channel].m_decimatorsFloat.decimate1(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate1(&it, buf, len); } else { @@ -569,22 +621,22 @@ void SoapySDRInputThread::callbackSIF(const float* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimatorsFloat.decimate2_inf(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate2_inf(&it, buf, len); break; case 2: - m_channels[channel].m_decimatorsFloat.decimate4_inf(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate4_inf(&it, buf, len); break; case 3: - m_channels[channel].m_decimatorsFloat.decimate8_inf(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate8_inf(&it, buf, len); break; case 4: - m_channels[channel].m_decimatorsFloat.decimate16_inf(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate16_inf(&it, buf, len); break; case 5: - m_channels[channel].m_decimatorsFloat.decimate32_inf(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate32_inf(&it, buf, len); break; case 6: - m_channels[channel].m_decimatorsFloat.decimate64_inf(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate64_inf(&it, buf, len); break; default: break; @@ -595,22 +647,22 @@ void SoapySDRInputThread::callbackSIF(const float* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimatorsFloat.decimate2_sup(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate2_sup(&it, buf, len); break; case 2: - m_channels[channel].m_decimatorsFloat.decimate4_sup(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate4_sup(&it, buf, len); break; case 3: - m_channels[channel].m_decimatorsFloat.decimate8_sup(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate8_sup(&it, buf, len); break; case 4: - m_channels[channel].m_decimatorsFloat.decimate16_sup(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate16_sup(&it, buf, len); break; case 5: - m_channels[channel].m_decimatorsFloat.decimate32_sup(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate32_sup(&it, buf, len); break; case 6: - m_channels[channel].m_decimatorsFloat.decimate64_sup(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate64_sup(&it, buf, len); break; default: break; @@ -621,22 +673,394 @@ void SoapySDRInputThread::callbackSIF(const float* buf, qint32 len, unsigned int switch (m_channels[channel].m_log2Decim) { case 1: - m_channels[channel].m_decimatorsFloat.decimate2_cen(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate2_cen(&it, buf, len); break; case 2: - m_channels[channel].m_decimatorsFloat.decimate4_cen(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate4_cen(&it, buf, len); break; case 3: - m_channels[channel].m_decimatorsFloat.decimate8_cen(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate8_cen(&it, buf, len); break; case 4: - m_channels[channel].m_decimatorsFloat.decimate16_cen(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate16_cen(&it, buf, len); break; case 5: - m_channels[channel].m_decimatorsFloat.decimate32_cen(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate32_cen(&it, buf, len); break; case 6: - m_channels[channel].m_decimatorsFloat.decimate64_cen(&it, buf, len); + m_channels[channel].m_decimators12QI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); +} + +void SoapySDRInputThread::callbackSI16IQ(const qint16* buf, qint32 len, unsigned int channel) +{ + SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); + + if (m_channels[channel].m_log2Decim == 0) + { + m_channels[channel].m_decimators16IQ.decimate1(&it, buf, len); + } + else + { + if (m_channels[channel].m_fcPos == 0) // Infra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimators16IQ.decimate2_inf(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimators16IQ.decimate4_inf(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimators16IQ.decimate8_inf(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimators16IQ.decimate16_inf(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimators16IQ.decimate32_inf(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimators16IQ.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 1) // Supra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimators16IQ.decimate2_sup(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimators16IQ.decimate4_sup(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimators16IQ.decimate8_sup(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimators16IQ.decimate16_sup(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimators16IQ.decimate32_sup(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimators16IQ.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 2) // Center + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimators16IQ.decimate2_cen(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimators16IQ.decimate4_cen(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimators16IQ.decimate8_cen(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimators16IQ.decimate16_cen(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimators16IQ.decimate32_cen(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimators16IQ.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); +} + +void SoapySDRInputThread::callbackSI16QI(const qint16* buf, qint32 len, unsigned int channel) +{ + SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); + + if (m_channels[channel].m_log2Decim == 0) + { + m_channels[channel].m_decimators16QI.decimate1(&it, buf, len); + } + else + { + if (m_channels[channel].m_fcPos == 0) // Infra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimators16QI.decimate2_inf(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimators16QI.decimate4_inf(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimators16QI.decimate8_inf(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimators16QI.decimate16_inf(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimators16QI.decimate32_inf(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimators16QI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 1) // Supra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimators16QI.decimate2_sup(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimators16QI.decimate4_sup(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimators16QI.decimate8_sup(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimators16QI.decimate16_sup(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimators16QI.decimate32_sup(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimators16QI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 2) // Center + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimators16QI.decimate2_cen(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimators16QI.decimate4_cen(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimators16QI.decimate8_cen(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimators16QI.decimate16_cen(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimators16QI.decimate32_cen(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimators16QI.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); +} + +void SoapySDRInputThread::callbackSIFIQ(const float* buf, qint32 len, unsigned int channel) +{ + SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); + + if (m_channels[channel].m_log2Decim == 0) + { + m_channels[channel].m_decimatorsFloatIQ.decimate1(&it, buf, len); + } + else + { + if (m_channels[channel].m_fcPos == 0) // Infra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsFloatIQ.decimate2_inf(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsFloatIQ.decimate4_inf(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsFloatIQ.decimate8_inf(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsFloatIQ.decimate16_inf(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsFloatIQ.decimate32_inf(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsFloatIQ.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 1) // Supra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsFloatIQ.decimate2_sup(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsFloatIQ.decimate4_sup(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsFloatIQ.decimate8_sup(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsFloatIQ.decimate16_sup(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsFloatIQ.decimate32_sup(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsFloatIQ.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 2) // Center + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsFloatIQ.decimate2_cen(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsFloatIQ.decimate4_cen(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsFloatIQ.decimate8_cen(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsFloatIQ.decimate16_cen(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsFloatIQ.decimate32_cen(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsFloatIQ.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + } + + m_channels[channel].m_sampleFifo->write(m_channels[channel].m_convertBuffer.begin(), it); +} + +void SoapySDRInputThread::callbackSIFQI(const float* buf, qint32 len, unsigned int channel) +{ + SampleVector::iterator it = m_channels[channel].m_convertBuffer.begin(); + + if (m_channels[channel].m_log2Decim == 0) + { + m_channels[channel].m_decimatorsFloatQI.decimate1(&it, buf, len); + } + else + { + if (m_channels[channel].m_fcPos == 0) // Infra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsFloatQI.decimate2_inf(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsFloatQI.decimate4_inf(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsFloatQI.decimate8_inf(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsFloatQI.decimate16_inf(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsFloatQI.decimate32_inf(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsFloatQI.decimate64_inf(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 1) // Supra + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsFloatQI.decimate2_sup(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsFloatQI.decimate4_sup(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsFloatQI.decimate8_sup(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsFloatQI.decimate16_sup(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsFloatQI.decimate32_sup(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsFloatQI.decimate64_sup(&it, buf, len); + break; + default: + break; + } + } + else if (m_channels[channel].m_fcPos == 2) // Center + { + switch (m_channels[channel].m_log2Decim) + { + case 1: + m_channels[channel].m_decimatorsFloatQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_channels[channel].m_decimatorsFloatQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_channels[channel].m_decimatorsFloatQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_channels[channel].m_decimatorsFloatQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_channels[channel].m_decimatorsFloatQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_channels[channel].m_decimatorsFloatQI.decimate64_cen(&it, buf, len); break; default: break; diff --git a/plugins/samplesource/soapysdrinput/soapysdrinputthread.h b/plugins/samplesource/soapysdrinput/soapysdrinputthread.h index 508f5d857..354896195 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinputthread.h +++ b/plugins/samplesource/soapysdrinput/soapysdrinputthread.h @@ -53,6 +53,7 @@ public: int getFcPos(unsigned int channel) const; void setFifo(unsigned int channel, SampleSinkFifo *sampleFifo); SampleSinkFifo *getFifo(unsigned int channel); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: struct Channel @@ -61,10 +62,14 @@ private: SampleSinkFifo* m_sampleFifo; unsigned int m_log2Decim; int m_fcPos; - Decimators m_decimators8; - Decimators m_decimators12; - Decimators m_decimators16; - DecimatorsFI m_decimatorsFloat; + Decimators m_decimators8IQ; + Decimators m_decimators12IQ; + Decimators m_decimators16IQ; + Decimators m_decimators8QI; + Decimators m_decimators12QI; + Decimators m_decimators16QI; + DecimatorsFI m_decimatorsFloatIQ; + DecimatorsFI m_decimatorsFloatQI; Channel() : m_sampleFifo(0), @@ -93,14 +98,23 @@ private: unsigned int m_sampleRate; unsigned int m_nbChannels; DecimatorType m_decimatorType; + bool m_iqOrder; void run(); unsigned int getNbFifos(); - void callbackSI8(const qint8* buf, qint32 len, unsigned int channel = 0); - void callbackSI12(const qint16* buf, qint32 len, unsigned int channel = 0); - void callbackSI16(const qint16* buf, qint32 len, unsigned int channel = 0); - void callbackSIF(const float* buf, qint32 len, unsigned int channel = 0); - void callbackMI(std::vector& buffs, qint32 samplesPerChannel); + + void callbackSI8IQ(const qint8* buf, qint32 len, unsigned int channel = 0); + void callbackSI12IQ(const qint16* buf, qint32 len, unsigned int channel = 0); + void callbackSI16IQ(const qint16* buf, qint32 len, unsigned int channel = 0); + void callbackSIFIQ(const float* buf, qint32 len, unsigned int channel = 0); + + void callbackSI8QI(const qint8* buf, qint32 len, unsigned int channel = 0); + void callbackSI12QI(const qint16* buf, qint32 len, unsigned int channel = 0); + void callbackSI16QI(const qint16* buf, qint32 len, unsigned int channel = 0); + void callbackSIFQI(const float* buf, qint32 len, unsigned int channel = 0); + + void callbackMIIQ(std::vector& buffs, qint32 samplesPerChannel); + void callbackMIQI(std::vector& buffs, qint32 samplesPerChannel); }; diff --git a/plugins/samplesource/testsource/testsourcethread.h b/plugins/samplesource/testsource/testsourcethread.h index 110013fbe..de1e2b944 100644 --- a/plugins/samplesource/testsource/testsourcethread.h +++ b/plugins/samplesource/testsource/testsourcethread.h @@ -131,9 +131,9 @@ private: MessageQueue m_inputMessageQueue; - Decimators m_decimators_8; - Decimators m_decimators_12; - Decimators m_decimators_16; + Decimators m_decimators_8; + Decimators m_decimators_12; + Decimators m_decimators_16; std::map m_timerHistogram; uint32_t m_histoCounter; diff --git a/plugins/samplesource/xtrxinput/xtrxinput.cpp b/plugins/samplesource/xtrxinput/xtrxinput.cpp index 7cbf6a9b6..cb3abebca 100644 --- a/plugins/samplesource/xtrxinput/xtrxinput.cpp +++ b/plugins/samplesource/xtrxinput/xtrxinput.cpp @@ -52,7 +52,7 @@ MESSAGE_CLASS_DEFINITION(XTRXInput::MsgStartStop, Message) XTRXInput::XTRXInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), - m_XTRXInputThread(0), + m_XTRXInputThread(nullptr), m_deviceDescription("XTRXInput"), m_running(false) { @@ -201,9 +201,9 @@ void XTRXInput::init() XTRXInputThread *XTRXInput::findThread() { - if (m_XTRXInputThread == 0) // this does not own the thread + if (!m_XTRXInputThread) // this does not own the thread { - XTRXInputThread *xtrxInputThread = 0; + XTRXInputThread *xtrxInputThread = nullptr; // find a buddy that has allocated the thread const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); @@ -243,7 +243,7 @@ void XTRXInput::moveThreadToBuddy() if (buddySource) { buddySource->setThread(m_XTRXInputThread); - m_XTRXInputThread = 0; // zero for others + m_XTRXInputThread = nullptr; // zero for others } } } @@ -308,8 +308,9 @@ bool XTRXInput::start() xtrxInputThread->stopWork(); delete xtrxInputThread; xtrxInputThread = new XTRXInputThread(m_deviceShared.m_dev->getDevice(), 2); // MI mode (2 channels) - m_XTRXInputThread = xtrxInputThread; // take ownership + xtrxInputThread->setIQOrder(m_settings.m_iqOrder); m_deviceShared.m_thread = xtrxInputThread; + m_XTRXInputThread = xtrxInputThread; // take ownership for (int i = 0; i < 2; i++) // restore original FIFO references { @@ -394,8 +395,8 @@ void XTRXInput::stop() qDebug("XTRXInput::stop: SI mode. Just stop and delete the thread"); xtrxInputThread->stopWork(); delete xtrxInputThread; - m_XTRXInputThread = 0; - m_deviceShared.m_thread = 0; + m_XTRXInputThread = nullptr; + m_deviceShared.m_thread = nullptr; // remove old thread address from buddies (reset in all buddies) const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); @@ -410,6 +411,7 @@ void XTRXInput::stop() m_XTRXInputThread = xtrxInputThread; // take ownership m_deviceShared.m_thread = xtrxInputThread; + xtrxInputThread->setIQOrder(m_settings.m_iqOrder); xtrxInputThread->setFifo(requestedChannel, &m_sampleFifo); xtrxInputThread->setLog2Decimation(requestedChannel, m_settings.m_log2SoftDecim); @@ -1040,6 +1042,17 @@ bool XTRXInput::applySettings(const XTRXInputSettings& settings, bool force, boo } } + if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) + { + reverseAPIKeys.append("iqOrder"); + + if (inputThread) + { + inputThread->setIQOrder(settings.m_iqOrder); + qDebug() << "XTRXInput::applySettings: set IQ order to " << (settings.m_iqOrder ? "IQ" : "QI"); + } + } + if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) { reverseAPIKeys.append("antennaPath"); diff --git a/plugins/samplesource/xtrxinput/xtrxinputsettings.cpp b/plugins/samplesource/xtrxinput/xtrxinputsettings.cpp index 46c40ade0..b9a616f9d 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputsettings.cpp +++ b/plugins/samplesource/xtrxinput/xtrxinputsettings.cpp @@ -43,6 +43,7 @@ void XTRXInputSettings::resetToDefaults() m_extClock = false; m_extClockFreq = 0; // Auto m_pwrmode = 1; + m_iqOrder = true; m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -76,6 +77,7 @@ QByteArray XTRXInputSettings::serialize() const s.writeString(23, m_reverseAPIAddress); s.writeU32(24, m_reverseAPIPort); s.writeU32(25, m_reverseAPIDeviceIndex); + s.writeBool(26, m_iqOrder); return s.final(); } @@ -127,6 +129,7 @@ bool XTRXInputSettings::deserialize(const QByteArray& data) d.readU32(25, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(26, &m_iqOrder, true); return true; } diff --git a/plugins/samplesource/xtrxinput/xtrxinputsettings.h b/plugins/samplesource/xtrxinput/xtrxinputsettings.h index c649be6b0..4a5173bae 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputsettings.h +++ b/plugins/samplesource/xtrxinput/xtrxinputsettings.h @@ -56,6 +56,7 @@ struct XTRXInputSettings bool m_extClock; //!< True if external clock source uint32_t m_extClockFreq; //!< Frequency (Hz) of external clock source uint32_t m_pwrmode; + bool m_iqOrder; QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; diff --git a/plugins/samplesource/xtrxinput/xtrxinputthread.cpp b/plugins/samplesource/xtrxinput/xtrxinputthread.cpp index db7bff14a..674cdaf02 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputthread.cpp +++ b/plugins/samplesource/xtrxinput/xtrxinputthread.cpp @@ -29,7 +29,8 @@ XTRXInputThread::XTRXInputThread(struct xtrx_dev *dev, unsigned int nbChannels, m_running(false), m_dev(dev), m_nbChannels(nbChannels), - m_uniqueChannelIndex(uniqueChannelIndex) + m_uniqueChannelIndex(uniqueChannelIndex), + m_iqOrder(true) { qDebug("XTRXInputThread::XTRXInputThread: nbChannels: %u uniqueChannelIndex: %u", nbChannels, uniqueChannelIndex); m_channels = new Channel[2]; @@ -150,10 +151,17 @@ void XTRXInputThread::run() qDebug("XTRXInputThread::run: overflow"); } - if (m_nbChannels > 1) { + if (m_nbChannels > 1) + { callbackMI((const qint16*) buffs[0], (const qint16*) buffs[1], 2 * nfo.out_samples); - } else { - callbackSI((const qint16*) buffs[0], 2 * nfo.out_samples); + } + else + { + if (m_iqOrder) { + callbackSIIQ((const qint16*) buffs[0], 2 * nfo.out_samples); + } else { + callbackSIQI((const qint16*) buffs[0], 2 * nfo.out_samples); + } } } @@ -223,35 +231,73 @@ SampleSinkFifo *XTRXInputThread::getFifo(unsigned int channel) } } -void XTRXInputThread::callbackSI(const qint16* buf, qint32 len) +void XTRXInputThread::callbackSIIQ(const qint16* buf, qint32 len) { SampleVector::iterator it = m_channels[m_uniqueChannelIndex].m_convertBuffer.begin(); if (m_channels[m_uniqueChannelIndex].m_log2Decim == 0) { - m_channels[m_uniqueChannelIndex].m_decimators.decimate1(&it, buf, len); + m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate1(&it, buf, len); } else { switch (m_channels[m_uniqueChannelIndex].m_log2Decim) { case 1: - m_channels[m_uniqueChannelIndex].m_decimators.decimate2_cen(&it, buf, len); + m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate2_cen(&it, buf, len); break; case 2: - m_channels[m_uniqueChannelIndex].m_decimators.decimate4_cen(&it, buf, len); + m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate4_cen(&it, buf, len); break; case 3: - m_channels[m_uniqueChannelIndex].m_decimators.decimate8_cen(&it, buf, len); + m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate8_cen(&it, buf, len); break; case 4: - m_channels[m_uniqueChannelIndex].m_decimators.decimate16_cen(&it, buf, len); + m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate16_cen(&it, buf, len); break; case 5: - m_channels[m_uniqueChannelIndex].m_decimators.decimate32_cen(&it, buf, len); + m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate32_cen(&it, buf, len); break; case 6: - m_channels[m_uniqueChannelIndex].m_decimators.decimate64_cen(&it, buf, len); + m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate64_cen(&it, buf, len); + break; + default: + break; + } + } + + m_channels[m_uniqueChannelIndex].m_sampleFifo->write(m_channels[m_uniqueChannelIndex].m_convertBuffer.begin(), it); +} + +void XTRXInputThread::callbackSIQI(const qint16* buf, qint32 len) +{ + SampleVector::iterator it = m_channels[m_uniqueChannelIndex].m_convertBuffer.begin(); + + if (m_channels[m_uniqueChannelIndex].m_log2Decim == 0) + { + m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate1(&it, buf, len); + } + else + { + switch (m_channels[m_uniqueChannelIndex].m_log2Decim) + { + case 1: + m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate2_cen(&it, buf, len); + break; + case 2: + m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate4_cen(&it, buf, len); + break; + case 3: + m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate8_cen(&it, buf, len); + break; + case 4: + m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate16_cen(&it, buf, len); + break; + case 5: + m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate32_cen(&it, buf, len); + break; + case 6: + m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate64_cen(&it, buf, len); break; default: break; @@ -267,10 +313,21 @@ void XTRXInputThread::callbackMI(const qint16* buf0, const qint16* buf1, qint32 // channel 0 m_uniqueChannelIndex = 0; - callbackSI(buf0, len); + + if (m_iqOrder) { + callbackSIIQ(buf0, len); + } else { + callbackSIQI(buf0, len); + } + // channel 1 m_uniqueChannelIndex = 1; - callbackSI(buf1, len); + + if (m_iqOrder) { + callbackSIIQ(buf1, len); + } else { + callbackSIQI(buf1, len); + } m_uniqueChannelIndex = uniqueChannelIndex; } diff --git a/plugins/samplesource/xtrxinput/xtrxinputthread.h b/plugins/samplesource/xtrxinput/xtrxinputthread.h index df48631fc..5a8e6ee92 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputthread.h +++ b/plugins/samplesource/xtrxinput/xtrxinputthread.h @@ -47,6 +47,7 @@ public: unsigned int getLog2Decimation(unsigned int channel) const; void setFifo(unsigned int channel, SampleSinkFifo *sampleFifo); SampleSinkFifo *getFifo(unsigned int channel); + void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; } private: struct Channel @@ -54,7 +55,8 @@ private: SampleVector m_convertBuffer; SampleSinkFifo* m_sampleFifo; unsigned int m_log2Decim; - Decimators m_decimators; + Decimators m_decimatorsIQ; + Decimators m_decimatorsQI; Channel() : m_sampleFifo(0), @@ -73,10 +75,12 @@ private: Channel *m_channels; //!< Array of channels dynamically allocated for the given number of Rx channels unsigned int m_nbChannels; unsigned int m_uniqueChannelIndex; + bool m_iqOrder; void run(); unsigned int getNbFifos(); - void callbackSI(const qint16* buf, qint32 len); + void callbackSIQI(const qint16* buf, qint32 len); + void callbackSIIQ(const qint16* buf, qint32 len); void callbackMI(const qint16* buf0, const qint16* buf1, qint32 len); }; diff --git a/sdrbase/dsp/decimators.h b/sdrbase/dsp/decimators.h index c3866f177..27af7c864 100644 --- a/sdrbase/dsp/decimators.h +++ b/sdrbase/dsp/decimators.h @@ -388,7 +388,7 @@ struct TripleByteLE #endif /** Decimators with integer input and integer output */ -template +template class Decimators { public: @@ -442,60 +442,68 @@ public: private: #ifdef SDR_RX_SAMPLE_24BIT - IntHalfbandFilterEO m_decimator2; // 1st stages - IntHalfbandFilterEO m_decimator4; // 2nd stages - IntHalfbandFilterEO m_decimator8; // 3rd stages - IntHalfbandFilterEO m_decimator16; // 4th stages - IntHalfbandFilterEO m_decimator32; // 5th stages - IntHalfbandFilterEO m_decimator64; // 6th stages + IntHalfbandFilterEO m_decimator2; // 1st stages + IntHalfbandFilterEO m_decimator4; // 2nd stages + IntHalfbandFilterEO m_decimator8; // 3rd stages + IntHalfbandFilterEO m_decimator16; // 4th stages + IntHalfbandFilterEO m_decimator32; // 5th stages + IntHalfbandFilterEO m_decimator64; // 6th stages #else - IntHalfbandFilterEO m_decimator2; // 1st stages - IntHalfbandFilterEO m_decimator4; // 2nd stages - IntHalfbandFilterEO m_decimator8; // 3rd stages - IntHalfbandFilterEO m_decimator16; // 4th stages - IntHalfbandFilterEO m_decimator32; // 5th stages - IntHalfbandFilterEO m_decimator64; // 6th stages + IntHalfbandFilterEO m_decimator2; // 1st stages + IntHalfbandFilterEO m_decimator4; // 2nd stages + IntHalfbandFilterEO m_decimator8; // 3rd stages + IntHalfbandFilterEO m_decimator16; // 4th stages + IntHalfbandFilterEO m_decimator32; // 5th stages + IntHalfbandFilterEO m_decimator64; // 6th stages #endif }; -template -void Decimators::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) { qint32 xreal, yimag; for (int pos = 0; pos < len - 1; pos += 2) { - xreal = buf[pos+0]; - yimag = buf[pos+1]; + xreal = IQorder ? buf[pos+0] : buf[pos+1]; + yimag = IQorder ? buf[pos+1] : buf[pos+0]; (**it).setReal(xreal << decimation_shifts::pre1); // Valgrind optim (2 - comment not repeated) (**it).setImag(yimag << decimation_shifts::pre1); ++(*it); // Valgrind optim (comment not repeated) } } -template -void Decimators::decimate2_u(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_u(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType xreal, yimag; for (int pos = 0; pos < len - 7; pos += 8) { - xreal = (buf[pos+0] - buf[pos+3]) << decimation_shifts::pre2; - yimag = (buf[pos+1] + buf[pos+2] - 255) << decimation_shifts::pre2; + xreal = IQorder ? + (buf[pos+0] - buf[pos+3]) << decimation_shifts::pre2 : + (buf[pos+1] + buf[pos+2] - 255) << decimation_shifts::pre2; + yimag = IQorder ? + (buf[pos+1] + buf[pos+2] - 255) << decimation_shifts::pre2 : + (buf[pos+0] - buf[pos+3]) << decimation_shifts::pre2; (**it).setReal(xreal >> decimation_shifts::post2); (**it).setImag(yimag >> decimation_shifts::post2); ++(*it); - xreal = (buf[pos+7] - buf[pos+4]) << decimation_shifts::pre2; - yimag = (255 - buf[pos+5] - buf[pos+6]) << decimation_shifts::pre2; + xreal = IQorder ? + (buf[pos+7] - buf[pos+4]) << decimation_shifts::pre2 : + (255 - buf[pos+5] - buf[pos+6]) << decimation_shifts::pre2; + yimag = IQorder ? + (255 - buf[pos+5] - buf[pos+6]) << decimation_shifts::pre2 : + (buf[pos+7] - buf[pos+4]) << decimation_shifts::pre2; (**it).setReal(xreal >> decimation_shifts::post2); (**it).setImag(yimag >> decimation_shifts::post2); ++(*it); } } -template -void Decimators::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[4]; @@ -522,8 +530,8 @@ void Decimators::decimate2_inf(SampleVector: } } -template -void Decimators::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[4]; @@ -550,8 +558,8 @@ void Decimators::decimate2_sup(SampleVector: } } -template -void Decimators::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[4]; @@ -578,8 +586,8 @@ void Decimators::decimate2_cen(SampleVector: } } -template -void Decimators::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -628,8 +636,8 @@ void Decimators::decimate4_inf(SampleVector: } } -template -void Decimators::decimate4_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -678,8 +686,8 @@ void Decimators::decimate4_inf_txsync(Sample } } -template -void Decimators::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -728,8 +736,8 @@ void Decimators::decimate4_sup(SampleVector: } } -template -void Decimators::decimate4_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -778,8 +786,8 @@ void Decimators::decimate4_sup_txsync(Sample } } -template -void Decimators::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -821,8 +829,8 @@ void Decimators::decimate4_cen(SampleVector: } } -template -void Decimators::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[16], buf4[8], buf8[4]; @@ -894,8 +902,8 @@ void Decimators::decimate8_inf(SampleVector: } } -template -void Decimators::decimate8_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[16], buf4[8], buf8[4]; @@ -937,8 +945,8 @@ void Decimators::decimate8_inf_txsync(Sample } } -template -void Decimators::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[16], buf4[8], buf8[4]; @@ -1010,8 +1018,8 @@ void Decimators::decimate8_sup(SampleVector: } } -template -void Decimators::decimate8_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[16], buf4[8], buf8[4]; @@ -1053,8 +1061,8 @@ void Decimators::decimate8_sup_txsync(Sample } } -template -void Decimators::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[8]; @@ -1113,8 +1121,8 @@ void Decimators::decimate8_cen(SampleVector: } } -template -void Decimators::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[32], buf4[16], buf8[8], buf16[4]; @@ -1246,8 +1254,8 @@ void Decimators::decimate16_inf(SampleVector } } -template -void Decimators::decimate16_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[32], buf4[16], buf8[8], buf16[4]; @@ -1296,8 +1304,8 @@ void Decimators::decimate16_inf_txsync(Sampl } } -template -void Decimators::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[32], buf4[16], buf8[8], buf16[4]; @@ -1429,8 +1437,8 @@ void Decimators::decimate16_sup(SampleVector } } -template -void Decimators::decimate16_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[32], buf4[16], buf8[8], buf16[4]; @@ -1479,8 +1487,8 @@ void Decimators::decimate16_sup_txsync(Sampl } } -template -void Decimators::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[16]; @@ -1588,8 +1596,8 @@ void Decimators::decimate16_cen(SampleVector } } -template -void Decimators::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[64], buf4[32], buf8[16], buf16[8], buf32[4]; @@ -1841,8 +1849,8 @@ void Decimators::decimate32_inf(SampleVector } } -template -void Decimators::decimate32_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[64], buf4[32], buf8[16], buf16[8], buf32[4]; @@ -1898,8 +1906,8 @@ void Decimators::decimate32_inf_txsync(Sampl } } -template -void Decimators::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[64], buf4[32], buf8[16], buf16[8], buf32[4]; @@ -2151,8 +2159,8 @@ void Decimators::decimate32_sup(SampleVector } } -template -void Decimators::decimate32_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[64], buf4[32], buf8[16], buf16[8], buf32[4]; @@ -2208,8 +2216,8 @@ void Decimators::decimate32_sup_txsync(Sampl } } -template -void Decimators::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[32]; @@ -2414,8 +2422,8 @@ void Decimators::decimate32_cen(SampleVector } } -template -void Decimators::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[128], buf4[64], buf8[32], buf16[16], buf32[8], buf64[4]; @@ -2907,8 +2915,8 @@ void Decimators::decimate64_inf(SampleVector } } -template -void Decimators::decimate64_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_inf_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[128], buf4[64], buf8[32], buf16[16], buf32[8], buf64[4]; @@ -2971,8 +2979,8 @@ void Decimators::decimate64_inf_txsync(Sampl } } -template -void Decimators::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[128], buf4[64], buf8[32], buf16[16], buf32[8], buf64[4]; @@ -3036,8 +3044,8 @@ void Decimators::decimate64_sup(SampleVector } } -template -void Decimators::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[64]; @@ -3436,8 +3444,8 @@ void Decimators::decimate64_cen(SampleVector } } -template -void Decimators::decimate64_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) +template +void Decimators::decimate64_sup_txsync(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[128], buf4[64], buf8[32], buf16[16], buf32[8], buf64[4]; @@ -3503,8 +3511,8 @@ void Decimators::decimate64_sup_txsync(Sampl // ============================================================================================================== -template -void Decimators::decimate1(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate1(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { qint32 xreal, yimag; @@ -3518,8 +3526,8 @@ void Decimators::decimate1(SampleVector::ite } } -template -void Decimators::decimate2_u(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate2_u(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { StorageType xreal, yimag; @@ -3541,8 +3549,8 @@ void Decimators::decimate2_u(SampleVector::i } } -template -void Decimators::decimate2_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate2_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { StorageType intbuf[2]; @@ -3563,8 +3571,8 @@ void Decimators::decimate2_cen(SampleVector: } } -template -void Decimators::decimate4_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate4_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { StorageType intbuf[4]; @@ -3598,8 +3606,8 @@ void Decimators::decimate4_cen(SampleVector: } } -template -void Decimators::decimate8_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate8_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { StorageType intbuf[8]; @@ -3659,8 +3667,8 @@ void Decimators::decimate8_cen(SampleVector: } -template -void Decimators::decimate16_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate16_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { StorageType intbuf[16]; @@ -3768,8 +3776,8 @@ void Decimators::decimate16_cen(SampleVector } } -template -void Decimators::decimate32_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate32_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { StorageType intbuf[32]; @@ -3974,8 +3982,8 @@ void Decimators::decimate32_cen(SampleVector } } -template -void Decimators::decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) +template +void Decimators::decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len) { StorageType intbuf[64]; diff --git a/sdrbase/dsp/decimatorsff.cpp b/sdrbase/dsp/decimatorsff.cpp index 12672a52b..0c785d404 100644 --- a/sdrbase/dsp/decimatorsff.cpp +++ b/sdrbase/dsp/decimatorsff.cpp @@ -17,7 +17,8 @@ #include "decimatorsff.h" -void DecimatorsFF::decimate1(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFF::decimate1(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -31,29 +32,23 @@ void DecimatorsFF::decimate1(FSampleVector::iterator* it, const float* buf, qint } } -void DecimatorsFF::decimate2_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFF::decimate1(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { - float intbuf[2]; + float xreal, yimag; - for (int pos = 0; pos < nbIAndQ - 3; pos += 4) + for (int pos = 0; pos < nbIAndQ - 1; pos += 2) { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - - (**it).setReal(intbuf[0]); - (**it).setImag(intbuf[1]); - - ++(*it); + xreal = buf[pos+1]; + yimag = buf[pos+0]; + (**it).setReal(xreal); + (**it).setImag(yimag); + ++(*it); // Valgrind optim (comment not repeated) } } -void DecimatorsFF::decimate2_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFF::decimate2_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -73,7 +68,29 @@ void DecimatorsFF::decimate2_inf(FSampleVector::iterator* it, const float* buf, } } -void DecimatorsFF::decimate2_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFF::decimate2_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal, yimag; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + xreal = (buf[pos+1] + buf[pos+2]); + yimag = (buf[pos+0] - buf[pos+3]); + (**it).setReal(xreal); + (**it).setImag(yimag); + ++(*it); + + xreal = (- buf[pos+5] - buf[pos+6]); + yimag = (buf[pos+7] - buf[pos+4]); + (**it).setReal(xreal); + (**it).setImag(yimag); + ++(*it); + } +} + +template<> +void DecimatorsFF::decimate2_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -93,7 +110,29 @@ void DecimatorsFF::decimate2_sup(FSampleVector::iterator* it, const float* buf, } } -void DecimatorsFF::decimate4_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFF::decimate2_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal, yimag; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + xreal = (- buf[pos+0] - buf[pos+3]); + yimag = (buf[pos+1] - buf[pos+2]); + (**it).setReal(xreal); + (**it).setImag(yimag); + ++(*it); + + xreal = (buf[pos+4] + buf[pos+7]); + yimag = (buf[pos+6] - buf[pos+5]); + (**it).setReal(xreal); + (**it).setImag(yimag); + ++(*it); + } +} + +template<> +void DecimatorsFF::decimate4_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -109,7 +148,25 @@ void DecimatorsFF::decimate4_inf(FSampleVector::iterator* it, const float* buf, } } -void DecimatorsFF::decimate4_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFF::decimate4_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal, yimag; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + xreal = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + yimag = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + + (**it).setReal(xreal); + (**it).setImag(yimag); + + ++(*it); + } +} + +template<> +void DecimatorsFF::decimate4_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { // Sup (USB): // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 @@ -131,1044 +188,25 @@ void DecimatorsFF::decimate4_sup(FSampleVector::iterator* it, const float* buf, } } -void DecimatorsFF::decimate8_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFF::decimate4_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { - float xreal[2], yimag[2]; - - for (int pos = 0; pos < nbIAndQ - 15; pos += 8) - { - xreal[0] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[0] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - - xreal[1] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[1] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - - (**it).setReal(xreal[1]); - (**it).setImag(yimag[1]); - - ++(*it); - } -} - -void DecimatorsFF::decimate8_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[2], yimag[2]; - - for (int pos = 0; pos < nbIAndQ - 15; pos += 8) - { - xreal[0] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[0] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); - pos += 8; - - xreal[1] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[1] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - - (**it).setReal(xreal[1]); - (**it).setImag(yimag[1]); - - ++(*it); - } -} - -void DecimatorsFF::decimate16_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - // Offset tuning: 4x downsample and rotate, then - // downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] - float xreal[4], yimag[4]; - - for (int pos = 0; pos < nbIAndQ - 31; ) - { - for (int i = 0; i < 4; i++) - { - xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - - (**it).setReal(xreal[3]); - (**it).setImag(yimag[3]); - - ++(*it); - } -} - -void DecimatorsFF::decimate16_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - // Offset tuning: 4x downsample and rotate, then - // downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] - float xreal[4], yimag[4]; - - for (int pos = 0; pos < nbIAndQ - 31; ) - { - for (int i = 0; i < 4; i++) - { - xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - - (**it).setReal(xreal[3]); - (**it).setImag(yimag[3]); - - ++(*it); - } -} - -void DecimatorsFF::decimate32_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[8], yimag[8]; - - for (int pos = 0; pos < nbIAndQ - 63; ) - { - for (int i = 0; i < 8; i++) - { - xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - - (**it).setReal(xreal[7]); - (**it).setImag(yimag[7]); - - ++(*it); - } -} - -void DecimatorsFF::decimate32_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[8], yimag[8]; - - for (int pos = 0; pos < nbIAndQ - 63; ) - { - for (int i = 0; i < 8; i++) - { - xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - - (**it).setReal(xreal[7]); - (**it).setImag(yimag[7]); - - ++(*it); - } -} - -void DecimatorsFF::decimate64_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[16], yimag[16]; - - for (int pos = 0; pos < nbIAndQ - 127; ) - { - for (int i = 0; i < 16; i++) - { - xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); - m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); - m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); - m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); - m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); - - m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); - - (**it).setReal(xreal[15]); - (**it).setImag(yimag[15]); - - ++(*it); - } -} - -void DecimatorsFF::decimate64_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[16], yimag[16]; - - for (int pos = 0; pos < nbIAndQ - 127; ) - { - for (int i = 0; i < 16; i++) - { - xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); - m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); - m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); - m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); - m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); - - m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); - - (**it).setReal(xreal[15]); - (**it).setImag(yimag[15]); - - ++(*it); - } -} - -void DecimatorsFF::decimate4_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[4]; + // Sup (USB): + // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 + // [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] + // 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] + float xreal, yimag; for (int pos = 0; pos < nbIAndQ - 7; pos += 8) { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; + xreal = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); + yimag = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); + (**it).setReal(xreal); + (**it).setImag(yimag); - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - - (**it).setReal(intbuf[2]); - (**it).setImag(intbuf[3]); ++(*it); } } - -void DecimatorsFF::decimate8_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[8]; - - for (int pos = 0; pos < nbIAndQ - 15; pos += 16) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - - (**it).setReal(intbuf[6]); - (**it).setImag(intbuf[7]); - ++(*it); - } -} - -void DecimatorsFF::decimate16_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[16]; - - for (int pos = 0; pos < nbIAndQ - 31; pos += 32) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - intbuf[8] = buf[pos+18]; - intbuf[9] = buf[pos+19]; - intbuf[10] = buf[pos+22]; - intbuf[11] = buf[pos+23]; - intbuf[12] = buf[pos+26]; - intbuf[13] = buf[pos+27]; - intbuf[14] = buf[pos+30]; - intbuf[15] = buf[pos+31]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - m_decimator2.myDecimate( - buf[pos+16], - buf[pos+17], - &intbuf[8], - &intbuf[9]); - m_decimator2.myDecimate( - buf[pos+20], - buf[pos+21], - &intbuf[10], - &intbuf[11]); - m_decimator2.myDecimate( - buf[pos+24], - buf[pos+25], - &intbuf[12], - &intbuf[13]); - m_decimator2.myDecimate( - buf[pos+28], - buf[pos+29], - &intbuf[14], - &intbuf[15]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - m_decimator4.myDecimate( - intbuf[8], - intbuf[9], - &intbuf[10], - &intbuf[11]); - m_decimator4.myDecimate( - intbuf[12], - intbuf[13], - &intbuf[14], - &intbuf[15]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - m_decimator8.myDecimate( - intbuf[10], - intbuf[11], - &intbuf[14], - &intbuf[15]); - - m_decimator16.myDecimate( - intbuf[6], - intbuf[7], - &intbuf[14], - &intbuf[15]); - - (**it).setReal(intbuf[14]); - (**it).setImag(intbuf[15]); - ++(*it); - } -} - -void DecimatorsFF::decimate32_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[32]; - - for (int pos = 0; pos < nbIAndQ - 63; pos += 64) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - intbuf[8] = buf[pos+18]; - intbuf[9] = buf[pos+19]; - intbuf[10] = buf[pos+22]; - intbuf[11] = buf[pos+23]; - intbuf[12] = buf[pos+26]; - intbuf[13] = buf[pos+27]; - intbuf[14] = buf[pos+30]; - intbuf[15] = buf[pos+31]; - intbuf[16] = buf[pos+34]; - intbuf[17] = buf[pos+35]; - intbuf[18] = buf[pos+38]; - intbuf[19] = buf[pos+39]; - intbuf[20] = buf[pos+42]; - intbuf[21] = buf[pos+43]; - intbuf[22] = buf[pos+46]; - intbuf[23] = buf[pos+47]; - intbuf[24] = buf[pos+50]; - intbuf[25] = buf[pos+51]; - intbuf[26] = buf[pos+54]; - intbuf[27] = buf[pos+55]; - intbuf[28] = buf[pos+58]; - intbuf[29] = buf[pos+59]; - intbuf[30] = buf[pos+62]; - intbuf[31] = buf[pos+63]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - m_decimator2.myDecimate( - buf[pos+16], - buf[pos+17], - &intbuf[8], - &intbuf[9]); - m_decimator2.myDecimate( - buf[pos+20], - buf[pos+21], - &intbuf[10], - &intbuf[11]); - m_decimator2.myDecimate( - buf[pos+24], - buf[pos+25], - &intbuf[12], - &intbuf[13]); - m_decimator2.myDecimate( - buf[pos+28], - buf[pos+29], - &intbuf[14], - &intbuf[15]); - m_decimator2.myDecimate( - buf[pos+32], - buf[pos+33], - &intbuf[16], - &intbuf[17]); - m_decimator2.myDecimate( - buf[pos+36], - buf[pos+37], - &intbuf[18], - &intbuf[19]); - m_decimator2.myDecimate( - buf[pos+40], - buf[pos+41], - &intbuf[20], - &intbuf[21]); - m_decimator2.myDecimate( - buf[pos+44], - buf[pos+45], - &intbuf[22], - &intbuf[23]); - m_decimator2.myDecimate( - buf[pos+48], - buf[pos+49], - &intbuf[24], - &intbuf[25]); - m_decimator2.myDecimate( - buf[pos+52], - buf[pos+53], - &intbuf[26], - &intbuf[27]); - m_decimator2.myDecimate( - buf[pos+56], - buf[pos+57], - &intbuf[28], - &intbuf[29]); - m_decimator2.myDecimate( - buf[pos+60], - buf[pos+61], - &intbuf[30], - &intbuf[31]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - m_decimator4.myDecimate( - intbuf[8], - intbuf[9], - &intbuf[10], - &intbuf[11]); - m_decimator4.myDecimate( - intbuf[12], - intbuf[13], - &intbuf[14], - &intbuf[15]); - m_decimator4.myDecimate( - intbuf[16], - intbuf[17], - &intbuf[18], - &intbuf[19]); - m_decimator4.myDecimate( - intbuf[20], - intbuf[21], - &intbuf[22], - &intbuf[23]); - m_decimator4.myDecimate( - intbuf[24], - intbuf[25], - &intbuf[26], - &intbuf[27]); - m_decimator4.myDecimate( - intbuf[28], - intbuf[29], - &intbuf[30], - &intbuf[31]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - m_decimator8.myDecimate( - intbuf[10], - intbuf[11], - &intbuf[14], - &intbuf[15]); - m_decimator8.myDecimate( - intbuf[18], - intbuf[19], - &intbuf[22], - &intbuf[23]); - m_decimator8.myDecimate( - intbuf[26], - intbuf[27], - &intbuf[30], - &intbuf[31]); - - m_decimator16.myDecimate( - intbuf[6], - intbuf[7], - &intbuf[14], - &intbuf[15]); - m_decimator16.myDecimate( - intbuf[22], - intbuf[23], - &intbuf[30], - &intbuf[31]); - - m_decimator32.myDecimate( - intbuf[14], - intbuf[15], - &intbuf[30], - &intbuf[31]); - - (**it).setReal(intbuf[30]); - (**it).setImag(intbuf[31]); - ++(*it); - } -} - -void DecimatorsFF::decimate64_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[64]; - - for (int pos = 0; pos < nbIAndQ - 127; pos += 128) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - intbuf[8] = buf[pos+18]; - intbuf[9] = buf[pos+19]; - intbuf[10] = buf[pos+22]; - intbuf[11] = buf[pos+23]; - intbuf[12] = buf[pos+26]; - intbuf[13] = buf[pos+27]; - intbuf[14] = buf[pos+30]; - intbuf[15] = buf[pos+31]; - intbuf[16] = buf[pos+34]; - intbuf[17] = buf[pos+35]; - intbuf[18] = buf[pos+38]; - intbuf[19] = buf[pos+39]; - intbuf[20] = buf[pos+42]; - intbuf[21] = buf[pos+43]; - intbuf[22] = buf[pos+46]; - intbuf[23] = buf[pos+47]; - intbuf[24] = buf[pos+50]; - intbuf[25] = buf[pos+51]; - intbuf[26] = buf[pos+54]; - intbuf[27] = buf[pos+55]; - intbuf[28] = buf[pos+58]; - intbuf[29] = buf[pos+59]; - intbuf[30] = buf[pos+62]; - intbuf[31] = buf[pos+63]; - - intbuf[32] = buf[pos+66]; - intbuf[33] = buf[pos+67]; - intbuf[34] = buf[pos+70]; - intbuf[35] = buf[pos+71]; - intbuf[36] = buf[pos+74]; - intbuf[37] = buf[pos+75]; - intbuf[38] = buf[pos+78]; - intbuf[39] = buf[pos+79]; - intbuf[40] = buf[pos+82]; - intbuf[41] = buf[pos+83]; - intbuf[42] = buf[pos+86]; - intbuf[43] = buf[pos+87]; - intbuf[44] = buf[pos+90]; - intbuf[45] = buf[pos+91]; - intbuf[46] = buf[pos+94]; - intbuf[47] = buf[pos+95]; - intbuf[48] = buf[pos+98]; - intbuf[49] = buf[pos+99]; - intbuf[50] = buf[pos+102]; - intbuf[51] = buf[pos+103]; - intbuf[52] = buf[pos+106]; - intbuf[53] = buf[pos+107]; - intbuf[54] = buf[pos+110]; - intbuf[55] = buf[pos+111]; - intbuf[56] = buf[pos+114]; - intbuf[57] = buf[pos+115]; - intbuf[58] = buf[pos+118]; - intbuf[59] = buf[pos+119]; - intbuf[60] = buf[pos+122]; - intbuf[61] = buf[pos+123]; - intbuf[62] = buf[pos+126]; - intbuf[63] = buf[pos+127]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - m_decimator2.myDecimate( - buf[pos+16], - buf[pos+17], - &intbuf[8], - &intbuf[9]); - m_decimator2.myDecimate( - buf[pos+20], - buf[pos+21], - &intbuf[10], - &intbuf[11]); - m_decimator2.myDecimate( - buf[pos+24], - buf[pos+25], - &intbuf[12], - &intbuf[13]); - m_decimator2.myDecimate( - buf[pos+28], - buf[pos+29], - &intbuf[14], - &intbuf[15]); - m_decimator2.myDecimate( - buf[pos+32], - buf[pos+33], - &intbuf[16], - &intbuf[17]); - m_decimator2.myDecimate( - buf[pos+36], - buf[pos+37], - &intbuf[18], - &intbuf[19]); - m_decimator2.myDecimate( - buf[pos+40], - buf[pos+41], - &intbuf[20], - &intbuf[21]); - m_decimator2.myDecimate( - buf[pos+44], - buf[pos+45], - &intbuf[22], - &intbuf[23]); - m_decimator2.myDecimate( - buf[pos+48], - buf[pos+49], - &intbuf[24], - &intbuf[25]); - m_decimator2.myDecimate( - buf[pos+52], - buf[pos+53], - &intbuf[26], - &intbuf[27]); - m_decimator2.myDecimate( - buf[pos+56], - buf[pos+57], - &intbuf[28], - &intbuf[29]); - m_decimator2.myDecimate( - buf[pos+60], - buf[pos+61], - &intbuf[30], - &intbuf[31]); - m_decimator2.myDecimate( - buf[pos+64], - buf[pos+65], - &intbuf[32], - &intbuf[33]); - m_decimator2.myDecimate( - buf[pos+68], - buf[pos+69], - &intbuf[34], - &intbuf[35]); - m_decimator2.myDecimate( - buf[pos+72], - buf[pos+73], - &intbuf[36], - &intbuf[37]); - m_decimator2.myDecimate( - buf[pos+76], - buf[pos+77], - &intbuf[38], - &intbuf[39]); - m_decimator2.myDecimate( - buf[pos+80], - buf[pos+81], - &intbuf[40], - &intbuf[41]); - m_decimator2.myDecimate( - buf[pos+84], - buf[pos+85], - &intbuf[42], - &intbuf[43]); - m_decimator2.myDecimate( - buf[pos+88], - buf[pos+89], - &intbuf[44], - &intbuf[45]); - m_decimator2.myDecimate( - buf[pos+92], - buf[pos+93], - &intbuf[46], - &intbuf[47]); - m_decimator2.myDecimate( - buf[pos+96], - buf[pos+97], - &intbuf[48], - &intbuf[49]); - m_decimator2.myDecimate( - buf[pos+100], - buf[pos+101], - &intbuf[50], - &intbuf[51]); - m_decimator2.myDecimate( - buf[pos+104], - buf[pos+105], - &intbuf[52], - &intbuf[53]); - m_decimator2.myDecimate( - buf[pos+108], - buf[pos+109], - &intbuf[54], - &intbuf[55]); - m_decimator2.myDecimate( - buf[pos+112], - buf[pos+113], - &intbuf[56], - &intbuf[57]); - m_decimator2.myDecimate( - buf[pos+116], - buf[pos+117], - &intbuf[58], - &intbuf[59]); - m_decimator2.myDecimate( - buf[pos+120], - buf[pos+121], - &intbuf[60], - &intbuf[61]); - m_decimator2.myDecimate( - buf[pos+124], - buf[pos+125], - &intbuf[62], - &intbuf[63]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - m_decimator4.myDecimate( - intbuf[8], - intbuf[9], - &intbuf[10], - &intbuf[11]); - m_decimator4.myDecimate( - intbuf[12], - intbuf[13], - &intbuf[14], - &intbuf[15]); - m_decimator4.myDecimate( - intbuf[16], - intbuf[17], - &intbuf[18], - &intbuf[19]); - m_decimator4.myDecimate( - intbuf[20], - intbuf[21], - &intbuf[22], - &intbuf[23]); - m_decimator4.myDecimate( - intbuf[24], - intbuf[25], - &intbuf[26], - &intbuf[27]); - m_decimator4.myDecimate( - intbuf[28], - intbuf[29], - &intbuf[30], - &intbuf[31]); - m_decimator4.myDecimate( - intbuf[32], - intbuf[33], - &intbuf[34], - &intbuf[35]); - m_decimator4.myDecimate( - intbuf[36], - intbuf[37], - &intbuf[38], - &intbuf[39]); - m_decimator4.myDecimate( - intbuf[40], - intbuf[41], - &intbuf[42], - &intbuf[43]); - m_decimator4.myDecimate( - intbuf[44], - intbuf[45], - &intbuf[46], - &intbuf[47]); - m_decimator4.myDecimate( - intbuf[48], - intbuf[49], - &intbuf[50], - &intbuf[51]); - m_decimator4.myDecimate( - intbuf[52], - intbuf[53], - &intbuf[54], - &intbuf[55]); - m_decimator4.myDecimate( - intbuf[56], - intbuf[57], - &intbuf[58], - &intbuf[59]); - m_decimator4.myDecimate( - intbuf[60], - intbuf[61], - &intbuf[62], - &intbuf[63]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - m_decimator8.myDecimate( - intbuf[10], - intbuf[11], - &intbuf[14], - &intbuf[15]); - m_decimator8.myDecimate( - intbuf[18], - intbuf[19], - &intbuf[22], - &intbuf[23]); - m_decimator8.myDecimate( - intbuf[26], - intbuf[27], - &intbuf[30], - &intbuf[31]); - m_decimator8.myDecimate( - intbuf[34], - intbuf[35], - &intbuf[38], - &intbuf[39]); - m_decimator8.myDecimate( - intbuf[42], - intbuf[43], - &intbuf[46], - &intbuf[47]); - m_decimator8.myDecimate( - intbuf[50], - intbuf[51], - &intbuf[54], - &intbuf[55]); - m_decimator8.myDecimate( - intbuf[58], - intbuf[59], - &intbuf[62], - &intbuf[63]); - - m_decimator16.myDecimate( - intbuf[6], - intbuf[7], - &intbuf[14], - &intbuf[15]); - m_decimator16.myDecimate( - intbuf[22], - intbuf[23], - &intbuf[30], - &intbuf[31]); - m_decimator16.myDecimate( - intbuf[38], - intbuf[39], - &intbuf[46], - &intbuf[47]); - m_decimator16.myDecimate( - intbuf[54], - intbuf[55], - &intbuf[62], - &intbuf[63]); - - m_decimator32.myDecimate( - intbuf[14], - intbuf[15], - &intbuf[30], - &intbuf[31]); - m_decimator32.myDecimate( - intbuf[46], - intbuf[47], - &intbuf[62], - &intbuf[63]); - - m_decimator64.myDecimate( - intbuf[30], - intbuf[31], - &intbuf[62], - &intbuf[63]); - - (**it).setReal(intbuf[62]); - (**it).setImag(intbuf[63]); - ++(*it); - } -} - diff --git a/sdrbase/dsp/decimatorsff.h b/sdrbase/dsp/decimatorsff.h index 581d436ec..0daab553b 100644 --- a/sdrbase/dsp/decimatorsff.h +++ b/sdrbase/dsp/decimatorsff.h @@ -24,6 +24,7 @@ #define DECIMATORSFF_HB_FILTER_ORDER 64 /** Decimators with float input and float output */ +template class SDRBASE_API DecimatorsFF { public: @@ -47,14 +48,1089 @@ public: void decimate64_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ); void decimate64_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ); - IntHalfbandFilterEOF m_decimator2; // 1st stages - IntHalfbandFilterEOF m_decimator4; // 2nd stages - IntHalfbandFilterEOF m_decimator8; // 3rd stages - IntHalfbandFilterEOF m_decimator16; // 4th stages - IntHalfbandFilterEOF m_decimator32; // 5th stages - IntHalfbandFilterEOF m_decimator64; // 6th stages + IntHalfbandFilterEOF m_decimator2; // 1st stages + IntHalfbandFilterEOF m_decimator4; // 2nd stages + IntHalfbandFilterEOF m_decimator8; // 3rd stages + IntHalfbandFilterEOF m_decimator16; // 4th stages + IntHalfbandFilterEOF m_decimator32; // 5th stages + IntHalfbandFilterEOF m_decimator64; // 6th stages }; +template +void DecimatorsFF::decimate2_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[2]; + for (int pos = 0; pos < nbIAndQ - 3; pos += 4) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + + (**it).setReal(intbuf[0]); + (**it).setImag(intbuf[1]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate8_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[2], yimag[2]; + + for (int pos = 0; pos < nbIAndQ - 15; pos += 8) + { + xreal[0] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[0] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + + xreal[1] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[1] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + + (**it).setReal(xreal[1]); + (**it).setImag(yimag[1]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate8_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[2], yimag[2]; + + for (int pos = 0; pos < nbIAndQ - 15; pos += 8) + { + xreal[0] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[0] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); + pos += 8; + + xreal[1] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[1] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + + (**it).setReal(xreal[1]); + (**it).setImag(yimag[1]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate16_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + // Offset tuning: 4x downsample and rotate, then + // downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] + float xreal[4], yimag[4]; + + for (int pos = 0; pos < nbIAndQ - 31; ) + { + for (int i = 0; i < 4; i++) + { + xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + + (**it).setReal(xreal[3]); + (**it).setImag(yimag[3]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate16_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + // Offset tuning: 4x downsample and rotate, then + // downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] + float xreal[4], yimag[4]; + + for (int pos = 0; pos < nbIAndQ - 31; ) + { + for (int i = 0; i < 4; i++) + { + xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + + (**it).setReal(xreal[3]); + (**it).setImag(yimag[3]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate32_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[8], yimag[8]; + + for (int pos = 0; pos < nbIAndQ - 63; ) + { + for (int i = 0; i < 8; i++) + { + xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + + (**it).setReal(xreal[7]); + (**it).setImag(yimag[7]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate32_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[8], yimag[8]; + + for (int pos = 0; pos < nbIAndQ - 63; ) + { + for (int i = 0; i < 8; i++) + { + xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + + (**it).setReal(xreal[7]); + (**it).setImag(yimag[7]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate64_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[16], yimag[16]; + + for (int pos = 0; pos < nbIAndQ - 127; ) + { + for (int i = 0; i < 16; i++) + { + xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); + m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); + m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); + m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); + m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); + + m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); + + (**it).setReal(xreal[15]); + (**it).setImag(yimag[15]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate64_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[16], yimag[16]; + + for (int pos = 0; pos < nbIAndQ - 127; ) + { + for (int i = 0; i < 16; i++) + { + xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); + m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); + m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); + m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); + m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); + + m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); + + (**it).setReal(xreal[15]); + (**it).setImag(yimag[15]); + + ++(*it); + } +} + +template +void DecimatorsFF::decimate4_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[4]; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + + (**it).setReal(intbuf[2]); + (**it).setImag(intbuf[3]); + ++(*it); + } +} + +template +void DecimatorsFF::decimate8_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[8]; + + for (int pos = 0; pos < nbIAndQ - 15; pos += 16) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + + (**it).setReal(intbuf[6]); + (**it).setImag(intbuf[7]); + ++(*it); + } +} + +template +void DecimatorsFF::decimate16_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[16]; + + for (int pos = 0; pos < nbIAndQ - 31; pos += 32) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + intbuf[8] = buf[pos+18]; + intbuf[9] = buf[pos+19]; + intbuf[10] = buf[pos+22]; + intbuf[11] = buf[pos+23]; + intbuf[12] = buf[pos+26]; + intbuf[13] = buf[pos+27]; + intbuf[14] = buf[pos+30]; + intbuf[15] = buf[pos+31]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + m_decimator2.myDecimate( + buf[pos+16], + buf[pos+17], + &intbuf[8], + &intbuf[9]); + m_decimator2.myDecimate( + buf[pos+20], + buf[pos+21], + &intbuf[10], + &intbuf[11]); + m_decimator2.myDecimate( + buf[pos+24], + buf[pos+25], + &intbuf[12], + &intbuf[13]); + m_decimator2.myDecimate( + buf[pos+28], + buf[pos+29], + &intbuf[14], + &intbuf[15]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + m_decimator4.myDecimate( + intbuf[8], + intbuf[9], + &intbuf[10], + &intbuf[11]); + m_decimator4.myDecimate( + intbuf[12], + intbuf[13], + &intbuf[14], + &intbuf[15]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + m_decimator8.myDecimate( + intbuf[10], + intbuf[11], + &intbuf[14], + &intbuf[15]); + + m_decimator16.myDecimate( + intbuf[6], + intbuf[7], + &intbuf[14], + &intbuf[15]); + + (**it).setReal(intbuf[14]); + (**it).setImag(intbuf[15]); + ++(*it); + } +} + +template +void DecimatorsFF::decimate32_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[32]; + + for (int pos = 0; pos < nbIAndQ - 63; pos += 64) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + intbuf[8] = buf[pos+18]; + intbuf[9] = buf[pos+19]; + intbuf[10] = buf[pos+22]; + intbuf[11] = buf[pos+23]; + intbuf[12] = buf[pos+26]; + intbuf[13] = buf[pos+27]; + intbuf[14] = buf[pos+30]; + intbuf[15] = buf[pos+31]; + intbuf[16] = buf[pos+34]; + intbuf[17] = buf[pos+35]; + intbuf[18] = buf[pos+38]; + intbuf[19] = buf[pos+39]; + intbuf[20] = buf[pos+42]; + intbuf[21] = buf[pos+43]; + intbuf[22] = buf[pos+46]; + intbuf[23] = buf[pos+47]; + intbuf[24] = buf[pos+50]; + intbuf[25] = buf[pos+51]; + intbuf[26] = buf[pos+54]; + intbuf[27] = buf[pos+55]; + intbuf[28] = buf[pos+58]; + intbuf[29] = buf[pos+59]; + intbuf[30] = buf[pos+62]; + intbuf[31] = buf[pos+63]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + m_decimator2.myDecimate( + buf[pos+16], + buf[pos+17], + &intbuf[8], + &intbuf[9]); + m_decimator2.myDecimate( + buf[pos+20], + buf[pos+21], + &intbuf[10], + &intbuf[11]); + m_decimator2.myDecimate( + buf[pos+24], + buf[pos+25], + &intbuf[12], + &intbuf[13]); + m_decimator2.myDecimate( + buf[pos+28], + buf[pos+29], + &intbuf[14], + &intbuf[15]); + m_decimator2.myDecimate( + buf[pos+32], + buf[pos+33], + &intbuf[16], + &intbuf[17]); + m_decimator2.myDecimate( + buf[pos+36], + buf[pos+37], + &intbuf[18], + &intbuf[19]); + m_decimator2.myDecimate( + buf[pos+40], + buf[pos+41], + &intbuf[20], + &intbuf[21]); + m_decimator2.myDecimate( + buf[pos+44], + buf[pos+45], + &intbuf[22], + &intbuf[23]); + m_decimator2.myDecimate( + buf[pos+48], + buf[pos+49], + &intbuf[24], + &intbuf[25]); + m_decimator2.myDecimate( + buf[pos+52], + buf[pos+53], + &intbuf[26], + &intbuf[27]); + m_decimator2.myDecimate( + buf[pos+56], + buf[pos+57], + &intbuf[28], + &intbuf[29]); + m_decimator2.myDecimate( + buf[pos+60], + buf[pos+61], + &intbuf[30], + &intbuf[31]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + m_decimator4.myDecimate( + intbuf[8], + intbuf[9], + &intbuf[10], + &intbuf[11]); + m_decimator4.myDecimate( + intbuf[12], + intbuf[13], + &intbuf[14], + &intbuf[15]); + m_decimator4.myDecimate( + intbuf[16], + intbuf[17], + &intbuf[18], + &intbuf[19]); + m_decimator4.myDecimate( + intbuf[20], + intbuf[21], + &intbuf[22], + &intbuf[23]); + m_decimator4.myDecimate( + intbuf[24], + intbuf[25], + &intbuf[26], + &intbuf[27]); + m_decimator4.myDecimate( + intbuf[28], + intbuf[29], + &intbuf[30], + &intbuf[31]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + m_decimator8.myDecimate( + intbuf[10], + intbuf[11], + &intbuf[14], + &intbuf[15]); + m_decimator8.myDecimate( + intbuf[18], + intbuf[19], + &intbuf[22], + &intbuf[23]); + m_decimator8.myDecimate( + intbuf[26], + intbuf[27], + &intbuf[30], + &intbuf[31]); + + m_decimator16.myDecimate( + intbuf[6], + intbuf[7], + &intbuf[14], + &intbuf[15]); + m_decimator16.myDecimate( + intbuf[22], + intbuf[23], + &intbuf[30], + &intbuf[31]); + + m_decimator32.myDecimate( + intbuf[14], + intbuf[15], + &intbuf[30], + &intbuf[31]); + + (**it).setReal(intbuf[30]); + (**it).setImag(intbuf[31]); + ++(*it); + } +} + +template +void DecimatorsFF::decimate64_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[64]; + + for (int pos = 0; pos < nbIAndQ - 127; pos += 128) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + intbuf[8] = buf[pos+18]; + intbuf[9] = buf[pos+19]; + intbuf[10] = buf[pos+22]; + intbuf[11] = buf[pos+23]; + intbuf[12] = buf[pos+26]; + intbuf[13] = buf[pos+27]; + intbuf[14] = buf[pos+30]; + intbuf[15] = buf[pos+31]; + intbuf[16] = buf[pos+34]; + intbuf[17] = buf[pos+35]; + intbuf[18] = buf[pos+38]; + intbuf[19] = buf[pos+39]; + intbuf[20] = buf[pos+42]; + intbuf[21] = buf[pos+43]; + intbuf[22] = buf[pos+46]; + intbuf[23] = buf[pos+47]; + intbuf[24] = buf[pos+50]; + intbuf[25] = buf[pos+51]; + intbuf[26] = buf[pos+54]; + intbuf[27] = buf[pos+55]; + intbuf[28] = buf[pos+58]; + intbuf[29] = buf[pos+59]; + intbuf[30] = buf[pos+62]; + intbuf[31] = buf[pos+63]; + + intbuf[32] = buf[pos+66]; + intbuf[33] = buf[pos+67]; + intbuf[34] = buf[pos+70]; + intbuf[35] = buf[pos+71]; + intbuf[36] = buf[pos+74]; + intbuf[37] = buf[pos+75]; + intbuf[38] = buf[pos+78]; + intbuf[39] = buf[pos+79]; + intbuf[40] = buf[pos+82]; + intbuf[41] = buf[pos+83]; + intbuf[42] = buf[pos+86]; + intbuf[43] = buf[pos+87]; + intbuf[44] = buf[pos+90]; + intbuf[45] = buf[pos+91]; + intbuf[46] = buf[pos+94]; + intbuf[47] = buf[pos+95]; + intbuf[48] = buf[pos+98]; + intbuf[49] = buf[pos+99]; + intbuf[50] = buf[pos+102]; + intbuf[51] = buf[pos+103]; + intbuf[52] = buf[pos+106]; + intbuf[53] = buf[pos+107]; + intbuf[54] = buf[pos+110]; + intbuf[55] = buf[pos+111]; + intbuf[56] = buf[pos+114]; + intbuf[57] = buf[pos+115]; + intbuf[58] = buf[pos+118]; + intbuf[59] = buf[pos+119]; + intbuf[60] = buf[pos+122]; + intbuf[61] = buf[pos+123]; + intbuf[62] = buf[pos+126]; + intbuf[63] = buf[pos+127]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + m_decimator2.myDecimate( + buf[pos+16], + buf[pos+17], + &intbuf[8], + &intbuf[9]); + m_decimator2.myDecimate( + buf[pos+20], + buf[pos+21], + &intbuf[10], + &intbuf[11]); + m_decimator2.myDecimate( + buf[pos+24], + buf[pos+25], + &intbuf[12], + &intbuf[13]); + m_decimator2.myDecimate( + buf[pos+28], + buf[pos+29], + &intbuf[14], + &intbuf[15]); + m_decimator2.myDecimate( + buf[pos+32], + buf[pos+33], + &intbuf[16], + &intbuf[17]); + m_decimator2.myDecimate( + buf[pos+36], + buf[pos+37], + &intbuf[18], + &intbuf[19]); + m_decimator2.myDecimate( + buf[pos+40], + buf[pos+41], + &intbuf[20], + &intbuf[21]); + m_decimator2.myDecimate( + buf[pos+44], + buf[pos+45], + &intbuf[22], + &intbuf[23]); + m_decimator2.myDecimate( + buf[pos+48], + buf[pos+49], + &intbuf[24], + &intbuf[25]); + m_decimator2.myDecimate( + buf[pos+52], + buf[pos+53], + &intbuf[26], + &intbuf[27]); + m_decimator2.myDecimate( + buf[pos+56], + buf[pos+57], + &intbuf[28], + &intbuf[29]); + m_decimator2.myDecimate( + buf[pos+60], + buf[pos+61], + &intbuf[30], + &intbuf[31]); + m_decimator2.myDecimate( + buf[pos+64], + buf[pos+65], + &intbuf[32], + &intbuf[33]); + m_decimator2.myDecimate( + buf[pos+68], + buf[pos+69], + &intbuf[34], + &intbuf[35]); + m_decimator2.myDecimate( + buf[pos+72], + buf[pos+73], + &intbuf[36], + &intbuf[37]); + m_decimator2.myDecimate( + buf[pos+76], + buf[pos+77], + &intbuf[38], + &intbuf[39]); + m_decimator2.myDecimate( + buf[pos+80], + buf[pos+81], + &intbuf[40], + &intbuf[41]); + m_decimator2.myDecimate( + buf[pos+84], + buf[pos+85], + &intbuf[42], + &intbuf[43]); + m_decimator2.myDecimate( + buf[pos+88], + buf[pos+89], + &intbuf[44], + &intbuf[45]); + m_decimator2.myDecimate( + buf[pos+92], + buf[pos+93], + &intbuf[46], + &intbuf[47]); + m_decimator2.myDecimate( + buf[pos+96], + buf[pos+97], + &intbuf[48], + &intbuf[49]); + m_decimator2.myDecimate( + buf[pos+100], + buf[pos+101], + &intbuf[50], + &intbuf[51]); + m_decimator2.myDecimate( + buf[pos+104], + buf[pos+105], + &intbuf[52], + &intbuf[53]); + m_decimator2.myDecimate( + buf[pos+108], + buf[pos+109], + &intbuf[54], + &intbuf[55]); + m_decimator2.myDecimate( + buf[pos+112], + buf[pos+113], + &intbuf[56], + &intbuf[57]); + m_decimator2.myDecimate( + buf[pos+116], + buf[pos+117], + &intbuf[58], + &intbuf[59]); + m_decimator2.myDecimate( + buf[pos+120], + buf[pos+121], + &intbuf[60], + &intbuf[61]); + m_decimator2.myDecimate( + buf[pos+124], + buf[pos+125], + &intbuf[62], + &intbuf[63]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + m_decimator4.myDecimate( + intbuf[8], + intbuf[9], + &intbuf[10], + &intbuf[11]); + m_decimator4.myDecimate( + intbuf[12], + intbuf[13], + &intbuf[14], + &intbuf[15]); + m_decimator4.myDecimate( + intbuf[16], + intbuf[17], + &intbuf[18], + &intbuf[19]); + m_decimator4.myDecimate( + intbuf[20], + intbuf[21], + &intbuf[22], + &intbuf[23]); + m_decimator4.myDecimate( + intbuf[24], + intbuf[25], + &intbuf[26], + &intbuf[27]); + m_decimator4.myDecimate( + intbuf[28], + intbuf[29], + &intbuf[30], + &intbuf[31]); + m_decimator4.myDecimate( + intbuf[32], + intbuf[33], + &intbuf[34], + &intbuf[35]); + m_decimator4.myDecimate( + intbuf[36], + intbuf[37], + &intbuf[38], + &intbuf[39]); + m_decimator4.myDecimate( + intbuf[40], + intbuf[41], + &intbuf[42], + &intbuf[43]); + m_decimator4.myDecimate( + intbuf[44], + intbuf[45], + &intbuf[46], + &intbuf[47]); + m_decimator4.myDecimate( + intbuf[48], + intbuf[49], + &intbuf[50], + &intbuf[51]); + m_decimator4.myDecimate( + intbuf[52], + intbuf[53], + &intbuf[54], + &intbuf[55]); + m_decimator4.myDecimate( + intbuf[56], + intbuf[57], + &intbuf[58], + &intbuf[59]); + m_decimator4.myDecimate( + intbuf[60], + intbuf[61], + &intbuf[62], + &intbuf[63]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + m_decimator8.myDecimate( + intbuf[10], + intbuf[11], + &intbuf[14], + &intbuf[15]); + m_decimator8.myDecimate( + intbuf[18], + intbuf[19], + &intbuf[22], + &intbuf[23]); + m_decimator8.myDecimate( + intbuf[26], + intbuf[27], + &intbuf[30], + &intbuf[31]); + m_decimator8.myDecimate( + intbuf[34], + intbuf[35], + &intbuf[38], + &intbuf[39]); + m_decimator8.myDecimate( + intbuf[42], + intbuf[43], + &intbuf[46], + &intbuf[47]); + m_decimator8.myDecimate( + intbuf[50], + intbuf[51], + &intbuf[54], + &intbuf[55]); + m_decimator8.myDecimate( + intbuf[58], + intbuf[59], + &intbuf[62], + &intbuf[63]); + + m_decimator16.myDecimate( + intbuf[6], + intbuf[7], + &intbuf[14], + &intbuf[15]); + m_decimator16.myDecimate( + intbuf[22], + intbuf[23], + &intbuf[30], + &intbuf[31]); + m_decimator16.myDecimate( + intbuf[38], + intbuf[39], + &intbuf[46], + &intbuf[47]); + m_decimator16.myDecimate( + intbuf[54], + intbuf[55], + &intbuf[62], + &intbuf[63]); + + m_decimator32.myDecimate( + intbuf[14], + intbuf[15], + &intbuf[30], + &intbuf[31]); + m_decimator32.myDecimate( + intbuf[46], + intbuf[47], + &intbuf[62], + &intbuf[63]); + + m_decimator64.myDecimate( + intbuf[30], + intbuf[31], + &intbuf[62], + &intbuf[63]); + + (**it).setReal(intbuf[62]); + (**it).setImag(intbuf[63]); + ++(*it); + } +} #endif /* SDRBASE_DSP_DECIMATORSFF_H_ */ diff --git a/sdrbase/dsp/decimatorsfi.cpp b/sdrbase/dsp/decimatorsfi.cpp index f8de83a5a..659a56b25 100644 --- a/sdrbase/dsp/decimatorsfi.cpp +++ b/sdrbase/dsp/decimatorsfi.cpp @@ -17,7 +17,8 @@ #include "decimatorsfi.h" -void DecimatorsFI::decimate1(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFI::decimate1(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -31,29 +32,23 @@ void DecimatorsFI::decimate1(SampleVector::iterator* it, const float* buf, qint3 } } -void DecimatorsFI::decimate2_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFI::decimate1(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { - float intbuf[2]; + float xreal, yimag; - for (int pos = 0; pos < nbIAndQ - 3; pos += 4) + for (int pos = 0; pos < nbIAndQ - 1; pos += 2) { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - - (**it).setReal(intbuf[0] * SDR_RX_SCALED); - (**it).setImag(intbuf[1] * SDR_RX_SCALED); - - ++(*it); + xreal = buf[pos+1]; + yimag = buf[pos+0]; + (**it).setReal(xreal * SDR_RX_SCALEF); + (**it).setImag(yimag * SDR_RX_SCALEF); + ++(*it); // Valgrind optim (comment not repeated) } } -void DecimatorsFI::decimate2_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFI::decimate2_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -73,7 +68,29 @@ void DecimatorsFI::decimate2_inf(SampleVector::iterator* it, const float* buf, q } } -void DecimatorsFI::decimate2_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFI::decimate2_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal, yimag; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + xreal = (buf[pos+1] + buf[pos+2]); + yimag = (buf[pos+0] - buf[pos+3]); + (**it).setReal(xreal * SDR_RX_SCALED); + (**it).setImag(yimag * SDR_RX_SCALED); + ++(*it); + + xreal = (- buf[pos+5] - buf[pos+6]); + yimag = (buf[pos+7] - buf[pos+4]); + (**it).setReal(xreal * SDR_RX_SCALED); + (**it).setImag(yimag * SDR_RX_SCALED); + ++(*it); + } +} + +template<> +void DecimatorsFI::decimate2_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -93,7 +110,29 @@ void DecimatorsFI::decimate2_sup(SampleVector::iterator* it, const float* buf, q } } -void DecimatorsFI::decimate4_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFI::decimate2_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal, yimag; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + xreal = (- buf[pos+0] - buf[pos+3]); + yimag = (buf[pos+1] - buf[pos+2]); + (**it).setReal(xreal * SDR_RX_SCALED); + (**it).setImag(yimag * SDR_RX_SCALED); + ++(*it); + + xreal = (buf[pos+4] + buf[pos+7]); + yimag = (buf[pos+6] - buf[pos+5]); + (**it).setReal(xreal * SDR_RX_SCALED); + (**it).setImag(yimag * SDR_RX_SCALED); + ++(*it); + } +} + +template<> +void DecimatorsFI::decimate4_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { float xreal, yimag; @@ -109,7 +148,25 @@ void DecimatorsFI::decimate4_inf(SampleVector::iterator* it, const float* buf, q } } -void DecimatorsFI::decimate4_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFI::decimate4_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal, yimag; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + xreal = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + yimag = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + + (**it).setReal(xreal * SDR_RX_SCALED); + (**it).setImag(yimag * SDR_RX_SCALED); + + ++(*it); + } +} + +template<> +void DecimatorsFI::decimate4_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { // Sup (USB): // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 @@ -131,1043 +188,25 @@ void DecimatorsFI::decimate4_sup(SampleVector::iterator* it, const float* buf, q } } -void DecimatorsFI::decimate8_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +template<> +void DecimatorsFI::decimate4_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) { - float xreal[2], yimag[2]; - - for (int pos = 0; pos < nbIAndQ - 15; pos += 8) - { - xreal[0] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[0] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - - xreal[1] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[1] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - - (**it).setReal(xreal[1] * SDR_RX_SCALED); - (**it).setImag(yimag[1] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate8_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[2], yimag[2]; - - for (int pos = 0; pos < nbIAndQ - 15; pos += 8) - { - xreal[0] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[0] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); - pos += 8; - - xreal[1] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[1] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - - (**it).setReal(xreal[1] * SDR_RX_SCALED); - (**it).setImag(yimag[1] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate16_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - // Offset tuning: 4x downsample and rotate, then - // downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] - float xreal[4], yimag[4]; - - for (int pos = 0; pos < nbIAndQ - 31; ) - { - for (int i = 0; i < 4; i++) - { - xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - - (**it).setReal(xreal[3] * SDR_RX_SCALED); - (**it).setImag(yimag[3] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate16_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - // Offset tuning: 4x downsample and rotate, then - // downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] - float xreal[4], yimag[4]; - - for (int pos = 0; pos < nbIAndQ - 31; ) - { - for (int i = 0; i < 4; i++) - { - xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - - (**it).setReal(xreal[3] * SDR_RX_SCALED); - (**it).setImag(yimag[3] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate32_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[8], yimag[8]; - - for (int pos = 0; pos < nbIAndQ - 63; ) - { - for (int i = 0; i < 8; i++) - { - xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - - (**it).setReal(xreal[7] * SDR_RX_SCALED); - (**it).setImag(yimag[7] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate32_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[8], yimag[8]; - - for (int pos = 0; pos < nbIAndQ - 63; ) - { - for (int i = 0; i < 8; i++) - { - xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - - (**it).setReal(xreal[7] * SDR_RX_SCALED); - (**it).setImag(yimag[7] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate64_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[16], yimag[16]; - - for (int pos = 0; pos < nbIAndQ - 127; ) - { - for (int i = 0; i < 16; i++) - { - xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); - yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); - m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); - m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); - m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); - m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); - - m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); - - (**it).setReal(xreal[15] * SDR_RX_SCALED); - (**it).setImag(yimag[15] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate64_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float xreal[16], yimag[16]; - - for (int pos = 0; pos < nbIAndQ - 127; ) - { - for (int i = 0; i < 16; i++) - { - xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); - pos += 8; - } - - m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); - m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); - m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); - m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); - m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); - m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); - m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); - m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); - - m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); - m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); - m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); - m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); - - m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); - m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); - - m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); - - (**it).setReal(xreal[15] * SDR_RX_SCALED); - (**it).setImag(yimag[15] * SDR_RX_SCALED); - - ++(*it); - } -} - -void DecimatorsFI::decimate4_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[4]; + // Sup (USB): + // x y x y x y x y / x -> 1,-2,-5,6 / y -> -0,-3,4,7 + // [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] + // 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] + float xreal, yimag; for (int pos = 0; pos < nbIAndQ - 7; pos += 8) { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; + xreal = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); + yimag = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); + (**it).setReal(xreal * SDR_RX_SCALED); + (**it).setImag(yimag * SDR_RX_SCALED); - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - - (**it).setReal(intbuf[2] * SDR_RX_SCALED); - (**it).setImag(intbuf[3] * SDR_RX_SCALED); - ++(*it); - } -} - -void DecimatorsFI::decimate8_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[8]; - - for (int pos = 0; pos < nbIAndQ - 15; pos += 16) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - - (**it).setReal(intbuf[6] * SDR_RX_SCALED); - (**it).setImag(intbuf[7] * SDR_RX_SCALED); - ++(*it); - } -} - -void DecimatorsFI::decimate16_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[16]; - - for (int pos = 0; pos < nbIAndQ - 31; pos += 32) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - intbuf[8] = buf[pos+18]; - intbuf[9] = buf[pos+19]; - intbuf[10] = buf[pos+22]; - intbuf[11] = buf[pos+23]; - intbuf[12] = buf[pos+26]; - intbuf[13] = buf[pos+27]; - intbuf[14] = buf[pos+30]; - intbuf[15] = buf[pos+31]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - m_decimator2.myDecimate( - buf[pos+16], - buf[pos+17], - &intbuf[8], - &intbuf[9]); - m_decimator2.myDecimate( - buf[pos+20], - buf[pos+21], - &intbuf[10], - &intbuf[11]); - m_decimator2.myDecimate( - buf[pos+24], - buf[pos+25], - &intbuf[12], - &intbuf[13]); - m_decimator2.myDecimate( - buf[pos+28], - buf[pos+29], - &intbuf[14], - &intbuf[15]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - m_decimator4.myDecimate( - intbuf[8], - intbuf[9], - &intbuf[10], - &intbuf[11]); - m_decimator4.myDecimate( - intbuf[12], - intbuf[13], - &intbuf[14], - &intbuf[15]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - m_decimator8.myDecimate( - intbuf[10], - intbuf[11], - &intbuf[14], - &intbuf[15]); - - m_decimator16.myDecimate( - intbuf[6], - intbuf[7], - &intbuf[14], - &intbuf[15]); - - (**it).setReal(intbuf[14] * SDR_RX_SCALED); - (**it).setImag(intbuf[15] * SDR_RX_SCALED); - ++(*it); - } -} - -void DecimatorsFI::decimate32_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[32]; - - for (int pos = 0; pos < nbIAndQ - 63; pos += 64) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - intbuf[8] = buf[pos+18]; - intbuf[9] = buf[pos+19]; - intbuf[10] = buf[pos+22]; - intbuf[11] = buf[pos+23]; - intbuf[12] = buf[pos+26]; - intbuf[13] = buf[pos+27]; - intbuf[14] = buf[pos+30]; - intbuf[15] = buf[pos+31]; - intbuf[16] = buf[pos+34]; - intbuf[17] = buf[pos+35]; - intbuf[18] = buf[pos+38]; - intbuf[19] = buf[pos+39]; - intbuf[20] = buf[pos+42]; - intbuf[21] = buf[pos+43]; - intbuf[22] = buf[pos+46]; - intbuf[23] = buf[pos+47]; - intbuf[24] = buf[pos+50]; - intbuf[25] = buf[pos+51]; - intbuf[26] = buf[pos+54]; - intbuf[27] = buf[pos+55]; - intbuf[28] = buf[pos+58]; - intbuf[29] = buf[pos+59]; - intbuf[30] = buf[pos+62]; - intbuf[31] = buf[pos+63]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - m_decimator2.myDecimate( - buf[pos+16], - buf[pos+17], - &intbuf[8], - &intbuf[9]); - m_decimator2.myDecimate( - buf[pos+20], - buf[pos+21], - &intbuf[10], - &intbuf[11]); - m_decimator2.myDecimate( - buf[pos+24], - buf[pos+25], - &intbuf[12], - &intbuf[13]); - m_decimator2.myDecimate( - buf[pos+28], - buf[pos+29], - &intbuf[14], - &intbuf[15]); - m_decimator2.myDecimate( - buf[pos+32], - buf[pos+33], - &intbuf[16], - &intbuf[17]); - m_decimator2.myDecimate( - buf[pos+36], - buf[pos+37], - &intbuf[18], - &intbuf[19]); - m_decimator2.myDecimate( - buf[pos+40], - buf[pos+41], - &intbuf[20], - &intbuf[21]); - m_decimator2.myDecimate( - buf[pos+44], - buf[pos+45], - &intbuf[22], - &intbuf[23]); - m_decimator2.myDecimate( - buf[pos+48], - buf[pos+49], - &intbuf[24], - &intbuf[25]); - m_decimator2.myDecimate( - buf[pos+52], - buf[pos+53], - &intbuf[26], - &intbuf[27]); - m_decimator2.myDecimate( - buf[pos+56], - buf[pos+57], - &intbuf[28], - &intbuf[29]); - m_decimator2.myDecimate( - buf[pos+60], - buf[pos+61], - &intbuf[30], - &intbuf[31]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - m_decimator4.myDecimate( - intbuf[8], - intbuf[9], - &intbuf[10], - &intbuf[11]); - m_decimator4.myDecimate( - intbuf[12], - intbuf[13], - &intbuf[14], - &intbuf[15]); - m_decimator4.myDecimate( - intbuf[16], - intbuf[17], - &intbuf[18], - &intbuf[19]); - m_decimator4.myDecimate( - intbuf[20], - intbuf[21], - &intbuf[22], - &intbuf[23]); - m_decimator4.myDecimate( - intbuf[24], - intbuf[25], - &intbuf[26], - &intbuf[27]); - m_decimator4.myDecimate( - intbuf[28], - intbuf[29], - &intbuf[30], - &intbuf[31]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - m_decimator8.myDecimate( - intbuf[10], - intbuf[11], - &intbuf[14], - &intbuf[15]); - m_decimator8.myDecimate( - intbuf[18], - intbuf[19], - &intbuf[22], - &intbuf[23]); - m_decimator8.myDecimate( - intbuf[26], - intbuf[27], - &intbuf[30], - &intbuf[31]); - - m_decimator16.myDecimate( - intbuf[6], - intbuf[7], - &intbuf[14], - &intbuf[15]); - m_decimator16.myDecimate( - intbuf[22], - intbuf[23], - &intbuf[30], - &intbuf[31]); - - m_decimator32.myDecimate( - intbuf[14], - intbuf[15], - &intbuf[30], - &intbuf[31]); - - (**it).setReal(intbuf[30] * SDR_RX_SCALED); - (**it).setImag(intbuf[31] * SDR_RX_SCALED); - ++(*it); - } -} - -void DecimatorsFI::decimate64_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) -{ - float intbuf[64]; - - for (int pos = 0; pos < nbIAndQ - 127; pos += 128) - { - intbuf[0] = buf[pos+2]; - intbuf[1] = buf[pos+3]; - intbuf[2] = buf[pos+6]; - intbuf[3] = buf[pos+7]; - intbuf[4] = buf[pos+10]; - intbuf[5] = buf[pos+11]; - intbuf[6] = buf[pos+14]; - intbuf[7] = buf[pos+15]; - intbuf[8] = buf[pos+18]; - intbuf[9] = buf[pos+19]; - intbuf[10] = buf[pos+22]; - intbuf[11] = buf[pos+23]; - intbuf[12] = buf[pos+26]; - intbuf[13] = buf[pos+27]; - intbuf[14] = buf[pos+30]; - intbuf[15] = buf[pos+31]; - intbuf[16] = buf[pos+34]; - intbuf[17] = buf[pos+35]; - intbuf[18] = buf[pos+38]; - intbuf[19] = buf[pos+39]; - intbuf[20] = buf[pos+42]; - intbuf[21] = buf[pos+43]; - intbuf[22] = buf[pos+46]; - intbuf[23] = buf[pos+47]; - intbuf[24] = buf[pos+50]; - intbuf[25] = buf[pos+51]; - intbuf[26] = buf[pos+54]; - intbuf[27] = buf[pos+55]; - intbuf[28] = buf[pos+58]; - intbuf[29] = buf[pos+59]; - intbuf[30] = buf[pos+62]; - intbuf[31] = buf[pos+63]; - - intbuf[32] = buf[pos+66]; - intbuf[33] = buf[pos+67]; - intbuf[34] = buf[pos+70]; - intbuf[35] = buf[pos+71]; - intbuf[36] = buf[pos+74]; - intbuf[37] = buf[pos+75]; - intbuf[38] = buf[pos+78]; - intbuf[39] = buf[pos+79]; - intbuf[40] = buf[pos+82]; - intbuf[41] = buf[pos+83]; - intbuf[42] = buf[pos+86]; - intbuf[43] = buf[pos+87]; - intbuf[44] = buf[pos+90]; - intbuf[45] = buf[pos+91]; - intbuf[46] = buf[pos+94]; - intbuf[47] = buf[pos+95]; - intbuf[48] = buf[pos+98]; - intbuf[49] = buf[pos+99]; - intbuf[50] = buf[pos+102]; - intbuf[51] = buf[pos+103]; - intbuf[52] = buf[pos+106]; - intbuf[53] = buf[pos+107]; - intbuf[54] = buf[pos+110]; - intbuf[55] = buf[pos+111]; - intbuf[56] = buf[pos+114]; - intbuf[57] = buf[pos+115]; - intbuf[58] = buf[pos+118]; - intbuf[59] = buf[pos+119]; - intbuf[60] = buf[pos+122]; - intbuf[61] = buf[pos+123]; - intbuf[62] = buf[pos+126]; - intbuf[63] = buf[pos+127]; - - m_decimator2.myDecimate( - buf[pos+0], - buf[pos+1], - &intbuf[0], - &intbuf[1]); - m_decimator2.myDecimate( - buf[pos+4], - buf[pos+5], - &intbuf[2], - &intbuf[3]); - m_decimator2.myDecimate( - buf[pos+8], - buf[pos+9], - &intbuf[4], - &intbuf[5]); - m_decimator2.myDecimate( - buf[pos+12], - buf[pos+13], - &intbuf[6], - &intbuf[7]); - m_decimator2.myDecimate( - buf[pos+16], - buf[pos+17], - &intbuf[8], - &intbuf[9]); - m_decimator2.myDecimate( - buf[pos+20], - buf[pos+21], - &intbuf[10], - &intbuf[11]); - m_decimator2.myDecimate( - buf[pos+24], - buf[pos+25], - &intbuf[12], - &intbuf[13]); - m_decimator2.myDecimate( - buf[pos+28], - buf[pos+29], - &intbuf[14], - &intbuf[15]); - m_decimator2.myDecimate( - buf[pos+32], - buf[pos+33], - &intbuf[16], - &intbuf[17]); - m_decimator2.myDecimate( - buf[pos+36], - buf[pos+37], - &intbuf[18], - &intbuf[19]); - m_decimator2.myDecimate( - buf[pos+40], - buf[pos+41], - &intbuf[20], - &intbuf[21]); - m_decimator2.myDecimate( - buf[pos+44], - buf[pos+45], - &intbuf[22], - &intbuf[23]); - m_decimator2.myDecimate( - buf[pos+48], - buf[pos+49], - &intbuf[24], - &intbuf[25]); - m_decimator2.myDecimate( - buf[pos+52], - buf[pos+53], - &intbuf[26], - &intbuf[27]); - m_decimator2.myDecimate( - buf[pos+56], - buf[pos+57], - &intbuf[28], - &intbuf[29]); - m_decimator2.myDecimate( - buf[pos+60], - buf[pos+61], - &intbuf[30], - &intbuf[31]); - m_decimator2.myDecimate( - buf[pos+64], - buf[pos+65], - &intbuf[32], - &intbuf[33]); - m_decimator2.myDecimate( - buf[pos+68], - buf[pos+69], - &intbuf[34], - &intbuf[35]); - m_decimator2.myDecimate( - buf[pos+72], - buf[pos+73], - &intbuf[36], - &intbuf[37]); - m_decimator2.myDecimate( - buf[pos+76], - buf[pos+77], - &intbuf[38], - &intbuf[39]); - m_decimator2.myDecimate( - buf[pos+80], - buf[pos+81], - &intbuf[40], - &intbuf[41]); - m_decimator2.myDecimate( - buf[pos+84], - buf[pos+85], - &intbuf[42], - &intbuf[43]); - m_decimator2.myDecimate( - buf[pos+88], - buf[pos+89], - &intbuf[44], - &intbuf[45]); - m_decimator2.myDecimate( - buf[pos+92], - buf[pos+93], - &intbuf[46], - &intbuf[47]); - m_decimator2.myDecimate( - buf[pos+96], - buf[pos+97], - &intbuf[48], - &intbuf[49]); - m_decimator2.myDecimate( - buf[pos+100], - buf[pos+101], - &intbuf[50], - &intbuf[51]); - m_decimator2.myDecimate( - buf[pos+104], - buf[pos+105], - &intbuf[52], - &intbuf[53]); - m_decimator2.myDecimate( - buf[pos+108], - buf[pos+109], - &intbuf[54], - &intbuf[55]); - m_decimator2.myDecimate( - buf[pos+112], - buf[pos+113], - &intbuf[56], - &intbuf[57]); - m_decimator2.myDecimate( - buf[pos+116], - buf[pos+117], - &intbuf[58], - &intbuf[59]); - m_decimator2.myDecimate( - buf[pos+120], - buf[pos+121], - &intbuf[60], - &intbuf[61]); - m_decimator2.myDecimate( - buf[pos+124], - buf[pos+125], - &intbuf[62], - &intbuf[63]); - - m_decimator4.myDecimate( - intbuf[0], - intbuf[1], - &intbuf[2], - &intbuf[3]); - m_decimator4.myDecimate( - intbuf[4], - intbuf[5], - &intbuf[6], - &intbuf[7]); - m_decimator4.myDecimate( - intbuf[8], - intbuf[9], - &intbuf[10], - &intbuf[11]); - m_decimator4.myDecimate( - intbuf[12], - intbuf[13], - &intbuf[14], - &intbuf[15]); - m_decimator4.myDecimate( - intbuf[16], - intbuf[17], - &intbuf[18], - &intbuf[19]); - m_decimator4.myDecimate( - intbuf[20], - intbuf[21], - &intbuf[22], - &intbuf[23]); - m_decimator4.myDecimate( - intbuf[24], - intbuf[25], - &intbuf[26], - &intbuf[27]); - m_decimator4.myDecimate( - intbuf[28], - intbuf[29], - &intbuf[30], - &intbuf[31]); - m_decimator4.myDecimate( - intbuf[32], - intbuf[33], - &intbuf[34], - &intbuf[35]); - m_decimator4.myDecimate( - intbuf[36], - intbuf[37], - &intbuf[38], - &intbuf[39]); - m_decimator4.myDecimate( - intbuf[40], - intbuf[41], - &intbuf[42], - &intbuf[43]); - m_decimator4.myDecimate( - intbuf[44], - intbuf[45], - &intbuf[46], - &intbuf[47]); - m_decimator4.myDecimate( - intbuf[48], - intbuf[49], - &intbuf[50], - &intbuf[51]); - m_decimator4.myDecimate( - intbuf[52], - intbuf[53], - &intbuf[54], - &intbuf[55]); - m_decimator4.myDecimate( - intbuf[56], - intbuf[57], - &intbuf[58], - &intbuf[59]); - m_decimator4.myDecimate( - intbuf[60], - intbuf[61], - &intbuf[62], - &intbuf[63]); - - m_decimator8.myDecimate( - intbuf[2], - intbuf[3], - &intbuf[6], - &intbuf[7]); - m_decimator8.myDecimate( - intbuf[10], - intbuf[11], - &intbuf[14], - &intbuf[15]); - m_decimator8.myDecimate( - intbuf[18], - intbuf[19], - &intbuf[22], - &intbuf[23]); - m_decimator8.myDecimate( - intbuf[26], - intbuf[27], - &intbuf[30], - &intbuf[31]); - m_decimator8.myDecimate( - intbuf[34], - intbuf[35], - &intbuf[38], - &intbuf[39]); - m_decimator8.myDecimate( - intbuf[42], - intbuf[43], - &intbuf[46], - &intbuf[47]); - m_decimator8.myDecimate( - intbuf[50], - intbuf[51], - &intbuf[54], - &intbuf[55]); - m_decimator8.myDecimate( - intbuf[58], - intbuf[59], - &intbuf[62], - &intbuf[63]); - - m_decimator16.myDecimate( - intbuf[6], - intbuf[7], - &intbuf[14], - &intbuf[15]); - m_decimator16.myDecimate( - intbuf[22], - intbuf[23], - &intbuf[30], - &intbuf[31]); - m_decimator16.myDecimate( - intbuf[38], - intbuf[39], - &intbuf[46], - &intbuf[47]); - m_decimator16.myDecimate( - intbuf[54], - intbuf[55], - &intbuf[62], - &intbuf[63]); - - m_decimator32.myDecimate( - intbuf[14], - intbuf[15], - &intbuf[30], - &intbuf[31]); - m_decimator32.myDecimate( - intbuf[46], - intbuf[47], - &intbuf[62], - &intbuf[63]); - - m_decimator64.myDecimate( - intbuf[30], - intbuf[31], - &intbuf[62], - &intbuf[63]); - - (**it).setReal(intbuf[62] * SDR_RX_SCALED); - (**it).setImag(intbuf[63] * SDR_RX_SCALED); ++(*it); } } diff --git a/sdrbase/dsp/decimatorsfi.h b/sdrbase/dsp/decimatorsfi.h index f4811d158..c4b3f7c11 100644 --- a/sdrbase/dsp/decimatorsfi.h +++ b/sdrbase/dsp/decimatorsfi.h @@ -24,6 +24,7 @@ #define DECIMATORSFI_HB_FILTER_ORDER 64 /** Decimators with float input and integer output */ +template class SDRBASE_API DecimatorsFI { public: @@ -47,14 +48,1089 @@ public: void decimate64_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ); void decimate64_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ); - IntHalfbandFilterEOF m_decimator2; // 1st stages - IntHalfbandFilterEOF m_decimator4; // 2nd stages - IntHalfbandFilterEOF m_decimator8; // 3rd stages - IntHalfbandFilterEOF m_decimator16; // 4th stages - IntHalfbandFilterEOF m_decimator32; // 5th stages - IntHalfbandFilterEOF m_decimator64; // 6th stages + IntHalfbandFilterEOF m_decimator2; // 1st stages + IntHalfbandFilterEOF m_decimator4; // 2nd stages + IntHalfbandFilterEOF m_decimator8; // 3rd stages + IntHalfbandFilterEOF m_decimator16; // 4th stages + IntHalfbandFilterEOF m_decimator32; // 5th stages + IntHalfbandFilterEOF m_decimator64; // 6th stages }; +template +void DecimatorsFI::decimate2_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[2]; + for (int pos = 0; pos < nbIAndQ - 3; pos += 4) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + + (**it).setReal(intbuf[0] * SDR_RX_SCALED); + (**it).setImag(intbuf[1] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate8_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[2], yimag[2]; + + for (int pos = 0; pos < nbIAndQ - 15; pos += 8) + { + xreal[0] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[0] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + + xreal[1] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[1] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + + (**it).setReal(xreal[1] * SDR_RX_SCALED); + (**it).setImag(yimag[1] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate8_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[2], yimag[2]; + + for (int pos = 0; pos < nbIAndQ - 15; pos += 8) + { + xreal[0] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[0] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); + pos += 8; + + xreal[1] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[1] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]); + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + + (**it).setReal(xreal[1] * SDR_RX_SCALED); + (**it).setImag(yimag[1] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate16_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + // Offset tuning: 4x downsample and rotate, then + // downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6] + float xreal[4], yimag[4]; + + for (int pos = 0; pos < nbIAndQ - 31; ) + { + for (int i = 0; i < 4; i++) + { + xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + + (**it).setReal(xreal[3] * SDR_RX_SCALED); + (**it).setImag(yimag[3] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate16_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + // Offset tuning: 4x downsample and rotate, then + // downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7] + float xreal[4], yimag[4]; + + for (int pos = 0; pos < nbIAndQ - 31; ) + { + for (int i = 0; i < 4; i++) + { + xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + + (**it).setReal(xreal[3] * SDR_RX_SCALED); + (**it).setImag(yimag[3] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate32_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[8], yimag[8]; + + for (int pos = 0; pos < nbIAndQ - 63; ) + { + for (int i = 0; i < 8; i++) + { + xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + + (**it).setReal(xreal[7] * SDR_RX_SCALED); + (**it).setImag(yimag[7] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate32_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[8], yimag[8]; + + for (int pos = 0; pos < nbIAndQ - 63; ) + { + for (int i = 0; i < 8; i++) + { + xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + + (**it).setReal(xreal[7] * SDR_RX_SCALED); + (**it).setImag(yimag[7] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate64_inf(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[16], yimag[16]; + + for (int pos = 0; pos < nbIAndQ - 127; ) + { + for (int i = 0; i < 16; i++) + { + xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]); + yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); + m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); + m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); + m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); + m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); + + m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); + + (**it).setReal(xreal[15] * SDR_RX_SCALED); + (**it).setImag(yimag[15] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate64_sup(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float xreal[16], yimag[16]; + + for (int pos = 0; pos < nbIAndQ - 127; ) + { + for (int i = 0; i < 16; i++) + { + xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]); + yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]); + pos += 8; + } + + m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]); + m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]); + m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[5]); + m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]); + m_decimator2.myDecimate(xreal[8], yimag[8], &xreal[9], &yimag[9]); + m_decimator2.myDecimate(xreal[10], yimag[10], &xreal[11], &yimag[11]); + m_decimator2.myDecimate(xreal[12], yimag[12], &xreal[13], &yimag[13]); + m_decimator2.myDecimate(xreal[14], yimag[14], &xreal[15], &yimag[15]); + + m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]); + m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]); + m_decimator4.myDecimate(xreal[9], yimag[9], &xreal[11], &yimag[11]); + m_decimator4.myDecimate(xreal[13], yimag[13], &xreal[15], &yimag[15]); + + m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]); + m_decimator8.myDecimate(xreal[11], yimag[11], &xreal[15], &yimag[15]); + + m_decimator16.myDecimate(xreal[7], yimag[7], &xreal[15], &yimag[15]); + + (**it).setReal(xreal[15] * SDR_RX_SCALED); + (**it).setImag(yimag[15] * SDR_RX_SCALED); + + ++(*it); + } +} + +template +void DecimatorsFI::decimate4_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[4]; + + for (int pos = 0; pos < nbIAndQ - 7; pos += 8) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + + (**it).setReal(intbuf[2] * SDR_RX_SCALED); + (**it).setImag(intbuf[3] * SDR_RX_SCALED); + ++(*it); + } +} + +template +void DecimatorsFI::decimate8_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[8]; + + for (int pos = 0; pos < nbIAndQ - 15; pos += 16) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + + (**it).setReal(intbuf[6] * SDR_RX_SCALED); + (**it).setImag(intbuf[7] * SDR_RX_SCALED); + ++(*it); + } +} + +template +void DecimatorsFI::decimate16_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[16]; + + for (int pos = 0; pos < nbIAndQ - 31; pos += 32) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + intbuf[8] = buf[pos+18]; + intbuf[9] = buf[pos+19]; + intbuf[10] = buf[pos+22]; + intbuf[11] = buf[pos+23]; + intbuf[12] = buf[pos+26]; + intbuf[13] = buf[pos+27]; + intbuf[14] = buf[pos+30]; + intbuf[15] = buf[pos+31]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + m_decimator2.myDecimate( + buf[pos+16], + buf[pos+17], + &intbuf[8], + &intbuf[9]); + m_decimator2.myDecimate( + buf[pos+20], + buf[pos+21], + &intbuf[10], + &intbuf[11]); + m_decimator2.myDecimate( + buf[pos+24], + buf[pos+25], + &intbuf[12], + &intbuf[13]); + m_decimator2.myDecimate( + buf[pos+28], + buf[pos+29], + &intbuf[14], + &intbuf[15]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + m_decimator4.myDecimate( + intbuf[8], + intbuf[9], + &intbuf[10], + &intbuf[11]); + m_decimator4.myDecimate( + intbuf[12], + intbuf[13], + &intbuf[14], + &intbuf[15]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + m_decimator8.myDecimate( + intbuf[10], + intbuf[11], + &intbuf[14], + &intbuf[15]); + + m_decimator16.myDecimate( + intbuf[6], + intbuf[7], + &intbuf[14], + &intbuf[15]); + + (**it).setReal(intbuf[14] * SDR_RX_SCALED); + (**it).setImag(intbuf[15] * SDR_RX_SCALED); + ++(*it); + } +} + +template +void DecimatorsFI::decimate32_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[32]; + + for (int pos = 0; pos < nbIAndQ - 63; pos += 64) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + intbuf[8] = buf[pos+18]; + intbuf[9] = buf[pos+19]; + intbuf[10] = buf[pos+22]; + intbuf[11] = buf[pos+23]; + intbuf[12] = buf[pos+26]; + intbuf[13] = buf[pos+27]; + intbuf[14] = buf[pos+30]; + intbuf[15] = buf[pos+31]; + intbuf[16] = buf[pos+34]; + intbuf[17] = buf[pos+35]; + intbuf[18] = buf[pos+38]; + intbuf[19] = buf[pos+39]; + intbuf[20] = buf[pos+42]; + intbuf[21] = buf[pos+43]; + intbuf[22] = buf[pos+46]; + intbuf[23] = buf[pos+47]; + intbuf[24] = buf[pos+50]; + intbuf[25] = buf[pos+51]; + intbuf[26] = buf[pos+54]; + intbuf[27] = buf[pos+55]; + intbuf[28] = buf[pos+58]; + intbuf[29] = buf[pos+59]; + intbuf[30] = buf[pos+62]; + intbuf[31] = buf[pos+63]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + m_decimator2.myDecimate( + buf[pos+16], + buf[pos+17], + &intbuf[8], + &intbuf[9]); + m_decimator2.myDecimate( + buf[pos+20], + buf[pos+21], + &intbuf[10], + &intbuf[11]); + m_decimator2.myDecimate( + buf[pos+24], + buf[pos+25], + &intbuf[12], + &intbuf[13]); + m_decimator2.myDecimate( + buf[pos+28], + buf[pos+29], + &intbuf[14], + &intbuf[15]); + m_decimator2.myDecimate( + buf[pos+32], + buf[pos+33], + &intbuf[16], + &intbuf[17]); + m_decimator2.myDecimate( + buf[pos+36], + buf[pos+37], + &intbuf[18], + &intbuf[19]); + m_decimator2.myDecimate( + buf[pos+40], + buf[pos+41], + &intbuf[20], + &intbuf[21]); + m_decimator2.myDecimate( + buf[pos+44], + buf[pos+45], + &intbuf[22], + &intbuf[23]); + m_decimator2.myDecimate( + buf[pos+48], + buf[pos+49], + &intbuf[24], + &intbuf[25]); + m_decimator2.myDecimate( + buf[pos+52], + buf[pos+53], + &intbuf[26], + &intbuf[27]); + m_decimator2.myDecimate( + buf[pos+56], + buf[pos+57], + &intbuf[28], + &intbuf[29]); + m_decimator2.myDecimate( + buf[pos+60], + buf[pos+61], + &intbuf[30], + &intbuf[31]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + m_decimator4.myDecimate( + intbuf[8], + intbuf[9], + &intbuf[10], + &intbuf[11]); + m_decimator4.myDecimate( + intbuf[12], + intbuf[13], + &intbuf[14], + &intbuf[15]); + m_decimator4.myDecimate( + intbuf[16], + intbuf[17], + &intbuf[18], + &intbuf[19]); + m_decimator4.myDecimate( + intbuf[20], + intbuf[21], + &intbuf[22], + &intbuf[23]); + m_decimator4.myDecimate( + intbuf[24], + intbuf[25], + &intbuf[26], + &intbuf[27]); + m_decimator4.myDecimate( + intbuf[28], + intbuf[29], + &intbuf[30], + &intbuf[31]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + m_decimator8.myDecimate( + intbuf[10], + intbuf[11], + &intbuf[14], + &intbuf[15]); + m_decimator8.myDecimate( + intbuf[18], + intbuf[19], + &intbuf[22], + &intbuf[23]); + m_decimator8.myDecimate( + intbuf[26], + intbuf[27], + &intbuf[30], + &intbuf[31]); + + m_decimator16.myDecimate( + intbuf[6], + intbuf[7], + &intbuf[14], + &intbuf[15]); + m_decimator16.myDecimate( + intbuf[22], + intbuf[23], + &intbuf[30], + &intbuf[31]); + + m_decimator32.myDecimate( + intbuf[14], + intbuf[15], + &intbuf[30], + &intbuf[31]); + + (**it).setReal(intbuf[30] * SDR_RX_SCALED); + (**it).setImag(intbuf[31] * SDR_RX_SCALED); + ++(*it); + } +} + +template +void DecimatorsFI::decimate64_cen(SampleVector::iterator* it, const float* buf, qint32 nbIAndQ) +{ + float intbuf[64]; + + for (int pos = 0; pos < nbIAndQ - 127; pos += 128) + { + intbuf[0] = buf[pos+2]; + intbuf[1] = buf[pos+3]; + intbuf[2] = buf[pos+6]; + intbuf[3] = buf[pos+7]; + intbuf[4] = buf[pos+10]; + intbuf[5] = buf[pos+11]; + intbuf[6] = buf[pos+14]; + intbuf[7] = buf[pos+15]; + intbuf[8] = buf[pos+18]; + intbuf[9] = buf[pos+19]; + intbuf[10] = buf[pos+22]; + intbuf[11] = buf[pos+23]; + intbuf[12] = buf[pos+26]; + intbuf[13] = buf[pos+27]; + intbuf[14] = buf[pos+30]; + intbuf[15] = buf[pos+31]; + intbuf[16] = buf[pos+34]; + intbuf[17] = buf[pos+35]; + intbuf[18] = buf[pos+38]; + intbuf[19] = buf[pos+39]; + intbuf[20] = buf[pos+42]; + intbuf[21] = buf[pos+43]; + intbuf[22] = buf[pos+46]; + intbuf[23] = buf[pos+47]; + intbuf[24] = buf[pos+50]; + intbuf[25] = buf[pos+51]; + intbuf[26] = buf[pos+54]; + intbuf[27] = buf[pos+55]; + intbuf[28] = buf[pos+58]; + intbuf[29] = buf[pos+59]; + intbuf[30] = buf[pos+62]; + intbuf[31] = buf[pos+63]; + + intbuf[32] = buf[pos+66]; + intbuf[33] = buf[pos+67]; + intbuf[34] = buf[pos+70]; + intbuf[35] = buf[pos+71]; + intbuf[36] = buf[pos+74]; + intbuf[37] = buf[pos+75]; + intbuf[38] = buf[pos+78]; + intbuf[39] = buf[pos+79]; + intbuf[40] = buf[pos+82]; + intbuf[41] = buf[pos+83]; + intbuf[42] = buf[pos+86]; + intbuf[43] = buf[pos+87]; + intbuf[44] = buf[pos+90]; + intbuf[45] = buf[pos+91]; + intbuf[46] = buf[pos+94]; + intbuf[47] = buf[pos+95]; + intbuf[48] = buf[pos+98]; + intbuf[49] = buf[pos+99]; + intbuf[50] = buf[pos+102]; + intbuf[51] = buf[pos+103]; + intbuf[52] = buf[pos+106]; + intbuf[53] = buf[pos+107]; + intbuf[54] = buf[pos+110]; + intbuf[55] = buf[pos+111]; + intbuf[56] = buf[pos+114]; + intbuf[57] = buf[pos+115]; + intbuf[58] = buf[pos+118]; + intbuf[59] = buf[pos+119]; + intbuf[60] = buf[pos+122]; + intbuf[61] = buf[pos+123]; + intbuf[62] = buf[pos+126]; + intbuf[63] = buf[pos+127]; + + m_decimator2.myDecimate( + buf[pos+0], + buf[pos+1], + &intbuf[0], + &intbuf[1]); + m_decimator2.myDecimate( + buf[pos+4], + buf[pos+5], + &intbuf[2], + &intbuf[3]); + m_decimator2.myDecimate( + buf[pos+8], + buf[pos+9], + &intbuf[4], + &intbuf[5]); + m_decimator2.myDecimate( + buf[pos+12], + buf[pos+13], + &intbuf[6], + &intbuf[7]); + m_decimator2.myDecimate( + buf[pos+16], + buf[pos+17], + &intbuf[8], + &intbuf[9]); + m_decimator2.myDecimate( + buf[pos+20], + buf[pos+21], + &intbuf[10], + &intbuf[11]); + m_decimator2.myDecimate( + buf[pos+24], + buf[pos+25], + &intbuf[12], + &intbuf[13]); + m_decimator2.myDecimate( + buf[pos+28], + buf[pos+29], + &intbuf[14], + &intbuf[15]); + m_decimator2.myDecimate( + buf[pos+32], + buf[pos+33], + &intbuf[16], + &intbuf[17]); + m_decimator2.myDecimate( + buf[pos+36], + buf[pos+37], + &intbuf[18], + &intbuf[19]); + m_decimator2.myDecimate( + buf[pos+40], + buf[pos+41], + &intbuf[20], + &intbuf[21]); + m_decimator2.myDecimate( + buf[pos+44], + buf[pos+45], + &intbuf[22], + &intbuf[23]); + m_decimator2.myDecimate( + buf[pos+48], + buf[pos+49], + &intbuf[24], + &intbuf[25]); + m_decimator2.myDecimate( + buf[pos+52], + buf[pos+53], + &intbuf[26], + &intbuf[27]); + m_decimator2.myDecimate( + buf[pos+56], + buf[pos+57], + &intbuf[28], + &intbuf[29]); + m_decimator2.myDecimate( + buf[pos+60], + buf[pos+61], + &intbuf[30], + &intbuf[31]); + m_decimator2.myDecimate( + buf[pos+64], + buf[pos+65], + &intbuf[32], + &intbuf[33]); + m_decimator2.myDecimate( + buf[pos+68], + buf[pos+69], + &intbuf[34], + &intbuf[35]); + m_decimator2.myDecimate( + buf[pos+72], + buf[pos+73], + &intbuf[36], + &intbuf[37]); + m_decimator2.myDecimate( + buf[pos+76], + buf[pos+77], + &intbuf[38], + &intbuf[39]); + m_decimator2.myDecimate( + buf[pos+80], + buf[pos+81], + &intbuf[40], + &intbuf[41]); + m_decimator2.myDecimate( + buf[pos+84], + buf[pos+85], + &intbuf[42], + &intbuf[43]); + m_decimator2.myDecimate( + buf[pos+88], + buf[pos+89], + &intbuf[44], + &intbuf[45]); + m_decimator2.myDecimate( + buf[pos+92], + buf[pos+93], + &intbuf[46], + &intbuf[47]); + m_decimator2.myDecimate( + buf[pos+96], + buf[pos+97], + &intbuf[48], + &intbuf[49]); + m_decimator2.myDecimate( + buf[pos+100], + buf[pos+101], + &intbuf[50], + &intbuf[51]); + m_decimator2.myDecimate( + buf[pos+104], + buf[pos+105], + &intbuf[52], + &intbuf[53]); + m_decimator2.myDecimate( + buf[pos+108], + buf[pos+109], + &intbuf[54], + &intbuf[55]); + m_decimator2.myDecimate( + buf[pos+112], + buf[pos+113], + &intbuf[56], + &intbuf[57]); + m_decimator2.myDecimate( + buf[pos+116], + buf[pos+117], + &intbuf[58], + &intbuf[59]); + m_decimator2.myDecimate( + buf[pos+120], + buf[pos+121], + &intbuf[60], + &intbuf[61]); + m_decimator2.myDecimate( + buf[pos+124], + buf[pos+125], + &intbuf[62], + &intbuf[63]); + + m_decimator4.myDecimate( + intbuf[0], + intbuf[1], + &intbuf[2], + &intbuf[3]); + m_decimator4.myDecimate( + intbuf[4], + intbuf[5], + &intbuf[6], + &intbuf[7]); + m_decimator4.myDecimate( + intbuf[8], + intbuf[9], + &intbuf[10], + &intbuf[11]); + m_decimator4.myDecimate( + intbuf[12], + intbuf[13], + &intbuf[14], + &intbuf[15]); + m_decimator4.myDecimate( + intbuf[16], + intbuf[17], + &intbuf[18], + &intbuf[19]); + m_decimator4.myDecimate( + intbuf[20], + intbuf[21], + &intbuf[22], + &intbuf[23]); + m_decimator4.myDecimate( + intbuf[24], + intbuf[25], + &intbuf[26], + &intbuf[27]); + m_decimator4.myDecimate( + intbuf[28], + intbuf[29], + &intbuf[30], + &intbuf[31]); + m_decimator4.myDecimate( + intbuf[32], + intbuf[33], + &intbuf[34], + &intbuf[35]); + m_decimator4.myDecimate( + intbuf[36], + intbuf[37], + &intbuf[38], + &intbuf[39]); + m_decimator4.myDecimate( + intbuf[40], + intbuf[41], + &intbuf[42], + &intbuf[43]); + m_decimator4.myDecimate( + intbuf[44], + intbuf[45], + &intbuf[46], + &intbuf[47]); + m_decimator4.myDecimate( + intbuf[48], + intbuf[49], + &intbuf[50], + &intbuf[51]); + m_decimator4.myDecimate( + intbuf[52], + intbuf[53], + &intbuf[54], + &intbuf[55]); + m_decimator4.myDecimate( + intbuf[56], + intbuf[57], + &intbuf[58], + &intbuf[59]); + m_decimator4.myDecimate( + intbuf[60], + intbuf[61], + &intbuf[62], + &intbuf[63]); + + m_decimator8.myDecimate( + intbuf[2], + intbuf[3], + &intbuf[6], + &intbuf[7]); + m_decimator8.myDecimate( + intbuf[10], + intbuf[11], + &intbuf[14], + &intbuf[15]); + m_decimator8.myDecimate( + intbuf[18], + intbuf[19], + &intbuf[22], + &intbuf[23]); + m_decimator8.myDecimate( + intbuf[26], + intbuf[27], + &intbuf[30], + &intbuf[31]); + m_decimator8.myDecimate( + intbuf[34], + intbuf[35], + &intbuf[38], + &intbuf[39]); + m_decimator8.myDecimate( + intbuf[42], + intbuf[43], + &intbuf[46], + &intbuf[47]); + m_decimator8.myDecimate( + intbuf[50], + intbuf[51], + &intbuf[54], + &intbuf[55]); + m_decimator8.myDecimate( + intbuf[58], + intbuf[59], + &intbuf[62], + &intbuf[63]); + + m_decimator16.myDecimate( + intbuf[6], + intbuf[7], + &intbuf[14], + &intbuf[15]); + m_decimator16.myDecimate( + intbuf[22], + intbuf[23], + &intbuf[30], + &intbuf[31]); + m_decimator16.myDecimate( + intbuf[38], + intbuf[39], + &intbuf[46], + &intbuf[47]); + m_decimator16.myDecimate( + intbuf[54], + intbuf[55], + &intbuf[62], + &intbuf[63]); + + m_decimator32.myDecimate( + intbuf[14], + intbuf[15], + &intbuf[30], + &intbuf[31]); + m_decimator32.myDecimate( + intbuf[46], + intbuf[47], + &intbuf[62], + &intbuf[63]); + + m_decimator64.myDecimate( + intbuf[30], + intbuf[31], + &intbuf[62], + &intbuf[63]); + + (**it).setReal(intbuf[62] * SDR_RX_SCALED); + (**it).setImag(intbuf[63] * SDR_RX_SCALED); + ++(*it); + } +} #endif /* SDRBASE_DSP_DECIMATORSFI_H_ */ diff --git a/sdrbase/dsp/decimatorsif.h b/sdrbase/dsp/decimatorsif.h index 19d3e0884..b9ea215b2 100644 --- a/sdrbase/dsp/decimatorsif.h +++ b/sdrbase/dsp/decimatorsif.h @@ -51,7 +51,7 @@ struct decimation_scale<16> }; -template +template class DecimatorsIF { public: // interleaved I/Q input buffer @@ -75,73 +75,73 @@ public: void decimate64_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ); void decimate64_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ); - IntHalfbandFilterEOF m_decimator2; // 1st stages - IntHalfbandFilterEOF m_decimator4; // 2nd stages - IntHalfbandFilterEOF m_decimator8; // 3rd stages - IntHalfbandFilterEOF m_decimator16; // 4th stages - IntHalfbandFilterEOF m_decimator32; // 5th stages - IntHalfbandFilterEOF m_decimator64; // 6th stages + IntHalfbandFilterEOF m_decimator2; // 1st stages + IntHalfbandFilterEOF m_decimator4; // 2nd stages + IntHalfbandFilterEOF m_decimator8; // 3rd stages + IntHalfbandFilterEOF m_decimator16; // 4th stages + IntHalfbandFilterEOF m_decimator32; // 5th stages + IntHalfbandFilterEOF m_decimator64; // 6th stages }; -template -void DecimatorsIF::decimate1(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate1(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal, yimag; for (int pos = 0; pos < nbIAndQ - 1; pos += 2) { - xreal = buf[pos+0] * decimation_scale::scaleIn; - yimag = buf[pos+1] * decimation_scale::scaleIn; + xreal = (IQOrder ? buf[pos+0] : buf[pos+1]) * decimation_scale::scaleIn; + yimag = (IQOrder ? buf[pos+1] : buf[pos+0]) * decimation_scale::scaleIn; (**it).setReal(xreal); (**it).setImag(yimag); ++(*it); // Valgrind optim (comment not repeated) } } -template -void DecimatorsIF::decimate2_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate2_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal, yimag; for (int pos = 0; pos < nbIAndQ - 7; pos += 8) { - xreal = (buf[pos+0] - buf[pos+3]) * decimation_scale::scaleIn; - yimag = (buf[pos+1] + buf[pos+2]) * decimation_scale::scaleIn; + xreal = (IQOrder ? (buf[pos+0] - buf[pos+3]) : (buf[pos+1] + buf[pos+2])) * decimation_scale::scaleIn; + yimag = (IQOrder ? (buf[pos+1] + buf[pos+2]) : (buf[pos+0] - buf[pos+3])) * decimation_scale::scaleIn; (**it).setReal(xreal); (**it).setImag(yimag); ++(*it); - xreal = (buf[pos+7] - buf[pos+4]) * decimation_scale::scaleIn; - yimag = (- buf[pos+5] - buf[pos+6]) * decimation_scale::scaleIn; + xreal = (IQOrder ? (buf[pos+7] - buf[pos+4]) : (- buf[pos+5] - buf[pos+6])) * decimation_scale::scaleIn; + yimag = (IQOrder ? (- buf[pos+5] - buf[pos+6]) : (buf[pos+7] - buf[pos+4])) * decimation_scale::scaleIn; (**it).setReal(xreal); (**it).setImag(yimag); ++(*it); } } -template -void DecimatorsIF::decimate2_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate2_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal, yimag; for (int pos = 0; pos < nbIAndQ - 7; pos += 8) { - xreal = (buf[pos+1] - buf[pos+2]) * decimation_scale::scaleIn; - yimag = (- buf[pos+0] - buf[pos+3]) * decimation_scale::scaleIn; + xreal = (IQOrder ? (buf[pos+1] - buf[pos+2]) : (- buf[pos+0] - buf[pos+3])) * decimation_scale::scaleIn; + yimag = (IQOrder ? (- buf[pos+0] - buf[pos+3]) : (buf[pos+1] - buf[pos+2])) * decimation_scale::scaleIn; (**it).setReal(xreal); (**it).setImag(yimag); ++(*it); - xreal = (buf[pos+6] - buf[pos+5]) * decimation_scale::scaleIn; - yimag = (buf[pos+4] + buf[pos+7]) * decimation_scale::scaleIn; + xreal = (IQOrder ? (buf[pos+6] - buf[pos+5]) : (buf[pos+4] + buf[pos+7])) * decimation_scale::scaleIn; + yimag = (IQOrder ? (buf[pos+4] + buf[pos+7]) : (buf[pos+6] - buf[pos+5])) * decimation_scale::scaleIn; (**it).setReal(xreal); (**it).setImag(yimag); ++(*it); } } -template -void DecimatorsIF::decimate2_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate2_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float intbuf[2]; @@ -163,15 +163,19 @@ void DecimatorsIF::decimate2_cen(FSampleVector::iterator* it, cons } } -template -void DecimatorsIF::decimate4_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate4_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal, yimag; for (int pos = 0; pos < nbIAndQ - 7; pos += 8) { - xreal = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]) * decimation_scale::scaleIn; - yimag = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]) * decimation_scale::scaleIn; + xreal = IQOrder ? + (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]) * decimation_scale::scaleIn : + (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]) * decimation_scale::scaleIn; + yimag = IQOrder ? + (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]) * decimation_scale::scaleIn : + (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]) * decimation_scale::scaleIn; (**it).setReal(xreal); (**it).setImag(yimag); @@ -180,15 +184,19 @@ void DecimatorsIF::decimate4_inf(FSampleVector::iterator* it, cons } } -template -void DecimatorsIF::decimate4_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate4_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal, yimag; for (int pos = 0; pos < nbIAndQ - 7; pos += 8) { - xreal = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]) * decimation_scale::scaleIn; - yimag = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]) * decimation_scale::scaleIn; + xreal = IQOrder ? + (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]) * decimation_scale::scaleIn : + (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]) * decimation_scale::scaleIn; + yimag = IQOrder ? + (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]) * decimation_scale::scaleIn : + (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]) * decimation_scale::scaleIn; (**it).setReal(xreal); (**it).setImag(yimag); @@ -197,8 +205,8 @@ void DecimatorsIF::decimate4_sup(FSampleVector::iterator* it, cons } } -template -void DecimatorsIF::decimate4_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate4_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float intbuf[4]; @@ -232,8 +240,8 @@ void DecimatorsIF::decimate4_cen(FSampleVector::iterator* it, cons } } -template -void DecimatorsIF::decimate8_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate8_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[2], yimag[2]; @@ -255,8 +263,8 @@ void DecimatorsIF::decimate8_inf(FSampleVector::iterator* it, cons } } -template -void DecimatorsIF::decimate8_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate8_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[2], yimag[2]; @@ -278,8 +286,8 @@ void DecimatorsIF::decimate8_sup(FSampleVector::iterator* it, cons } } -template -void DecimatorsIF::decimate8_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate8_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float intbuf[8]; @@ -338,8 +346,8 @@ void DecimatorsIF::decimate8_cen(FSampleVector::iterator* it, cons } } -template -void DecimatorsIF::decimate16_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate16_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[4], yimag[4]; @@ -364,8 +372,8 @@ void DecimatorsIF::decimate16_inf(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate16_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate16_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[4], yimag[4]; @@ -390,8 +398,8 @@ void DecimatorsIF::decimate16_sup(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate16_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate16_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float intbuf[16]; @@ -499,8 +507,8 @@ void DecimatorsIF::decimate16_cen(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate32_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate32_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[8], yimag[8]; @@ -530,8 +538,8 @@ void DecimatorsIF::decimate32_inf(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate32_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate32_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[8], yimag[8]; @@ -561,8 +569,8 @@ void DecimatorsIF::decimate32_sup(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate32_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate32_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float intbuf[32]; @@ -767,8 +775,8 @@ void DecimatorsIF::decimate32_cen(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate64_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate64_inf(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[16], yimag[16]; @@ -807,8 +815,8 @@ void DecimatorsIF::decimate64_inf(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate64_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate64_sup(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float xreal[16], yimag[16]; @@ -847,8 +855,8 @@ void DecimatorsIF::decimate64_sup(FSampleVector::iterator* it, con } } -template -void DecimatorsIF::decimate64_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) +template +void DecimatorsIF::decimate64_cen(FSampleVector::iterator* it, const T* buf, qint32 nbIAndQ) { float intbuf[64]; diff --git a/sdrbase/dsp/decimatorsu.h b/sdrbase/dsp/decimatorsu.h index d4fe9fb03..8a38e13f7 100644 --- a/sdrbase/dsp/decimatorsu.h +++ b/sdrbase/dsp/decimatorsu.h @@ -173,7 +173,7 @@ struct decimation_shifts<24, 8> static const uint post64 = 0; }; -template +template class DecimatorsU { public: @@ -200,39 +200,39 @@ public: private: #ifdef SDR_RX_SAMPLE_24BIT - IntHalfbandFilterEO m_decimator2; // 1st stages - IntHalfbandFilterEO m_decimator4; // 2nd stages - IntHalfbandFilterEO m_decimator8; // 3rd stages - IntHalfbandFilterEO m_decimator16; // 4th stages - IntHalfbandFilterEO m_decimator32; // 5th stages - IntHalfbandFilterEO m_decimator64; // 6th stages + IntHalfbandFilterEO m_decimator2; // 1st stages + IntHalfbandFilterEO m_decimator4; // 2nd stages + IntHalfbandFilterEO m_decimator8; // 3rd stages + IntHalfbandFilterEO m_decimator16; // 4th stages + IntHalfbandFilterEO m_decimator32; // 5th stages + IntHalfbandFilterEO m_decimator64; // 6th stages #else - IntHalfbandFilterEO m_decimator2; // 1st stages - IntHalfbandFilterEO m_decimator4; // 2nd stages - IntHalfbandFilterEO m_decimator8; // 3rd stages - IntHalfbandFilterEO m_decimator16; // 4th stages - IntHalfbandFilterEO m_decimator32; // 5th stages - IntHalfbandFilterEO m_decimator64; // 6th stages + IntHalfbandFilterEO m_decimator2; // 1st stages + IntHalfbandFilterEO m_decimator4; // 2nd stages + IntHalfbandFilterEO m_decimator8; // 3rd stages + IntHalfbandFilterEO m_decimator16; // 4th stages + IntHalfbandFilterEO m_decimator32; // 5th stages + IntHalfbandFilterEO m_decimator64; // 6th stages #endif }; -template -void DecimatorsU::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate1(SampleVector::iterator* it, const T* buf, qint32 len) { qint32 xreal, yimag; for (int pos = 0; pos < len - 1; pos += 2) { - xreal = buf[pos+0] - Shift; - yimag = buf[pos+1] - Shift; + xreal = IQOrder ? buf[pos+0] - Shift : buf[pos+1] - Shift; + yimag = IQOrder ? buf[pos+1] - Shift : buf[pos+0] - Shift; (**it).setReal(xreal << decimation_shifts::pre1); // Valgrind optim (2 - comment not repeated) (**it).setImag(yimag << decimation_shifts::pre1); ++(*it); // Valgrind optim (comment not repeated) } } -template -void DecimatorsU::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate2_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[4]; @@ -259,8 +259,8 @@ void DecimatorsU::decimate2_inf(Sampl } } -template -void DecimatorsU::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[4]; @@ -287,8 +287,8 @@ void DecimatorsU::decimate2_sup(Sampl } } -template -void DecimatorsU::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate4_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -337,8 +337,8 @@ void DecimatorsU::decimate4_inf(Sampl } } -template -void DecimatorsU::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate4_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -387,8 +387,8 @@ void DecimatorsU::decimate4_sup(Sampl } } -template -void DecimatorsU::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate8_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[16], buf4[8], buf8[4]; @@ -463,8 +463,8 @@ void DecimatorsU::decimate8_inf(Sampl } } -template -void DecimatorsU::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[16], buf4[8], buf8[4]; @@ -539,8 +539,8 @@ void DecimatorsU::decimate8_sup(Sampl } } -template -void DecimatorsU::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate16_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[32], buf4[16], buf8[8], buf16[4]; @@ -679,8 +679,8 @@ void DecimatorsU::decimate16_inf(Samp } } -template -void DecimatorsU::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate16_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[32], buf4[16], buf8[8], buf16[4]; @@ -819,8 +819,8 @@ void DecimatorsU::decimate16_sup(Samp } } -template -void DecimatorsU::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate32_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[64], buf4[32], buf8[16], buf16[8], buf32[4]; @@ -1087,8 +1087,8 @@ void DecimatorsU::decimate32_inf(Samp } } -template -void DecimatorsU::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate32_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[64], buf4[32], buf8[16], buf16[8], buf32[4]; @@ -1355,8 +1355,8 @@ void DecimatorsU::decimate32_sup(Samp } } -template -void DecimatorsU::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate64_inf(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[128], buf4[64], buf8[32], buf16[16], buf32[8], buf64[4]; @@ -1879,8 +1879,8 @@ void DecimatorsU::decimate64_inf(Samp } } -template -void DecimatorsU::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate64_sup(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[128], buf4[64], buf8[32], buf16[16], buf32[8], buf64[4]; @@ -2403,8 +2403,8 @@ void DecimatorsU::decimate64_sup(Samp } } -template -void DecimatorsU::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[4]; @@ -2431,8 +2431,8 @@ void DecimatorsU::decimate2_cen(Sampl } } -template -void DecimatorsU::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType buf2[8], buf4[4]; @@ -2474,8 +2474,8 @@ void DecimatorsU::decimate4_cen(Sampl } } -template -void DecimatorsU::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[8]; @@ -2534,8 +2534,8 @@ void DecimatorsU::decimate8_cen(Sampl } } -template -void DecimatorsU::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[16]; @@ -2643,8 +2643,8 @@ void DecimatorsU::decimate16_cen(Samp } } -template -void DecimatorsU::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[32]; @@ -2849,8 +2849,8 @@ void DecimatorsU::decimate32_cen(Samp } } -template -void DecimatorsU::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) +template +void DecimatorsU::decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len) { StorageType intbuf[64]; diff --git a/sdrbase/dsp/downchannelizer.cpp b/sdrbase/dsp/downchannelizer.cpp index 1e4f14b83..cdbbaff44 100644 --- a/sdrbase/dsp/downchannelizer.cpp +++ b/sdrbase/dsp/downchannelizer.cpp @@ -164,43 +164,43 @@ void DownChannelizer::applyDecimation() #ifdef SDR_RX_SAMPLE_24BIT DownChannelizer::FilterStage::FilterStage(Mode mode) : - m_filter(new IntHalfbandFilterEO), + m_filter(new IntHalfbandFilterEO), m_workFunction(0), m_mode(mode), m_sse(true) { switch(mode) { case ModeCenter: - m_workFunction = &IntHalfbandFilterEO::workDecimateCenter; + m_workFunction = &IntHalfbandFilterEO::workDecimateCenter; break; case ModeLowerHalf: - m_workFunction = &IntHalfbandFilterEO::workDecimateLowerHalf; + m_workFunction = &IntHalfbandFilterEO::workDecimateLowerHalf; break; case ModeUpperHalf: - m_workFunction = &IntHalfbandFilterEO::workDecimateUpperHalf; + m_workFunction = &IntHalfbandFilterEO::workDecimateUpperHalf; break; } } #else DownChannelizer::FilterStage::FilterStage(Mode mode) : - m_filter(new IntHalfbandFilterEO), + m_filter(new IntHalfbandFilterEO), m_workFunction(0), m_mode(mode), m_sse(true) { switch(mode) { case ModeCenter: - m_workFunction = &IntHalfbandFilterEO::workDecimateCenter; + m_workFunction = &IntHalfbandFilterEO::workDecimateCenter; break; case ModeLowerHalf: - m_workFunction = &IntHalfbandFilterEO::workDecimateLowerHalf; + m_workFunction = &IntHalfbandFilterEO::workDecimateLowerHalf; break; case ModeUpperHalf: - m_workFunction = &IntHalfbandFilterEO::workDecimateUpperHalf; + m_workFunction = &IntHalfbandFilterEO::workDecimateUpperHalf; break; } } diff --git a/sdrbase/dsp/downchannelizer.h b/sdrbase/dsp/downchannelizer.h index 186e02b00..f04e0c0cc 100644 --- a/sdrbase/dsp/downchannelizer.h +++ b/sdrbase/dsp/downchannelizer.h @@ -53,11 +53,11 @@ protected: }; #ifdef SDR_RX_SAMPLE_24BIT - typedef bool (IntHalfbandFilterEO::*WorkFunction)(Sample* s); - IntHalfbandFilterEO* m_filter; + typedef bool (IntHalfbandFilterEO::*WorkFunction)(Sample* s); + IntHalfbandFilterEO* m_filter; #else - typedef bool (IntHalfbandFilterEO::*WorkFunction)(Sample* s); - IntHalfbandFilterEO* m_filter; + typedef bool (IntHalfbandFilterEO::*WorkFunction)(Sample* s); + IntHalfbandFilterEO* m_filter; #endif WorkFunction m_workFunction; diff --git a/sdrbase/dsp/inthalfbandfiltereo.h b/sdrbase/dsp/inthalfbandfiltereo.h index a6a839bc5..95795a83f 100644 --- a/sdrbase/dsp/inthalfbandfiltereo.h +++ b/sdrbase/dsp/inthalfbandfiltereo.h @@ -28,7 +28,7 @@ #include "dsp/dsptypes.h" #include "dsp/hbfiltertraits.h" -template +template class IntHalfbandFilterEO { public: IntHalfbandFilterEO() @@ -800,17 +800,17 @@ protected: { if ((m_ptr % 2) == 0) { - m_even[0][m_ptr/2] = sampleI; - m_even[1][m_ptr/2] = sampleQ; - m_even[0][m_ptr/2 + m_size] = sampleI; - m_even[1][m_ptr/2 + m_size] = sampleQ; + m_even[0][m_ptr/2] = IQorder ? sampleI : sampleQ; + m_even[1][m_ptr/2] = IQorder ? sampleQ : sampleI; + m_even[0][m_ptr/2 + m_size] = IQorder ? sampleI : sampleQ; + m_even[1][m_ptr/2 + m_size] = IQorder ? sampleQ : sampleI; } else { - m_odd[0][m_ptr/2] = sampleI; - m_odd[1][m_ptr/2] = sampleQ; - m_odd[0][m_ptr/2 + m_size] = sampleI; - m_odd[1][m_ptr/2 + m_size] = sampleQ; + m_odd[0][m_ptr/2] = IQorder ? sampleI : sampleQ; + m_odd[1][m_ptr/2] = IQorder ? sampleQ : sampleI; + m_odd[0][m_ptr/2 + m_size] = IQorder ? sampleI : sampleQ; + m_odd[1][m_ptr/2 + m_size] = IQorder ? sampleQ : sampleI; } } @@ -818,17 +818,17 @@ protected: { if ((m_ptr % 2) == 0) { - m_even[0][m_ptr/2] = x; - m_even[1][m_ptr/2] = y; - m_even[0][m_ptr/2 + m_size] = x; - m_even[1][m_ptr/2 + m_size] = y; + m_even[0][m_ptr/2] = IQorder ? x : y; + m_even[1][m_ptr/2] = IQorder ? y : x; + m_even[0][m_ptr/2 + m_size] = IQorder ? x : y; + m_even[1][m_ptr/2 + m_size] = IQorder ? y : x; } else { - m_odd[0][m_ptr/2] = x; - m_odd[1][m_ptr/2] = y; - m_odd[0][m_ptr/2 + m_size] = x; - m_odd[1][m_ptr/2 + m_size] = y; + m_odd[0][m_ptr/2] = IQorder ? x : y; + m_odd[1][m_ptr/2] = IQorder ? y : x; + m_odd[0][m_ptr/2 + m_size] = IQorder ? x : y; + m_odd[1][m_ptr/2 + m_size] = IQorder ? y : x; } } diff --git a/sdrbase/dsp/inthalfbandfiltereof.h b/sdrbase/dsp/inthalfbandfiltereof.h index 7c3732f29..1e624fc4c 100644 --- a/sdrbase/dsp/inthalfbandfiltereof.h +++ b/sdrbase/dsp/inthalfbandfiltereof.h @@ -29,7 +29,7 @@ #include "dsp/hbfiltertraits.h" #include "export.h" -template +template class IntHalfbandFilterEOF { public: IntHalfbandFilterEOF(); @@ -152,17 +152,17 @@ protected: { if ((m_ptr % 2) == 0) { - m_even[0][m_ptr/2] = x; - m_even[1][m_ptr/2] = y; - m_even[0][m_ptr/2 + m_size] = x; - m_even[1][m_ptr/2 + m_size] = y; + m_even[0][m_ptr/2] = IQOrder ? x : y; + m_even[1][m_ptr/2] = IQOrder ? y : x; + m_even[0][m_ptr/2 + m_size] = IQOrder ? x : y; + m_even[1][m_ptr/2 + m_size] = IQOrder ? y : x; } else { - m_odd[0][m_ptr/2] = x; - m_odd[1][m_ptr/2] = y; - m_odd[0][m_ptr/2 + m_size] = x; - m_odd[1][m_ptr/2 + m_size] = y; + m_odd[0][m_ptr/2] = IQOrder ? x : y; + m_odd[1][m_ptr/2] = IQOrder ? y : x; + m_odd[0][m_ptr/2 + m_size] = IQOrder ? x : y; + m_odd[1][m_ptr/2 + m_size] = IQOrder ? y : x; } } @@ -233,8 +233,8 @@ protected: } }; -template -IntHalfbandFilterEOF::IntHalfbandFilterEOF() +template +IntHalfbandFilterEOF::IntHalfbandFilterEOF() { m_size = HBFIRFilterTraits::hbOrder/2; diff --git a/sdrbench/mainbench.h b/sdrbench/mainbench.h index b5e9551f0..c92f603f1 100644 --- a/sdrbench/mainbench.h +++ b/sdrbench/mainbench.h @@ -68,10 +68,10 @@ private: std::uniform_real_distribution m_uniform_distribution_f; std::uniform_int_distribution m_uniform_distribution_s16; - Decimators m_decimatorsII; - DecimatorsIF m_decimatorsIF; - DecimatorsFI m_decimatorsFI; - DecimatorsFF m_decimatorsFF; + Decimators m_decimatorsII; + DecimatorsIF m_decimatorsIF; + DecimatorsFI m_decimatorsFI; + DecimatorsFF m_decimatorsFF; SampleVector m_convertBuffer; FSampleVector m_convertBufferF;