[Scummvm-cvs-logs] SF.net SVN: scummvm: [27911] tools/branches/gsoc2007-toolsgui

lightcast at users.sourceforge.net lightcast at users.sourceforge.net
Thu Jul 5 01:05:29 CEST 2007


Revision: 27911
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27911&view=rev
Author:   lightcast
Date:     2007-07-04 16:05:29 -0700 (Wed, 04 Jul 2007)

Log Message:
-----------
Modified the command line arguments to be more consistent with the rest of the compression tools.

Modified Paths:
--------------
    tools/branches/gsoc2007-toolsgui/compress_kyra.cpp
    tools/branches/gsoc2007-toolsgui/compress_scumm_bun.cpp
    tools/branches/gsoc2007-toolsgui/compress_scumm_san.cpp

Modified: tools/branches/gsoc2007-toolsgui/compress_kyra.cpp
===================================================================
--- tools/branches/gsoc2007-toolsgui/compress_kyra.cpp	2007-07-04 23:04:49 UTC (rev 27910)
+++ tools/branches/gsoc2007-toolsgui/compress_kyra.cpp	2007-07-04 23:05:29 UTC (rev 27911)
@@ -39,10 +39,14 @@
 	if (argc < 3)
 		showhelp(argv[0]);
 
+	char inputFile[256];
+	char outputFile[256];
 	int i = 0;
+
 	/* Compression mode */
 	gCompMode = kMP3Mode;
 	i = 1;
+
 	if (strcmp(argv[1], "--mp3") == 0) {
 		gCompMode = kMP3Mode;
 		i++;
@@ -60,31 +64,34 @@
 	case kMP3Mode:
 		outputExt = OUTPUT_MP3;
 		tempEncoded = TEMP_MP3;
-		if (!process_mp3_parms(argc - 1, argv, i))
+		if (!process_mp3_parms(argc - 2, argv, i))
 			showhelp(argv[0]);
 		break;
 	case kVorbisMode:
 		outputExt = OUTPUT_OGG;
 		tempEncoded = TEMP_OGG;
-		if (!process_ogg_parms(argc - 1, argv, i))
+		if (!process_ogg_parms(argc - 2, argv, i))
 			showhelp(argv[0]);
 		break;
 	case kFlacMode:
 		outputExt = OUTPUT_FLAC;
 		tempEncoded = TEMP_FLAC;
-		if (!process_flac_parms(argc - 1, argv, i))
+		if (!process_flac_parms(argc - 2, argv, i))
 			showhelp(argv[0]);
 		break;
 	}
-	
-	if (scumm_stricmp(argv[argc - 2], argv[argc - 1]) == 0)
+
+	sprintf(inputFile, "%s/%s", argv[argc - 2], argv[argc - 3]);
+	sprintf(outputFile, "%s/%s", argv[argc - 1], argv[argc - 3]);
+
+	if (scumm_stricmp(inputFile, outputFile) == 0)
 		error("infile and outfile are the same file");
