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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue May 19 19:39:03 CEST 2009


Revision: 40729
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40729&view=rev
Author:   thebluegr
Date:     2009-05-19 17:39:03 +0000 (Tue, 19 May 2009)

Log Message:
-----------
Some fixes to the video decoders, thanks to salty-horse's comments

Modified Paths:
--------------
    scummvm/trunk/graphics/video/flic_player.cpp
    scummvm/trunk/graphics/video/flic_player.h
    scummvm/trunk/graphics/video/smk_player.h
    scummvm/trunk/graphics/video/video_player.h

Modified: scummvm/trunk/graphics/video/flic_player.cpp
===================================================================
--- scummvm/trunk/graphics/video/flic_player.cpp	2009-05-19 16:06:16 UTC (rev 40728)
+++ scummvm/trunk/graphics/video/flic_player.cpp	2009-05-19 17:39:03 UTC (rev 40729)
@@ -72,8 +72,9 @@
 	}
 	_fileStream->readUint16LE();	// flags
 	// Note: The normal delay is a 32-bit integer (dword), whereas the overriden delay is a 16-bit integer (word)
-	_videoInfo.frameDelay = _fileStream->readUint32LE() * 1000;	// "speed", in milliseconds
-	_videoInfo.frameRate = 1000 / _videoInfo.frameDelay;
+	// frameDelay is the FLIC "speed", in milliseconds. Our frameDelay is calculated in 1/100 ms, so we convert it here
+	_videoInfo.frameDelay = _fileStream->readUint32LE() / 100;
+	_videoInfo.frameRate = 100 * 1000 / _videoInfo.frameDelay;
 
 	_fileStream->seek(80);
 	_offsetFrame1 = _fileStream->readUint32LE();
@@ -206,10 +207,10 @@
 	case FRAME_TYPE: {
 		chunkCount = _fileStream->readUint16LE();
 		// Note: The overriden delay is a 16-bit integer (word), whereas the normal delay is a 32-bit integer (dword)
-		uint16 newFrameDelay = _fileStream->readUint16LE() * 1000;	// "speed", in milliseconds
+		uint16 newFrameDelay = _fileStream->readUint16LE() / 100;	// "speed", in milliseconds
 		if (newFrameDelay > 0) {
 			_videoInfo.frameDelay = newFrameDelay;
-			_videoInfo.frameRate = 1000 / _videoInfo.frameDelay;
+			_videoInfo.frameRate = 100 * 1000 / _videoInfo.frameDelay;
 		}
 		_fileStream->readUint16LE();	// reserved, always 0
 		uint16 newWidth = _fileStream->readUint16LE();
@@ -272,27 +273,27 @@
 	_fileStream->seek(_offsetFrame1);
 }
 
-void FlicDecoder::unpackPalette(uint8 *mem) {
-	uint16 numPackets = READ_LE_UINT16(mem); mem += 2;
+void FlicDecoder::unpackPalette(uint8 *data) {
+	uint16 numPackets = READ_LE_UINT16(data); data += 2;
 
-	if (0 == READ_LE_UINT16(mem)) { //special case
-		mem += 2;
+	if (0 == READ_LE_UINT16(data)) { //special case
+		data += 2;
 		for (int i = 0; i < 256; ++i) {
-			memcpy(_palette + i * 3, mem + i * 3, 3);
+			memcpy(_palette + i * 3, data + i * 3, 3);
 		}
 	} else {
 		uint8 palPos = 0;
 
 		while (numPackets--) {
-			palPos += *mem++;
-			uint8 change = *mem++;
+			palPos += *data++;
+			uint8 change = *data++;
 
 			for (int i = 0; i < change; ++i) {
-				memcpy(_palette + (palPos + i) * 3, mem + i * 3, 3);
+				memcpy(_palette + (palPos + i) * 3, data + i * 3, 3);
 			}
 
 			palPos += change;
-			mem += (change * 3);
+			data += (change * 3);
 		}
 	}
 }

Modified: scummvm/trunk/graphics/video/flic_player.h
===================================================================
--- scummvm/trunk/graphics/video/flic_player.h	2009-05-19 16:06:16 UTC (rev 40728)
+++ scummvm/trunk/graphics/video/flic_player.h	2009-05-19 17:39:03 UTC (rev 40729)
@@ -66,8 +66,7 @@
 	void clearDirtyRects() { _dirtyRects.clear(); }
 	void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
 
-	byte getPixel(int offset) { return _videoFrameBuffer[offset]; }
-	byte* getPalette() { _paletteChanged = false; return _palette; }
+	const byte *getPalette() { _paletteChanged = false; return _palette; }
 	bool paletteChanged() { return _paletteChanged; }
 	void reset();
 

Modified: scummvm/trunk/graphics/video/smk_player.h
===================================================================
--- scummvm/trunk/graphics/video/smk_player.h	2009-05-19 16:06:16 UTC (rev 40728)
+++ scummvm/trunk/graphics/video/smk_player.h	2009-05-19 17:39:03 UTC (rev 40729)
@@ -110,6 +110,7 @@
 	// (bit 0) is set, it denotes a frame that contains a palette record
 	byte *_frameTypes;
 	byte *_frameData;
+	// The RGB palette
 	byte *_palette;
 
 	Audio::Mixer *_mixer;

Modified: scummvm/trunk/graphics/video/video_player.h
===================================================================
--- scummvm/trunk/graphics/video/video_player.h	2009-05-19 16:06:16 UTC (rev 40728)
+++ scummvm/trunk/graphics/video/video_player.h	2009-05-19 17:39:03 UTC (rev 40729)
@@ -117,6 +117,23 @@
 	virtual void setPalette(byte *pal);
 
 	/**
+	 * Gets the value of the pixel at the specified x and y coordinates
+	 * Note: This method assumes that the video's pitch equals its width, and that
+	 * the video has an 8bpp palette
+	 * @param x	the x coordinate of the pixel
+	 * @param y	the y coordinate of the pixel
+	 */
+	byte getPixel(int x, int y) {
+		return *(_videoFrameBuffer + y * _videoInfo.width + x * 1);
+	}
+
+	/**
+	 * Gets the value of the pixel at the specified offset
+	 * @param offset	the offset of the pixel in the video buffer
+	 */
+	byte getPixel(int offset) { return getPixel(offset, 0); }
+
+	/**
 	 * Return the black palette color for the current frame
 	 */
 	byte getBlack() { return _curFrameBlack; }
@@ -153,7 +170,7 @@
 		uint32 height;
 		uint32 frameCount;
 		int32 frameRate;
-		int32 frameDelay;
+		int32 frameDelay;		// 1/100 ms
 		uint32 frameOffs;
 		uint32 currentFrame;
 		uint32 startTime;


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