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

lightcast at users.sourceforge.net lightcast at users.sourceforge.net
Thu Jul 5 01:04:40 CEST 2007


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

Log Message:
-----------
Modified compress_queen.c to use the compression functions in compress.c

Modified Paths:
--------------
    tools/branches/gsoc2007-toolsgui/compress_queen.c

Modified: tools/branches/gsoc2007-toolsgui/compress_queen.c
===================================================================
--- tools/branches/gsoc2007-toolsgui/compress_queen.c	2007-07-04 23:03:34 UTC (rev 27908)
+++ tools/branches/gsoc2007-toolsgui/compress_queen.c	2007-07-04 23:04:40 UTC (rev 27909)
@@ -20,9 +20,10 @@
  *
  */
 
-#include "util.h"
+#include "compress.h"
 
 static const uint32 QTBL = 'QTBL';
+static CompressMode gCompMode = kMP3Mode;
 
 #define INPUT_TBL	"queen.tbl"
 #define FINAL_OUT	"queen.1c"
@@ -31,12 +32,6 @@
 #define TEMP_TBL	"tempfile.tbl"
 #define TEMP_SB		"tempfile.sb"
 
-#define TEMP_MP3	"tempfile.mp3"
-#define TEMP_OGG	"tempfile.ogg"
-#define TEMP_FLAC	"tempfile.fla"
-
-const char *tempEncoded;
-
 #define CURRENT_TBL_VERSION	2
 #define EXTRA_TBL_HEADER 8
 #define SB_HEADER_SIZE_V104 110
@@ -126,13 +121,43 @@
 
 void showhelp(char *exename)
 {
-	printf("\nUsage: %s [--mp3/--vorbis/--flac <args>] queen.1\n", exename);
+	printf("\nUsage: %s [params] queen.1\n", exename);
+
 	printf("\nParams:\n");
-	printf(" --mp3 <args>         encode to MP3 format\n");
-	printf(" --vorbis <args>      encode to Ogg Vorbis Format\n");
-	printf(" --flac <args>        encode to Flac Format\n");
-	printf("                      (Optional: <args> are passed on to the encoder)\n");
-	printf("\nExample: %s --mp3 -q 5 queen.1\n", exename);
+
+	printf(" --mp3        encode to MP3 format (default)\n");
+	printf(" --vorbis     encode to Ogg Vorbis format\n");
+	printf(" --flac       encode to Flac format\n");
+	printf("(If one of these is specified, it must be the first parameter.)\n");
+
+	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);
+	printf(" --vbr        LAME uses the VBR mode (default)\n");
+	printf(" --abr        LAME uses the ABR mode\n");
+	printf(" -V <value>   specifies the value (0 - 9) of VBR quality (0=best) (default:%d)\n", vbrqualDef);
+	printf(" -q <value>   specifies the MPEG algorithm quality (0-9; 0=best) (default:%d)\n", algqualDef);
+	printf(" --silent     the output of LAME is hidden (default:disabled)\n");
+
+	printf("\nVorbis mode params:\n");
+	printf(" -b <rate>    <rate> is the nominal bitrate (default:unset)\n");
+	printf(" -m <rate>    <rate> is the minimum bitrate (default:unset)\n");
+	printf(" -M <rate>    <rate> is the maximum bitrate (default:unset)\n");
+	printf(" -q <value>   specifies the value (0 - 10) of VBR quality (10=best) (default:%d)\n", oggqualDef);
+	printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
+
+	printf("\nFlac mode params:\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");
+
+	printf("\n\nIf a parameter is not given the default value is used\n");
+	printf("If using VBR mode for MP3 -b and -B must be multiples of 8; the maximum is 160!\n");
 	exit(2);
 }
 
@@ -219,8 +244,6 @@
 	FILE *inputData, *inputTbl, *outputTbl, *outputData, *tmpFile, *compFile;
 	uint8 compressionType = COMPRESSION_NONE;
 	char tmp[5];
-	char sysBuf[1024];
-	char *ptr = sysBuf;
 	int size, i = 1;
 	uint32 prevOffset;
 
@@ -228,39 +251,40 @@
 	if (argc < 2)
 		showhelp(argv[0]);
 
+	/* compression mode */
+	compressionType = COMPRESSION_MP3;
+	gCompMode = kMP3Mode;
+
 	if (strcmp(argv[1], "--mp3") == 0) {
 		compressionType = COMPRESSION_MP3;
-		tempEncoded = TEMP_MP3;
+		gCompMode = kMP3Mode;
 		i++;
-		ptr += sprintf(ptr, "lame -r -h -s 11 --bitwidth 8 -m m ");
-		for (; i < (argc - 1); i++) {
-			/* Append optional encoder arguments */
-			ptr += sprintf(ptr, "%s ", argv[i]);
-		}
-		ptr += sprintf(ptr, "%s %s", TEMP_SB, tempEncoded);
 	} else if (strcmp(argv[1], "--vorbis") == 0) {
 		compressionType = COMPRESSION_OGG;
-		tempEncoded = TEMP_OGG;
+		gCompMode = kVorbisMode;
 		i++;
-		ptr += sprintf(ptr, "oggenc -r -B 8 -C 1 -R 11025 %s -o %s ", TEMP_SB, tempEncoded);
-		for (; i < (argc - 1); i++) {
-			/* Append optional encoder arguments */
-			ptr += sprintf(ptr, "%s ", argv[i]);
-		}
 	} else if (strcmp(argv[1], "--flac") == 0) {
 		compressionType = COMPRESSION_FLAC;
-		tempEncoded = TEMP_FLAC;
+		gCompMode = kFlacMode;
 		i++;
-		ptr += sprintf(ptr, "flac --force-raw-format --endian=little --sign=unsigned --bps=8 --channels=1 --sample-rate=11025 " );
-		ptr += sprintf(ptr, "--no-padding --lax --no-seektable --no-ogg " );
-		for (; i < (argc - 1); i++) {
-			/* Append optional encoder arguments */
-			ptr += sprintf(ptr, "%s ", argv[i]);
-		}
+	}
 
-		ptr += sprintf(ptr, "-o %s %s", tempEncoded, TEMP_SB );
-	} else {
-		showhelp(argv[0]);
+	switch (gCompMode) {
+	case kMP3Mode:
+		tempEncoded = TEMP_MP3;
+		if (!process_mp3_parms(argc, argv, i))
+			showhelp(argv[0]);
+		break;
+	case kVorbisMode:
+		tempEncoded = TEMP_OGG;
+		if (!process_ogg_parms(argc, argv, i))
+			showhelp(argv[0]);
+		break;
+	case kFlacMode:
+		tempEncoded = TEMP_FLAC;
+		if (!process_flac_parms(argc, argv, i))
+			showhelp(argv[0]);
+		break;
 	}
 
 	/* Open input file (QUEEN.1) */
@@ -342,11 +366,8 @@
 			fclose(tmpFile);
 
 			/* Invoke encoder */
-			if (system(sysBuf)) {
-				printf("Got error from encoder. (check your parameters)\n");
-				unlink(TEMP_SB);
-				exit(-1);
-			}
+			setRawAudioType(false, false, 8);
+			encodeAudio(TEMP_SB, true, 11025, tempEncoded, gCompMode);
 
 			/* Append MP3/OGG to data file */
 			compFile = fopen(tempEncoded, "rb");


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