mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	SDRdaemonFEC support: full compile
This commit is contained in:
		
							parent
							
								
									eb3fedecda
								
							
						
					
					
						commit
						0812ab0d13
					
				| @ -22,7 +22,6 @@ | ||||
| #include "sdrdaemonfecbuffer.h" | ||||
| 
 | ||||
| 
 | ||||
| const int SDRdaemonFECBuffer::m_udpPayloadSize = 512; | ||||
| const int SDRdaemonFECBuffer::m_sampleSize = 2; | ||||
| const int SDRdaemonFECBuffer::m_iqSampleSize = 2 * m_sampleSize; | ||||
| const int SDRdaemonFECBuffer::m_rawBufferLengthSeconds = 8; // should be even
 | ||||
| @ -55,7 +54,7 @@ void SDRdaemonFECBuffer::initDecoderSlotsAddresses() | ||||
| { | ||||
|     for (int i = 0; i < nbDecoderSlots; i++) | ||||
|     { | ||||
|         for (int j = 0; j < nbOriginalBlocks - 1; j++) | ||||
|         for (int j = 0; j < m_nbOriginalBlocks - 1; j++) | ||||
|         { | ||||
|             m_decoderSlots[i].m_originalBlockPtrs[j] = &m_frames[i].m_blocks[j]; | ||||
|         } | ||||
| @ -94,12 +93,12 @@ void SDRdaemonFECBuffer::initDecodeSlot(int slotIndex) | ||||
|     m_decoderSlots[slotIndex].m_decoded = false; | ||||
|     m_decoderSlots[slotIndex].m_blockZero.m_metaData.init(); | ||||
|     memset((void *) m_decoderSlots[slotIndex].m_blockZero.m_samples, 0, samplesPerBlockZero * sizeof(Sample)); | ||||
|     memset((void *) m_frames[slotIndex].m_blocks, 0, (nbOriginalBlocks - 1) * samplesPerBlock * sizeof(Sample)); | ||||
|     memset((void *) m_frames[slotIndex].m_blocks, 0, (m_nbOriginalBlocks - 1) * samplesPerBlock * sizeof(Sample)); | ||||
| } | ||||
| 
 | ||||
| void SDRdaemonFECBuffer::writeData(char *array, uint32_t length) | ||||
| { | ||||
|     assert(length == udpSize); | ||||
|     assert(length == m_udpPayloadSize); | ||||
| 
 | ||||
|     bool dataAvailable = false; | ||||
|     SuperBlock *superBlock = (SuperBlock *) array; | ||||
| @ -160,7 +159,7 @@ void SDRdaemonFECBuffer::writeData(char *array, uint32_t length) | ||||
|     int blockIndex = superBlock->header.blockIndex; | ||||
|     int blockHead = m_decoderSlots[decoderIndex].m_blockCount; | ||||
| 
 | ||||
|     if (blockHead < nbOriginalBlocks) // not enough blocks to decode -> store data
 | ||||
|     if (blockHead < m_nbOriginalBlocks) // not enough blocks to decode -> store data
 | ||||
|     { | ||||
|         if (blockIndex == 0) // first block with meta
 | ||||
|         { | ||||
| @ -171,7 +170,7 @@ void SDRdaemonFECBuffer::writeData(char *array, uint32_t length) | ||||
|                     (const void *) m_decoderSlots[decoderIndex].m_blockZero.m_samples, | ||||
|                     samplesPerBlockZero * sizeof(Sample)); | ||||
|         } | ||||
|         else if (blockIndex < nbOriginalBlocks) // normal block
 | ||||
|         else if (blockIndex < m_nbOriginalBlocks) // normal block
 | ||||
|         { | ||||
|             m_frames[decoderIndex].m_blocks[blockIndex - 1] = superBlock->protectedBlock; | ||||
|             m_decoderSlots[decoderIndex].m_cm256DescriptorBlocks[blockHead].Block = (void *) &m_frames[decoderIndex].m_blocks[blockIndex - 1]; | ||||
|  | ||||
| @ -138,15 +138,14 @@ public: | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	static const int m_udpPayloadSize; | ||||
|     static const int m_udpPayloadSize = SDRDAEMONFEC_UDPSIZE; | ||||
|     static const int m_nbOriginalBlocks = SDRDAEMONFEC_NBORIGINALBLOCKS; | ||||
| 	static const int m_sampleSize; | ||||
| 	static const int m_iqSampleSize; | ||||
| 	static const int m_rawBufferLengthSeconds; | ||||
| 	static const int m_rawBufferMinNbFrames; //!< Minimum number of frames for the length of buffer
 | ||||
| 
 | ||||
| private: | ||||
|     static const int udpSize = SDRDAEMONFEC_UDPSIZE; | ||||
|     static const int nbOriginalBlocks = SDRDAEMONFEC_NBORIGINALBLOCKS; | ||||
|     static const int nbDecoderSlots = SDRDAEMONFEC_NBDECODERSLOTS; | ||||
| 
 | ||||
| #pragma pack(push, 1) | ||||
| @ -158,16 +157,16 @@ private: | ||||
|     struct BufferFrame | ||||
|     { | ||||
|         BufferBlockZero m_blockZero; | ||||
|         ProtectedBlock  m_blocks[nbOriginalBlocks - 1]; | ||||
|         ProtectedBlock  m_blocks[m_nbOriginalBlocks - 1]; | ||||
|     }; | ||||
| #pragma pack(pop) | ||||
| 
 | ||||
|     struct DecoderSlot | ||||
|     { | ||||
|         ProtectedBlockZero   m_blockZero; | ||||
|         ProtectedBlock*      m_originalBlockPtrs[nbOriginalBlocks]; | ||||
|         ProtectedBlock       m_recoveryBlocks[nbOriginalBlocks]; // max size
 | ||||
|         cm256_block          m_cm256DescriptorBlocks[nbOriginalBlocks]; | ||||
|         ProtectedBlock*      m_originalBlockPtrs[m_nbOriginalBlocks]; | ||||
|         ProtectedBlock       m_recoveryBlocks[m_nbOriginalBlocks]; // max size
 | ||||
|         cm256_block          m_cm256DescriptorBlocks[m_nbOriginalBlocks]; | ||||
|         int                  m_blockCount; //!< total number of blocks received for this frame
 | ||||
|         int                  m_recoveryCount; //!< number of recovery blocks received
 | ||||
|         bool                 m_decoded; //!< true if decoded
 | ||||
|  | ||||
| @ -32,8 +32,6 @@ | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonUDPLink, Message) | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonAutoCorr, Message) | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonWork, Message) | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonAutoFollowPolicy, Message) | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonResetIndexes, Message) | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonStreamTiming, Message) | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgReportSDRdaemonAcquisition, Message) | ||||
| MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgReportSDRdaemonStreamData, Message) | ||||
| @ -128,26 +126,6 @@ bool SDRdaemonFECInput::handleMessage(const Message& message) | ||||
| 		m_deviceAPI->configureCorrections(dcBlock, iqImbalance); | ||||
| 		return true; | ||||
| 	} | ||||
|     else if (MsgConfigureSDRdaemonAutoFollowPolicy::match(message)) | ||||
| 	{ | ||||
|         MsgConfigureSDRdaemonAutoFollowPolicy& conf = (MsgConfigureSDRdaemonAutoFollowPolicy&) message; | ||||
| 		bool autoFollowRate = conf.autoFollowRate(); | ||||
|         bool autoCorrBuffer = conf.autoCorrBuffer(); | ||||
|         if (autoFollowRate != m_autoFollowRate) { | ||||
|             m_SDRdaemonUDPHandler->setAutoFollowRate(autoFollowRate); | ||||
|             m_autoFollowRate = autoFollowRate; | ||||
|         } | ||||
|         if (autoCorrBuffer != m_autoCorrBuffer) { | ||||
|             m_SDRdaemonUDPHandler->setAutoCorrBuffer(autoCorrBuffer); | ||||
|             m_autoCorrBuffer = autoCorrBuffer; | ||||
|         } | ||||
| 		return true; | ||||
| 	} | ||||
|     else if (MsgConfigureSDRdaemonResetIndexes::match(message)) | ||||
|     { | ||||
|         m_SDRdaemonUDPHandler->resetIndexes(); | ||||
|         return true; | ||||
|     } | ||||
| 	else if (MsgConfigureSDRdaemonWork::match(message)) | ||||
| 	{ | ||||
| 		MsgConfigureSDRdaemonWork& conf = (MsgConfigureSDRdaemonWork&) message; | ||||
|  | ||||
| @ -94,43 +94,6 @@ public: | ||||
| 		{ } | ||||
| 	}; | ||||
| 
 | ||||
