diff options
author | Max Horn | 2005-12-11 13:18:27 +0000 |
---|---|---|
committer | Max Horn | 2005-12-11 13:18:27 +0000 |
commit | 2c12614ae138642e0e128815346c670c0955c760 (patch) | |
tree | b000ffcb369d863d3098dcdfec3f513797c6e860 /sound/adpcm.cpp | |
parent | 0dbbdc60595ecb1d163fe76a4d1f8205183f492f (diff) | |
download | scummvm-rg350-2c12614ae138642e0e128815346c670c0955c760.tar.gz scummvm-rg350-2c12614ae138642e0e128815346c670c0955c760.tar.bz2 scummvm-rg350-2c12614ae138642e0e128815346c670c0955c760.zip |
Simplify ADPCM IMA decoding (based on IMA docs). The result will only be 99.9% identical, but the code should be faster on most modern machines
svn-id: r19777
Diffstat (limited to 'sound/adpcm.cpp')
-rw-r--r-- | sound/adpcm.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/sound/adpcm.cpp b/sound/adpcm.cpp index e777a243b2..daec184d6a 100644 --- a/sound/adpcm.cpp +++ b/sound/adpcm.cpp @@ -143,16 +143,9 @@ static const int16 okiStepSize[49] = { // Decode Linear to ADPCM int16 ADPCMInputStream::decodeOKI(byte code) { - int16 diff, E, SS, samp; - - SS = okiStepSize[_status.stepIndex]; - E = SS/8; - if (code & 0x01) - E += SS/4; - if (code & 0x02) - E += SS/2; - if (code & 0x04) - E += SS; + int16 diff, E, samp; + + E = (2 * (code & 0x7) + 1) * okiStepSize[_status.stepIndex] / 8; diff = (code & 0x08) ? -E : E; samp = _status.last + diff; @@ -190,16 +183,9 @@ static const uint16 imaStepTable[89] = { }; int16 ADPCMInputStream::decodeMSIMA(byte code) { - int32 diff, E, SS, samp; - - SS = imaStepTable[_status.stepIndex]; - E = SS >> 3; - if (code & 0x04) - E += SS; - if (code & 0x02) - E += SS >> 1; - if (code & 0x01) - E += SS >> 2; + int32 diff, E, samp; + + E = (2 * (code & 0x7) + 1) * imaStepTable[_status.stepIndex] / 8; diff = (code & 0x08) ? -E : E; samp = _status.last + diff; |