diff -ur ScummVM-tools-cvs20050605/Makefile ScummVM-tools-cvs20050605+hack/Makefile
--- ScummVM-tools-cvs20050605/Makefile	2005-05-18 12:18:54.000000000 +0200
+++ ScummVM-tools-cvs20050605+hack/Makefile	2005-06-09 07:13:22.000000000 +0200
@@ -37,7 +37,7 @@
 
 all: $(TARGETS)
 
-compress_san$(EXEEXT): compress_san.o util.o
+compress_san$(EXEEXT): compress_san.o compress.o util.o
 	$(CXX) $(LDFLAGS) -o $@ $+ -lz
 
 descumm$(EXEEXT): descumm-tool.o descumm.o descumm6.o descumm-common.o util.o
@@ -55,7 +55,7 @@
 compress_scumm_sou$(EXEEXT): compress_scumm_sou.o compress.o util.o
 	$(CC) $(LDFLAGS) -o $@ $+
 
-compress_scumm_bun$(EXEEXT): compress_scumm_bun.o util.o
+compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o
 	$(CXX) $(LDFLAGS) -o $@ $+
 
 extract_loom_tg16$(EXEEXT): extract_loom_tg16.o
diff -ur ScummVM-tools-cvs20050605/compress.c ScummVM-tools-cvs20050605+hack/compress.c
--- ScummVM-tools-cvs20050605/compress.c	2005-02-07 14:38:52.000000000 +0100
+++ ScummVM-tools-cvs20050605+hack/compress.c	2005-06-09 07:34:46.000000000 +0200
@@ -290,7 +290,7 @@
 	encodeAudio(outName, true, real_samplerate, tempEncoded, compMode);
 }
 
-void process_mp3_parms(int argc, char *argv[], int i) {
+int process_mp3_parms(int argc, char *argv[], int i) {
 	for (; i < argc; i++) {
 		if (strcmp(argv[i], "--vbr") == 0) {
 			encparms.abr=0;
@@ -331,19 +331,20 @@
 		} else if (strcmp(argv[i], "--silent") == 0) {
 			encparms.silent = 1;
 		} else if (strcmp(argv[i], "--help") == 0) {
-			showhelp(argv[0]);
+			return 0;
 		} else if (argv[i][0] == '-') {
-			showhelp(argv[0]);
+			return 0;
 		} else {
 			break;
 		}
 	}
 	if (i != (argc - 1)) {
-		showhelp(argv[0]);
+		return 0;
 	}
+	return 1;
 }
 
-void process_ogg_parms(int argc, char *argv[], int i) {
+int 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]);
@@ -365,23 +366,24 @@
 			oggparms.silent = 1;
 		}
 		else if (strcmp(argv[i], "--help") == 0) {
-			showhelp(argv[0]);
+			return 0;
 		}
 		else if (argv[i][0] == '-') {
-			showhelp(argv[0]);
+			return 0;
 		}
 		else
 			break;
 	}
 	if (i != argc - 1)
-		showhelp(argv[0]);
+		return 0;
+	return 1;
 }
 
-void process_flac_parms(int argc, char *argv[], int i){
+int process_flac_parms(int argc, char *argv[], int i){
 	flacparms.argv = &argv[i];
 	flacparms.numArgs = argc - 1 - i;
 
 	if (i >= argc)
-		showhelp(argv[0]);
+		return 0;
+	return 1;
 }
-
diff -ur ScummVM-tools-cvs20050605/compress.h ScummVM-tools-cvs20050605+hack/compress.h
--- ScummVM-tools-cvs20050605/compress.h	2005-01-02 17:49:03.000000000 +0100
+++ ScummVM-tools-cvs20050605+hack/compress.h	2005-06-09 07:21:21.000000000 +0200
@@ -24,6 +24,9 @@
 
 #include "util.h"
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
 
 /* These are the defaults parameters for the Lame invocation */
 #define minBitrDef 24
@@ -48,19 +51,18 @@
 
 const extern char *tempEncoded;
 
-extern void process_mp3_parms(int argc, char *argv[], int i);
-extern void process_ogg_parms(int argc, char *argv[], int i);
-extern void process_flac_parms(int argc, char *argv[], int i);
+extern int process_mp3_parms(int argc, char *argv[], int i);
+extern int process_ogg_parms(int argc, char *argv[], int i);
+extern int process_flac_parms(int argc, char *argv[], int i);
 
 extern void extractAndEncodeVOC(const char *outName, FILE *input, CompressMode compMode);
 extern void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode);
 
 extern void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode);
 extern void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample);
