diff options
author | Max Horn | 2005-12-09 22:04:28 +0000 |
---|---|---|
committer | Max Horn | 2005-12-09 22:04:28 +0000 |
commit | 3107d08f271f9606210dca05db72ace13fe37afc (patch) | |
tree | 93b6889e5481f336f57da270c2c01532b0b632b1 | |
parent | e0e1dcda08ba26674e3f988594535ce542f44925 (diff) | |
download | scummvm-rg350-3107d08f271f9606210dca05db72ace13fe37afc.tar.gz scummvm-rg350-3107d08f271f9606210dca05db72ace13fe37afc.tar.bz2 scummvm-rg350-3107d08f271f9606210dca05db72ace13fe37afc.zip |
Unified IMA code a little bit
svn-id: r19767
-rw-r--r-- | scumm/imuse_digi/dimuse_codecs.cpp | 50 | ||||
-rw-r--r-- | sound/adpcm.cpp | 8 |
2 files changed, 32 insertions, 26 deletions
diff --git a/scumm/imuse_digi/dimuse_codecs.cpp b/scumm/imuse_digi/dimuse_codecs.cpp index c5b3e35a80..81f5168a81 100644 --- a/scumm/imuse_digi/dimuse_codecs.cpp +++ b/scumm/imuse_digi/dimuse_codecs.cpp @@ -63,42 +63,48 @@ static const int16 *imcTable; static byte _destImcTable[89]; static uint32 _destImcTable2[89 * 64]; -static const int16 imcTable[] = { - 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x0010, 0x0011, - 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, 0x0022, 0x0025, 0x0029, 0x002D, - 0x0032, 0x0037, 0x003C, 0x0042, 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, - 0x0082, 0x008F, 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, - 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292, 0x02D4, 0x031C, - 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, 0x0610, 0x06AB, 0x0756, 0x0812, - 0x08E0, 0x09C3, 0x0ABD, 0x0BD0, 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, - 0x1706, 0x1954, 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, - 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF +static const int16 imcTable[89] = { + 7, 8, 9, 10, 11, 12, 13, 14, + 16, 17, 19, 21, 23, 25, 28, 31, + 34, 37, 41, 45, 50, 55, 60, 66, + 73, 80, 88, 97, 107, 118, 130, 143, + 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, + 724, 796, 876, 963, 1060, 1166, 1282, 1411, + 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, + 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, + 7132, 7845, 8630, 9493,10442,11487,12635,13899, + 15289,16818,18500,20350,22385,24623,27086,29794, + 32767 }; #endif static const byte imxOtherTable[6][64] = { { - 0xFF, 0x04 + 0xFF, + 4 }, { - 0xFF, 0xFF, 0x02, 0x08 + 0xFF, 0xFF, + 2, 8 }, { - 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x02, 0x04, 0x06 + 0xFF, 0xFF, 0xFF, 0xFF, + 1, 2, 4, 6 }, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x01, 0x02, 0x04, 0x06, 0x08, 0x0C, 0x10, 0x20 + 1, 2, 4, 6, 8, 12, 16, 32 }, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x01, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, - 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x20 + 1, 2, 4, 6, 8, 10, 12, 14, + 16, 18, 20, 22, 24, 26, 28, 32 }, { @@ -106,10 +112,10 @@ static const byte imxOtherTable[6][64] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20 + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32 } }; @@ -647,8 +653,8 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in curTablePos += (int8)imxOtherTable[curTableEntryBitCount - 2][data]; if (curTablePos < 0) curTablePos = 0; - else if (curTablePos > 88) - curTablePos = 88; + else if (curTablePos >= ARRAYSIZE(imcTable)) + curTablePos = ARRAYSIZE(imcTable) - 1; } } } diff --git a/sound/adpcm.cpp b/sound/adpcm.cpp index bae635547e..e777a243b2 100644 --- a/sound/adpcm.cpp +++ b/sound/adpcm.cpp @@ -166,8 +166,8 @@ int16 ADPCMInputStream::decodeOKI(byte code) { _status.stepIndex += stepAdjust(code); if (_status.stepIndex < 0) _status.stepIndex = 0; - if (_status.stepIndex > 48) - _status.stepIndex = 48; + if (_status.stepIndex > ARRAYSIZE(okiStepSize) - 1) + _status.stepIndex = ARRAYSIZE(okiStepSize) - 1; // * 16 effectively converts 12-bit input to 16-bit output return samp * 16; @@ -213,8 +213,8 @@ int16 ADPCMInputStream::decodeMSIMA(byte code) { _status.stepIndex += stepAdjust(code); if (_status.stepIndex < 0) _status.stepIndex = 0; - if (_status.stepIndex > 88) - _status.stepIndex = 88; + if (_status.stepIndex > ARRAYSIZE(imaStepTable) - 1) + _status.stepIndex = ARRAYSIZE(imaStepTable) - 1; return samp; } |