[Scummvm-cvs-logs] SF.net SVN: scummvm:[49279] scummvm/trunk/graphics/video/avi_decoder.cpp

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Fri May 28 01:57:44 CEST 2010


Revision: 49279
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49279&view=rev
Author:   mthreepwood
Date:     2010-05-27 23:57:44 +0000 (Thu, 27 May 2010)

Log Message:
-----------
Cleanup AVI a bit, add support for stereo audio

Modified Paths:
--------------
    scummvm/trunk/graphics/video/avi_decoder.cpp

Modified: scummvm/trunk/graphics/video/avi_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/avi_decoder.cpp	2010-05-27 23:47:31 UTC (rev 49278)
+++ scummvm/trunk/graphics/video/avi_decoder.cpp	2010-05-27 23:57:44 UTC (rev 49279)
@@ -154,11 +154,9 @@
 	sHeader.bufferSize = _fileStream->readUint32LE();
 	sHeader.quality = _fileStream->readUint32LE();
 	sHeader.sampleSize = _fileStream->readUint32LE();
-	sHeader.frame.left = _fileStream->readSint16LE();
-	sHeader.frame.top = _fileStream->readSint16LE();
-	sHeader.frame.right = _fileStream->readSint16LE();
-	sHeader.frame.bottom = _fileStream->readSint16LE();
 
+	_fileStream->skip(sHeader.size - 48); // Skip over the remainder of the chunk (frame)
+
 	if (_fileStream->readUint32BE() != ID_STRF)
 		error("Could not find STRF tag");
 	/* uint32 strfSize = */ _fileStream->readUint32LE();
@@ -188,11 +186,14 @@
 				_palette[i * 3 + 2] = _fileStream->readByte();
 				_palette[i * 3 + 1] = _fileStream->readByte();
 				_palette[i * 3] = _fileStream->readByte();
-				/*_palette[i * 4 + 3] = */_fileStream->readByte();
+				_fileStream->readByte();
 			}
 
 			_dirtyPalette = true;
 		}
+
+		if (!_vidsHeader.streamHandler)
+			_vidsHeader.streamHandler = _bmInfo.compression;
 	} else if (sHeader.streamType == ID_AUDS) {
 		_audsHeader = sHeader;
 
@@ -202,6 +203,11 @@
 		_wvInfo.avgBytesPerSec = _fileStream->readUint32LE();
 		_wvInfo.blockAlign = _fileStream->readUint16LE();
 		_wvInfo.size = _fileStream->readUint16LE();
+
+		// AVI seems to treat the sampleSize as including the second
+		// channel as well, so divide for our sake.
+		if (_wvInfo.channels == 2)
+			_audsHeader.sampleSize /= 2;
 	}
 }
 
@@ -325,6 +331,9 @@
 		else
 			flags |= Audio::FLAG_UNSIGNED;
 
+		if (_wvInfo.channels == 2)
+			flags |= Audio::FLAG_STEREO;
+
 		_audStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, flags);
 		_fileStream->skip(chunkSize & 1); // Alignment
 	} else if (getStreamType(nextTag) == 'dc' || getStreamType(nextTag) == 'id' ||
@@ -396,7 +405,7 @@
 
 Audio::QueuingAudioStream *AviDecoder::createAudioStream() {
 	if (_wvInfo.tag == AVI_WAVE_FORMAT_PCM)
-		return Audio::makeQueuingAudioStream(AUDIO_RATE, false);
+		return Audio::makeQueuingAudioStream(AUDIO_RATE, _wvInfo.channels == 2);
 
 	if (_wvInfo.tag != 0) // No sound
 		warning ("Unsupported AVI audio format %d", _wvInfo.tag);


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