-/*
- * Stuff which is in compress_scumm_sou.c / compress_simon.c / compress_sword2.c
- */
-extern void showhelp(char *exename);
 
+#if defined(__cplusplus)
+}
+#endif
 
 #endif
diff -ur ScummVM-tools-cvs20050605/compress_saga.c ScummVM-tools-cvs20050605+hack/compress_saga.c
--- ScummVM-tools-cvs20050605/compress_saga.c	2005-01-02 17:49:03.000000000 +0100
+++ ScummVM-tools-cvs20050605+hack/compress_saga.c	2005-06-09 07:24:54.000000000 +0200
@@ -221,15 +221,18 @@
 	switch (gCompMode) {
 	case kMP3Mode:
 		tempEncoded = TEMP_MP3;
-		process_mp3_parms(argc, argv, i);
+		if (!process_mp3_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kVorbisMode:
 		tempEncoded = TEMP_OGG;
-		process_ogg_parms(argc, argv, i);
+		if (!process_ogg_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kFlacMode:
 		tempEncoded = TEMP_FLAC;
-		process_flac_parms(argc, argv, i);
+		if (!process_flac_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	}
 
diff -ur ScummVM-tools-cvs20050605/compress_san.cpp ScummVM-tools-cvs20050605+hack/compress_san.cpp
--- ScummVM-tools-cvs20050605/compress_san.cpp	2005-06-05 20:39:05.000000000 +0200
+++ ScummVM-tools-cvs20050605+hack/compress_san.cpp	2005-06-09 07:38:21.000000000 +0200
@@ -19,7 +19,7 @@
  *
  */
 
-#include "util.h"
+#include "compress.h"
 #include "zlib.h"
 
 inline uint16 READ_LE_UINT16(const void *ptr) {
@@ -44,7 +44,7 @@
 }
 
 void showhelp(char *exename) {
-	printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg]\n", exename);
+	printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);
 	exit(2);
 }
 
@@ -85,28 +85,19 @@
 
 void encodeWaveWithOgg(char *filename) {
 	char fbuf[2048];
-	bool err = false;
-
-	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);
-	}
+	char fbuf2[2048];
+	sprintf(fbuf, "\"%s\".wav", filename);
+	sprintf(fbuf2, "\"%s\".ogg", filename);
+	encodeAudio(fbuf, false, -1, fbuf2, kVorbisMode);
 }
 
 void encodeWaveWithLame(char *filename) {
 	char fbuf[2048];
-	bool err = false;
+	char fbuf2[2048];
 
-	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");
-		printf("Encoder Commandline: %s\n", fbuf );
-		exit(-1);
-	}
+	sprintf(fbuf, "\"%s\".wav", filename);
+	sprintf(fbuf2, "\"%s\".mp3", filename);
+	encodeAudio(fbuf, false, -1, fbuf2, kMP3Mode);
 }
 
 void writeWaveHeader(int s_size) {
@@ -662,8 +653,38 @@
 	strcpy(inputDir, argv[2]);
 	strcpy(outputDir, argv[3]);
 
-	if ((argc == 5) && (strcmp(argv[4], "--ogg") == 0)) {
-		_oggMode = true;
+	if (argc > 4) {
+		int i = 4;
+
+		if (strcmp(argv[i], "--ogg") == 0) {
+			_oggMode = true;
+			i++;
+		}
+
+		if (argc > i) {
+			// HACK: The functions in compress.c expect the last
+			// argument to be a filename. As we don't expect one,
+			// we simply add a dummy argument to the list.
+			char **args = (char **)malloc((argc + 1) * sizeof(char *));
+			char dummyName[] = "dummy";
+			int j;
+
+			for (j = 0; j < argc; j++)
+				args[j] = argv[j];
+			args[j] = dummyName;
+		
+			int result;
+
+			if (_oggMode)
+				result = process_ogg_parms(argc + 1, args, i);
+			else
+				result = process_mp3_parms(argc + 1, args, i);
+
+			if (!result)
+				showhelp(argv[0]);
+
+			free(args);
+		}
 	}
 
 	char *index = strrchr(inputFilename, '.');
diff -ur ScummVM-tools-cvs20050605/compress_scumm_bun.cpp ScummVM-tools-cvs20050605+hack/compress_scumm_bun.cpp
--- ScummVM-tools-cvs20050605/compress_scumm_bun.cpp	2005-06-05 20:39:05.000000000 +0200
+++ ScummVM-tools-cvs20050605+hack/compress_scumm_bun.cpp	2005-06-09 07:38:30.000000000 +0200
@@ -19,7 +19,7 @@
  *
  */
 
-#include "util.h"
+#include "compress.h"
 
 inline uint16 READ_LE_UINT16(const void *ptr) {
 	const byte *b = (const byte *)ptr;
@@ -655,7 +655,7 @@
 }
 
 void showhelp(char *exename) {
-	printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg]\n", exename);
+	printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);
 	exit(2);
 }
 