-	process(argv[argc - 2], argv[argc - 1]);
+	process(inputFile, outputFile);
 	return 0;
 }
 
 static void showhelp(const char *exename) {
-	printf("\nUsage: %s <params> infile outfile\n", exename);
+	printf("\nUsage: %s [params] <inputfile> <inputdir> <outputdir>\n", exename);
 
 	printf("\nParams:\n");
 	printf(" --mp3        encode to MP3 format (default)\n");
@@ -109,8 +116,12 @@
 	printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
 
 	printf("\nFlac mode params:\n");
-	printf(" [params]     optional arguments passed directly to the encoder\n");
-	printf("              recommended is: --best -b 1152\n");
+ 	printf(" --fast       FLAC uses compresion level 0\n");
+ 	printf(" --best       FLAC uses compresion level 8\n");
+ 	printf(" -<value>     specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef);
+ 	printf(" -b <value>   specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef);
+	printf(" --verify     files are encoded and then decoded to check accuracy\n");
+	printf(" --silent     the output of FLAC is hidden (default:disabled)\n");
 
 	printf("\n --help     this help message\n");
 
@@ -136,7 +147,7 @@
 		return;
 	if (!output.loadFile(0, false))
 		return;
-		
+
 	PAKFile::cFileList *list = input.getFileList();
 	char outputName[32];
 	for (; list; list = list->next) {
@@ -150,22 +161,22 @@
 
 		input.outputFileAs(list->filename, TEMPFILE);
 		strncpy(outputName, list->filename, 32);
-		
+
 		FILE *tempFile = fopen(TEMPFILE, "rb");
 		fseek(tempFile, 26, SEEK_CUR);
 		extractAndEncodeVOC(TEMP_RAW, tempFile, gCompMode);
 		fclose(tempFile);
-		
+
 		char *vocStart = strstr(outputName, ".VOC");
 		for (unsigned int i = 0; i < strlen(outputExt); ++i)
 			vocStart[i] = outputExt[i];
 		output.addFile(outputName, tempEncoded);
-		
+
 		unlink(TEMPFILE);
 		unlink(TEMP_RAW);
 		unlink(tempEncoded);
 	}
-	
+
 	if (output.getFileList()) {
 		output.saveFile(outfile);
 	} else {

Modified: tools/branches/gsoc2007-toolsgui/compress_scumm_bun.cpp
===================================================================
--- tools/branches/gsoc2007-toolsgui/compress_scumm_bun.cpp	2007-07-04 23:04:49 UTC (rev 27910)
+++ tools/branches/gsoc2007-toolsgui/compress_scumm_bun.cpp	2007-07-04 23:05:29 UTC (rev 27911)
@@ -614,7 +614,7 @@
 }
 
 void showhelp(char *exename) {
-	printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);
+	printf("\nUsage: %s [--vorbis] [params] <inputfile> <inputdir> <outputdir>\n", exename);
 	printf("\nMP3 mode params:\n");
 	printf(" -b <rate>    <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
 	printf(" -B <rate>    <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
@@ -1064,42 +1064,26 @@
 	uint32 tag;
 	int32 numFiles, offset, i;
 
-	strcpy(inputFilename, argv[1]);
-	strcpy(inputDir, argv[2]);
-	strcpy(outputDir, argv[3]);
+	strcpy(inputFilename, argv[argc - 3]);
+	strcpy(inputDir, argv[argc - 2]);
+	strcpy(outputDir, argv[argc - 1]);
 
 	if (argc > 4) {
-		i = 4;
+		int result;
+		i = 1;
 
-		if (strcmp(argv[i], "--ogg") == 0) {
+		if (strcmp(argv[i], "--vorbis") == 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;
+		if (_oggMode)
+			result = process_ogg_parms(argc - 2, argv, i);
+		else
+			result = process_mp3_parms(argc - 2, argv, i);
 
-			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);
-		}
+		if (!result)
+			showhelp(argv[0]);
 	}
 
 	char *index = strrchr(inputFilename, '.');
@@ -1141,7 +1125,7 @@
 		char filename[13], c;
 		int z = 0;
 		int z2;
-			
+
 		for (z2 = 0; z2 < 8; z2++)
 			if ((c = readByte(input)) != 0)
 				filename[z++] = c;
@@ -1181,6 +1165,6 @@
 	fclose(input);
 
 	printf("compression done.\n");
-		
+
 	return 0;
 }

Modified: tools/branches/gsoc2007-toolsgui/compress_scumm_san.cpp
===================================================================
--- tools/branches/gsoc2007-toolsgui/compress_scumm_san.cpp	2007-07-04 23:04:49 UTC (rev 27910)
+++ tools/branches/gsoc2007-toolsgui/compress_scumm_san.cpp	2007-07-04 23:05:29 UTC (rev 27911)
@@ -24,7 +24,7 @@
 #include "zlib.h"
 
 void showhelp(char *exename) {
-	printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);
+	printf("\nUsage: %s [--vorbis] [encoder params] <inputfile> <inputdir> <outputdir>\n", exename);
 	printf("\nMP3 mode params:\n");
 	printf(" -b <rate>    <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
 	printf(" -B <rate>    <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
@@ -643,42 +643,27 @@
 	char inputFilename[200];
 	char tmpPath[200];
 
-	strcpy(inputFilename, argv[1]);
-	strcpy(inputDir, argv[2]);
-	strcpy(outputDir, argv[3]);
+	strcpy(inputFilename, argv[argc - 3]);
+	strcpy(inputDir, argv[argc - 2]);
+	strcpy(outputDir, argv[argc - 1]);
 
 	if (argc > 4) {
-		int i = 4;
+		int result;
+		int i = 1;
 
-		if (strcmp(argv[i], "--ogg") == 0) {
+		if (strcmp(argv[1], "--vorbis") == 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 - 2, argv, i);
+		else
+			result = process_mp3_parms(argc - 2, argv, i);
 
-			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);
-		}
+		if (!result)
+			showhelp(argv[0]);
 	}
 
 	char *index = strrchr(inputFilename, '.');
@@ -903,10 +888,10 @@
 	}
 
 	free(frameInfo);
-	
+
 	fclose(output);
 
 	printf("compression done.\n");
-		
+
 	return 0;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list