1st bugfix round

This commit is contained in:
Christian R. Helmrich
2020-01-16 15:00:04 +01:00
parent 630a1b0db7
commit 16efffb1bb
3 changed files with 10 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ static const uint8_t staticHeaderTemplate[STAT_HEADER_SIZE] = {
}; };
// static helper functions // static helper functions
static uint32_t toBigEndian (const unsigned ui) // Motorola endianness static uint32_t toBigEndian (const unsigned ui) // to Motorola endianness
{ {
return ((ui & UCHAR_MAX) << 24) | (((ui >> 8) & UCHAR_MAX) << 16) | (((ui >> 16) & UCHAR_MAX) << 8) | ((ui >> 24) & UCHAR_MAX); return ((ui & UCHAR_MAX) << 24) | (((ui >> 8) & UCHAR_MAX) << 16) | (((ui >> 16) & UCHAR_MAX) << 8) | ((ui >> 24) & UCHAR_MAX);
} }

View File

@@ -386,13 +386,18 @@ unsigned BasicWavReader::read (int32_t* const frameBuf, const uint16_t frameCoun
{ {
unsigned framesRead; unsigned framesRead;
if ((frameBuf == nullptr) || (m_fileHandle == -1) || (__min (m_frameLimit, frameCount) == 0) || (m_byteBuffer == nullptr)) if ((frameBuf == nullptr) || (m_fileHandle == -1) || (__min (m_frameLimit, frameCount) == 0) || (m_byteBuffer == nullptr) ||
(m_bytesRemaining <= 0)) // end of chunk reached
{ {
return 0; // invalid args or class not initialized return 0; // invalid args or class not initialized
} }
framesRead = m_readDataFunc (m_fileHandle, frameBuf, __min (m_frameLimit, frameCount), m_waveChannels, m_byteBuffer); framesRead = m_readDataFunc (m_fileHandle, frameBuf, __min (m_frameLimit, frameCount), m_waveChannels, m_byteBuffer);
m_bytesRead = m_waveFrameSize * framesRead; m_bytesRead = m_waveFrameSize * framesRead;
m_bytesRemaining -= m_bytesRead; if ((m_bytesRemaining -= m_bytesRead) < 0)
{
m_bytesRead = unsigned (m_bytesRead + m_bytesRemaining);
framesRead = m_bytesRead / m_waveFrameSize;
}
m_chunkLength += m_bytesRead; m_chunkLength += m_bytesRead;
return framesRead; return framesRead;

View File

@@ -64,7 +64,7 @@ static inline uint32_t packAvgTempAnalysisStats (const unsigned avgAbsHpL, cons
static inline int16_t getMaxAbsHpValueLocation (const unsigned maxAbsValL, const unsigned maxAbsValR, const unsigned maxAbsValP, static inline int16_t getMaxAbsHpValueLocation (const unsigned maxAbsValL, const unsigned maxAbsValR, const unsigned maxAbsValP,
const int16_t maxAbsIdxL, const int16_t maxAbsIdxR) const int16_t maxAbsIdxL, const int16_t maxAbsIdxR)
{ {
if ((maxAbsValP * 8 < maxAbsValL * 3) || (maxAbsValL * 8 < maxAbsValR * 3)) // has transient if ((maxAbsValP * 5 < maxAbsValL * 2) || (maxAbsValL * 5 < maxAbsValR * 2)) // has transient
{ {
return maxAbsValR > maxAbsValL ? maxAbsIdxR : maxAbsIdxL; return maxAbsValR > maxAbsValL ? maxAbsIdxR : maxAbsIdxL;
} }