@@ -673,28 +673,19 @@
 
 void encodeWaveWithOgg(char *filename) {
 	char fbuf[2048];
-	bool err = false;
-
-	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);
-	}
+	char fbuf2[2048];
+	sprintf(fbuf, "\"%s\".wav", filename);
+	sprintf(fbuf2, "\"%s\".ogg", filename);
+	encodeAudio(fbuf, false, -1, fbuf2, kVorbisMode);
 }
 
 void encodeWaveWithLame(char *filename) {
 	char fbuf[2048];
-	bool err = false;
+	char fbuf2[2048];
 
-	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");
-		printf("Encoder Commandline: %s\n", fbuf );
-		exit(-1);
-	}
+	sprintf(fbuf, "\"%s\".wav", filename);
+	sprintf(fbuf2, "\"%s\".wav", filename);
+	encodeAudio(fbuf, false, -1, fbuf2, kMP3Mode);
 }
 
 void writeWaveHeader(int s_size, int rate, int chan) {
@@ -1103,8 +1094,38 @@
 	strcpy(inputDir, argv[2]);
 	strcpy(outputDir, argv[3]);
 
-	if ((argc == 5) && (strcmp(argv[4], "--ogg") == 0)) {
-		_oggMode = true;
+	if (argc > 4) {
+		i = 4;
+
+		if (strcmp(argv[i], "--ogg") == 0) {
+			_oggMode = true;
+			i++;
+		}
+
+		if (argc > i) {
+			// HACK: The functions in compress.c expect the last
+			// argument to be a filename. As we don't expect one,
+			// we simply add a dummy argument to the list.
+			char **args = (char **)malloc((argc + 1) * sizeof(char *));
+			char dummyName[] = "dummy";
+			int j;
+
+			for (j = 0; j < argc; j++)
+				args[j] = argv[j];
+			args[j] = dummyName;
+		
+			int result;
+
+			if (_oggMode)
+				result = process_ogg_parms(argc + 1, args, i);
+			else
+				result = process_mp3_parms(argc + 1, args, i);
+
+			if (!result)
+				showhelp(argv[0]);
+
+			free(args);
+		}
 	}
 
 	char *index = strrchr(inputFilename, '.');
diff -ur ScummVM-tools-cvs20050605/compress_scumm_sou.c ScummVM-tools-cvs20050605+hack/compress_scumm_sou.c
--- ScummVM-tools-cvs20050605/compress_scumm_sou.c	2005-03-02 08:38:54.000000000 +0100
+++ ScummVM-tools-cvs20050605+hack/compress_scumm_sou.c	2005-06-09 07:25:29.000000000 +0200
@@ -206,17 +206,20 @@
 	case kMP3Mode:
 		outputName = OUTPUT_MP3;
 		tempEncoded = TEMP_MP3;
-		process_mp3_parms(argc, argv, i);
+		if (!process_mp3_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kVorbisMode:
 		outputName = OUTPUT_OGG;
 		tempEncoded = TEMP_OGG;
-		process_ogg_parms(argc, argv, i);
+		if (!process_ogg_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kFlacMode:
 		outputName = OUTPUT_FLAC;
 		tempEncoded = TEMP_FLAC;
-		process_flac_parms(argc, argv, i);
+		if (!process_flac_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	}
 
diff -ur ScummVM-tools-cvs20050605/compress_simon.c ScummVM-tools-cvs20050605+hack/compress_simon.c
--- ScummVM-tools-cvs20050605/compress_simon.c	2005-03-30 09:11:07.000000000 +0200
+++ ScummVM-tools-cvs20050605+hack/compress_simon.c	2005-06-09 07:26:02.000000000 +0200
@@ -332,15 +332,18 @@
 	switch (gCompMode) {
 	case kMP3Mode:
 		tempEncoded = TEMP_MP3;
-		process_mp3_parms(argc, argv, i);
+		if (!process_mp3_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kVorbisMode:
 		tempEncoded = TEMP_OGG;
-		process_ogg_parms(argc, argv, i);
+		if (!process_ogg_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kFlacMode:
 		tempEncoded = TEMP_FLAC;
-		process_flac_parms(argc, argv, i);
+		if (!process_flac_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	}
 
diff -ur ScummVM-tools-cvs20050605/compress_sword1.c ScummVM-tools-cvs20050605+hack/compress_sword1.c
--- ScummVM-tools-cvs20050605/compress_sword1.c	2005-02-07 14:38:52.000000000 +0100
+++ ScummVM-tools-cvs20050605+hack/compress_sword1.c	2005-06-09 07:28:12.000000000 +0200
@@ -527,17 +527,20 @@
 	/*       As we don't expect one, we simply add a dummy argument to the list. */
 	char **args;
 	int cnt;
+	int result;
 	char dummyName[] = "dummy";
 	args = (char **)malloc((argc + 1) * sizeof(char *));
 	for (cnt = 0; cnt < argc; cnt++)
 		args[cnt] = argv[cnt];
 	args[argc] = dummyName;
-    if (mode == kMP3Mode)
-		process_mp3_parms(argc + 1, args, i);
+	if (mode == kMP3Mode)
+		result = process_mp3_parms(argc + 1, args, i);
 	else if (mode == kVorbisMode)
-		process_ogg_parms(argc + 1, args, i);
+		result = process_ogg_parms(argc + 1, args, i);
 	else
 		error("Unknown encoding method");
+	if (!result)
+		showhelp(argv[0]);
 	free(args);
 }
 
diff -ur ScummVM-tools-cvs20050605/compress_sword2.c ScummVM-tools-cvs20050605+hack/compress_sword2.c
--- ScummVM-tools-cvs20050605/compress_sword2.c	2005-01-02 17:49:03.000000000 +0100
+++ ScummVM-tools-cvs20050605+hack/compress_sword2.c	2005-06-09 07:27:41.000000000 +0200
@@ -122,15 +122,18 @@
 	switch (gCompMode) {
 	case kMP3Mode:
 		tempEncoded = TEMP_MP3;
-		process_mp3_parms(argc, argv, i);
+		if (!process_mp3_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kVorbisMode:
 		tempEncoded = TEMP_OGG;
-		process_ogg_parms(argc, argv, i);
+		if (!process_ogg_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	case kFlacMode:
 		tempEncoded = TEMP_FLAC;
-		process_flac_parms(argc, argv, i);
+		if (!process_flac_parms(argc, argv, i))
+			showhelp(argv[0]);
 		break;
 	}
 
