[Scummvm-cvs-logs] CVS: scummvm/scumm/smush chunk_type.h,1.8,1.9 smush_player.cpp,1.117,1.118 smush_player.h,1.27,1.28

Pawel Kolodziejski aquadran at users.sourceforge.net
Tue Apr 13 12:35:14 CEST 2004


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11113

Modified Files:
	chunk_type.h smush_player.cpp smush_player.h 
Log Message:
added support for compressed FOBJ chunks in smush movie files.
the *.san files from 'data' dir in FT can NOT be compressed !

Index: chunk_type.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/chunk_type.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- chunk_type.h	6 Jan 2004 12:45:31 -0000	1.8
+++ chunk_type.h	13 Apr 2004 19:20:15 -0000	1.9
@@ -32,6 +32,7 @@
 static const Chunk::type TYPE_FRME = 'FRME';
 static const Chunk::type TYPE_NPAL = 'NPAL';
 static const Chunk::type TYPE_FOBJ = 'FOBJ';
+static const Chunk::type TYPE_ZFOB = 'ZFOB';
 static const Chunk::type TYPE_PSAD = 'PSAD';
 static const Chunk::type TYPE_TRES = 'TRES';
 static const Chunk::type TYPE_XPAL = 'XPAL';

Index: smush_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- smush_player.cpp	10 Apr 2004 09:17:35 -0000	1.117
+++ smush_player.cpp	13 Apr 2004 19:20:16 -0000	1.118
@@ -48,6 +48,10 @@
 #include <png.h>
 #endif
 
+#ifdef USE_ZLIB
+#include <zlib.h>
+#endif
+
 namespace Scumm {
 
 const int MAX_STRINGS = 200;
@@ -673,6 +677,78 @@
 
 void smush_decode_codec1(byte *dst, byte *src, int left, int top, int height, int width, int dstWidth);
 
+#ifdef USE_ZLIB
+void SmushPlayer::handleZlibFrameObject(Chunk &b) {
+	if (_skipNext) {
+		_skipNext = false;
+		return;
+	}
+
+	int32 chunkSize = b.getSize();
+	byte *chunkBuffer = (byte *)malloc(chunkSize);
+	assert(chunkBuffer);
+	b.read(chunkBuffer, chunkSize);
+
+	unsigned long decompressedSize = READ_BE_UINT32(chunkBuffer);
+	byte *fobjBuffer = (byte *)malloc(decompressedSize);
+	int result = uncompress(fobjBuffer, &decompressedSize, chunkBuffer + 4, chunkSize - 4);
+	if (result != Z_OK)
+		error("SmushPlayer::handleZlibFrameObject() Zlib uncompress error");
+	free(chunkBuffer);
+
+	byte *ptr = fobjBuffer;
+	int codec = READ_LE_UINT16(ptr); ptr += 2;
+	int left = READ_LE_UINT16(ptr); ptr += 2;
+	int top = READ_LE_UINT16(ptr); ptr += 2;
+	int width = READ_LE_UINT16(ptr); ptr += 2;
+	int height = READ_LE_UINT16(ptr); ptr += 2;
+
+	if ((height == 242) && (width == 384)) {
+		_dst = _specialBuffer = (byte *)malloc(242 * 384);
+	} else if ((height > _vm->_screenHeight) || (width > _vm->_screenWidth))
+		return;
+	// FT Insane uses smaller frames to draw overlays with moving objects
+	// Other .san files do have them as well but their purpose in unknown
+	// and often it causes memory overdraw. So just skip those frames
+	else if (!_insanity && ((height != _vm->_screenHeight) || (width != _vm->_screenWidth)))
+		return;
+
+	if (!_alreadyInit) {
+		_codec37.init(width, height);
+		_codec47.init(width, height);
+		_alreadyInit = true;
+	}
+
+	_width = width;
+	_height = height;
+
+	switch (codec) {
+	case 1:
+	case 3:
+		smush_decode_codec1(_dst, fobjBuffer + 14, left, top, height, width, _vm->_screenWidth);
+		break;
+	case 37:
+		_codec37.decode(_dst, fobjBuffer + 14);
+		break;
+	case 47:
+		_codec47.decode(_dst, fobjBuffer + 14);
+		break;
+	default:
+		error("Invalid codec for frame object : %d", (int)codec);
+	}
+
+	if (_storeFrame) {
+		if (_frameBuffer == NULL) {
+			_frameBuffer = (byte *)malloc(_width * _height);
+		}
+		memcpy(_frameBuffer, _dst, _width * _height);
+		_storeFrame = false;
+	}
+
+	free(fobjBuffer);
+}
+#endif
+
 void SmushPlayer::handleFrameObject(Chunk &b) {
 	checkBlock(b, TYPE_FOBJ, 14);
 	if (_skipNext) {
@@ -760,6 +836,11 @@
 		case TYPE_FOBJ:
 			handleFrameObject(*sub);
 			break;
+#ifdef USE_ZLIB
+		case TYPE_ZFOB:
+			handleZlibFrameObject(*sub);
+			break;
+#endif
 		case TYPE_PSAD:
 			handleSoundFrame(*sub);
 			break;

Index: smush_player.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- smush_player.h	10 Apr 2004 09:17:36 -0000	1.27
+++ smush_player.h	13 Apr 2004 19:20:16 -0000	1.28
@@ -100,6 +100,7 @@
 	void handleAnimHeader(Chunk &);
 	void handleFrame(Chunk &);
 	void handleNewPalette(Chunk &);
+	void handleZlibFrameObject(Chunk &b);
 	void handleFrameObject(Chunk &);
 	void handleSoundBuffer(int32, int32, int32, int32, int32, int32, Chunk &, int32);
 	void handleSoundFrame(Chunk &);





More information about the Scummvm-git-logs mailing list