[Scummvm-cvs-logs] CVS: tools extract.c,1.31,1.32 extract.h,1.4,1.5 extract-common.c,1.1,1.2 simon2mp3.c,1.18,1.19
Max Horn
fingolfin at users.sourceforge.net
Sun Nov 9 05:51:31 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: tools simon2mp3.c,1.17,1.18 extract.c,1.30,1.31 extract.h,1.3,1.4
- Next message: [Scummvm-cvs-logs] CVS: tools simon2mp3.c,1.19,1.20 extract-common.c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv13480
Modified Files:
extract.c extract.h extract-common.c simon2mp3.c
Log Message:
factor out more shared code
Index: extract.c
===================================================================
RCS file: /cvsroot/scummvm/tools/extract.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- extract.c 9 Nov 2003 13:35:53 -0000 1.31
+++ extract.c 9 Nov 2003 13:50:03 -0000 1.32
@@ -127,8 +127,13 @@
void get_part(void)
{
+ FILE *f;
+ uint32 tot_size;
+ char outname[256];
+ int size;
+ char fbuf[2048];
+
char buf[2048];
- int id;
int pos = ftell(input);
uint32 tags;
@@ -152,115 +157,29 @@
}
get_string(8, buf);
- if (!strncmp(buf, "Creative", 8)) {
+ if (!memcmp(buf, "Creative", 8)) {
get_string(18, buf);
- } else if (!strncmp(buf, "VTLK", 4)) {
+ } else if (!memcmp(buf, "VTLK", 4)) {
get_string(26, buf);
} else {
- exit(-1);
+ error("Unexpected data encountered");
}
printf("Voice file found (pos = %d) :", pos);
- id = fgetc(input);
- switch (id) {
- case 0x01:{
- int length = 0;
- int i;
- int sample_rate;
- int comp;
- FILE *f;
- char fbuf[2048];
- char *tmp;
- size_t size;
- uint32 tot_size;
- char rawname[256];
- char outname[256];
- int real_samplerate;
-
- /* Sound Data */
- printf(" Sound Data\n");
- for (i = 0; i < 3; i++)
- length = length | (fgetc(input) << (i * 8));
- printf(" - length = %d\n", length);
- sample_rate = fgetc(input);
- comp = fgetc(input);
-
- real_samplerate = getSampleRateFromVOCRate(sample_rate);
-
- printf(" - sample rate = %d (%02x)\n", real_samplerate, sample_rate);
- printf(" - compression = %s (%02x)\n",
- (comp == 0 ? "8bits" :
- (comp == 1 ? "4bits" :
- (comp == 2 ? "2.6bits" :
- (comp == 3 ? "2bits" :
- "Multi")))), comp);
-
- if (comp != 0) {
- exit(-1);
- }
- sprintf(rawname, TEMP_RAW);
- sprintf(outname, oggmode ? TEMP_OGG : TEMP_MP3);
-
- length -= 2;
- f = fopen(rawname, "wb");
- while (length > 0) {
- size = fread(fbuf, 1, length > 2048 ? 2048 : (uint32)length, input);
- if (size <= 0)
- break;
- length -= size;
- fwrite(fbuf, 1, size, f);
- }
- fclose(f);
-
- tmp = fbuf;
- if (oggmode) {
- tmp += sprintf(tmp, "oggenc --raw --raw-chan=1 --raw-bits=8 ");
- if (oggparms.nominalBitr != -1)
- tmp += sprintf(tmp, "--bitrate=%i ", oggparms.nominalBitr);
- if (oggparms.minBitr != -1)
- tmp += sprintf(tmp, "--min-bitrate=%i ", oggparms.minBitr);
- if (oggparms.maxBitr != -1)
- tmp += sprintf(tmp, "--max-bitrate=%i ", oggparms.maxBitr);
- if (oggparms.silent)
- tmp += sprintf(tmp, "--quiet ");
-
- tmp += sprintf(tmp, "--quality=%i ", oggparms.quality);
- tmp += sprintf(tmp, "--raw-rate=%i ", real_samplerate);
- tmp += sprintf(tmp, "--output=%s ", outname);
- tmp += sprintf(tmp, "%s ", rawname);
- system(fbuf);
- }
- else {
- tmp += sprintf(tmp, "lame -t -m m -r --bitwidth 8 ");
- if (encparms.abr == 1)
- tmp += sprintf(tmp, "--abr %i ", encparms.minBitr);
- else
- tmp += sprintf(tmp, "--vbr-new -b %i ", encparms.minBitr);
- if (encparms.silent == 1)
- tmp += sprintf(tmp, " --silent ");
-
- tmp += sprintf(tmp, "-q %i ", encparms.algqual);
- tmp += sprintf(tmp, "-V %i ", encparms.vbrqual);
- tmp += sprintf(tmp, "-B %i ", encparms.maxBitr);
- tmp += sprintf(tmp, "-s %d ", real_samplerate);
- tmp += sprintf(tmp, "%s %s ", rawname, outname);
- system(fbuf);
- }
-
- f = fopen(outname, "rb");
- tot_size = 0;
- while ((size = fread(fbuf, 1, 2048, f)) > 0) {
- tot_size += size;
- fwrite(fbuf, 1, size, output_snd);
- }
- fclose(f);
- put_int(tot_size);
- } break;
-
- default:
- error("Unknown chunk : %02x", id);
- break;
+ /* Conver the VOC data */
+ get_voc();
+
+ /* Append the converted data to the master output file */
+ sprintf(outname, oggmode ? TEMP_OGG : TEMP_MP3);
+ f = fopen(outname, "rb");
+ tot_size = 0;
+ while ((size = fread(fbuf, 1, 2048, f)) > 0) {
+ tot_size += size;
+ fwrite(fbuf, 1, size, output_snd);
}
+ fclose(f);
+
+ put_int(tot_size);
}
void showhelp(char *exename)
Index: extract.h
===================================================================
RCS file: /cvsroot/scummvm/tools/extract.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- extract.h 9 Nov 2003 13:35:53 -0000 1.4
+++ extract.h 9 Nov 2003 13:50:03 -0000 1.5
@@ -72,7 +72,7 @@
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);
+void get_voc(void);
/*
Index: extract-common.c
===================================================================
RCS file: /cvsroot/scummvm/tools/extract-common.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- extract-common.c 9 Nov 2003 13:17:54 -0000 1.1
+++ extract-common.c 9 Nov 2003 13:50:03 -0000 1.2
@@ -41,6 +41,103 @@
}
}
+void get_voc(void)
+{
+ int blocktype;
+
+ blocktype = fgetc(input);
+ switch (blocktype) {
+ case 0x01:{
+ int length = 0;
+ int i;
+ int sample_rate;
+ int comp;
+ FILE *f;
+ char fbuf[2048];
+ char *tmp;
+ size_t size;
+ char rawname[256];
+ char outname[256];
+ int real_samplerate;
+
+ /* Sound Data */
+ printf(" Sound Data\n");
+ for (i = 0; i < 3; i++)
+ length = length | (fgetc(input) << (i * 8));
+ length -= 2;
+ printf(" - length = %d\n", length);
+ sample_rate = fgetc(input);
+ comp = fgetc(input);
+
+ real_samplerate = getSampleRateFromVOCRate(sample_rate);
+
+ printf(" - sample rate = %d (%02x)\n", real_samplerate, sample_rate);
+ printf(" - compression = %s (%02x)\n",
+ (comp == 0 ? "8bits" :
+ (comp == 1 ? "4bits" :
+ (comp == 2 ? "2.6bits" :
+ (comp == 3 ? "2bits" :
+ "Multi")))), comp);
+
+ if (comp != 0)
+ error("Cannot handle compressed VOC data");
+
+ /* Copy the raw data to a temporary file */
+ sprintf(rawname, TEMP_RAW);
+ f = fopen(rawname, "wb");
+ while (length > 0) {
+ size = fread(fbuf, 1, length > 2048 ? 2048 : (uint32)length, input);
+ if (size <= 0)
+ break;
+ length -= size;
+ fwrite(fbuf, 1, size, f);
+ }
+ fclose(f);
+
+ /* Convert the raw temp file to OGG/MP3 */
+ sprintf(outname, oggmode ? TEMP_OGG : TEMP_MP3);
+ tmp = fbuf;
+ if (oggmode) {
+ tmp += sprintf(tmp, "oggenc --raw --raw-chan=1 --raw-bits=8 ");
+ if (oggparms.nominalBitr != -1)
+ tmp += sprintf(tmp, "--bitrate=%i ", oggparms.nominalBitr);
+ if (oggparms.minBitr != -1)
+ tmp += sprintf(tmp, "--min-bitrate=%i ", oggparms.minBitr);
+ if (oggparms.maxBitr != -1)
+ tmp += sprintf(tmp, "--max-bitrate=%i ", oggparms.maxBitr);
+ if (oggparms.silent)
+ tmp += sprintf(tmp, "--quiet ");
+
+ tmp += sprintf(tmp, "--quality=%i ", oggparms.quality);
+ tmp += sprintf(tmp, "--raw-rate=%i ", real_samplerate);
+ tmp += sprintf(tmp, "--output=%s ", outname);
+ tmp += sprintf(tmp, "%s ", rawname);
+ system(fbuf);
+ } else {
+ tmp += sprintf(tmp, "lame -t -m m -r --bitwidth 8 ");
+ if (encparms.abr == 1)
+ tmp += sprintf(tmp, "--abr %i ", encparms.minBitr);
+ else
+ tmp += sprintf(tmp, "--vbr-new -b %i ", encparms.minBitr);
+ if (encparms.silent == 1)
+ tmp += sprintf(tmp, " --silent ");
+
+ tmp += sprintf(tmp, "-q %i ", encparms.algqual);
+ tmp += sprintf(tmp, "-V %i ", encparms.vbrqual);
+ tmp += sprintf(tmp, "-B %i ", encparms.maxBitr);
+ tmp += sprintf(tmp, "-s %d ", real_samplerate);
+ tmp += sprintf(tmp, "%s %s ", rawname, outname);
+ system(fbuf);
+ }
+ break;
+ }
+
+ default:
+ error("Unknown chunk: %02x", blocktype);
+ break;
+ }
+}
+
void process_mp3_parms(int argc, char *argv[], int i) {
for(; i < argc; i++) {
if (strcmp(argv[i], "--vbr") == 0) {
Index: simon2mp3.c
===================================================================
RCS file: /cvsroot/scummvm/tools/simon2mp3.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- simon2mp3.c 9 Nov 2003 13:35:53 -0000 1.18
+++ simon2mp3.c 9 Nov 2003 13:50:03 -0000 1.19
@@ -150,13 +150,12 @@
return(size/6);
}
-void get_voc(void);
void get_wav(void);
unsigned int get_sound(int sound)
{
FILE *f;
- unsigned int tot_size;
+ uint32 tot_size;
char outname[256];
int size;
char fbuf[2048];
@@ -166,15 +165,16 @@
get_string(8);
if (!memcmp(buf, "Creative", 8)) {
printf("VOC found (pos = %d) :\n", offsets[sound]);
+ get_string(18);
get_voc();
} else if (!memcmp(buf, "RIFF", 4)) {
printf("WAV found (pos = %d) :\n", offsets[sound]);
get_wav();
} else {
- printf("Unexpected data at offset: %i\n", offsets[sound]);
- exit(-1);
+ error("Unexpected data at offset: %i", offsets[sound]);
}
+ /* Append the converted data to the master output file */
sprintf(outname, oggmode ? TEMP_OGG : TEMP_MP3);
f = fopen(outname, "rb");
tot_size = 0;
@@ -244,107 +244,6 @@
encparms.algqual, fbuf_temp, encparms.vbrqual,
encparms.maxBitr, wavname, outname);
system(fbuf);
- }
-}
-
-void get_voc(void)
-{
- int blocktype;
-
- get_string(18);
-
- blocktype = fgetc(input);
- switch (blocktype) {
- case 0x01:{
- int length = 0;
- int i;
- int sample_rate;
- int comp;
- FILE *f;
- char fbuf[2048];
- char *tmp;
- int size;
- char rawname[256];
- char outname[256];
- int real_samplerate;
-
- /* Sound Data */
- printf(" Sound Data\n");
- for (i = 0; i < 3; i++)
- length = length | (fgetc(input) << (i * 8));
- length -= 2;
- printf(" - length = %d\n", length);
- sample_rate = fgetc(input);
- comp = fgetc(input);
-
- real_samplerate = getSampleRateFromVOCRate(sample_rate);
-
- printf(" - sample rate = %d (%02x)\n", real_samplerate, sample_rate);
- printf(" - compression = %s (%02x)\n",
- (comp == 0 ? "8bits" :
- (comp == 1 ? "4bits" :
- (comp == 2 ? "2.6bits" :
- (comp == 3 ? "2bits" :
- "Multi")))), comp);
-
- if (comp != 0) {
- printf("Cannot handle compression\n");
- exit(-1);
- }
- sprintf(rawname, TEMP_RAW);
- sprintf(outname, oggmode ? TEMP_OGG : TEMP_MP3);
-
- f = fopen(rawname, "wb");
- while (length > 0) {
- size = fread(fbuf, 1, length > 2048 ? 2048 : length, input);
- if (size <= 0)
- break;
- length -= size;
- fwrite(fbuf, 1, size, f);
- }
- fclose(f);
-
- tmp = fbuf;
- if (oggmode) {
- tmp += sprintf(tmp, "oggenc --raw --raw-chan=1 --raw-bits=8 ");
- if (oggparms.nominalBitr != -1)
- tmp += sprintf(tmp, "--bitrate=%i ", oggparms.nominalBitr);
- if (oggparms.minBitr != -1)
- tmp += sprintf(tmp, "--min-bitrate=%i ", oggparms.minBitr);
- if (oggparms.maxBitr != -1)
- tmp += sprintf(tmp, "--max-bitrate=%i ", oggparms.maxBitr);
- if (oggparms.silent)
- tmp += sprintf(tmp, "--quiet ");
-
- tmp += sprintf(tmp, "--quality=%i ", oggparms.quality);
- tmp += sprintf(tmp, "--raw-rate=%i ", real_samplerate);
- tmp += sprintf(tmp, "--output=%s ", outname);
- tmp += sprintf(tmp, "%s ", rawname);
- system(fbuf);
- }
- else {
- tmp += sprintf(tmp, "lame -t -m m -r --bitwidth 8 ");
- if (encparms.abr == 1)
- tmp += sprintf(tmp, "--abr %i ", encparms.minBitr);
- else
- tmp += sprintf(tmp, "--vbr-new -b %i ", encparms.minBitr);
- if (encparms.silent == 1)
- tmp += sprintf(tmp, " --silent ");
-
- tmp += sprintf(tmp, "-q %i ", encparms.algqual);
- tmp += sprintf(tmp, "-V %i ", encparms.vbrqual);
- tmp += sprintf(tmp, "-B %i ", encparms.maxBitr);
- tmp += sprintf(tmp, "-s %d ", real_samplerate);
- tmp += sprintf(tmp, "%s %s ", rawname, outname);
- system(fbuf);
- }
- break;
- }
-
- default:
- printf("Unknown chunk : %02x\n", blocktype);
- exit(-1);
- break;
}
}
- Previous message: [Scummvm-cvs-logs] CVS: tools simon2mp3.c,1.17,1.18 extract.c,1.30,1.31 extract.h,1.3,1.4
- Next message: [Scummvm-cvs-logs] CVS: tools simon2mp3.c,1.19,1.20 extract-common.c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list