Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libaudiofile/WAVE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,15 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
{
_af_error(AF_BAD_NOT_IMPLEMENTED,
"IMA ADPCM compression supports only 4 bits per sample");
return AF_FAIL;
}

int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
if (bytesPerBlock > blockAlign || (samplesPerBlock % 8) != 1)
{
_af_error(AF_BAD_CODEC_CONFIG,
"Invalid samples per block for IMA ADPCM compression");
return AF_FAIL;
}

track->f.sampleWidth = 16;
Expand Down
2 changes: 1 addition & 1 deletion libaudiofile/modules/BlockCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void BlockCodec::runPull()

// Read the compressed data.
ssize_t bytesRead = read(m_inChunk->buffer, m_bytesPerPacket * blockCount);
int blocksRead = bytesRead >= 0 ? bytesRead / m_bytesPerPacket : 0;
int blocksRead = (bytesRead >= 0 && m_bytesPerPacket > 0) ? bytesRead / m_bytesPerPacket : 0;

// Decompress into m_outChunk.
for (int i=0; i<blocksRead; i++)
Expand Down