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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Sat Nov 13 20:15:31 CET 2010


Revision: 54231
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54231&view=rev
Author:   mthreepwood
Date:     2010-11-13 19:15:31 +0000 (Sat, 13 Nov 2010)

Log Message:
-----------
VIDEO: Switch Truemotion 1 to RGB565 for potential use with SCI CLUT tables

Modified Paths:
--------------
    scummvm/trunk/graphics/video/codecs/truemotion1.cpp
    scummvm/trunk/graphics/video/codecs/truemotion1.h

Modified: scummvm/trunk/graphics/video/codecs/truemotion1.cpp
===================================================================
--- scummvm/trunk/graphics/video/codecs/truemotion1.cpp	2010-11-13 14:46:27 UTC (rev 54230)
+++ scummvm/trunk/graphics/video/codecs/truemotion1.cpp	2010-11-13 19:15:31 UTC (rev 54231)
@@ -123,42 +123,40 @@
 	}
 }
 
-int TrueMotion1Decoder::makeYdt15Entry(int p1, int p2) {
+int TrueMotion1Decoder::makeYdt16Entry(int p1, int p2) {
 #ifdef SCUMM_BIG_ENDIAN
 	// Swap the values on BE systems. FFmpeg does this too.
 	SWAP<int>(p1, p2);
 #endif
 
 	int lo = _ydt[p1];
-	lo += (lo << 5) + (lo << 10);
+	lo += (lo << 6) + (lo << 11);
 	int hi = _ydt[p2];
-	hi += (hi << 5) + (hi << 10);
-	return (lo + (hi << 16)) << 1;
+	hi += (hi << 6) + (hi << 11);
+	return lo + (hi << 16);
 }
 
-int TrueMotion1Decoder::makeCdt15Entry(int p1, int p2) {
-#ifdef SCUMM_BIG_ENDIAN
-	// Swap the values on BE systems. FFmpeg does this too.
-	SWAP<int>(p1, p2);
-#endif
-
+int TrueMotion1Decoder::makeCdt16Entry(int p1, int p2) {
 	int b = _cdt[p2];
-	int r = _cdt[p1] << 10;
+	int r = _cdt[p1] << 11;
 	int lo = b + r;
-	return (lo + (lo << 16)) << 1;
+	return lo + (lo << 16);
 }
 
-void TrueMotion1Decoder::genVectorTable15(const byte *selVectorTable) {
+void TrueMotion1Decoder::genVectorTable16(const byte *selVectorTable) {
+	memset(&_yPredictorTable, 0, sizeof(PredictorTableEntry) * 1024);
+	memset(&_cPredictorTable, 0, sizeof(PredictorTableEntry) * 1024);
+
 	for (int i = 0; i < 1024; i += 4) {
 		int len = *selVectorTable++ / 2;
 		for (int j = 0; j < len; j++) {
 			byte deltaPair = *selVectorTable++;
-			_yPredictorTable[i + j] = 0xfffffffe & makeYdt15Entry(deltaPair >> 4, deltaPair & 0xf);
-			_cPredictorTable[i + j] = 0xfffffffe & makeCdt15Entry(deltaPair >> 4, deltaPair & 0xf);
+			_yPredictorTable[i + j].color = makeYdt16Entry(deltaPair >> 4, deltaPair & 0xf);
+			_cPredictorTable[i + j].color = makeCdt16Entry(deltaPair >> 4, deltaPair & 0xf);
 		}
 
-		_yPredictorTable[i + (len - 1)] |= 1;
-		_cPredictorTable[i + (len - 1)] |= 1;
+		_yPredictorTable[i + (len - 1)].getNextIndex = true;
+		_cPredictorTable[i + (len - 1)].getNextIndex = true;
 	}
 }
 
@@ -229,7 +227,7 @@
 		error("Invalid vector table id %d", _header.vectable);
 
 	if (_header.deltaset != _lastDeltaset || _header.vectable != _lastVectable)
-		genVectorTable15(selVectorTable);
+		genVectorTable16(selVectorTable);
 
 	// set up pointers to the other key data chunks
 	_mbChangeBits = _buf + _header.headerSize;
@@ -259,15 +257,15 @@
 } while (0) \
 
 #define APPLY_C_PREDICTOR() \
-	predictor_pair = _cPredictorTable[index]; \
-	horizPred += (predictor_pair >> 1); \
-	if (predictor_pair & 1) { \
+	predictor_pair = _cPredictorTable[index].color; \
+	horizPred += predictor_pair; \
+	if (_cPredictorTable[index].getNextIndex) { \
 		GET_NEXT_INDEX(); \
 		if (!index) { \
 			GET_NEXT_INDEX(); \
-			predictor_pair = _cPredictorTable[index]; \
-			horizPred += ((predictor_pair >> 1) * 5); \
-			if (predictor_pair & 1) \
+			predictor_pair = _cPredictorTable[index].color; \
+			horizPred += predictor_pair * 5; \
+			if (_cPredictorTable[index].getNextIndex) \
 				GET_NEXT_INDEX(); \
 			else \
 				index++; \
@@ -276,15 +274,15 @@
 		index++
 
 #define APPLY_Y_PREDICTOR() \
-	predictor_pair = _yPredictorTable[index]; \
-	horizPred += (predictor_pair >> 1); \
-	if (predictor_pair & 1) { \
+	predictor_pair = _yPredictorTable[index].color; \
+	horizPred += predictor_pair; \
+	if (_yPredictorTable[index].getNextIndex) { \
 		GET_NEXT_INDEX(); \
 		if (!index) { \
 			GET_NEXT_INDEX(); \
-			predictor_pair = _yPredictorTable[index]; \
-			horizPred += ((predictor_pair >> 1) * 5); \
-			if (predictor_pair & 1) \
+			predictor_pair = _yPredictorTable[index].color; \
+			horizPred += predictor_pair * 5; \
+			if (_yPredictorTable[index].getNextIndex) \
 				GET_NEXT_INDEX(); \
 			else \
 				index++; \

Modified: scummvm/trunk/graphics/video/codecs/truemotion1.h
===================================================================
--- scummvm/trunk/graphics/video/codecs/truemotion1.h	2010-11-13 14:46:27 UTC (rev 54230)
+++ scummvm/trunk/graphics/video/codecs/truemotion1.h	2010-11-13 19:15:31 UTC (rev 54231)
@@ -42,8 +42,8 @@
 
 	Surface *decodeImage(Common::SeekableReadStream *stream);
 
-	// Always return RGB555
-	PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); }
+	// Always return RGB565
+	PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); }
 
 private:
 	Surface *_surface;
@@ -54,11 +54,14 @@
 
 	uint16 _width, _height;
 	int _flags;
+	
+	struct PredictorTableEntry {
+		uint32 color;
+		bool getNextIndex;
+	};
 
-	uint32 _yPredictorTable[1024];
-	uint32 _cPredictorTable[1024];
-	uint32 _fatYPredictorTable[1024];
-	uint32 _fatCPredictorTable[1024];
+	PredictorTableEntry _yPredictorTable[1024];
+	PredictorTableEntry _cPredictorTable[1024];
 
 	int _blockType;
 	int _blockWidth;
@@ -92,9 +95,9 @@
 	void selectDeltaTables(int deltaTableIndex);
 	void decodeHeader(Common::SeekableReadStream *stream);
 	void decode16();
-	int makeYdt15Entry(int p1, int p2);
-	int makeCdt15Entry(int p1, int p2);
-	void genVectorTable15(const byte *selVectorTable);
+	int makeYdt16Entry(int p1, int p2);
+	int makeCdt16Entry(int p1, int p2);
+	void genVectorTable16(const byte *selVectorTable);
 };
 
 } // End of namespace Graphics


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