[Scummvm-cvs-logs] SF.net SVN: scummvm:[36194] scummvm/trunk/sound/adpcm.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Feb 1 23:06:43 CET 2009


Revision: 36194
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36194&view=rev
Author:   thebluegr
Date:     2009-02-01 22:06:43 +0000 (Sun, 01 Feb 2009)

Log Message:
-----------
Fixed incorrect usage of a boolean (boolean variables are not supposed to be used as indexes to arrays...)

Modified Paths:
--------------
    scummvm/trunk/sound/adpcm.cpp

Modified: scummvm/trunk/sound/adpcm.cpp
===================================================================
--- scummvm/trunk/sound/adpcm.cpp	2009-02-01 21:26:56 UTC (rev 36193)
+++ scummvm/trunk/sound/adpcm.cpp	2009-02-01 22:06:43 UTC (rev 36194)
@@ -76,7 +76,7 @@
 	void reset();
 	int16 stepAdjust(byte);
 	int16 decodeOKI(byte);
-	int16 decodeIMA(byte code, bool right = false); // Default to using the left channel/using one channel
+	int16 decodeIMA(byte code, int channel = 0); // Default to using the left channel/using one channel
 	int16 decodeMS(ADPCMChannelStatus *c, byte);
 	int16 decodeTinsel(int16, double);
 
@@ -219,7 +219,7 @@
 	for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
 		data = _stream->readByte();
 		buffer[samples] = TO_LE_16(decodeIMA((data >> 4) & 0x0f));
-		buffer[samples + 1] = TO_LE_16(decodeIMA(data & 0x0f, _channels == 2));
+		buffer[samples + 1] = TO_LE_16(decodeIMA(data & 0x0f, _channels == 2 ? 1 : 0));
 	}
 	return samples;
 }
@@ -520,14 +520,14 @@
 	32767
 };
 
-int16 ADPCMInputStream::decodeIMA(byte code, bool right) {
-	int32 E = (2 * (code & 0x7) + 1) * imaStepTable[_status.ima_ch[right].stepIndex] / 8;
+int16 ADPCMInputStream::decodeIMA(byte code, int channel) {
+	int32 E = (2 * (code & 0x7) + 1) * imaStepTable[_status.ima_ch[channel].stepIndex] / 8;
 	int32 diff = (code & 0x08) ? -E : E;
-	int32 samp = CLIP<int32>(_status.ima_ch[right].last + diff, -32768, 32767);
+	int32 samp = CLIP<int32>(_status.ima_ch[channel].last + diff, -32768, 32767);
 
-	_status.ima_ch[right].last = samp;
-	_status.ima_ch[right].stepIndex += stepAdjust(code);
-	_status.ima_ch[right].stepIndex = CLIP<int32>(_status.ima_ch[right].stepIndex, 0, ARRAYSIZE(imaStepTable) - 1);
+	_status.ima_ch[channel].last = samp;
+	_status.ima_ch[channel].stepIndex += stepAdjust(code);
+	_status.ima_ch[channel].stepIndex = CLIP<int32>(_status.ima_ch[channel].stepIndex, 0, ARRAYSIZE(imaStepTable) - 1);
 
 	return samp;
 }


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