[Scummvm-cvs-logs] CVS: tools README,1.35,1.36 compress_san.cpp,1.33,1.34 compress_scumm_bun.cpp,1.16,1.17

Pawel Kolodziejski aquadran at users.sourceforge.net
Thu Jan 27 19:43:48 CET 2005


Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32136

Modified Files:
	README compress_san.cpp compress_scumm_bun.cpp 
Log Message:
added support for mp3 compression

Index: README
===================================================================
RCS file: /cvsroot/scummvm/tools/README,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- README	24 Jan 2005 22:26:29 -0000	1.35
+++ README	27 Jan 2005 23:59:00 -0000	1.36
@@ -57,7 +57,7 @@
                 than the original! This is because the original files already
                 use lossy compression.
 
-        compress_san <inputfile> <inputdir> <outputdir>
+        compress_san <inputfile> <inputdir> <outputdir> [--ogg]
                 Compresses '.san' smush animation files. It uses lossless
                 zlib for compressing FOBJ gfx chunks inside a san file.
                 It also can create a separate Ogg file with the audio track.
@@ -68,15 +68,19 @@
                 In order to use such compressed files, your ScummVM binary 
                 must have been built with zlib support enabled (you can find
                 out whether that's the case by looking at the About dialog).
-                For the Ogg compression feature, your ScummVM binary naturally
-                must have been built with Ogg support enabled.
+                For the Ogg or Mad compression feature, your ScummVM binary
+                naturally must have been built with Ogg or Mad support enabled.
+
+        compress_scumm_bun <inputfile> <inputdir> <outputdir> [--ogg]
 
-        compress_scumm_bun <inputfile> <inputdir> <outputdir>
                 Compresses '.bun' music/voice files.
 
                 Example of usage:
                 compress_scumm.bun digmusic.bun uncomp comp
 
+                For the Ogg or Mad compression feature, your ScummVM binary
+                naturally must have been built with Ogg or Mad support enabled.
+
 Script Tools:
         descumm
                 Decompiles SCUMM scripts

Index: compress_san.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/compress_san.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- compress_san.cpp	25 Jan 2005 23:05:56 -0000	1.33
+++ compress_san.cpp	27 Jan 2005 23:59:00 -0000	1.34
@@ -79,12 +79,26 @@
 static FILE *_waveTmpFile;
 static int32 _waveDataSize;
 static AudioTrackInfo _audioTracks[MAX_TRACKS];
+static bool _oggMode = false; // mp3 default
 
 void encodeWaveWithOgg(char *filename) {
 	char fbuf[2048];
 	bool err = false;
 
-	sprintf(fbuf, "oggenc -q 0 %s", filename);
+	sprintf(fbuf, "oggenc -q 0 %s.wav", filename);
+	err = system(fbuf) != 0;
+	if (err) {
+		printf("Got error from encoder. (check your parameters)\n");
+		printf("Encoder Commandline: %s\n", fbuf );
+		exit(-1);
+	}
+}
+
+void encodeWaveWithLame(char *filename) {
+	char fbuf[2048];
+	bool err = false;
+
+	sprintf(fbuf, "lame --vbr-new -V 9 -quiet -t \"%s\".wav \"%s\".mp3", filename, filename);
 	err = system(fbuf) != 0;
 	if (err) {
 		printf("Got error from encoder. (check your parameters)\n");
@@ -642,6 +656,10 @@
 	strcpy(inputDir, argv[2]);
 	strcpy(outputDir, argv[3]);
 
+	if ((argc == 5) && (strcmp(argv[4], "--ogg") == 0)) {
+		_oggMode = true;
+	}
+
 	char *index = strrchr(inputFilename, '.');
 	if (index != NULL) {
 		*index = 0;
@@ -810,8 +828,12 @@
 
 	if (_waveTmpFile) {
 		writeWaveHeader(_waveDataSize);
+		sprintf(tmpPath, "%s/%s", outputDir, inputFilename);
+		if (_oggMode)
+			encodeWaveWithOgg(tmpPath);
+		else
+			encodeWaveWithLame(tmpPath);
 		sprintf(tmpPath, "%s/%s.wav", outputDir, inputFilename);
-		encodeWaveWithOgg(tmpPath);
 		unlink(tmpPath);
 	}
 

Index: compress_scumm_bun.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/compress_scumm_bun.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- compress_scumm_bun.cpp	25 Jan 2005 20:00:37 -0000	1.16
+++ compress_scumm_bun.cpp	27 Jan 2005 23:59:00 -0000	1.17
@@ -675,7 +675,20 @@
 	char fbuf[2048];
 	bool err = false;
 
-	sprintf(fbuf, "oggenc -q 0 \"%s\"", filename);
+	sprintf(fbuf, "oggenc -q 0 %s.wav", filename);
+	err = system(fbuf) != 0;
+	if (err) {
+		printf("Got error from encoder. (check your parameters)\n");
+		printf("Encoder Commandline: %s\n", fbuf );
+		exit(-1);
+	}
+}
+
+void encodeWaveWithLame(char *filename) {
+	char fbuf[2048];
+	bool err = false;
+
+	sprintf(fbuf, "lame --vbr-new -V 9 -quiet -t \"%s\".wav \"%s\".mp3", filename, filename);
 	err = system(fbuf) != 0;
 	if (err) {
 		printf("Got error from encoder. (check your parameters)\n");
@@ -766,6 +779,8 @@
 	_waveDataSize += size;
 }
 
+static bool _oggMode = false; // mp3 default
+
 typedef struct { int offset, size, codec; } CompTable;
 
 byte *decompressBundleSound(int index, FILE *input, int32 &finalSize) {
@@ -968,21 +983,32 @@
 		writeWaveHeader(_waveDataSize);
 
 		free(outputData);
-		encodeWaveWithOgg(tmpPath);
+		sprintf(tmpPath, "%s/%s_reg%03d", dir, filename, l);
+		if (_oggMode)
+			encodeWaveWithOgg(tmpPath);
+		else
+			encodeWaveWithLame(tmpPath);
+		sprintf(tmpPath, "%s/%s_reg%03d.wav", dir, filename, l);
 		unlink(tmpPath);
 
 		int32 startPos = ftell(output);
-		sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.ogg", filename, l);
+		if (_oggMode)
+			sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.ogg", filename, l);
+		else
+			sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.mp3", filename, l);
 		cbundleTable[cbundleCurIndex].offset = startPos;
 
-		sprintf(tmpPath, "%s/%s_reg%03d.ogg", dir, filename, l);
-		FILE *oggFile = fopen(tmpPath, "rb");
-		fseek(oggFile, 0, SEEK_END);
-		size = ftell(oggFile);
-		fseek(oggFile, 0, SEEK_SET);
+		if (_oggMode)
+			sprintf(tmpPath, "%s/%s_reg%03d.ogg", dir, filename, l);
+		else
+			sprintf(tmpPath, "%s/%s_reg%03d.mp3", dir, filename, l);
+		FILE *cmpFile = fopen(tmpPath, "rb");
+		fseek(cmpFile, 0, SEEK_END);
+		size = ftell(cmpFile);
+		fseek(cmpFile, 0, SEEK_SET);
 		byte *tmpBuf = (byte *)malloc(size);
-		fread(tmpBuf, size, 1, oggFile);
-		fclose(oggFile);
+		fread(tmpBuf, size, 1, cmpFile);
+		fclose(cmpFile);
 		unlink(tmpPath);
 		fwrite(tmpBuf, size, 1, output);
 		free(tmpBuf);
@@ -1127,6 +1153,10 @@
 	strcpy(inputDir, argv[2]);
 	strcpy(outputDir, argv[3]);
 
+	if ((argc == 5) && (strcmp(argv[4], "--ogg") == 0)) {
+		_oggMode = true;
+	}
+
 	char *index = strrchr(inputFilename, '.');
 	if (index != NULL) {
 		*index = 0;





More information about the Scummvm-git-logs mailing list