1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-29 19:28:47 -05:00

Remote input buffer size rework: dynamically allocatable number of decoder slots

This commit is contained in:
f4exb 2020-06-28 07:19:20 +02:00
parent 16364d604a
commit 385d8cc2db
2 changed files with 40 additions and 11 deletions

View File

@ -27,8 +27,9 @@
RemoteInputBuffer::RemoteInputBuffer() : RemoteInputBuffer::RemoteInputBuffer() :
m_decoderSlots(nullptr),
m_frames(nullptr),
m_decoderIndexHead(m_nbDecoderSlots/2), m_decoderIndexHead(m_nbDecoderSlots/2),
m_frameHead(0),
m_curNbBlocks(0), m_curNbBlocks(0),
m_minNbBlocks(256), m_minNbBlocks(256),
m_curOriginalBlocks(0), m_curOriginalBlocks(0),
@ -46,8 +47,7 @@ RemoteInputBuffer::RemoteInputBuffer() :
m_balCorrLimit(0) m_balCorrLimit(0)
{ {
m_currentMeta.init(); m_currentMeta.init();
m_framesNbBytes = m_nbDecoderSlots * sizeof(BufferFrame); setNbDecoderSlots(16);
m_wrDeltaEstimate = m_framesNbBytes / 2;
m_tvOut_sec = 0; m_tvOut_sec = 0;
m_tvOut_usec = 0; m_tvOut_usec = 0;
m_readNbBytes = 1; m_readNbBytes = 1;
@ -70,6 +70,32 @@ RemoteInputBuffer::~RemoteInputBuffer()
if (m_readBuffer) { if (m_readBuffer) {
delete[] m_readBuffer; delete[] m_readBuffer;
} }
if (m_decoderSlots) {
delete[] m_decoderSlots;
}
if (m_frames) {
delete[] m_frames;
}
}
void RemoteInputBuffer::setNbDecoderSlots(int nbDecoderSlots)
{
m_nbDecoderSlots = nbDecoderSlots;
m_framesSize = m_nbDecoderSlots * (RemoteNbOrginalBlocks - 1) * RemoteNbBytesPerBlock;
m_framesNbBytes = m_nbDecoderSlots * sizeof(BufferFrame);
m_wrDeltaEstimate = m_framesNbBytes / 2;
if (m_decoderSlots) {
delete[] m_decoderSlots;
}
if (m_frames) {
delete[] m_frames;
}
m_decoderSlots = new DecoderSlot[m_nbDecoderSlots];
m_frames = new BufferFrame[m_nbDecoderSlots];
m_frameHead = -1;
} }
void RemoteInputBuffer::initDecodeAllSlots() void RemoteInputBuffer::initDecodeAllSlots()

View File

@ -28,7 +28,6 @@
#define REMOTEINPUT_UDPSIZE 512 // UDP payload size #define REMOTEINPUT_UDPSIZE 512 // UDP payload size
#define REMOTEINPUT_NBORIGINALBLOCKS 128 // number of sample blocks per frame excluding FEC blocks #define REMOTEINPUT_NBORIGINALBLOCKS 128 // number of sample blocks per frame excluding FEC blocks
#define REMOTEINPUT_NBDECODERSLOTS 16 // power of two sub multiple of uint16_t size. A too large one is superfluous.
class RemoteInputBuffer class RemoteInputBuffer
{ {
@ -36,6 +35,9 @@ public:
RemoteInputBuffer(); RemoteInputBuffer();
~RemoteInputBuffer(); ~RemoteInputBuffer();
// Sizing
void setNbDecoderSlots(int nbDecoderSlots);
// R/W operations // R/W operations
void writeData(char *array); //!< Write data into buffer. void writeData(char *array); //!< Write data into buffer.
uint8_t *readData(int32_t length); //!< Read data from buffer uint8_t *readData(int32_t length); //!< Read data from buffer
@ -107,8 +109,8 @@ public:
} }
private: private:
static const int m_framesSize = REMOTEINPUT_NBDECODERSLOTS * (RemoteNbOrginalBlocks - 1) * RemoteNbBytesPerBlock; int m_nbDecoderSlots;
static const int m_nbDecoderSlots = REMOTEINPUT_NBDECODERSLOTS; int m_framesSize;
#pragma pack(push, 1) #pragma pack(push, 1)
struct BufferFrame struct BufferFrame
@ -128,13 +130,14 @@ private:
int m_recoveryCount; //!< number of recovery blocks received int m_recoveryCount; //!< number of recovery blocks received
bool m_decoded; //!< true if decoded bool m_decoded; //!< true if decoded
bool m_metaRetrieved; //!< true if meta data (block zero) was retrieved bool m_metaRetrieved; //!< true if meta data (block zero) was retrieved
DecoderSlot() {}
}; };
RemoteMetaDataFEC m_currentMeta; //!< Stored current meta data RemoteMetaDataFEC m_currentMeta; //!< Stored current meta data
CM256::cm256_encoder_params m_paramsCM256; //!< CM256 decoder parameters block CM256::cm256_encoder_params m_paramsCM256; //!< CM256 decoder parameters block
DecoderSlot m_decoderSlots[m_nbDecoderSlots]; //!< CM256 decoding control/buffer slots DecoderSlot *m_decoderSlots; //!< CM256 decoding control/buffer slots
BufferFrame m_frames[m_nbDecoderSlots]; //!< Samples buffer BufferFrame *m_frames; //!< Samples buffer
int m_framesNbBytes; //!< Number of bytes in samples buffer int m_framesNbBytes; //!< Number of bytes in samples buffer
int m_decoderIndexHead; //!< index of the current head frame slot in decoding slots int m_decoderIndexHead; //!< index of the current head frame slot in decoding slots
int m_frameHead; //!< index of the current head frame sent int m_frameHead; //!< index of the current head frame sent
int m_curNbBlocks; //!< (stats) instantaneous number of blocks received int m_curNbBlocks; //!< (stats) instantaneous number of blocks received