Skip to content
Permalink
Browse files

adpcm: clamp shift bigger than 12 to 9

  • Loading branch information
JaCzekanski committed Sep 19, 2019
1 parent 986d8c3 commit 6b897562f0912f1e60c422b934a4709a438dea0b
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/sound/adpcm.cpp
@@ -20,7 +20,7 @@ std::vector<int16_t> decode(uint8_t buffer[16], int32_t prevSample[2]) {
// Read ADPCM header
auto shift = buffer[0] & 0x0f;
auto filter = (buffer[0] & 0x70) >> 4; // 0x40 for xa adpcm
if (shift > 9) shift = 9;
if (shift > 12) shift = 9;

assert(filter <= 4);
if (filter > 4) filter = 4; // TODO: Not sure, check behaviour on real HW
@@ -103,7 +103,7 @@ std::vector<int16_t> decodePacket(uint8_t buffer[128], int32_t prevSample[2], bo
// Read ADPCM header
auto shift = buffer[4 + block] & 0x0f;
auto filter = (buffer[4 + block] & 0x30) >> 4;
if (shift > 9) shift = 9;
if (shift > 12) shift = 9;

auto filterPos = filterTablePos[filter];
auto filterNeg = filterTableNeg[filter];

0 comments on commit 6b89756

Please sign in to comment.
You can’t perform that action at this time.