[Scummvm-cvs-logs] SF.net SVN: scummvm: [22232] tools/trunk/encode_dxa.cpp

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Apr 29 16:10:03 CEST 2006


Revision: 22232
Author:   sev
Date:     2006-04-29 16:09:20 -0700 (Sat, 29 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22232&view=rev

Log Message:
-----------
Always use smallest result giving method for DXA compression. This gives
big size gain.

Modified Paths:
--------------
    tools/trunk/encode_dxa.cpp
Modified: tools/trunk/encode_dxa.cpp
===================================================================
--- tools/trunk/encode_dxa.cpp	2006-04-29 22:33:31 UTC (rev 22231)
+++ tools/trunk/encode_dxa.cpp	2006-04-29 23:09:20 UTC (rev 22232)
@@ -186,9 +186,6 @@
 #ifdef USE_ZMBV
 		compType = 10;
 #endif
-
-		writeByte(_dxa, compType);
-
 		switch (compType) {
 		case 2:
 			{
@@ -197,6 +194,8 @@
 
 				compress2(outbuf, &outsize, frame, _width * _height, 9);
 
+				writeByte(_dxa, compType);
+
 				writeUint32BE(_dxa, outsize);
 
 				fwrite(outbuf, outsize, 1, _dxa);
@@ -207,20 +206,38 @@
 			}
 		case 3:
 			{
-				uLong outsize = _width * _height;
-				uint8 *outbuf = new uint8[outsize];
+				uLong outsize1 = _width * _height;
+				uLong outsize2 = outsize1;
+				uLong outsize;
+				uint8 *outbuf;
+				uint8 *outbuf1 = new uint8[outsize1];
+				uint8 *outbuf2 = new uint8[outsize2];
 				uint8 *xorbuf = new uint8[_width * _height];
 
 				for (int i = 0; i < _width * _height; i++)
 					xorbuf[i] = _prevframe[i] ^ frame[i];
 
-				compress2(outbuf, &outsize, xorbuf, _width * _height, 9);
+				compress2(outbuf1, &outsize1, xorbuf, _width * _height, 9);
+				compress2(outbuf2, &outsize2, frame, _width * _height, 9);
 
+				if (outsize1 < outsize2) {
+					compType = 3;
+					outsize = outsize1;
+					outbuf = outbuf1;
+				} else {
+					compType = 2;
+					outsize = outsize2;
+					outbuf = outbuf2;
+				}
+
+				writeByte(_dxa, compType);
+
 				writeUint32BE(_dxa, outsize);
 
 				fwrite(outbuf, outsize, 1, _dxa);
 
-				delete[] outbuf;
+				delete[] outbuf1;
+				delete[] outbuf2;
 				delete[] xorbuf;
 
 				break;
@@ -236,6 +253,8 @@
 					_codec->CompressLines(1, &ptr);
 				}
 				outsize = _codec->FinishCompressFrame();
+
+				writeByte(_dxa, compType);
 				writeUint32BE(_dxa, outsize);
 				fwrite(_codecBuf, outsize, 1, _dxa);
 				break;


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