[Scummvm-cvs-logs] SF.net SVN: scummvm: [23971] scummvm/branches/branch-0-9-0

sev at users.sourceforge.net sev at users.sourceforge.net
Thu Sep 21 22:14:59 CEST 2006


Revision: 23971
          http://svn.sourceforge.net/scummvm/?rev=23971&view=rev
Author:   sev
Date:     2006-09-21 13:14:24 -0700 (Thu, 21 Sep 2006)

Log Message:
-----------
Backport fix for bug #1501302: "FF: Crackling Audio (Mac version)"

Modified Paths:
--------------
    scummvm/branches/branch-0-9-0/NEWS
    scummvm/branches/branch-0-9-0/sound/adpcm.cpp

Modified: scummvm/branches/branch-0-9-0/NEWS
===================================================================
--- scummvm/branches/branch-0-9-0/NEWS	2006-09-21 20:12:16 UTC (rev 23970)
+++ scummvm/branches/branch-0-9-0/NEWS	2006-09-21 20:14:24 UTC (rev 23971)
@@ -21,6 +21,7 @@
    - Improved support for international versions of the Feeble Files.
    - Fixed undefined behaviour when loading music.
    - Fixed crash when displaying some subtitles in the Feeble Files.
+   - Fixed crackling sound in Mac version of Feeble Files
 
  BASS:
    - Fixed character spacing in LINC terminals in floppy version v0.0303

Modified: scummvm/branches/branch-0-9-0/sound/adpcm.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/sound/adpcm.cpp	2006-09-21 20:12:16 UTC (rev 23970)
+++ scummvm/branches/branch-0-9-0/sound/adpcm.cpp	2006-09-21 20:14:24 UTC (rev 23971)
@@ -96,7 +96,8 @@
 	_status.stepIndex = 0;
 	memset(_status.ch, 0, sizeof(_status.ch));
 	_endpos = stream->pos() + size;
-	_blockPos = _blockLen = 0;
+	_blockLen = 0;
+	_blockPos = _blockAlign; // To make sure first header is read
 
 	if (type == kADPCMMSIma && blockAlign == 0)
 		error("ADPCMInputStream(): blockAlign isn't specifiled for MS IMA ADPCM");
@@ -217,18 +218,22 @@
 			if (stereo)
 				_status.ch[1].delta = _stream->readSint16LE();
 
-			buffer[samples++] = _status.ch[0].sample1 = _stream->readSint16LE();
+			_status.ch[0].sample1 = _stream->readSint16LE();
 			if (stereo)
-				buffer[samples++] = _status.ch[1].sample1 = _stream->readSint16LE();
+				_status.ch[1].sample1 = _stream->readSint16LE();
 
 			buffer[samples++] = _status.ch[0].sample2 = _stream->readSint16LE();
+
 			if (stereo)
 				buffer[samples++] = _status.ch[1].sample2 = _stream->readSint16LE();
 
+			buffer[samples++] = _status.ch[0].sample1;
+			if (stereo)
+				buffer[samples++] = _status.ch[1].sample1;
+
 			_blockPos = channels * 7;
 		}
 
-
 		for (; samples < numSamples && _blockPos < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
 			data = _stream->readByte();
 			_blockPos++;
@@ -241,6 +246,33 @@
 }
 
 
+static const int MSADPCMAdaptationTable[] = {
+	230, 230, 230, 230, 307, 409, 512, 614,
+	768, 614, 512, 409, 307, 230, 230, 230
+};
+
+
+int16 ADPCMInputStream::decodeMS(ADPCMChannelStatus *c, byte code) {
+	int32 predictor;
+
+	predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
+	predictor += (signed)((code & 0x08) ? (code - 0x10) : (code)) * c->delta;
+
+	if (predictor < -0x8000)
+		predictor = -0x8000;
+	else if (predictor > 0x7fff)
+		predictor = 0x7fff;
+
+	c->sample2 = c->sample1;
+	c->sample1 = predictor;
+	c->delta = (MSADPCMAdaptationTable[(int)code] * c->delta) >> 8;
+
+	if (c->delta < 16)
+		c->delta = 16;
+
+	return (int16)predictor;
+}
+
 // adjust the step for use on the next sample.
 int16 ADPCMInputStream::stepAdjust(byte code) {
 	static const int16 adjusts[] = {-1, -1, -1, -1, 2, 4, 6, 8};
@@ -322,33 +354,6 @@
 	return samp;
 }
 
-static const int MSADPCMAdaptationTable[] = {
-	230, 230, 230, 230, 307, 409, 512, 614,
-	768, 614, 512, 409, 307, 230, 230, 230
-};
-
-
-int16 ADPCMInputStream::decodeMS(ADPCMChannelStatus *c, byte code) {
-	int32 predictor;
-
-	predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
-	predictor += (signed)((code & 0x08) ? (code - 0x10) : (code)) * c->delta;
-
-	if (predictor < -0x8000)
-		predictor = -0x8000;
-	else if (predictor > 0x7fff)
-		predictor = 0x7fff;
-
-	c->sample2 = c->sample1;
-	c->sample1 = predictor;
-	c->delta = (MSADPCMAdaptationTable[(int)code] * c->delta) >> 8;
-
-	if (c->delta < 16)
-		c->delta = 16;
-
-	return (int16)predictor;
-}
-
 AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) {
 	return new ADPCMInputStream(stream, size, type, rate, channels, blockAlign);
 }


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