[Scummvm-cvs-logs] CVS: tools compress_scumm_bun.cpp,1.4,1.5
Pawel Kolodziejski
aquadran at users.sourceforge.net
Sun Jan 23 10:41:05 CET 2005
Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28699
Modified Files:
compress_scumm_bun.cpp
Log Message:
updated
Index: compress_scumm_bun.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/compress_scumm_bun.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- compress_scumm_bun.cpp 23 Jan 2005 18:26:28 -0000 1.4
+++ compress_scumm_bun.cpp 23 Jan 2005 18:40:32 -0000 1.5
@@ -820,14 +820,83 @@
return compFinal;
}
-byte *convertTo16bitStereo(byte *ptr, int size, int bits, int freq, int channels) {
+byte *convertTo16bitStereo(byte *ptr, int inputSize, int &outputSize, int bits, int freq, int channels) {
+ outputSize = inputSize;
+ if (bits == 8)
+ outputSize *= 2;
+ if (bits == 12)
+ outputSize = (outputSize / 3) * 4;
+ if (channels == 1)
+ outputSize *= 2;
+ if (freq == 11025)
+ outputSize *= 2;
-// char tmpPath[200];
-// sprintf(tmpPath, "%s/%s.wav", outputDir, bundleTable[h].filename);
-// writeToTempWave(tmpPath, outputData, size);
-// fclose(_waveTmpFile);
+ byte *outputBuf = (byte *)malloc(outputSize);
+ if (bits == 8) {
+ byte *buf = outputBuf;
+ byte *src = ptr;
+ for (int i = 0; i < inputSize; i++) {
+ uint16 val = (*src++ - 0x80) << 8;
+ *buf++ = (byte)val;
+ *buf++ = (byte)(val >> 8);
+ if (freq == 11025) {
+ *buf++ = (byte)val;
+ *buf++ = (byte)(val >> 8);
+ }
+ if (channels == 1) {
+ *buf++ = (byte)val;
+ *buf++ = (byte)(val >> 8);
+ if (freq == 11025) {
+ *buf++ = (byte)val;
+ *buf++ = (byte)(val >> 8);
+ }
+ }
+ }
+ }
+ if (bits == 12) {
+ int loop_size = inputSize / 3;
+ byte *decoded = outputBuf;
+ byte *source = ptr;
+ uint32 value;
- return NULL;
+ while (loop_size--) {
+ byte v1 = *source++;
+ byte v2 = *source++;
+ byte v3 = *source++;
+ value = ((((v2 & 0x0f) << 8) | v1) << 4) - 0x8000;
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ if (freq == 11025) {
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ }
+ if (channels == 1) {
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ if (freq == 11025) {
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ }
+ }
+ value = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ if (freq == 11025) {
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ }
+ if (channels == 1) {
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ if (freq == 11025) {
+ *decoded++ = (byte)(value & 0xff);
+ *decoded++ = (byte)((value >> 8) & 0xff);
+ }
+ }
+ }
+ }
+
+ return outputBuf;
}
void countMapElements(byte *ptr, int &numRegions, int &numJumps, int &numSyncs) {
@@ -1028,12 +1097,17 @@
bundleTable[i].size = readUint32BE(input);
}
- int32 size = 0;
for (int h = 0; h < numFiles; h++) {
+ int offsetData = 0, bits = 0, freq = 0, channels = 0, size = 0, outputSize = 0;
byte *compFinal = decompressBundleSound(h, input, size);
- int offsetData = 0, bits = 0, freq = 0, channels = 0;
writeToRMAPFile(compFinal, outputDir, bundleTable[h].filename, offsetData, bits, freq, channels);
- byte *outputData = convertTo16bitStereo(compFinal + offsetData, size - offsetData, bits, freq, channels);
+ byte *outputData = convertTo16bitStereo(compFinal + offsetData, size - offsetData, outputSize, bits, freq, channels);
+
+ char tmp2Path[200];
+ sprintf(tmp2Path, "%s/%s.wav", outputDir, bundleTable[h].filename);
+ writeToTempWave(tmp2Path, outputData, outputSize);
+ fclose(_waveTmpFile);
+
free(compFinal);
}
More information about the Scummvm-git-logs
mailing list