[Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse_bndmgr.h,1.22,1.23 dimuse_codecs.cpp,1.18,1.19 dimuse_sndmgr.cpp,1.80,1.81

Max Horn fingolfin at users.sourceforge.net
Fri Dec 9 15:08:02 CET 2005


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

Modified Files:
	dimuse_bndmgr.h dimuse_codecs.cpp dimuse_sndmgr.cpp 
Log Message:
Simplified COMI IMA codec (resulting code needs less memory and should be faster on modern CPUs)

Index: dimuse_bndmgr.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_bndmgr.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- dimuse_bndmgr.h	26 Oct 2005 21:17:55 -0000	1.22
+++ dimuse_bndmgr.h	9 Dec 2005 23:07:20 -0000	1.23
@@ -105,9 +105,6 @@
 
 uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size);
 void initializeImcTables();
-#ifdef PALMOS_68K
-void releaseImcTables();
-#endif
 int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 input_size);
 
 } // End of namespace BundleCodecs

Index: dimuse_codecs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_codecs.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dimuse_codecs.cpp	9 Dec 2005 22:04:28 -0000	1.18
+++ dimuse_codecs.cpp	9 Dec 2005 23:07:20 -0000	1.19
@@ -54,15 +54,11 @@
  * varies the size of each "packet" between 2 and 7 bits.
  */
 
-#ifdef PALMOS_68K
-static byte *_destImcTable = NULL;		// save 23k of memory !
-static uint32 *_destImcTable2 = NULL;
+static byte _imcTableEntryBitCount[89];
 
+#ifdef PALMOS_68K
 static const int16 *imcTable;
 #else
-static byte _destImcTable[89];
-static uint32 _destImcTable2[89 * 64];
-
 static const int16 imcTable[89] = {
 		7,	  8,	9,	 10,   11,	 12,   13,	 14,
 	   16,	 17,   19,	 21,   23,	 25,   28,	 31,
@@ -119,53 +115,26 @@
 	}
 };
 
-#ifdef PALMOS_68K
-void releaseImcTables() {
-	free(_destImcTable);
-	free(_destImcTable2);
-}
-#endif
-
 void initializeImcTables() {
 	int pos;
 
-#ifdef PALMOS_68K
-	if (!_destImcTable) _destImcTable = (byte *)calloc(89, sizeof(byte));
-	if (!_destImcTable2) _destImcTable2 = (uint32 *)calloc(89 * 64, sizeof(uint32));
-#endif
-
-	for (pos = 0; pos <= 88; ++pos) {
-		byte put = 1;
+	for (pos = 0; pos < ARRAYSIZE(imcTable); ++pos) {
+		byte put = 0;
 		int32 tableValue = ((imcTable[pos] * 4) / 7) / 2;
 		while (tableValue != 0) {
 			tableValue /= 2;
 			put++;
 		}
-		if (put < 3) {
-			put = 3;
-		}
-		if (put > 8) {
-			put = 8;
+		if (put < 2) {
+			put = 2;
 		}
-		_destImcTable[pos] = put - 1;
-	}
-
-	for (int n = 0; n < 64; n++) {
-		for (pos = 0; pos <= 88; ++pos) {
-			int32 count = 32;
-			int32 put = 0;
-			int32 tableValue = imcTable[pos];
-	 		do {
-				if ((count & n) != 0) {
-					put += tableValue;
-				}
-				count /= 2;
-				tableValue /= 2;
-			} while (count != 0);
-			_destImcTable2[n + pos * 64] = put;
+		if (put > 7) {
+			put = 7;
 		}
+		_imcTableEntryBitCount[pos] = put;
 	}
 }
+
 #define NextBit                            \
 	do {                                   \
 		bit = mask & 1;                    \
@@ -613,7 +582,7 @@
 										: outputSamplesLeft / 2);
 				for (i = 0; i < bound; ++i) {
 					// Determine the size (in bits) of the next data packet
-					const int32 curTableEntryBitCount = _destImcTable[curTablePos];
+					const int32 curTableEntryBitCount = _imcTableEntryBitCount[curTablePos];
 					assert(2 <= curTableEntryBitCount && curTableEntryBitCount <= 7);
 
 					// Read the next data packet
@@ -629,9 +598,7 @@
 					const byte dataBitMask = (signBitMask - 1);
 					const byte data = (packet & dataBitMask);
 
-					const int32 tmpA = (data << (7 - curTableEntryBitCount));
-					const int32 imcTableEntry = imcTable[curTablePos] >> (curTableEntryBitCount - 1);
-					int32 delta = imcTableEntry + _destImcTable2[tmpA + (curTablePos * 64)];
+					int32 delta = imcTable[curTablePos] * (2 * data + 1) >> (curTableEntryBitCount - 1);
 
 					// The topmost bit in the data packet tells is a sign bit
 					if ((packet & signBitMask) != 0) {

Index: dimuse_sndmgr.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_sndmgr.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- dimuse_sndmgr.cpp	26 Oct 2005 21:17:55 -0000	1.80
+++ dimuse_sndmgr.cpp	9 Dec 2005 23:07:20 -0000	1.81
@@ -48,9 +48,6 @@
 	for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) {
 		closeSound(&_sounds[l]);
 	}
-#ifdef PALMOS_68K
-	BundleCodecs::releaseImcTables();
-#endif
 }
 
 void ImuseDigiSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps, int &numSyncs) {





More information about the Scummvm-git-logs mailing list