[Scummvm-cvs-logs] CVS: tools extract-common.c,NONE,1.1 util.c,NONE,1.1 Makefile,1.22,1.23 extract.c,1.28,1.29 extract.h,1.2,1.3 simon2mp3.c,1.16,1.17 util.h,1.2,1.3

Max Horn fingolfin at users.sourceforge.net
Sun Nov 9 05:19:19 CET 2003


Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv8523

Modified Files:
	Makefile extract.c extract.h simon2mp3.c util.h 
Added Files:
	extract-common.c util.c 
Log Message:
more unification / cleanup

--- NEW FILE: extract-common.c ---
/* Scumm Tools
 * Copyright (C) 2003  The ScummVM Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/tools/extract-common.c,v 1.1 2003/11/09 13:17:54 fingolfin Exp $
 *
 */

#include "extract.h"

FILE *input, *output_idx, *output_snd;

lameparams encparms = { minBitrDef, maxBitrDef, abrDef, vbrDef, algqualDef, vbrqualDef, 0 };
oggencparams oggparms = { -1, -1, -1, oggqualDef, 0 };

int oggmode = 0;


int getSampleRateFromVOCRate(int vocSR) {
	if (vocSR == 0xa5 || vocSR == 0xa6 || vocSR == 0x83) {
		return 11025;
	} else if (vocSR == 0xd2 || vocSR == 0xd3) {
		return 22050;
	} else {
		int sr = 1000000L / (256L - vocSR);
		warning("inexact sample rate used: %i (0x%x)", sr, vocSR);
		return sr;
	}
}

void process_mp3_parms(int argc, char *argv[], int i) {
	for(; i < argc; i++) {
		if (strcmp(argv[i], "--vbr") == 0) {
			encparms.vbr=1;
			encparms.abr=0;
		} else if (strcmp(argv[i], "--abr") == 0) {
			encparms.vbr=0;
			encparms.abr=1;
		} else if (strcmp(argv[i], "-b") == 0) {
			encparms.minBitr = atoi(argv[i + 1]);
			if ((encparms.minBitr % 8) != 0)
				encparms.minBitr -= encparms.minBitr % 8;
			if (encparms.minBitr >160)
				encparms.minBitr = 160;
			if (encparms.minBitr < 8)
				encparms.minBitr=8;
			i++;
		} else if (strcmp(argv[i], "-B") == 0) {
			encparms.maxBitr = atoi(argv[i + 1]);
			if ((encparms.maxBitr % 8) != 0)
				encparms.maxBitr -= encparms.maxBitr % 8;
			if (encparms.maxBitr > 160)
				encparms.maxBitr = 160;
			if (encparms.maxBitr < 8)
				encparms.maxBitr = 8;
			i++;
		} else if (strcmp(argv[i], "-V") == 0) {
			encparms.vbrqual = atoi(argv[i + 1]);
			if(encparms.vbrqual < 0)
				encparms.vbrqual = 0;
			if(encparms.vbrqual > 9)
				encparms.vbrqual = 9;
			i++;
		} else if (strcmp(argv[i], "-q") == 0) {
			encparms.algqual = atoi(argv[i + 1]);
			if (encparms.algqual < 0)
				encparms.algqual = 0;
			if (encparms.algqual > 9)
				encparms.algqual = 9;
			i++;
		} else if (strcmp(argv[i], "--silent") == 0) {
			encparms.silent = 1;
		} else if (strcmp(argv[i], "--help") == 0) {
			showhelp(argv[0]);
		} else if (argv[i][0] == '-') {
			showhelp(argv[0]);
		} else {
			break;
		}
	}
	if (i != (argc - 1)) {
		showhelp(argv[0]);
	}
}

void process_ogg_parms(int argc, char *argv[], int i) {
	for (; i < argc; i++) {
		if (strcmp(argv[i], "-b") == 0) {
			oggparms.nominalBitr = atoi(argv[i + 1]);
			i++;
		}
		else if (strcmp(argv[i], "-m") == 0) {
			oggparms.minBitr = atoi(argv[i + 1]);
			i++;
		}
		else if (strcmp(argv[i], "-M") == 0) {
			oggparms.maxBitr = atoi(argv[i + 1]);
			i++;
		}
		else if (strcmp(argv[i], "-q") == 0) {
			oggparms.quality = atoi(argv[i + 1]);
			i++;
		}
		else if (strcmp(argv[i], "--silent") == 0) {
			oggparms.silent = 1;
		}
		else if (strcmp(argv[i], "--help") == 0) {
			showhelp(argv[0]);
		}
		else if (argv[i][0] == '-') {
			showhelp(argv[0]);
		}
		else
			break;
	}
	if (i != argc - 1)
		showhelp(argv[0]);
}


--- NEW FILE: util.c ---
/* Scumm Tools
 * Copyright (C) 2003  The ScummVM Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/tools/util.c,v 1.1 2003/11/09 13:17:54 fingolfin Exp $
 *
 */

