[Scummvm-cvs-logs] SF.net SVN: scummvm:[53893] scummvm/trunk/graphics/video/smk_decoder.cpp

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Thu Oct 28 00:41:08 CEST 2010


Revision: 53893
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53893&view=rev
Author:   athrxx
Date:     2010-10-27 22:41:08 +0000 (Wed, 27 Oct 2010)

Log Message:
-----------
TOON: fix some evaluation order bugs in smacker decoder

These bugs would cause crashs in MSVC 2008/2010 release builds.

Modified Paths:
--------------
    scummvm/trunk/graphics/video/smk_decoder.cpp

Modified: scummvm/trunk/graphics/video/smk_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/smk_decoder.cpp	2010-10-27 22:37:51 UTC (rev 53892)
+++ scummvm/trunk/graphics/video/smk_decoder.cpp	2010-10-27 22:41:08 UTC (rev 53893)
@@ -252,9 +252,12 @@
 	_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,14 +783,24 @@
 
 	int32 bases[2];
 
-	if (isStereo)
-		bases[1] = (!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();
+		}
+	}
 
-	bases[0] = (!is16Bits) ?   audioBS.getBits8() :
-	               ((int16) (((audioBS.getBits8() << 8) | 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)) {
 		if (is16Bits)
@@ -811,8 +824,9 @@
 			}
 		} 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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list