[Scummvm-cvs-logs] SF.net SVN: scummvm:[53578] scummvm/trunk/sound/decoders

sev at users.sourceforge.net sev at users.sourceforge.net
Mon Oct 18 21:10:57 CEST 2010


Revision: 53578
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53578&view=rev
Author:   sev
Date:     2010-10-18 19:10:57 +0000 (Mon, 18 Oct 2010)

Log Message:
-----------
SOUND: Add support for LastExpress version of IMA ADPCM sound.

Patch by littleboy.

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

Modified: scummvm/trunk/sound/decoders/adpcm.cpp
===================================================================
--- scummvm/trunk/sound/decoders/adpcm.cpp	2010-10-18 19:07:24 UTC (rev 53577)
+++ scummvm/trunk/sound/decoders/adpcm.cpp	2010-10-18 19:10:57 UTC (rev 53578)
@@ -290,8 +290,8 @@
 
 class MSIma_ADPCMStream : public Ima_ADPCMStream {
 public:
-	MSIma_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign)
-		: Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {
+	MSIma_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign, bool invertSamples = false)
+		: Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign), _invertSamples(invertSamples) {
 		if (blockAlign == 0)
 			error("ADPCMStream(): blockAlign isn't specified for MS IMA ADPCM");
 	}
@@ -305,6 +305,9 @@
 
 	int readBufferMSIMA1(int16 *buffer, const int numSamples);
 	int readBufferMSIMA2(int16 *buffer, const int numSamples);
+
+private:
+	bool _invertSamples;    // Some implementations invert the way samples are decoded
 };
 
 int MSIma_ADPCMStream::readBufferMSIMA1(int16 *buffer, const int numSamples) {
@@ -324,8 +327,8 @@
 		for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
 			data = _stream->readByte();
 			_blockPos[0]++;
-			buffer[samples] = decodeIMA(data & 0x0f);
-			buffer[samples + 1] = decodeIMA((data >> 4) & 0x0f);
+			buffer[samples] = decodeIMA(_invertSamples ? (data >> 4) & 0x0f : data & 0x0f);
+			buffer[samples + 1] = decodeIMA(_invertSamples ? data & 0x0f : (data >> 4) & 0x0f);
 		}
 	}
 	return samples;
@@ -733,6 +736,8 @@
 		return new Oki_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign);
 	case kADPCMMSIma:
 		return new MSIma_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign);
+	case kADPCMMSImaLastExpress:
+		return new MSIma_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign, true);
 	case kADPCMMS:
 		return new MS_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign);
 	case kADPCMTinsel4:

Modified: scummvm/trunk/sound/decoders/adpcm.h
===================================================================
--- scummvm/trunk/sound/decoders/adpcm.h	2010-10-18 19:07:24 UTC (rev 53577)
+++ scummvm/trunk/sound/decoders/adpcm.h	2010-10-18 19:10:57 UTC (rev 53578)
@@ -50,14 +50,15 @@
 // Usually, if the audio stream we're trying to play has the FourCC header
 // string intact, it's easy to discern which encoding is used
 enum typesADPCM {
-	kADPCMOki,		// Dialogic/Oki ADPCM (aka VOX)
-	kADPCMMSIma,	// Microsoft IMA ADPCM
-	kADPCMMS,		// Microsoft ADPCM
-	kADPCMTinsel4,	// 4-bit ADPCM used by the Tinsel engine
-	kADPCMTinsel6,	// 6-bit ADPCM used by the Tinsel engine
-	kADPCMTinsel8,	// 8-bit ADPCM used by the Tinsel engine
-	kADPCMIma,		// Standard IMA ADPCM
-	kADPCMApple		// Apple QuickTime IMA ADPCM
+	kADPCMOki,                 // Dialogic/Oki ADPCM (aka VOX)
+	kADPCMMSIma,               // Microsoft IMA ADPCM
+	kADPCMMSImaLastExpress,    // Microsoft IMA ADPCM (with inverted samples)
+	kADPCMMS,                  // Microsoft ADPCM
+	kADPCMTinsel4,             // 4-bit ADPCM used by the Tinsel engine
+	kADPCMTinsel6,             // 6-bit ADPCM used by the Tinsel engine
+	kADPCMTinsel8,             // 8-bit ADPCM used by the Tinsel engine
+	kADPCMIma,                 // Standard IMA ADPCM
+	kADPCMApple                // Apple QuickTime IMA ADPCM
 };
 
 /**


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