diff options
author | Florian Kagerer | 2010-10-27 22:41:08 +0000 |
---|---|---|
committer | Florian Kagerer | 2010-10-27 22:41:08 +0000 |
commit | ab1c54a9eef79090c7cf81f09e561480b4964671 (patch) | |
tree | d0ecbc3f577880fc3ab702610d4d06b7ba3c42a7 /graphics/video | |
parent | 2ad28b8cd53c363f12d920c746795e0d371dc9f9 (diff) | |
download | scummvm-rg350-ab1c54a9eef79090c7cf81f09e561480b4964671.tar.gz scummvm-rg350-ab1c54a9eef79090c7cf81f09e561480b4964671.tar.bz2 scummvm-rg350-ab1c54a9eef79090c7cf81f09e561480b4964671.zip |
TOON: fix some evaluation order bugs in smacker decoder
These bugs would cause crashs in MSVC 2008/2010 release builds.
svn-id: r53893
Diffstat (limited to 'graphics/video')
-rw-r--r-- | graphics/video/smk_decoder.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/graphics/video/smk_decoder.cpp b/graphics/video/smk_decoder.cpp index 71858dd3aa..de1eb4436f 100644 --- a/graphics/video/smk_decoder.cpp +++ b/graphics/video/smk_decoder.cpp @@ -252,9 +252,12 @@ BigHuffmanTree::BigHuffmanTree(BitStream &bs, int allocSize) _loBytes = new SmallHuffmanTree(_bs); _hiBytes = new SmallHuffmanTree(_bs); - _markers[0] = _bs.getBits8() | (_bs.getBits8() << 8); - _markers[1] = _bs.getBits8() | (_bs.getBits8() << 8); - _markers[2] = _bs.getBits8() | (_bs.getBits8() << 8); + _markers[0] = _bs.getBits8(); + _markers[0] |= (_bs.getBits8() << 8); + _markers[1] = _bs.getBits8(); + _markers[1] |= (_bs.getBits8() << 8); + _markers[2] = _bs.getBits8(); + _markers[2] |= (_bs.getBits8() << 8); _last[0] = _last[1] = _last[2] = 0xffffffff; @@ -780,13 +783,23 @@ void SmackerDecoder::queueCompressedBuffer(byte *buffer, uint32 bufferSize, int32 bases[2]; - if (isStereo) - bases[1] = (!is16Bits) ? audioBS.getBits8() : - ((int16) (((audioBS.getBits8() << 8) | audioBS.getBits8()))); - - bases[0] = (!is16Bits) ? audioBS.getBits8() : - ((int16) (((audioBS.getBits8() << 8) | audioBS.getBits8()))); + if (isStereo) { + if (is16Bits) { + byte hi = audioBS.getBits8(); + byte lo = audioBS.getBits8(); + bases[1] = (int16) ((hi << 8) | lo); + } else { + bases[1] = audioBS.getBits8(); + } + } + if (is16Bits) { + byte hi = audioBS.getBits8(); + byte lo = audioBS.getBits8(); + bases[0] = (int16) ((hi << 8) | lo); + } else { + bases[0] = audioBS.getBits8(); + } // The bases are the first samples, too for (int i = 0; i < (isStereo ? 2 : 1); i++, curPointer += (is16Bits ? 2 : 1), curPos += (is16Bits ? 2 : 1)) { @@ -811,8 +824,9 @@ void SmackerDecoder::queueCompressedBuffer(byte *buffer, uint32 bufferSize, } } else { for (int k = 0; k < (isStereo ? 2 : 1); k++) { - bases[k] += (int16) (audioTrees[k * 2]->getCode(audioBS) | - (audioTrees[k * 2 + 1]->getCode(audioBS) << 8)); + byte lo = audioTrees[k * 2]->getCode(audioBS); + byte hi = audioTrees[k * 2 + 1]->getCode(audioBS); + bases[k] += (int16) (lo | (hi << 8)); WRITE_BE_UINT16(curPointer, bases[k]); curPointer += 2; |