1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 22:14:45 -04:00

SDRDaemon: make Rx side truly 24/16 bit compatible in all configurations

This commit is contained in:
f4exb
2018-09-10 02:52:36 +02:00
parent 22746ff813
commit 404c73fb80
12 changed files with 25 additions and 21 deletions
@@ -159,9 +159,10 @@ The value is a percentage of the nominal time it takes to process a block of sam
- Sample rate on the network: _SR_
- Delay percentage: _d_
- Number of FEC blocks: _F_
- There are 127 blocks of I/Q data per frame (1 meta block for 128 blocks) and each I/Q data block of 512 bytes (128 samples) has a 4 bytes header (1 sample) thus there are 127 samples remaining effectively. This gives the constant 127*127 = 16219 samples per frame in the formula
- There are 127 blocks of I/Q data per frame (1 meta block for 128 blocks) and each I/Q data block of 512 bytes (128 samples) has a 8 bytes header (1 sample for 24 bit and 2 samples for 16 bit) thus there are 126 (16 bit) or 63 (24 bit) samples remaining effectively.
Formula: ((127 ✕ 127 ✕ _d_) / _SR_) / (128 + _F_)
Formula (16 bit): ((127 ✕ 126 ✕ _d_) / _SR_) / (128 + _F_)
Formula (24 bit): ((127 ✕ 63 ✕ _d_) / _SR_) / (128 + _F_) thus half the above
<h3>8: Desired distant device sample rate</h3>
@@ -62,6 +62,7 @@ public:
uint16_t frameIndex;
uint8_t blockIndex;
uint8_t filler;
uint32_t filler2;
};
static const int framesSize = SDRDAEMONSOURCE_NBDECODERSLOTS * (SDRDAEMONSOURCE_NBORIGINALBLOCKS - 1) * (SDRDAEMONSOURCE_UDPSIZE - sizeof(Header));
@@ -56,7 +56,7 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
m_bufferGauge(-50),
m_nbOriginalBlocks(128),
m_nbFECBlocks(0),
m_sampleBits(16),
m_sampleBits(16), // assume 16 bits to start with
m_sampleBytes(2),
m_samplesCount(0),
m_tickCount(0),
@@ -264,7 +264,7 @@ void SDRdaemonSourceUDPHandler::tick()
}
const SDRdaemonSourceBuffer::MetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta();
m_readLength = m_readLengthSamples * metaData.m_sampleBytes * 2;
m_readLength = m_readLengthSamples * (metaData.m_sampleBytes & 0xF) * 2;
if (SDR_RX_SAMP_SZ == metaData.m_sampleBits) // same sample size
{
@@ -304,9 +304,9 @@ void SDRdaemonSourceUDPHandler::tick()
for (unsigned int is = 0; is < m_readLengthSamples; is++)
{
m_converterBuffer[is] = ((int32_t *)buf)[2*is]>>8; // I -> MSB
m_converterBuffer[is] = ((int32_t *)buf)[2*is+1]>>8; // Q -> MSB
m_converterBuffer[is] <<=16;
m_converterBuffer[is] += ((int32_t *)buf)[2*is+1]>>8; // Q -> LSB
m_converterBuffer[is] += ((int32_t *)buf)[2*is]>>8; // I -> LSB
}
m_sampleFifo->write(reinterpret_cast<quint8*>(m_converterBuffer), m_readLengthSamples*sizeof(Sample));