[Scummvm-cvs-logs] SF.net SVN: scummvm: [28174] tools/trunk
Kirben at users.sourceforge.net
Kirben at users.sourceforge.net
Mon Jul 23 04:34:34 CEST 2007
Revision: 28174
http://scummvm.svn.sourceforge.net/scummvm/?rev=28174&view=rev
Author: Kirben
Date: 2007-07-22 19:34:34 -0700 (Sun, 22 Jul 2007)
Log Message:
-----------
Add support for FLAC compression of sound bundles in The Dig and COMI.
Modified Paths:
--------------
tools/trunk/README
tools/trunk/compress_scumm_bun.cpp
Modified: tools/trunk/README
===================================================================
--- tools/trunk/README 2007-07-23 02:34:21 UTC (rev 28173)
+++ tools/trunk/README 2007-07-23 02:34:34 UTC (rev 28174)
@@ -124,16 +124,13 @@
move the '.san' files before compressing them, make sure to
move the '.flu' files, too!
- compress_scumm_bun <inputfile> <inputdir> <outputdir> [--ogg]
+ compress_scumm_bun <inputfile> <inputdir> <outputdir> [params]
+ Used to the compress '.bun' music/voice files with MP3, Vorbis
+ or FLAC.
- Compresses '.bun' music/voice files.
-
Example of usage:
- compress_scumm.bun digmusic.bun uncomp comp
+ compress_scumm.bun digmusic.bun uncomp comp --flac
- For the Ogg or MP3 compression feature, your ScummVM binary
- naturally must have been built with Ogg or MP3 support enabled.
-
compress_kyra
Used to compress The Legend of Kyrandia's speech files with
MP3, Vorbis or FLAC.
Modified: tools/trunk/compress_scumm_bun.cpp
===================================================================
--- tools/trunk/compress_scumm_bun.cpp 2007-07-23 02:34:21 UTC (rev 28173)
+++ tools/trunk/compress_scumm_bun.cpp 2007-07-23 02:34:34 UTC (rev 28174)
@@ -614,7 +614,13 @@
}
void showhelp(char *exename) {
- printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);
+ printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [params] [encoder params]\n", exename);
+
+ printf("\nParams:\n");
+ printf(" --mp3 encode to MP3 format (default)\n");
+ printf(" --vorbis encode to Vorbis format\n");
+ printf(" --flac encode to Flac format\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);
@@ -630,6 +636,10 @@
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(" [params] optional arguments passed directly to the encoder\n");
+
exit(2);
}
@@ -645,6 +655,14 @@
static BundleAudioTable cbundleTable[10000]; // difficult to calculate
static int32 cbundleCurIndex = 0;
+void encodeWaveWithFlac(char *filename) {
+ char fbuf[2048];
+ char fbuf2[2048];
+ sprintf(fbuf, "%s.wav", filename);
+ sprintf(fbuf2, "%s.fla", filename);
+ encodeAudio(fbuf, false, -1, fbuf2, kFlacMode);
+}
+
void encodeWaveWithOgg(char *filename) {
char fbuf[2048];
char fbuf2[2048];
@@ -741,7 +759,7 @@
_waveDataSize += size;
}
-static bool _oggMode = false; // mp3 default
+static CompressMode gCompMode = kMP3Mode;
typedef struct { int offset, size, codec; } CompTable;
@@ -900,24 +918,43 @@
writeWaveHeader(_waveDataSize, freq, channels);
free(outputData);
sprintf(tmpPath, "%s/%s_reg%03d", dir, filename, l);
- if (_oggMode)
+
+ switch (gCompMode) {
+ case kMP3Mode:
+ encodeWaveWithLame(tmpPath);
+ break;
+ case kVorbisMode:
encodeWaveWithOgg(tmpPath);
- else
- encodeWaveWithLame(tmpPath);
+ break;
+ case kFlacMode:
+ encodeWaveWithFlac(tmpPath);
+ break;
+ default:
+ error("Unknown encoding method");
+ }
+
sprintf(tmpPath, "%s/%s_reg%03d.wav", dir, filename, l);
unlink(tmpPath);
int32 startPos = ftell(output);
- if (_oggMode)
+ switch (gCompMode) {
+ case kMP3Mode:
+ sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.mp3", filename, l);
+ sprintf(tmpPath, "%s/%s_reg%03d.mp3", dir, filename, l);
+ break;
+ case kVorbisMode:
sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.ogg", filename, l);
- else
- sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.mp3", filename, l);
+ sprintf(tmpPath, "%s/%s_reg%03d.ogg", dir, filename, l);
+ break;
+ case kFlacMode:
+ sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.fla", filename, l);
+ sprintf(tmpPath, "%s/%s_reg%03d.fla", dir, filename, l);
+ break;
+ default:
+ error("Unknown encoding method");
+ }
cbundleTable[cbundleCurIndex].offset = startPos;
- 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);
@@ -1071,9 +1108,15 @@
if (argc > 4) {
i = 4;
- if (strcmp(argv[i], "--ogg") == 0) {
- _oggMode = true;
+ if (!strcmp(argv[i], "--mp3")) {
+ gCompMode = kMP3Mode;
i++;
+ } else if (!strcmp(argv[i], "--vorbis")) {
+ gCompMode = kVorbisMode;
+ i++;
+ } else if (!strcmp(argv[i], "--flac")) {
+ gCompMode = kFlacMode;
+ i++;
}
if (argc > i) {
@@ -1088,16 +1131,29 @@
args[j] = argv[j];
args[j] = dummyName;
- int result;
+ switch (gCompMode) {
+ case kMP3Mode:
+ if (!process_mp3_parms(argc, argv, i)) {
+ showhelp(argv[0]);
+ }
- if (_oggMode)
- result = process_ogg_parms(argc + 1, args, i);
- else
- result = process_mp3_parms(argc + 1, args, i);
+ break;
+ case kVorbisMode:
+ if (!process_ogg_parms(argc, argv, i)) {
+ showhelp(argv[0]);
+ }
- if (!result)
- showhelp(argv[0]);
+ break;
+ case kFlacMode:
+ if (!process_flac_parms(argc, argv, i)){
+ showhelp(argv[0]);
+ }
+ break;
+ default:
+ error("Unknown encoding method");
+ }
+
free(args);
}
}
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