diff -ur ScummVM-tools-cvs20050605/Makefile ScummVM-tools-cvs20050605+hack/Makefile
old
|
new
|
|
37 | 37 | |
38 | 38 | all: $(TARGETS) |
39 | 39 | |
40 | | compress_san$(EXEEXT): compress_san.o util.o |
| 40 | compress_san$(EXEEXT): compress_san.o compress.o util.o |
41 | 41 | $(CXX) $(LDFLAGS) -o $@ $+ -lz |
42 | 42 | |
43 | 43 | descumm$(EXEEXT): descumm-tool.o descumm.o descumm6.o descumm-common.o util.o |
… |
… |
|
55 | 55 | compress_scumm_sou$(EXEEXT): compress_scumm_sou.o compress.o util.o |
56 | 56 | $(CC) $(LDFLAGS) -o $@ $+ |
57 | 57 | |
58 | | compress_scumm_bun$(EXEEXT): compress_scumm_bun.o util.o |
| 58 | compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o |
59 | 59 | $(CXX) $(LDFLAGS) -o $@ $+ |
60 | 60 | |
61 | 61 | extract_loom_tg16$(EXEEXT): extract_loom_tg16.o |
diff -ur ScummVM-tools-cvs20050605/compress.c ScummVM-tools-cvs20050605+hack/compress.c
old
|
new
|
|
290 | 290 | encodeAudio(outName, true, real_samplerate, tempEncoded, compMode); |
291 | 291 | } |
292 | 292 | |
293 | | void process_mp3_parms(int argc, char *argv[], int i) { |
| 293 | int process_mp3_parms(int argc, char *argv[], int i) { |
294 | 294 | for (; i < argc; i++) { |
295 | 295 | if (strcmp(argv[i], "--vbr") == 0) { |
296 | 296 | encparms.abr=0; |
… |
… |
|
331 | 331 | } else if (strcmp(argv[i], "--silent") == 0) { |
332 | 332 | encparms.silent = 1; |
333 | 333 | } else if (strcmp(argv[i], "--help") == 0) { |
334 | | showhelp(argv[0]); |
| 334 | return 0; |
335 | 335 | } else if (argv[i][0] == '-') { |
336 | | showhelp(argv[0]); |
| 336 | return 0; |
337 | 337 | } else { |
338 | 338 | break; |
339 | 339 | } |
340 | 340 | } |
341 | 341 | if (i != (argc - 1)) { |
342 | | showhelp(argv[0]); |
| 342 | return 0; |
343 | 343 | } |
| 344 | return 1; |
344 | 345 | } |
345 | 346 | |
346 | | void process_ogg_parms(int argc, char *argv[], int i) { |
| 347 | int process_ogg_parms(int argc, char *argv[], int i) { |
347 | 348 | for (; i < argc; i++) { |
348 | 349 | if (strcmp(argv[i], "-b") == 0) { |
349 | 350 | oggparms.nominalBitr = atoi(argv[i + 1]); |
… |
… |
|
365 | 366 | oggparms.silent = 1; |
366 | 367 | } |
367 | 368 | else if (strcmp(argv[i], "--help") == 0) { |
368 | | showhelp(argv[0]); |
| 369 | return 0; |
369 | 370 | } |
370 | 371 | else if (argv[i][0] == '-') { |
371 | | showhelp(argv[0]); |
| 372 | return 0; |
372 | 373 | } |
373 | 374 | else |
374 | 375 | break; |
375 | 376 | } |
376 | 377 | if (i != argc - 1) |
377 | | showhelp(argv[0]); |
| 378 | return 0; |
| 379 | return 1; |
378 | 380 | } |
379 | 381 | |
380 | | void process_flac_parms(int argc, char *argv[], int i){ |
| 382 | int process_flac_parms(int argc, char *argv[], int i){ |
381 | 383 | flacparms.argv = &argv[i]; |
382 | 384 | flacparms.numArgs = argc - 1 - i; |
383 | 385 | |
384 | 386 | if (i >= argc) |
385 | | showhelp(argv[0]); |
| 387 | return 0; |
| 388 | return 1; |
386 | 389 | } |
387 | | |
diff -ur ScummVM-tools-cvs20050605/compress.h ScummVM-tools-cvs20050605+hack/compress.h
old
|
new
|
|
24 | 24 | |
25 | 25 | #include "util.h" |
26 | 26 | |
| 27 | #if defined(__cplusplus) |
| 28 | extern "C" { |
| 29 | #endif |
27 | 30 | |
28 | 31 | /* These are the defaults parameters for the Lame invocation */ |
29 | 32 | #define minBitrDef 24 |
… |
… |
|
48 | 51 | |
49 | 52 | const extern char *tempEncoded; |
50 | 53 | |
51 | | extern void process_mp3_parms(int argc, char *argv[], int i); |
52 | | extern void process_ogg_parms(int argc, char *argv[], int i); |
53 | | extern void process_flac_parms(int argc, char *argv[], int i); |
| 54 | extern int process_mp3_parms(int argc, char *argv[], int i); |
| 55 | extern int process_ogg_parms(int argc, char *argv[], int i); |
| 56 | extern int process_flac_parms(int argc, char *argv[], int i); |
54 | 57 | |
55 | 58 | extern void extractAndEncodeVOC(const char *outName, FILE *input, CompressMode compMode); |
56 | 59 | extern void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode); |
57 | 60 | |
58 | 61 | extern void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode); |
59 | 62 | extern void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample); |
60 | | /* |
61 | | * Stuff which is in compress_scumm_sou.c / compress_simon.c / compress_sword2.c |
62 | | */ |
63 | | extern void showhelp(char *exename); |
64 | 63 | |
| 64 | #if defined(__cplusplus) |
| 65 | } |
| 66 | #endif |
65 | 67 | |
66 | 68 | #endif |
diff -ur ScummVM-tools-cvs20050605/compress_saga.c ScummVM-tools-cvs20050605+hack/compress_saga.c
old
|
new
|
|
221 | 221 | switch (gCompMode) { |
222 | 222 | case kMP3Mode: |
223 | 223 | tempEncoded = TEMP_MP3; |
224 | | process_mp3_parms(argc, argv, i); |
| 224 | if (!process_mp3_parms(argc, argv, i)) |
| 225 | showhelp(argv[0]); |
225 | 226 | break; |
226 | 227 | case kVorbisMode: |
227 | 228 | tempEncoded = TEMP_OGG; |
228 | | process_ogg_parms(argc, argv, i); |
| 229 | if (!process_ogg_parms(argc, argv, i)) |
| 230 | showhelp(argv[0]); |
229 | 231 | break; |
230 | 232 | case kFlacMode: |
231 | 233 | tempEncoded = TEMP_FLAC; |
232 | | process_flac_parms(argc, argv, i); |
| 234 | if (!process_flac_parms(argc, argv, i)) |
| 235 | showhelp(argv[0]); |
233 | 236 | break; |
234 | 237 | } |
235 | 238 | |
diff -ur ScummVM-tools-cvs20050605/compress_san.cpp ScummVM-tools-cvs20050605+hack/compress_san.cpp
old
|
new
|
|
19 | 19 | * |
20 | 20 | */ |
21 | 21 | |
22 | | #include "util.h" |
| 22 | #include "compress.h" |
23 | 23 | #include "zlib.h" |
24 | 24 | |
25 | 25 | inline uint16 READ_LE_UINT16(const void *ptr) { |
… |
… |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | void showhelp(char *exename) { |
47 | | printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg]\n", exename); |
| 47 | printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename); |
48 | 48 | exit(2); |
49 | 49 | } |
50 | 50 | |
… |
… |
|
85 | 85 | |
86 | 86 | void encodeWaveWithOgg(char *filename) { |
87 | 87 | char fbuf[2048]; |
88 | | bool err = false; |
89 | | |
90 | | sprintf(fbuf, "oggenc -q 0 %s.wav", filename); |
91 | | err = system(fbuf) != 0; |
92 | | if (err) { |
93 | | printf("Got error from encoder. (check your parameters)\n"); |
94 | | printf("Encoder Commandline: %s\n", fbuf ); |
95 | | exit(-1); |
96 | | } |
| 88 | char fbuf2[2048]; |
| 89 | sprintf(fbuf, "\"%s\".wav", filename); |
| 90 | sprintf(fbuf2, "\"%s\".ogg", filename); |
| 91 | encodeAudio(fbuf, false, -1, fbuf2, kVorbisMode); |
97 | 92 | } |
98 | 93 | |
99 | 94 | void encodeWaveWithLame(char *filename) { |
100 | 95 | char fbuf[2048]; |
101 | | bool err = false; |
| 96 | char fbuf2[2048]; |
102 | 97 | |
103 | | sprintf(fbuf, "lame --vbr-new -V 9 -quiet -t \"%s\".wav \"%s\".mp3", filename, filename); |
104 | | err = system(fbuf) != 0; |
105 | | if (err) { |
106 | | printf("Got error from encoder. (check your parameters)\n"); |
107 | | printf("Encoder Commandline: %s\n", fbuf ); |
108 | | exit(-1); |
109 | | } |
| 98 | sprintf(fbuf, "\"%s\".wav", filename); |
| 99 | sprintf(fbuf2, "\"%s\".mp3", filename); |
| 100 | encodeAudio(fbuf, false, -1, fbuf2, kMP3Mode); |
110 | 101 | } |
111 | 102 | |
112 | 103 | void writeWaveHeader(int s_size) { |
… |
… |
|
662 | 653 | strcpy(inputDir, argv[2]); |
663 | 654 | strcpy(outputDir, argv[3]); |
664 | 655 | |
665 | | if ((argc == 5) && (strcmp(argv[4], "--ogg") == 0)) { |
666 | | _oggMode = true; |
| 656 | if (argc > 4) { |
| 657 | int i = 4; |
| 658 | |
| 659 | if (strcmp(argv[i], "--ogg") == 0) { |
| 660 | _oggMode = true; |
| 661 | i++; |
| 662 | } |
| 663 | |
| 664 | if (argc > i) { |
| 665 | // HACK: The functions in compress.c expect the last |
| 666 | // argument to be a filename. As we don't expect one, |
| 667 | // we simply add a dummy argument to the list. |
| 668 | char **args = (char **)malloc((argc + 1) * sizeof(char *)); |
| 669 | char dummyName[] = "dummy"; |
| 670 | int j; |
| 671 | |
| 672 | for (j = 0; j < argc; j++) |
| 673 | args[j] = argv[j]; |
| 674 | args[j] = dummyName; |
| 675 | |
| 676 | int result; |
| 677 | |
| 678 | if (_oggMode) |
| 679 | result = process_ogg_parms(argc + 1, args, i); |
| 680 | else |
| 681 | result = process_mp3_parms(argc + 1, args, i); |
| 682 | |
| 683 | if (!result) |
| 684 | showhelp(argv[0]); |
| 685 | |
| 686 | free(args); |
| 687 | } |
667 | 688 | } |
668 | 689 | |
669 | 690 | char *index = strrchr(inputFilename, '.'); |
diff -ur ScummVM-tools-cvs20050605/compress_scumm_bun.cpp ScummVM-tools-cvs20050605+hack/compress_scumm_bun.cpp
old
|
new
|
|
19 | 19 | * |
20 | 20 | */ |
21 | 21 | |
22 | | #include "util.h" |
| 22 | #include "compress.h" |
23 | 23 | |
24 | 24 | inline uint16 READ_LE_UINT16(const void *ptr) { |
25 | 25 | const byte *b = (const byte *)ptr; |
… |
… |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | void showhelp(char *exename) { |
658 | | printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg]\n", exename); |
| 658 | printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename); |
659 | 659 | exit(2); |
660 | 660 | } |
661 | 661 | |
… |
… |
|
673 | 673 | |
674 | 674 | void encodeWaveWithOgg(char *filename) { |
675 | 675 | char fbuf[2048]; |
676 | | bool err = false; |
677 | | |
678 | | sprintf(fbuf, "oggenc -q 0 \"%s\".wav", filename); |
679 | | err = system(fbuf) != 0; |
680 | | if (err) { |
681 | | printf("Got error from encoder. (check your parameters)\n"); |
682 | | printf("Encoder Commandline: %s\n", fbuf ); |
683 | | exit(-1); |
684 | | } |
| 676 | char fbuf2[2048]; |
| 677 | sprintf(fbuf, "\"%s\".wav", filename); |
| 678 | sprintf(fbuf2, "\"%s\".ogg", filename); |
| 679 | encodeAudio(fbuf, false, -1, fbuf2, kVorbisMode); |
685 | 680 | } |
686 | 681 | |
687 | 682 | void encodeWaveWithLame(char *filename) { |
688 | 683 | char fbuf[2048]; |
689 | | bool err = false; |
| 684 | char fbuf2[2048]; |
690 | 685 | |
691 | | sprintf(fbuf, "lame --vbr-new -V 9 -quiet -t \"%s\".wav \"%s\".mp3", filename, filename); |
692 | | err = system(fbuf) != 0; |
693 | | if (err) { |
694 | | printf("Got error from encoder. (check your parameters)\n"); |
695 | | printf("Encoder Commandline: %s\n", fbuf ); |
696 | | exit(-1); |
697 | | } |
| 686 | sprintf(fbuf, "\"%s\".wav", filename); |
| 687 | sprintf(fbuf2, "\"%s\".wav", filename); |
| 688 | encodeAudio(fbuf, false, -1, fbuf2, kMP3Mode); |
698 | 689 | } |
699 | 690 | |
700 | 691 | void writeWaveHeader(int s_size, int rate, int chan) { |
… |
… |
|
1103 | 1094 | strcpy(inputDir, argv[2]); |
1104 | 1095 | strcpy(outputDir, argv[3]); |
1105 | 1096 | |
1106 | | if ((argc == 5) && (strcmp(argv[4], "--ogg") == 0)) { |
1107 | | _oggMode = true; |
| 1097 | if (argc > 4) { |
| 1098 | i = 4; |
| 1099 | |
| 1100 | if (strcmp(argv[i], "--ogg") == 0) { |
| 1101 | _oggMode = true; |
| 1102 | i++; |
| 1103 | } |
| 1104 | |
| 1105 | if (argc > i) { |
| 1106 | // HACK: The functions in compress.c expect the last |
| 1107 | // argument to be a filename. As we don't expect one, |
| 1108 | // we simply add a dummy argument to the list. |
| 1109 | char **args = (char **)malloc((argc + 1) * sizeof(char *)); |
| 1110 | char dummyName[] = "dummy"; |
| 1111 | int j; |
| 1112 | |
| 1113 | for (j = 0; j < argc; j++) |
| 1114 | args[j] = argv[j]; |
| 1115 | args[j] = dummyName; |
| 1116 | |
| 1117 | int result; |
| 1118 | |
| 1119 | if (_oggMode) |
| 1120 | result = process_ogg_parms(argc + 1, args, i); |
| 1121 | else |
| 1122 | result = process_mp3_parms(argc + 1, args, i); |
| 1123 | |
| 1124 | if (!result) |
| 1125 | showhelp(argv[0]); |
| 1126 | |
| 1127 | free(args); |
| 1128 | } |
1108 | 1129 | } |
1109 | 1130 | |
1110 | 1131 | char *index = strrchr(inputFilename, '.'); |
diff -ur ScummVM-tools-cvs20050605/compress_scumm_sou.c ScummVM-tools-cvs20050605+hack/compress_scumm_sou.c
old
|
new
|
|
206 | 206 | case kMP3Mode: |
207 | 207 | outputName = OUTPUT_MP3; |
208 | 208 | tempEncoded = TEMP_MP3; |
209 | | process_mp3_parms(argc, argv, i); |
| 209 | if (!process_mp3_parms(argc, argv, i)) |
| 210 | showhelp(argv[0]); |
210 | 211 | break; |
211 | 212 | case kVorbisMode: |
212 | 213 | outputName = OUTPUT_OGG; |
213 | 214 | tempEncoded = TEMP_OGG; |
214 | | process_ogg_parms(argc, argv, i); |
| 215 | if (!process_ogg_parms(argc, argv, i)) |
| 216 | showhelp(argv[0]); |
215 | 217 | break; |
216 | 218 | case kFlacMode: |
217 | 219 | outputName = OUTPUT_FLAC; |
218 | 220 | tempEncoded = TEMP_FLAC; |
219 | | process_flac_parms(argc, argv, i); |
| 221 | if (!process_flac_parms(argc, argv, i)) |
| 222 | showhelp(argv[0]); |
220 | 223 | break; |
221 | 224 | } |
222 | 225 | |
diff -ur ScummVM-tools-cvs20050605/compress_simon.c ScummVM-tools-cvs20050605+hack/compress_simon.c
old
|
new
|
|
332 | 332 | switch (gCompMode) { |
333 | 333 | case kMP3Mode: |
334 | 334 | tempEncoded = TEMP_MP3; |
335 | | process_mp3_parms(argc, argv, i); |
| 335 | if (!process_mp3_parms(argc, argv, i)) |
| 336 | showhelp(argv[0]); |
336 | 337 | break; |
337 | 338 | case kVorbisMode: |
338 | 339 | tempEncoded = TEMP_OGG; |
339 | | process_ogg_parms(argc, argv, i); |
| 340 | if (!process_ogg_parms(argc, argv, i)) |
| 341 | showhelp(argv[0]); |
340 | 342 | break; |
341 | 343 | case kFlacMode: |
342 | 344 | tempEncoded = TEMP_FLAC; |
343 | | process_flac_parms(argc, argv, i); |
| 345 | if (!process_flac_parms(argc, argv, i)) |
| 346 | showhelp(argv[0]); |
344 | 347 | break; |
345 | 348 | } |
346 | 349 | |
diff -ur ScummVM-tools-cvs20050605/compress_sword1.c ScummVM-tools-cvs20050605+hack/compress_sword1.c
old
|
new
|
|
527 | 527 | /* As we don't expect one, we simply add a dummy argument to the list. */ |
528 | 528 | char **args; |
529 | 529 | int cnt; |
| 530 | int result; |
530 | 531 | char dummyName[] = "dummy"; |
531 | 532 | args = (char **)malloc((argc + 1) * sizeof(char *)); |
532 | 533 | for (cnt = 0; cnt < argc; cnt++) |
533 | 534 | args[cnt] = argv[cnt]; |
534 | 535 | args[argc] = dummyName; |
535 | | if (mode == kMP3Mode) |
536 | | process_mp3_parms(argc + 1, args, i); |
| 536 | if (mode == kMP3Mode) |
| 537 | result = process_mp3_parms(argc + 1, args, i); |
537 | 538 | else if (mode == kVorbisMode) |
538 | | process_ogg_parms(argc + 1, args, i); |
| 539 | result = process_ogg_parms(argc + 1, args, i); |
539 | 540 | else |
540 | 541 | error("Unknown encoding method"); |
| 542 | if (!result) |
| 543 | showhelp(argv[0]); |
541 | 544 | free(args); |
542 | 545 | } |
543 | 546 | |
diff -ur ScummVM-tools-cvs20050605/compress_sword2.c ScummVM-tools-cvs20050605+hack/compress_sword2.c
old
|
new
|
|
122 | 122 | switch (gCompMode) { |
123 | 123 | case kMP3Mode: |
124 | 124 | tempEncoded = TEMP_MP3; |
125 | | process_mp3_parms(argc, argv, i); |
| 125 | if (!process_mp3_parms(argc, argv, i)) |
| 126 | showhelp(argv[0]); |
126 | 127 | break; |
127 | 128 | case kVorbisMode: |
128 | 129 | tempEncoded = TEMP_OGG; |
129 | | process_ogg_parms(argc, argv, i); |
| 130 | if (!process_ogg_parms(argc, argv, i)) |
| 131 | showhelp(argv[0]); |
130 | 132 | break; |
131 | 133 | case kFlacMode: |
132 | 134 | tempEncoded = TEMP_FLAC; |
133 | | process_flac_parms(argc, argv, i); |
| 135 | if (!process_flac_parms(argc, argv, i)) |
| 136 | showhelp(argv[0]); |
134 | 137 | break; |
135 | 138 | } |
136 | 139 | |