SDRDaemonSink: 16/24 bit support (1): works for 16 bit stream

pull/228/head
f4exb 2018-09-09 21:26:47 +02:00
rodzic 5dfc60331c
commit 7158107e58
6 zmienionych plików z 22 dodań i 14 usunięć

Wyświetl plik

@ -25,9 +25,6 @@
const int SDRdaemonSourceBuffer::m_sampleSize = 2;
const int SDRdaemonSourceBuffer::m_iqSampleSize = 2 * m_sampleSize;
SDRdaemonSourceBuffer::SDRdaemonSourceBuffer() : SDRdaemonSourceBuffer::SDRdaemonSourceBuffer() :
m_decoderIndexHead(nbDecoderSlots/2), m_decoderIndexHead(nbDecoderSlots/2),
m_frameHead(0), m_frameHead(0),
@ -152,7 +149,7 @@ void SDRdaemonSourceBuffer::rwCorrectionEstimate(int slotIndex)
dBytes = (nbDecoderSlots * sizeof(BufferFrame)) - normalizedReadIndex - rwDelta; dBytes = (nbDecoderSlots * sizeof(BufferFrame)) - normalizedReadIndex - rwDelta;
} }
m_balCorrection = (m_balCorrection / 4) + (dBytes / (int) (m_iqSampleSize * m_nbReads)); // correction is in number of samples. Alpha = 0.25 m_balCorrection = (m_balCorrection / 4) + (dBytes / (int) (m_currentMeta.m_sampleBytes * 2 * m_nbReads)); // correction is in number of samples. Alpha = 0.25
if (m_balCorrection < -m_balCorrLimit) { if (m_balCorrection < -m_balCorrLimit) {
m_balCorrection = -m_balCorrLimit; m_balCorrection = -m_balCorrLimit;
@ -310,9 +307,9 @@ void SDRdaemonSourceBuffer::writeData(char *array)
int sampleRate = metaData->m_sampleRate; int sampleRate = metaData->m_sampleRate;
if (sampleRate > 0) { if (sampleRate > 0) {
m_bufferLenSec = (float) m_framesNbBytes / (float) (sampleRate * m_iqSampleSize); m_bufferLenSec = (float) m_framesNbBytes / (float) (sampleRate * m_currentMeta.m_sampleBytes * 2);
m_balCorrLimit = sampleRate / 1000; // +/- 1 ms correction max per read m_balCorrLimit = sampleRate / 1000; // +/- 1 ms correction max per read
m_readNbBytes = (sampleRate * m_iqSampleSize) / 20; m_readNbBytes = (sampleRate * m_currentMeta.m_sampleBytes * 2) / 20;
} }
printMeta("SDRdaemonSourceBuffer::writeData: new meta", metaData); // print for change other than timestamp printMeta("SDRdaemonSourceBuffer::writeData: new meta", metaData); // print for change other than timestamp

Wyświetl plik

@ -52,6 +52,8 @@ public:
void init() void init()
{ {
memset((char *) this, 0, sizeof(MetaDataFEC)); memset((char *) this, 0, sizeof(MetaDataFEC));
m_sampleBits = 16; // assume 16 bits samples to start with
m_sampleBytes = 2;
} }
}; };
@ -158,8 +160,6 @@ public:
static const int m_udpPayloadSize = SDRDAEMONSOURCE_UDPSIZE; static const int m_udpPayloadSize = SDRDAEMONSOURCE_UDPSIZE;
static const int m_nbOriginalBlocks = SDRDAEMONSOURCE_NBORIGINALBLOCKS; static const int m_nbOriginalBlocks = SDRDAEMONSOURCE_NBORIGINALBLOCKS;
static const int m_sampleSize;
static const int m_iqSampleSize;
private: private:
static const int nbDecoderSlots = SDRDAEMONSOURCE_NBDECODERSLOTS; static const int nbDecoderSlots = SDRDAEMONSOURCE_NBDECODERSLOTS;

Wyświetl plik

@ -57,6 +57,7 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
m_nbOriginalBlocks(128), m_nbOriginalBlocks(128),
m_nbFECBlocks(0), m_nbFECBlocks(0),
m_sampleBits(16), m_sampleBits(16),
m_sampleBytes(2),
m_samplesCount(0), m_samplesCount(0),
m_tickCount(0), m_tickCount(0),
m_addressEdited(false), m_addressEdited(false),
@ -211,6 +212,7 @@ bool SDRdaemonSourceGui::handleMessage(const Message& message)
m_avgNbRecovery = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getAvgNbRecovery(); m_avgNbRecovery = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getAvgNbRecovery();
m_nbOriginalBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getNbOriginalBlocksPerFrame(); m_nbOriginalBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getNbOriginalBlocksPerFrame();
m_sampleBits = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getSampleBits(); m_sampleBits = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getSampleBits();
m_sampleBytes = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getSampleBytes();
int nbFECBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getNbFECBlocksPerFrame(); int nbFECBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getNbFECBlocksPerFrame();

Wyświetl plik

@ -86,6 +86,7 @@ private:
int m_nbOriginalBlocks; int m_nbOriginalBlocks;
int m_nbFECBlocks; int m_nbFECBlocks;
int m_sampleBits; int m_sampleBits;
int m_sampleBytes;
int m_samplesCount; int m_samplesCount;
std::size_t m_tickCount; std::size_t m_tickCount;

Wyświetl plik

