[Scummvm-cvs-logs] SF.net SVN: scummvm:[35432] scummvm/trunk/graphics/smk_player.cpp

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Fri Dec 19 02:01:08 CET 2008


Revision: 35432
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35432&view=rev
Author:   drmccoy
Date:     2008-12-19 01:01:07 +0000 (Fri, 19 Dec 2008)

Log Message:
-----------
Fixing 16bit audio

Modified Paths:
--------------
    scummvm/trunk/graphics/smk_player.cpp

Modified: scummvm/trunk/graphics/smk_player.cpp
===================================================================
--- scummvm/trunk/graphics/smk_player.cpp	2008-12-19 00:14:18 UTC (rev 35431)
+++ scummvm/trunk/graphics/smk_player.cpp	2008-12-19 01:01:07 UTC (rev 35432)
@@ -775,10 +775,10 @@
 
 	if (isStereo)
 		bases[1] = (!is16Bits) ?   audioBS.getBits8() :
-		                         ((audioBS.getBits8() << 8) || audioBS.getBits8());
+		               ((int16) (((audioBS.getBits8() << 8) | audioBS.getBits8())));
 
 	bases[0] = (!is16Bits) ?   audioBS.getBits8() :
-													 ((audioBS.getBits8() << 8) || audioBS.getBits8());
+	               ((int16) (((audioBS.getBits8() << 8) | audioBS.getBits8())));
 
 
 	// The bases are the first samples, too
@@ -797,6 +797,7 @@
 		// If the sample is stereo, the data is stored for the left and right channel, respectively
 		// (the exact opposite to the base values)
 		if (!is16Bits) {
+
 			for (int k = 0; k < (isStereo ? 2 : 1); k++) {
 				int8 v = (int8) ((int16) audioTrees[k]->getCode(audioBS));
 
@@ -807,19 +808,24 @@
 				*curPointer++ = data ^ 0x80;
 				curPos++;
 			}
+
 		} else {
+
 			for (int k = 0; k < (isStereo ? 2 : 1); k++) {
-				uint16 cur = bases[k];
-				// adding takes care of possible overflows
-				cur += audioTrees[k * 2]->getCode(audioBS);             // low byte
-				cur += (audioTrees[k * 2 + 1]->getCode(audioBS) << 8);  // high byte
-				*curPointer++ = (cur >> 8) & 0xFF;  // high byte
-				curPos++;
-				*curPointer++ = cur & 0xFF;         // low byte
-				curPos++;
+				int16 v = (int16) (audioTrees[k * 2]->getCode(audioBS) |
+				                  (audioTrees[k * 2 + 1]->getCode(audioBS) << 8));
+
+				bases[k] += v;
+
+				int16 data = CLIP<int32>(bases[k], -32768, 32767);
+
+				WRITE_BE_UINT16(curPointer, data);
+
+				curPointer += 2;
+				curPos += 2;
 			}
+		}
 
-		}
 	}
 
 	for (int k = 0; k < numBytes; k++)


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