mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 21:20:31 -05:00 
			
		
		
		
	SDRdaemon plugin: fixed LZ4 writes and uncompressed writes
This commit is contained in:
		
							parent
							
								
									501b14d1e7
								
							
						
					
					
						commit
						942a7ca803
					
				@ -96,7 +96,7 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
 | 
				
			|||||||
		m_nbBlocks = 0;
 | 
							m_nbBlocks = 0;
 | 
				
			||||||
		m_inCount = 0;
 | 
							m_inCount = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!(m_currentMeta == *metaData))
 | 
							if (!m_lz4 && !(m_currentMeta == *metaData))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			std::cerr << "SDRdaemonBuffer::readMeta: ";
 | 
								std::cerr << "SDRdaemonBuffer::readMeta: ";
 | 
				
			||||||
			printMeta(metaData);
 | 
								printMeta(metaData);
 | 
				
			||||||
@ -203,23 +203,7 @@ void SDRdaemonBuffer::writeDataLZ4(const char *array, uint32_t length)
 | 
				
			|||||||
            m_nbLz4CRCOK = 0;
 | 
					            m_nbLz4CRCOK = 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        uint64_t crc64 = m_crc64.calculate_crc(m_lz4InBuffer, m_lz4InSize);
 | 
					        writeToRawBufferLZ4();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (memcmp(&crc64, &m_dataCRC, 8) == 0)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            m_nbLz4CRCOK++;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) &m_rawBuffer[m_writeIndex], m_frameSize);
 | 
					 | 
				
			||||||
        m_nbLz4Decodes++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (compressedSize == m_lz4InSize)
 | 
					 | 
				
			||||||
    	{
 | 
					 | 
				
			||||||
        	m_nbLz4SuccessfulDecodes++;
 | 
					 | 
				
			||||||
    	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        writeToRawBufferLZ4((const char *) m_lz4InBuffer, m_frameSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		m_lz4InCount = 0;
 | 
							m_lz4InCount = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -235,22 +219,33 @@ void SDRdaemonBuffer::writeToRawBufferUncompressed(const char *array, uint32_t l
 | 
				
			|||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		std::memcpy((void *) &m_rawBuffer[m_writeIndex], (const void *) array, m_rawSize - m_writeIndex);
 | 
							std::memcpy((void *) &m_rawBuffer[m_writeIndex], (const void *) array, m_rawSize - m_writeIndex);
 | 
				
			||||||
		m_writeIndex = length - (m_rawSize - m_writeIndex);
 | 
							length -= m_rawSize - m_writeIndex;
 | 
				
			||||||
		std::memcpy((void *) m_rawBuffer, (const void *) &array[m_rawSize - m_writeIndex], m_writeIndex);
 | 
							std::memcpy((void *) m_rawBuffer, (const void *) &array[m_rawSize - m_writeIndex], length);
 | 
				
			||||||
 | 
							m_writeIndex = length;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SDRdaemonBuffer::writeToRawBufferLZ4(const char *array, uint32_t length)
 | 
					void SDRdaemonBuffer::writeToRawBufferLZ4()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    uint64_t crc64 = m_crc64.calculate_crc(m_lz4InBuffer, m_lz4InSize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (memcmp(&crc64, &m_dataCRC, 8) == 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        m_nbLz4CRCOK++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    	return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) m_lz4OutBuffer, m_frameSize);
 | 
					    int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) m_lz4OutBuffer, m_frameSize);
 | 
				
			||||||
    m_nbLz4Decodes++;
 | 
					    m_nbLz4Decodes++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (compressedSize == m_lz4InSize)
 | 
					    if (compressedSize == m_lz4InSize)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
    	m_nbLz4SuccessfulDecodes++;
 | 
					    	m_nbLz4SuccessfulDecodes++;
 | 
				
			||||||
 | 
					    	writeToRawBufferUncompressed((const char *) m_lz4OutBuffer, m_frameSize);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
    writeToRawBufferUncompressed((const char *) m_lz4OutBuffer, m_frameSize);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint8_t *SDRdaemonBuffer::readDataChunk()
 | 
					uint8_t *SDRdaemonBuffer::readDataChunk()
 | 
				
			||||||
 | 
				
			|||||||
@ -80,7 +80,7 @@ public:
 | 
				
			|||||||
private:
 | 
					private:
 | 
				
			||||||
	void updateLZ4Sizes(uint32_t frameSize);
 | 
						void updateLZ4Sizes(uint32_t frameSize);
 | 
				
			||||||
	void writeDataLZ4(const char *array, uint32_t length);
 | 
						void writeDataLZ4(const char *array, uint32_t length);
 | 
				
			||||||
	void writeToRawBufferLZ4(const char *array, uint32_t originalLength);
 | 
						void writeToRawBufferLZ4();
 | 
				
			||||||
	void writeToRawBufferUncompressed(const char *array, uint32_t length);
 | 
						void writeToRawBufferUncompressed(const char *array, uint32_t length);
 | 
				
			||||||
	void updateBufferSize(uint32_t sampleRate);
 | 
						void updateBufferSize(uint32_t sampleRate);
 | 
				
			||||||
    void printMeta(MetaData *metaData);
 | 
					    void printMeta(MetaData *metaData);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user