@ -141,6 +141,7 @@ public:
int getNbOriginalBlocksPerFrame() const { return m_nbOriginalBlocksPerFrame; } int getNbOriginalBlocksPerFrame() const { return m_nbOriginalBlocksPerFrame; }
int getNbFECBlocksPerFrame() const { return m_nbFECBlocksPerFrame; } int getNbFECBlocksPerFrame() const { return m_nbFECBlocksPerFrame; }
int getSampleBits() const { return m_sampleBits; } int getSampleBits() const { return m_sampleBits; }
int getSampleBytes() const { return m_sampleBytes; }
static MsgReportSDRdaemonSourceStreamTiming* create(uint32_t tv_sec, static MsgReportSDRdaemonSourceStreamTiming* create(uint32_t tv_sec,
uint32_t tv_usec, uint32_t tv_usec,
@ -156,7 +157,8 @@ public:
float avgNbRecovery, float avgNbRecovery,
int nbOriginalBlocksPerFrame, int nbOriginalBlocksPerFrame,
int nbFECBlocksPerFrame, int nbFECBlocksPerFrame,
int sampleBits) int sampleBits,
int sampleBytes)
{ {
return new MsgReportSDRdaemonSourceStreamTiming(tv_sec, return new MsgReportSDRdaemonSourceStreamTiming(tv_sec,
tv_usec, tv_usec,
@ -172,7 +174,8 @@ public:
avgNbRecovery, avgNbRecovery,
nbOriginalBlocksPerFrame, nbOriginalBlocksPerFrame,
nbFECBlocksPerFrame, nbFECBlocksPerFrame,
sampleBits); sampleBits,
sampleBytes);
} }
protected: protected:
@ -191,6 +194,7 @@ public:
int m_nbOriginalBlocksPerFrame; int m_nbOriginalBlocksPerFrame;
int m_nbFECBlocksPerFrame; int m_nbFECBlocksPerFrame;
int m_sampleBits; int m_sampleBits;
int m_sampleBytes;
MsgReportSDRdaemonSourceStreamTiming(uint32_t tv_sec, MsgReportSDRdaemonSourceStreamTiming(uint32_t tv_sec,
uint32_t tv_usec, uint32_t tv_usec,
@ -206,7 +210,8 @@ public:
float avgNbRecovery, float avgNbRecovery,
int nbOriginalBlocksPerFrame, int nbOriginalBlocksPerFrame,
int nbFECBlocksPerFrame, int nbFECBlocksPerFrame,
int sampleBits) : int sampleBits,
int sampleBytes) :
Message(), Message(),
m_tv_sec(tv_sec), m_tv_sec(tv_sec),
m_tv_usec(tv_usec), m_tv_usec(tv_usec),
@ -222,7 +227,8 @@ public:
m_avgNbRecovery(avgNbRecovery), m_avgNbRecovery(avgNbRecovery),
m_nbOriginalBlocksPerFrame(nbOriginalBlocksPerFrame), m_nbOriginalBlocksPerFrame(nbOriginalBlocksPerFrame),
m_nbFECBlocksPerFrame(nbFECBlocksPerFrame), m_nbFECBlocksPerFrame(nbFECBlocksPerFrame),
m_sampleBits(sampleBits) m_sampleBits(sampleBits),
m_sampleBytes(sampleBytes)
{ } { }
}; };

Wyświetl plik

@ -263,8 +263,8 @@ void SDRdaemonSourceUDPHandler::tick()
m_readLengthSamples += m_sdrDaemonBuffer.getRWBalanceCorrection(); m_readLengthSamples += m_sdrDaemonBuffer.getRWBalanceCorrection();
} }
m_readLength = m_readLengthSamples * SDRdaemonSourceBuffer::m_iqSampleSize;
const SDRdaemonSourceBuffer::MetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta(); const SDRdaemonSourceBuffer::MetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta();
m_readLength = m_readLengthSamples * metaData.m_sampleBytes * 2;
if (SDR_RX_SAMP_SZ == metaData.m_sampleBits) // same sample size if (SDR_RX_SAMP_SZ == metaData.m_sampleBits) // same sample size
{ {
@ -332,6 +332,7 @@ void SDRdaemonSourceUDPHandler::tick()
int nbOriginalBlocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbOriginalBlocks; int nbOriginalBlocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbOriginalBlocks;
int nbFECblocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbFECBlocks; int nbFECblocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbFECBlocks;
int sampleBits = m_sdrDaemonBuffer.getCurrentMeta().m_sampleBits; int sampleBits = m_sdrDaemonBuffer.getCurrentMeta().m_sampleBits;
int sampleBytes = m_sdrDaemonBuffer.getCurrentMeta().m_sampleBytes;
//framesDecodingStatus = (minNbOriginalBlocks == nbOriginalBlocks ? 2 : (minNbOriginalBlocks < nbOriginalBlocks - nbFECblocks ? 0 : 1)); //framesDecodingStatus = (minNbOriginalBlocks == nbOriginalBlocks ? 2 : (minNbOriginalBlocks < nbOriginalBlocks - nbFECblocks ? 0 : 1));
if (minNbBlocks < nbOriginalBlocks) { if (minNbBlocks < nbOriginalBlocks) {
@ -357,7 +358,8 @@ void SDRdaemonSourceUDPHandler::tick()
m_sdrDaemonBuffer.getAvgNbRecovery(), m_sdrDaemonBuffer.getAvgNbRecovery(),
nbOriginalBlocks, nbOriginalBlocks,
nbFECblocks, nbFECblocks,
sampleBits); sampleBits,
sampleBytes);
m_outputMessageQueueToGUI->push(report); m_outputMessageQueueToGUI->push(report);
} }