#include "util.h"
#include <stdarg.h>

void error(const char *s, ...) {
	char buf[1024];
	va_list va;

	va_start(va, s);
	vsprintf(buf, s, va);
	va_end(va);

	fprintf(stderr, "ERROR: %s!\n", buf);

	exit(1);
}

void warning(const char *s, ...) {
	char buf[1024];
	va_list va;

	va_start(va, s);
	vsprintf(buf, s, va);
	va_end(va);

	fprintf(stderr, "WARNING: %s!\n", buf);
}


Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/tools/Makefile,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- Makefile	9 Nov 2003 13:08:02 -0000	1.22
+++ Makefile	9 Nov 2003 13:17:54 -0000	1.23
@@ -26,10 +26,10 @@
 
 all: $(TARGETS)
 
-descumm$(EXEEXT): descumm-tool.o descumm.o descumm6.o descumm-common.o
+descumm$(EXEEXT): descumm-tool.o descumm.o descumm6.o descumm-common.o util.o
 	$(CXX) $(LFLAGS) -o $@ $+
 
-extract$(EXEEXT): extract.o extract-common.o
+extract$(EXEEXT): extract.o extract-common.o util.o
 	$(CC) $(LFLAGS) -o $@ $+
 
 mm_nes_extract$(EXEEXT): mm_nes_extract.o
@@ -44,12 +44,13 @@
 simon1decr$(EXEEXT): simon1decr.o
 	$(CC) $(LFLAGS) -o $@ $+
 
-simon2mp3$(EXEEXT): simon2mp3.o extract-common.o
+simon2mp3$(EXEEXT): simon2mp3.o extract-common.o util.o
 	$(CC) $(LFLAGS) -o $@ $+
 
 
 descumm.o descumm6.o descumm-common.o descumm-tool.o: descumm.h util.h
 extract.o simon2mp3.o extract-common.o: util.h extract.h
+util.o: util.h
 
 clean:
 	rm -f *.o $(TARGETS)

Index: extract.c
===================================================================
RCS file: /cvsroot/scummvm/tools/extract.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- extract.c	9 Nov 2003 13:08:02 -0000	1.28
+++ extract.c	9 Nov 2003 13:17:54 -0000	1.29
@@ -187,12 +187,7 @@
 		sample_rate = fgetc(input);
 		comp = fgetc(input);
 
-		if (sample_rate == 0xa5 || sample_rate == 0xa6)
-			real_samplerate = 11025;
-		else if (sample_rate == 0xd2 || sample_rate == 0xd3)
-			real_samplerate = 22050;
-		else
-			real_samplerate = 1000000 / (256 - sample_rate);
+		real_samplerate = getSampleRateFromVOCRate(sample_rate);
 
 		printf(" - sample rate = %d (%02x)\n", real_samplerate, sample_rate);
 		printf(" - compression = %s (%02x)\n",

Index: extract.h
===================================================================
RCS file: /cvsroot/scummvm/tools/extract.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- extract.h	9 Nov 2003 13:08:02 -0000	1.2
+++ extract.h	9 Nov 2003 13:17:54 -0000	1.3
@@ -68,6 +68,8 @@
 extern void process_mp3_parms(int argc, char *argv[], int i);
 extern void process_ogg_parms(int argc, char *argv[], int i);
 
+extern int getSampleRateFromVOCRate(int vocSR);
+
 
 /*
  * Stuff which is in extract.c / simon2mp3.c

Index: simon2mp3.c
===================================================================
RCS file: /cvsroot/scummvm/tools/simon2mp3.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- simon2mp3.c	9 Nov 2003 13:08:02 -0000	1.16
+++ simon2mp3.c	9 Nov 2003 13:17:54 -0000	1.17
@@ -277,15 +277,8 @@
 		sample_rate = fgetc(input);
 		comp = fgetc(input);
 		
-        	/* workaround for voc weakness */
-        	if (sample_rate == 0xa6) {
-                	real_samplerate = 11025;
-        	} else if (sample_rate == 0xd2) {
-                	real_samplerate = 22050;
-        	} else {
-                	real_samplerate = 1000000 / (256 - sample_rate);
-        	}
-		
+		real_samplerate = getSampleRateFromVOCRate(sample_rate);
+	
 		printf(" - sample rate = %d (%02x)\n", real_samplerate, sample_rate);
 		printf(" - compression = %s (%02x)\n",
 		       (comp ==	   0 ? "8bits"   :

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/tools/util.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- util.h	9 Nov 2003 13:08:02 -0000	1.2
+++ util.h	9 Nov 2003 13:17:54 -0000	1.3
@@ -76,5 +76,15 @@
 
 #define MKID(a) (((a&0xff) << 8) | ((a >> 8)&0xff))
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+extern void error(const char *s, ...);
+extern void warning(const char *s, ...);
+
+#if defined(__cplusplus)
+}
+#endif
 
 #endif





More information about the Scummvm-git-logs mailing list