|     class MsgConfigureSDRdaemonAutoFollowPolicy : public Message { | ||||
| 		MESSAGE_CLASS_DECLARATION | ||||
| 
 | ||||
| 	public: | ||||
| 		bool autoFollowRate() const { return m_autoFollowRate; } | ||||
|         bool autoCorrBuffer() const { return m_autoCorrBuffer; } | ||||
| 
 | ||||
|         static MsgConfigureSDRdaemonAutoFollowPolicy* create(bool autoFollowRate, bool autoCorrBuffer) | ||||
| 		{ | ||||
|             return new MsgConfigureSDRdaemonAutoFollowPolicy(autoFollowRate, autoCorrBuffer); | ||||
| 		} | ||||
| 
 | ||||
| 	private: | ||||
| 		bool m_autoFollowRate; | ||||
|         bool m_autoCorrBuffer; | ||||
| 
 | ||||
|         MsgConfigureSDRdaemonAutoFollowPolicy(bool autoFollowRate, bool autoCorrBuffer) : | ||||
| 			Message(), | ||||
|             m_autoFollowRate(autoFollowRate), | ||||
|             m_autoCorrBuffer(autoCorrBuffer) | ||||
| 		{ } | ||||
| 	}; | ||||
| 
 | ||||
|     class MsgConfigureSDRdaemonResetIndexes : public Message { | ||||
|         MESSAGE_CLASS_DECLARATION | ||||
|     public: | ||||
|         static MsgConfigureSDRdaemonResetIndexes* create() | ||||
|         { | ||||
|             return new MsgConfigureSDRdaemonResetIndexes(); | ||||
|         } | ||||
| 
 | ||||
|     private: | ||||
|         MsgConfigureSDRdaemonResetIndexes() : | ||||
|             Message() | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
| 	class MsgConfigureSDRdaemonStreamTiming : public Message { | ||||
| 		MESSAGE_CLASS_DECLARATION | ||||
| 
 | ||||
| @ -218,6 +181,7 @@ public: | ||||
| 				uint32_t tv_usec, | ||||
| 				float bufferLenSec, | ||||
|                 int32_t bufferGauge, | ||||
|                 int nbOriginalBlocks, | ||||
|                 int curNbBlocks, | ||||
|                 int curNbRecovery, | ||||
|                 float avgNbBlocks, | ||||
| @ -227,6 +191,7 @@ public: | ||||
| 					tv_usec, | ||||
| 					bufferLenSec, | ||||
|                     bufferGauge, | ||||
|                     nbOriginalBlocks, | ||||
|                     curNbBlocks, | ||||
|                     curNbRecovery, | ||||
|                     avgNbBlocks, | ||||
| @ -248,6 +213,7 @@ public: | ||||
| 				uint32_t tv_usec, | ||||
| 				float bufferLenSec, | ||||
|                 int32_t bufferGauge, | ||||
|                 int nbOriginalBlocks, | ||||
|                 int curNbBlocks, | ||||
|                 int curNbRecovery, | ||||
|                 float avgNbBlocks, | ||||
| @ -255,7 +221,7 @@ public: | ||||
| 			Message(), | ||||
| 			m_tv_sec(tv_sec), | ||||
| 			m_tv_usec(tv_usec), | ||||
| 			m_framesComplete(curNbBlocks == SDRdaemonFECBuffer::nbOriginalBlocks), | ||||
| 			m_framesComplete(curNbBlocks == nbOriginalBlocks), | ||||
| 			m_bufferLenSec(bufferLenSec), | ||||
|             m_bufferGauge(bufferGauge), | ||||
|             m_curNbBlocks(curNbBlocks), | ||||
|  | ||||
| @ -134,7 +134,7 @@ void SDRdaemonFECUDPHandler::dataReadyRead() | ||||
| 		qint64 pendingDataSize = m_dataSocket->pendingDatagramSize(); | ||||
| 		m_udpReadBytes = m_dataSocket->readDatagram(m_udpBuf, pendingDataSize, &m_remoteAddress, 0); | ||||
| 
 | ||||
| 		if (m_udpReadBytes == SDRdaemonFECBuffer::udpSize) { | ||||
| 		if (m_udpReadBytes == SDRdaemonFECBuffer::m_udpPayloadSize) { | ||||
| 		    processData(); | ||||
| 		} | ||||
| 	} | ||||
| @ -178,7 +178,7 @@ void SDRdaemonFECUDPHandler::tick() | ||||
|     if (throttlems != m_throttlems) | ||||
|     { | ||||
|         m_throttlems = throttlems; | ||||
|         m_readLengthSamples = (m_sdrDaemonBuffer.getSampleRate() * (m_throttlems+(m_throttleToggle ? 1 : 0))) / 1000; | ||||
|         m_readLengthSamples = (m_sdrDaemonBuffer.getCurrentMeta().m_sampleRate * (m_throttlems+(m_throttleToggle ? 1 : 0))) / 1000; | ||||
|         m_readLength = m_readLengthSamples * SDRdaemonFECBuffer::m_iqSampleSize; | ||||
|         m_throttleToggle = !m_throttleToggle; | ||||
|     } | ||||
| @ -199,6 +199,7 @@ void SDRdaemonFECUDPHandler::tick() | ||||
| 			m_tv_usec, | ||||
| 			m_sdrDaemonBuffer.getBufferLengthInSecs(), | ||||
|             m_sdrDaemonBuffer.getBufferGauge(), | ||||
|             m_sdrDaemonBuffer.getCurNbBlocks() == SDRdaemonFECBuffer::m_nbOriginalBlocks, | ||||
|             m_sdrDaemonBuffer.getCurNbBlocks(), | ||||
|             m_sdrDaemonBuffer.getCurNbRecovery(), | ||||
|             m_sdrDaemonBuffer.getAvgNbBlocks(), | ||||
|  | ||||
| @ -43,9 +43,7 @@ public: | ||||
| 	void stop(); | ||||
| 	void configureUDPLink(const QString& address, quint16 port); | ||||
| 	void getRemoteAddress(QString& s) const { s = m_remoteAddress.toString(); } | ||||
| 	void setAutoFollowRate(bool autoFollowRate) { m_sdrDaemonBuffer.setAutoFollowRate(autoFollowRate); } | ||||
|     void setAutoCorrBuffer(bool autoCorrBuffer) { m_autoCorrBuffer = autoCorrBuffer; m_sdrDaemonBuffer.setAutoCorrBuffer(autoCorrBuffer); } | ||||
|     void resetIndexes() { m_sdrDaemonBuffer.setResetIndexes(); } | ||||
|     int getNbOriginalBlocks() const { return SDRdaemonFECBuffer::m_nbOriginalBlocks; } | ||||
| public slots: | ||||
| 	void dataReadyRead(); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user