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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Dec 17 22:17:16 CET 2008


Revision: 35415
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35415&view=rev
Author:   thebluegr
Date:     2008-12-17 21:17:15 +0000 (Wed, 17 Dec 2008)

Log Message:
-----------
Some more Smacker audio code (still non-functional)

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

Modified: scummvm/trunk/graphics/smk_player.cpp
===================================================================
--- scummvm/trunk/graphics/smk_player.cpp	2008-12-17 19:25:54 UTC (rev 35414)
+++ scummvm/trunk/graphics/smk_player.cpp	2008-12-17 21:17:15 UTC (rev 35415)
@@ -419,7 +419,7 @@
 		_header.audioInfo[i].sampleRate = audioInfo & 0xFFFFFF;
 
 		if (_header.audioInfo[i].hasAudio && i == 0) {
-			byte flags = Audio::Mixer::FLAG_UNSIGNED;
+			byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LITTLE_ENDIAN;
 
 			if (_header.audioInfo[i].is16Bits)
 				flags = flags | Audio::Mixer::FLAG_16BITS;
@@ -469,10 +469,13 @@
 		_audioStarted = false;
 	}
 
+	// FIXME
+	/*
 	if (_audioStream) {
 		delete _audioStream;
 		_audioStream = 0;
 	}
+	*/
 
 	delete _fileStream;
 
@@ -728,6 +731,10 @@
 	SmallHuffmanTree *audioTrees[4];
 	int16 bases[2];
 	int k;
+	byte *unpackedBuffer = new byte[unpackedSize];
+	int curPos = 0;
+	byte *curPointer = unpackedBuffer;
+	uint16 lo, hi, cur;
 
 	if (!dataPresent)
 		return;
@@ -750,7 +757,38 @@
 	if (isStereo)
 		bases[1] = (!is16Bits) ? audioBS.getBits8() : (audioBS.getBits8() << 8) || audioBS.getBits8();
 	
-	// TODO: Finish the rest of this
+	while (curPos < unpackedSize) {
+		// If the sample is stereo, we get first the data for the left and then for the right channel
+		if (!is16Bits) {
+			for (k = 0; k < (isStereo ? 2 : 1); k++) {
+				*curPointer++ = (byte)(bases[k] + audioTrees[k]->getCode(audioBS));
+				curPos++;
+			}
+		} else {
+			if (isStereo) {
+				// Left channel
+				lo = (bases[1] & 0xFF) + audioTrees[3]->getCode(audioBS);
+				hi = (bases[1] & 0xFF00) + (audioTrees[2]->getCode(audioBS) << 8);
+				cur = hi + lo;	// adding takes care of possible overflows
+				*curPointer++ = cur & 0xFF;    // low
+				curPos++;
+				*curPointer++ = cur & 0xFF00;  // high
+				curPos++;
+			}
+
+			// Right channel
+			lo = (bases[0] & 0xFF) + audioTrees[1]->getCode(audioBS);
+			hi = (bases[0] & 0xFF00) + (audioTrees[0]->getCode(audioBS) << 8);
+			cur = hi + lo;	// adding takes care of possible overflows
+			*curPointer++ = cur & 0xFF;    // low
+			curPos++;
+			*curPointer++ = cur & 0xFF00;  // high
+			curPos++;
+		}
+	}
+
+	_audioStream->queueBuffer(unpackedBuffer, unpackedSize);
+	// unpackedBuffer will be deleted by AppendableAudioStream
 }
 
 void SMKPlayer::unpackPalette() {


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