Ticket #8707: SoC Tools Update #3.patch
File SoC Tools Update #3.patch, 73.3 KB (added by , 17 years ago) |
---|
-
compress.c
35 35 int nominalBitr; 36 36 int minBitr; 37 37 int maxBitr; 38 int quality;38 float quality; 39 39 bool silent; 40 40 } oggencparams; 41 41 42 /* FIXME: This is an evil way to pass on the params to FLAC.43 It makes it near impossible to reliably pass default params to the44 encoder.45 */46 42 typedef struct { 47 char * const* argv; 48 int numArgs; 43 int compressionLevel; 44 int blocksize; 45 bool verify; 46 bool silent; 49 47 } flaccparams; 50 48 51 49 typedef struct { 52 bool isLittleEndian; 53 bool isStereo; 54 bool isUnsigned; 50 bool isLittleEndian, isStereo; 55 51 uint8 bitsPerSample; 56 52 } rawtype; 57 53 58 54 lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0 }; 59 55 oggencparams oggparms = { -1, -1, -1, oggqualDef, 0 }; 60 flaccparams flacparms ;61 rawtype rawAudioType = { false, false, false,8 };56 flaccparams flacparms = { flacCompressDef, flacBlocksizeDef, false, false }; 57 rawtype rawAudioType = { false, false, 8 }; 62 58 63 59 const char *tempEncoded = TEMP_MP3; 64 60 65 void setRawAudioType(bool isLittleEndian, bool isStereo, bool isUnsigned,uint8 bitsPerSample) {61 void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample) { 66 62 rawAudioType.isLittleEndian = isLittleEndian; 67 63 rawAudioType.isStereo = isStereo; 68 rawAudioType.isUnsigned = isUnsigned;69 64 rawAudioType.bitsPerSample = bitsPerSample; 70 65 } 71 66 … … 105 100 } 106 101 107 102 void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode) { 103 bool err = false; 108 104 char fbuf[2048]; 109 105 char *tmp = fbuf; 110 int i;111 bool err = false;112 106 113 switch (compmode) { 114 case kVorbisMode: 115 tmp += sprintf(tmp, "oggenc "); 116 if (rawInput) { 117 tmp += sprintf(tmp, "--raw "); 118 tmp += sprintf(tmp, "--raw-chan=%d ", (rawAudioType.isStereo ? 2 : 1)); 119 tmp += sprintf(tmp, "--raw-bits=%d ", rawAudioType.bitsPerSample); 120 tmp += sprintf(tmp, "--raw-rate=%d ", rawSamplerate); 121 tmp += sprintf(tmp, "--raw-endianness=%d ", (rawAudioType.isLittleEndian ? 0 : 1)); 122 } 123 124 if (oggparms.nominalBitr != -1) 125 tmp += sprintf(tmp, "--bitrate=%d ", oggparms.nominalBitr); 126 if (oggparms.minBitr != -1) 127 tmp += sprintf(tmp, "--min-bitrate=%d ", oggparms.minBitr); 128 if (oggparms.maxBitr != -1) 129 tmp += sprintf(tmp, "--max-bitrate=%d ", oggparms.maxBitr); 130 if (oggparms.silent) 131 tmp += sprintf(tmp, "--quiet "); 132 tmp += sprintf(tmp, "--quality=%d ", oggparms.quality); 133 tmp += sprintf(tmp, "--output=\"%s\" ", outname); 134 tmp += sprintf(tmp, "\"%s\" ", inname); 135 err = system(fbuf) != 0; 136 break; 137 138 case kMP3Mode: 107 if (compmode == kMP3Mode) { 139 108 tmp += sprintf(tmp, "lame -t "); 140 109 if (rawInput) { 141 110 tmp += sprintf(tmp, "-r "); 142 111 tmp += sprintf(tmp, "--bitwidth %d ", rawAudioType.bitsPerSample); 143 if (rawAudioType.isLittleEndian) 112 113 if (rawAudioType.isLittleEndian) { 144 114 tmp += sprintf(tmp, "-x "); 115 } 116 145 117 tmp += sprintf(tmp, (rawAudioType.isStereo ? "-m j " : "-m m ")); 146 118 tmp += sprintf(tmp, "-s %d ", rawSamplerate); 147 119 } 148 120 149 if (encparms.abr) 121 if (encparms.abr) { 150 122 tmp += sprintf(tmp, "--abr %d ", encparms.minBitr); 151 else123 } else { 152 124 tmp += sprintf(tmp, "--vbr-new -b %d ", encparms.minBitr); 125 } 153 126 154 127 /* Explicitly specify a target sample rate, to work around a bug (?) 155 156 157 158 159 160 161 if (rawSamplerate != -1) 128 * in newer lame versions (>= 3.95) which causes it to malfunction 129 * for odd sample rates when in VBR mode. See also bug #934026. 130 * We essentially duplicate the old behaviour of lame (found in e.g. 131 * version 3.93.1): we round the input sample rate up to the next 132 * higher valid MP3 sample rate, with a margin of 3%. 133 */ 134 if (rawSamplerate != -1) { 162 135 tmp += sprintf(tmp, "--resample %d ", map2MP3Frequency(97 * rawSamplerate / 100)); 136 } 163 137 164 if (encparms.silent) 138 if (encparms.silent) { 165 139 tmp += sprintf(tmp, " --silent "); 140 } 141 166 142 tmp += sprintf(tmp, "-q %d ", encparms.algqual); 167 143 tmp += sprintf(tmp, "-V %d ", encparms.vbrqual); 168 144 tmp += sprintf(tmp, "-B %d ", encparms.maxBitr); 169 145 tmp += sprintf(tmp, "\"%s\" \"%s\" ", inname, outname); 146 170 147 err = system(fbuf) != 0; 171 break;172 148 173 case kFlacMode: 174 /* --lax is needed to allow 11kHz, we dont need place for meta-tags, and no seektable */ 175 /* -f is reqired to force override of unremoved temp file. See bug #1294648 */ 176 tmp += sprintf(tmp, "flac --best -b 1152 -f --lax --no-padding --no-seektable --no-ogg "); 149 if (err) { 150 printf("Got error from encoder. (check your parameters)\n"); 151 printf("Encoder Commandline: %s\n", fbuf ); 152 exit(-1); 153 } else { 154 return; 155 } 156 } 177 157 158 #ifdef DISABLE_OGG 159 if (compmode == kVorbisMode) { 160 tmp += sprintf(tmp, "oggenc "); 161 if (rawInput) { 162 tmp += sprintf(tmp, "--raw "); 163 tmp += sprintf(tmp, "--raw-chan=%d ", (rawAudioType.isStereo ? 2 : 1)); 164 tmp += sprintf(tmp, "--raw-bits=%d ", rawAudioType.bitsPerSample); 165 tmp += sprintf(tmp, "--raw-rate=%d ", rawSamplerate); 166 tmp += sprintf(tmp, "--raw-endianness=%d ", (rawAudioType.isLittleEndian ? 0 : 1)); 167 } 168 169 if (oggparms.nominalBitr != -1) { 170 tmp += sprintf(tmp, "--bitrate=%d ", oggparms.nominalBitr); 171 } else { 172 tmp += sprintf(tmp, "--quality=%d ", oggparms.quality); 173 } 174 175 if (oggparms.minBitr != -1) { 176 tmp += sprintf(tmp, "--min-bitrate=%d ", oggparms.minBitr); 177 } 178 179 if (oggparms.maxBitr != -1) { 180 tmp += sprintf(tmp, "--max-bitrate=%d ", oggparms.maxBitr); 181 } 182 183 if (oggparms.silent) { 184 tmp += sprintf(tmp, "--quiet "); 185 } 186 187 tmp += sprintf(tmp, "--output=\"%s\" ", outname); 188 tmp += sprintf(tmp, "\"%s\" ", inname); 189 190 err = system(fbuf) != 0; 191 192 if (err) { 193 printf("Got error from encoder. (check your parameters)\n"); 194 printf("Encoder Commandline: %s\n", fbuf ); 195 exit(-1); 196 } else { 197 return; 198 } 199 } 200 #endif 201 202 #ifdef DISABLE_FLAC 203 if (compmode == kFlacMode) { 204 /* --lax is needed to allow 11kHz, we dont need place for meta-tags, and no seektable */ 205 /* -f is reqired to force override of unremoved temp file. See bug #1294648 */ 206 tmp += sprintf(tmp, "flac -f --lax --no-padding --no-seektable --no-ogg "); 207 208 if (rawInput) { 209 tmp += sprintf(tmp, "--force-raw-format "); 210 tmp += sprintf(tmp, "--sign=%s ", ((rawAudioType.bitsPerSample == 8) ? "unsigned" : "signed")); 211 tmp += sprintf(tmp, "--channels=%d ", (rawAudioType.isStereo ? 2 : 1)); 212 tmp += sprintf(tmp, "--bps=%d ", rawAudioType.bitsPerSample); 213 tmp += sprintf(tmp, "--sample-rate=%d ", rawSamplerate); 214 tmp += sprintf(tmp, "--endian=%s ", (rawAudioType.isLittleEndian ? "little" : "big")); 215 } 216 217 if (flacparms.silent) { 218 tmp += sprintf(tmp, "--silent "); 219 } 220 221 if (flacparms.verify) { 222 tmp += sprintf(tmp, "--verify "); 223 } 224 225 tmp += sprintf(tmp, "--compression-level-%d ", flacparms.compressionLevel); 226 tmp += sprintf(tmp, "-b %d ", flacparms.blocksize); 227 tmp += sprintf(tmp, "-o \"%s\" ", outname); 228 tmp += sprintf(tmp, "\"%s\" ", inname); 229 230 err = system(fbuf) != 0; 231 232 if (err) { 233 printf("Got error from encoder. (check your parameters)\n"); 234 printf("Encoder Commandline: %s\n", fbuf ); 235 exit(-1); 236 } else { 237 return; 238 } 239 } 240 #endif 178 241 if (rawInput) { 179 tmp += sprintf(tmp, "--force-raw-format "); 180 tmp += sprintf(tmp, "--sign=%s ", (rawAudioType.isUnsigned ? "unsigned" : "signed")); 181 tmp += sprintf(tmp, "--channels=%d ", (rawAudioType.isStereo ? 2 : 1)); 182 tmp += sprintf(tmp, "--bps=%d ", rawAudioType.bitsPerSample); 183 tmp += sprintf(tmp, "--sample-rate=%d ", rawSamplerate); 184 tmp += sprintf(tmp, "--endian=%s ", (rawAudioType.isLittleEndian ? "little" : "big")); 242 FILE *inputRaw; 243 long length; 244 char *rawData; 245 246 inputRaw = fopen(inname, "rb"); 247 length = fileSize(inputRaw); 248 rawData = (char *)malloc(length); 249 fread(rawData, 1, length, inputRaw); 250 251 printf(" - length = %d\n", length); 252 printf(" - channels = %d\n", (rawAudioType.isStereo ? 2 : 1)); 253 printf(" - sample rate = %d\n", rawSamplerate); 254 printf(" - compression = %dbits\n", rawAudioType.bitsPerSample); 255 256 encodeRaw(rawData, length, rawSamplerate, outname, compmode); 257 258 fclose(inputRaw); 259 free(rawData); 260 } else { 261 FILE *inputWav; 262 int fmtHeaderSize, length, numChannels, sampleRate, bitsPerSample; 263 char *wavData; 264 265 inputWav = fopen(inname, "rb"); 266 267 /* Standard PCM fmt header is 16 bits, but at least Simon 1 and 2 use 18 bits */ 268 fseek(inputWav, 16, SEEK_SET); 269 fmtHeaderSize = readUint32LE(inputWav); 270 271 fseek(inputWav, 22, SEEK_SET); 272 numChannels = readUint16LE(inputWav); 273 sampleRate = readUint32LE(inputWav); 274 275 fseek(inputWav, 34, SEEK_SET); 276 bitsPerSample = readUint16LE(inputWav); 277 278 /* The size of the raw audio is after the RIFF chunk (12 bytes), fmt chunk (8 + fmtHeaderSize bytes), and data chunk id (4 bytes) */ 279 fseek(inputWav, 24 + fmtHeaderSize, SEEK_SET); 280 length = readUint32LE(inputWav); 281 282 wavData = (char *)malloc(length); 283 fread(wavData, 1, length, inputWav); 284 285 printf(" - length = %d\n", length); 286 printf(" - channels = %d\n", numChannels); 287 printf(" - sample rate = %d\n", sampleRate); 288 printf(" - compression = %dbits\n", bitsPerSample); 289 290 setRawAudioType(true, numChannels == 2, bitsPerSample); 291 encodeRaw(wavData, length, sampleRate, outname, compmode); 292 293 fclose(inputWav); 294 free (wavData); 185 295 } 296 } 186 297 187 for (i = 0; i < flacparms.numArgs; i++) { 188 /* Append optional encoder arguments */ 189 tmp += sprintf(tmp, "%s ", flacparms.argv[i]); 298 void encodeRaw(char *rawData, int length, int samplerate, const char *outname, CompressMode compmode) { 299 #ifndef DISABLE_OGG 300 if (compmode == kVorbisMode) { 301 FILE *outputOgg; 302 char outputString[256] = ""; 303 int numChannels = (rawAudioType.isStereo ? 2 : 1); 304 int totalSamples = length / ((rawAudioType.bitsPerSample / 8) * numChannels); 305 int samplesLeft = totalSamples; 306 int eos = 0; 307 int totalBytes = 0; 308 309 vorbis_info vi; 310 vorbis_comment vc; 311 vorbis_dsp_state vd; 312 vorbis_block vb; 313 314 ogg_stream_state os; 315 ogg_page og; 316 ogg_packet op; 317 318 ogg_packet header; 319 ogg_packet header_comm; 320 ogg_packet header_code; 321 322 outputOgg = fopen(outname,"wb"); 323 324 vorbis_info_init(&vi); 325 326 if (oggparms.nominalBitr > 0) { 327 int result = 0; 328 329 /* Input is in kbps, function takes bps */ 330 result = vorbis_encode_setup_managed(&vi, numChannels, samplerate, (oggparms.maxBitr > 0 ? 1000 * oggparms.maxBitr : -1), (1000 * oggparms.nominalBitr), (oggparms.minBitr > 0 ? 1000 * oggparms.minBitr : -1)); 331 332 if (result == OV_EFAULT) { 333 printf("Error: Internal Logic Fault.\n\n"); 334 vorbis_info_clear(&vi); 335 exit(-1); 336 } else if ((result == OV_EINVAL) || (result == OV_EIMPL)) { 337 printf("Error: Invalid bitrate parameters.\n\n"); 338 vorbis_info_clear(&vi); 339 exit(-1); 340 } 341 342 if (!oggparms.silent) { 343 sprintf(outputString, "Encoding to\n \"%s\"\nat average bitrate %i kbps (", outname, oggparms.nominalBitr); 344 345 if (oggparms.minBitr > 0) { 346 sprintf(outputString + strlen(outputString), "min %i kbps, ", oggparms.minBitr); 347 } else { 348 sprintf(outputString + strlen(outputString), "no min, "); 349 } 350 351 if (oggparms.maxBitr > 0) { 352 sprintf(outputString + strlen(outputString), "max %i kbps),\nusing full bitrate management engine\nSet optional hard quality restrictions\n", oggparms.maxBitr); 353 } else { 354 sprintf(outputString + strlen(outputString), "no max),\nusing full bitrate management engine\nSet optional hard quality restrictions\n"); 355 } 356 } 357 } else { 358 int result = 0; 359 360 /* Quality input is 1 - 10, function takes -0.1 through 1.0 */ 361 result = vorbis_encode_setup_vbr(&vi, numChannels, samplerate, oggparms.quality * 0.1); 362 363 if (result == OV_EFAULT) { 364 printf("Error: Internal Logic Fault.\n\n"); 365 vorbis_info_clear(&vi); 366 exit(-1); 367 } else if ((result == OV_EINVAL) || (result == OV_EIMPL)) { 368 printf("Error: Invalid bitrate parameters.\n\n"); 369 vorbis_info_clear(&vi); 370 exit(-1); 371 } 372 373 if (!oggparms.silent) { 374 sprintf(outputString, "Encoding to\n \"%s\"\nat quality %2.2f", outname, oggparms.quality); 375 } 376 377 if ((oggparms.minBitr > 0) || (oggparms.maxBitr > 0)) { 378 struct ovectl_ratemanage_arg extraParam; 379 vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_GET, &extraParam); 380 381 extraParam.bitrate_hard_min = (oggparms.minBitr > 0 ? (1000 * oggparms.minBitr) : -1); 382 extraParam.bitrate_hard_max = (oggparms.maxBitr > 0 ? (1000 * oggparms.maxBitr) : -1); 383 extraParam.management_active = 1; 384 385 vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, &extraParam); 386 387 if (!oggparms.silent) { 388 sprintf(outputString + strlen(outputString), " using constrained VBR ("); 389 390 if (oggparms.minBitr != -1) { 391 sprintf(outputString + strlen(outputString), "min %i kbps, ", oggparms.minBitr); 392 } else { 393 sprintf(outputString + strlen(outputString), "no min, "); 394 } 395 396 if (oggparms.maxBitr != -1) { 397 sprintf(outputString + strlen(outputString), "max %i kbps)\nSet optional hard quality restrictions\n", oggparms.maxBitr); 398 } else { 399 sprintf(outputString + strlen(outputString), "no max)\nSet optional hard quality restrictions\n"); 400 } 401 } 402 } else { 403 sprintf(outputString + strlen(outputString), "\n"); 404 } 190 405 } 191 406 192 tmp += sprintf(tmp, "-o \"%s\" ", outname); 193 tmp += sprintf(tmp, "\"%s\" ", inname); 407 printf(outputString); 194 408 195 err = system(fbuf) != 0; 196 break; 197 } 409 vorbis_encode_setup_init(&vi); 410 vorbis_comment_init(&vc); 411 vorbis_analysis_init(&vd, &vi); 412 vorbis_block_init(&vd, &vb); 413 ogg_stream_init(&os, 0); 414 vorbis_analysis_headerout(&vd, &vc, &header, &header_comm, &header_code); 198 415 199 if (err) { 200 printf("Got error from encoder. (check your parameters)\n"); 201 printf("Encoder Commandline: %s\n", fbuf ); 202 exit(-1); 416 ogg_stream_packetin(&os, &header); 417 ogg_stream_packetin(&os, &header_comm); 418 ogg_stream_packetin(&os, &header_code); 419 420 while (!eos) { 421 int result = ogg_stream_flush(&os,&og); 422 423 if (result == 0) { 424 break; 425 } 426 427 fwrite(og.header, 1, og.header_len, outputOgg); 428 fwrite(og.body, 1, og.body_len, outputOgg); 429 } 430 431 while (!eos) { 432 int i, j; 433 int numSamples = ((samplesLeft < 2048) ? samplesLeft : 2048); 434 float **buffer = vorbis_analysis_buffer(&vd, numSamples); 435 436 /* We must tell the encoder that we have reached the end of the stream */ 437 if (numSamples == 0) { 438 vorbis_analysis_wrote(&vd, 0); 439 } else { 440 /* Adapted from oggenc 1.1.1 */ 441 if (rawAudioType.bitsPerSample == 8) { 442 unsigned char *rawDataUnsigned = (unsigned char *)rawData; 443 for (i = 0; i < numSamples; i++) { 444 for (j = 0; j < numChannels; j++) { 445 buffer[j][i] = ((int)(rawDataUnsigned[i * numChannels + j]) - 128) / 128.0f; 446 } 447 } 448 } else if(rawAudioType.bitsPerSample == 16) { 449 if(rawAudioType.isLittleEndian) { 450 for(i = 0; i < numSamples; i++) { 451 for(j = 0; j < numChannels; j++) { 452 buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j) + 1] << 8) | (rawData[(i * 2 * numChannels) + (2 * j)] & 0xff)) / 32768.0f; 453 } 454 } 455 } 456 else { 457 for(i = 0; i < numSamples; i++) { 458 for(j = 0; j < numChannels; j++) { 459 buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j)] << 8) | (rawData[(i * 2 * numChannels) + (2 * j) + 1] & 0xff)) / 32768.0f; 460 } 461 } 462 } 463 } 464 465 vorbis_analysis_wrote(&vd, numSamples); 466 } 467 468 while (vorbis_analysis_blockout(&vd, &vb) == 1) { 469 vorbis_analysis(&vb, NULL); 470 vorbis_bitrate_addblock(&vb); 471 472 while (vorbis_bitrate_flushpacket(&vd, &op)) { 473 ogg_stream_packetin(&os, &op); 474 475 while (!eos) { 476 int result = ogg_stream_pageout(&os, &og); 477 478 if(result == 0) { 479 break; 480 } 481 482 totalBytes += fwrite(og.header, 1, og.header_len, outputOgg); 483 totalBytes += fwrite(og.body, 1, og.body_len, outputOgg); 484 485 if(ogg_page_eos(&og)) { 486 eos = 1; 487 } 488 } 489 } 490 } 491 492 rawData += 2048 * (rawAudioType.bitsPerSample / 8) * numChannels; 493 samplesLeft -= 2048; 494 } 495 496 ogg_stream_clear(&os); 497 vorbis_block_clear(&vb); 498 vorbis_dsp_clear(&vd); 499 vorbis_info_clear(&vi); 500 501 fclose(outputOgg); 502 503 if (!oggparms.silent) { 504 printf("\nDone encoding file \"%s\"\n", outname); 505 printf("\n\tFile length: %dm %ds\n", (int)(totalSamples / samplerate / 60), (totalSamples / samplerate % 60)); 506 printf("\tAverage bitrate: %.1f kb/s\n\n", (8.0 * (double)totalBytes / 1000.0) / ((double)totalSamples / (double)samplerate)); 507 } 508 } 509 #endif 510 511 #ifndef DISABLE_FLAC 512 if (compmode == kFlacMode) { 513 int i; 514 int numChannels = (rawAudioType.isStereo ? 2 : 1); 515 int samplesPerChannel = length / ((rawAudioType.bitsPerSample / 8) * numChannels); 516 FLAC__StreamEncoder *encoder; 517 FLAC__StreamEncoderInitStatus initStatus; 518 FLAC__int32 *flacData; 519 520 flacData = (FLAC__int32 *)malloc(samplesPerChannel * numChannels * sizeof(FLAC__int32)); 521 522 if (rawAudioType.bitsPerSample == 8) { 523 for (i = 0; i < samplesPerChannel * numChannels; i++) { 524 FLAC__uint8 *rawDataUnsigned; 525 rawDataUnsigned = (FLAC__uint8 *)rawData; 526 flacData[i] = (FLAC__int32)rawDataUnsigned[i] - 0x80; 527 } 528 } else if (rawAudioType.bitsPerSample == 16) { 529 /* The rawData pointer is an 8-bit char so we must create a new pointer to access 16-bit samples */ 530 FLAC__int16 *rawData16; 531 rawData16 = (FLAC__int16 *)rawData; 532 for (i = 0; i < samplesPerChannel * numChannels; i++) { 533 flacData[i] = (FLAC__int32)rawData16[i]; 534 } 535 } 536 537 if (!flacparms.silent) { 538 printf("Encoding to\n \"%s\"\nat compression level %d using blocksize %d\n\n", outname, flacparms.compressionLevel, flacparms.blocksize); 539 } 540 541 encoder = FLAC__stream_encoder_new(); 542 543 FLAC__stream_encoder_set_bits_per_sample(encoder, rawAudioType.bitsPerSample); 544 FLAC__stream_encoder_set_blocksize(encoder, flacparms.blocksize); 545 FLAC__stream_encoder_set_channels(encoder, numChannels); 546 FLAC__stream_encoder_set_compression_level(encoder, flacparms.compressionLevel); 547 FLAC__stream_encoder_set_sample_rate(encoder, samplerate); 548 FLAC__stream_encoder_set_streamable_subset(encoder, false); 549 FLAC__stream_encoder_set_total_samples_estimate(encoder, samplesPerChannel); 550 FLAC__stream_encoder_set_verify(encoder, flacparms.verify); 551 552 initStatus = FLAC__stream_encoder_init_file(encoder, outname, NULL, NULL); 553 554 if (initStatus != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { 555 printf("Got error from encoder. (check your paramters)\n"); 556 printf("FLAC error: %s\n\n", FLAC__StreamEncoderInitStatusString[initStatus]); 557 exit(-1); 558 } else { 559 FLAC__stream_encoder_process_interleaved(encoder, flacData, samplesPerChannel); 560 } 561 562 FLAC__stream_encoder_finish(encoder); 563 FLAC__stream_encoder_delete(encoder); 564 565 free(flacData); 566 567 if (!flacparms.silent) { 568 printf("\nDone encoding file \"%s\"\n", outname); 569 printf("\n\tFile length: %dm %ds\n\n", (int)(samplesPerChannel / samplerate / 60), (samplesPerChannel / samplerate % 60)); 570 } 203 571 } 572 #endif 204 573 } 205 574 206 575 void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode) { … … 261 630 length = fgetc(input); 262 631 length |= fgetc(input) << 8; 263 632 length |= fgetc(input) << 16; 633 264 634 if (blocktype == 1) { 265 635 length -= 2; 266 636 sample_rate = fgetc(input); … … 287 657 (comp == 3 ? "2bits" : 288 658 "Multi")))), comp); 289 659 290 if (comp != 0) 660 if (comp != 0) { 291 661 error("Cannot handle compressed VOC data"); 662 } 292 663 293 664 /* Copy the raw data to a temporary file */ 294 665 while (length > 0) { 295 666 size = fread(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : (uint32)length, input); 296 if (size <= 0) 667 668 if (size <= 0) { 297 669 break; 670 } 671 298 672 length -= (int)size; 299 673 fwrite(fbuf, 1, size, f); 300 674 } … … 304 678 305 679 assert(real_samplerate != -1); 306 680 307 setRawAudioType(false, false, true,8);681 setRawAudioType(false, false, 8); 308 682 309 683 /* Convert the raw temp file to OGG/MP3 */ 310 684 encodeAudio(outName, true, real_samplerate, tempEncoded, compMode); … … 318 692 encparms.abr=1; 319 693 } else if (strcmp(argv[i], "-b") == 0) { 320 694 encparms.minBitr = atoi(argv[i + 1]); 321 if ((encparms.minBitr % 8) != 0) 695 696 if ((encparms.minBitr % 8) != 0) { 322 697 encparms.minBitr -= encparms.minBitr % 8; 323 if (encparms.minBitr >160) 698 } 699 700 if (encparms.minBitr >160) { 324 701 encparms.minBitr = 160; 325 if (encparms.minBitr < 8) 326 encparms.minBitr=8; 702 } 703 704 if (encparms.minBitr < 8) { 705 encparms.minBitr = 8; 706 } 707 327 708 i++; 328 709 } else if (strcmp(argv[i], "-B") == 0) { 329 710 encparms.maxBitr = atoi(argv[i + 1]); 330 if ((encparms.maxBitr % 8) != 0) 711 712 if ((encparms.maxBitr % 8) != 0) { 331 713 encparms.maxBitr -= encparms.maxBitr % 8; 332 if (encparms.maxBitr > 160) 714 } 715 716 if (encparms.maxBitr > 160) { 333 717 encparms.maxBitr = 160; 334 if (encparms.maxBitr < 8) 718 } 719 720 if (encparms.maxBitr < 8) { 335 721 encparms.maxBitr = 8; 722 } 723 336 724 i++; 337 725 } else if (strcmp(argv[i], "-V") == 0) { 338 726 encparms.vbrqual = atoi(argv[i + 1]); 339 if(encparms.vbrqual < 0) 727 728 if(encparms.vbrqual < 0) { 340 729 encparms.vbrqual = 0; 341 if(encparms.vbrqual > 9) 730 } 731 732 if(encparms.vbrqual > 9) { 342 733 encparms.vbrqual = 9; 734 } 735 343 736 i++; 344 737 } else if (strcmp(argv[i], "-q") == 0) { 345 738 encparms.algqual = atoi(argv[i + 1]); 346 if (encparms.algqual < 0) 739 740 if (encparms.algqual < 0) { 347 741 encparms.algqual = 0; 348 if (encparms.algqual > 9) 742 } 743 744 if (encparms.algqual > 9) { 349 745 encparms.algqual = 9; 746 } 747 350 748 i++; 351 749 } else if (strcmp(argv[i], "--silent") == 0) { 352 750 encparms.silent = 1; … … 358 756 break; 359 757 } 360 758 } 759 361 760 if (i != (argc - 1)) { 362 761 return 0; 363 762 } 763 364 764 return 1; 365 765 } 366 766 … … 368 768 for (; i < argc; i++) { 369 769 if (strcmp(argv[i], "-b") == 0) { 370 770 oggparms.nominalBitr = atoi(argv[i + 1]); 771 772 if ((oggparms.nominalBitr % 8) != 0) { 773 oggparms.nominalBitr -= oggparms.nominalBitr % 8; 774 } 775 776 if (oggparms.nominalBitr >160) { 777 oggparms.nominalBitr = 160; 778 } 779 780 if (oggparms.nominalBitr < 8) { 781 oggparms.nominalBitr = 8; 782 } 783 371 784 i++; 372 } 373 else if (strcmp(argv[i], "-m") == 0) { 785 } else if (strcmp(argv[i], "-m") == 0) { 374 786 oggparms.minBitr = atoi(argv[i + 1]); 787 788 if ((oggparms.minBitr % 8) != 0) { 789 oggparms.minBitr -= oggparms.minBitr % 8; 790 } 791 792 if (oggparms.minBitr >160) { 793 oggparms.minBitr = 160; 794 } 795 796 if (oggparms.minBitr < 8) { 797 oggparms.minBitr = 8; 798 } 799 375 800 i++; 376 801 } 377 802 else if (strcmp(argv[i], "-M") == 0) { 378 803 oggparms.maxBitr = atoi(argv[i + 1]); 804 805 if ((oggparms.maxBitr % 8) != 0) { 806 oggparms.maxBitr -= encparms.minBitr % 8; 807 } 808 809 if (oggparms.maxBitr >160) { 810 oggparms.maxBitr = 160; 811 } 812 813 if (oggparms.maxBitr < 8) { 814 oggparms.maxBitr = 8; 815 } 816 379 817 i++; 380 818 } 381 819 else if (strcmp(argv[i], "-q") == 0) { … … 391 829 else if (argv[i][0] == '-') { 392 830 return 0; 393 831 } 394 else 832 else { 395 833 break; 834 } 396 835 } 397 if (i != argc - 1) 836 837 if (i != argc - 1) { 398 838 return 0; 839 } 840 399 841 return 1; 400 842 } 401 843 402 844 int process_flac_parms(int argc, char *argv[], int i){ 403 flacparms.argv = &argv[i]; 404 flacparms.numArgs = argc - 1 - i; 845 for (; i < argc; i++) { 846 if (strcmp(argv[i], "-b") == 0) { 847 flacparms.blocksize = atoi(argv[i + 1]); 848 i++; 849 } 850 else if (strcmp(argv[i], "--fast") == 0) { 851 flacparms.compressionLevel = 0; 852 } 853 else if (strcmp(argv[i], "--best") == 0) { 854 flacparms.compressionLevel = 8; 855 } 856 else if (strcmp(argv[i], "-0") == 0) { 857 flacparms.compressionLevel = 0; 858 } 859 else if (strcmp(argv[i], "-1") == 0) { 860 flacparms.compressionLevel = 1; 861 } 862 else if (strcmp(argv[i], "-2") == 0) { 863 flacparms.compressionLevel = 2; 864 } 865 else if (strcmp(argv[i], "-3") == 0) { 866 flacparms.compressionLevel = 3; 867 } 868 else if (strcmp(argv[i], "-4") == 0) { 869 flacparms.compressionLevel = 4; 870 } 871 else if (strcmp(argv[i], "-5") == 0) { 872 flacparms.compressionLevel = 5; 873 } 874 else if (strcmp(argv[i], "-6") == 0) { 875 flacparms.compressionLevel = 6; 876 } 877 else if (strcmp(argv[i], "-7") == 0) { 878 flacparms.compressionLevel = 7; 879 } 880 else if (strcmp(argv[i], "-8") == 0) { 881 flacparms.compressionLevel = 8; 882 } 883 else if (strcmp(argv[i], "--verify") == 0) { 884 flacparms.verify = true; 885 } 886 else if (strcmp(argv[i], "--silent") == 0) { 887 flacparms.silent = true; 888 } 889 else if (strcmp(argv[i], "--help") == 0) { 890 return 0; 891 } 892 else if (argv[i][0] == '-') { 893 return 0; 894 } 895 else { 896 break; 897 } 898 } 405 899 406 if (i >= argc)900 if (i != argc - 1) { 407 901 return 0; 902 } 903 408 904 return 1; 409 905 } -
compress.h
24 24 #define EXTRACT_H 25 25 26 26 #include "util.h" 27 #include <vorbis/vorbisenc.h> 28 #include <FLAC/stream_encoder.h> 27 29 28 30 #if defined(__cplusplus) 29 31 extern "C" { … … 38 40 /* The default for oggenc invocation is to use the --quality option only */ 39 41 #define oggqualDef 3 40 42 43 /* These are the default parameters for the FLAC invocation */ 44 #define flacCompressDef 8 45 #define flacBlocksizeDef 1152 46 41 47 #define TEMP_WAV "tempfile.wav" 42 48 #define TEMP_RAW "tempfile.raw" 43 49 #define TEMP_MP3 "tempfile.mp3" … … 60 66 extern void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode); 61 67 62 68 extern void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode); 63 extern void setRawAudioType(bool isLittleEndian, bool isStereo, bool isUnSigned, uint8 bitsPerSample); 69 extern void encodeRaw(char *rawData, int length, int samplerate, const char *outname, CompressMode compmode); 70 extern void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample); 64 71 65 72 #if defined(__cplusplus) 66 73 } -
compress_agos.c
74 74 unlink(TEMP_RAW); 75 75 unlink(tempEncoded); 76 76 unlink(TEMP_WAV); 77 77 78 78 exit(0); 79 79 } 80 80 81 81 82 82 static int get_offsets(uint32 filenums[], uint32 offsets[]) 83 83 { 84 84 int i; … … 173 173 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 174 174 175 175 printf("\nFlac mode params:\n"); 176 printf(" [params] optional arguments passed directly to the encoder\n"); 177 printf(" recommended is: --best -b 1152\n"); 176 printf(" --fast FLAC uses compresion level 0\n"); 177 printf(" --best FLAC uses compresion level 8\n"); 178 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 179 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 180 printf(" --verify files are encoded and then decoded to check accuracy\n"); 181 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 178 182 179 183 printf("\n --help this help message\n"); 180 184 … … 253 257 char tmp[256]; 254 258 uint32 filenums[32768]; 255 259 uint32 offsets[32768]; 256 260 257 261 sprintf(infile_base, "simon2"); 258 262 259 263 input = fopen("voices.idx", "rb"); … … 295 299 sprintf(tmp, "voices%d.dat", filenums[i]); 296 300 if (input) 297 301 fclose(input); 298 input = fopen(tmp, "rb"); 302 input = fopen(tmp, "rb"); 299 303 if (!input) { 300 304 printf("Cannot open file: %s\n", tmp); 301 305 exit(-1); … … 311 315 int main(int argc, char *argv[]) 312 316 { 313 317 int i; 314 318 315 319 if (argc < 2) 316 320 showhelp(argv[0]); 317 321 -
compress_kyra.cpp
39 39 if (argc < 3) 40 40 showhelp(argv[0]); 41 41 42 char inputFile[256]; 43 char outputFile[256]; 42 44 int i = 0; 45 43 46 /* Compression mode */ 44 47 gCompMode = kMP3Mode; 45 48 i = 1; 49 46 50 if (strcmp(argv[1], "--mp3") == 0) { 47 51 gCompMode = kMP3Mode; 48 52 i++; … … 60 64 case kMP3Mode: 61 65 outputExt = OUTPUT_MP3; 62 66 tempEncoded = TEMP_MP3; 63 if (!process_mp3_parms(argc - 1, argv, i))67 if (!process_mp3_parms(argc - 2, argv, i)) 64 68 showhelp(argv[0]); 65 69 break; 66 70 case kVorbisMode: 67 71 outputExt = OUTPUT_OGG; 68 72 tempEncoded = TEMP_OGG; 69 if (!process_ogg_parms(argc - 1, argv, i))73 if (!process_ogg_parms(argc - 2, argv, i)) 70 74 showhelp(argv[0]); 71 75 break; 72 76 case kFlacMode: 73 77 outputExt = OUTPUT_FLAC; 74 78 tempEncoded = TEMP_FLAC; 75 if (!process_flac_parms(argc - 1, argv, i))79 if (!process_flac_parms(argc - 2, argv, i)) 76 80 showhelp(argv[0]); 77 81 break; 78 82 } 79 80 if (scumm_stricmp(argv[argc - 2], argv[argc - 1]) == 0) 83 84 sprintf(inputFile, "%s/%s", argv[argc - 2], argv[argc - 3]); 85 sprintf(outputFile, "%s/%s", argv[argc - 1], argv[argc - 3]); 86 87 if (scumm_stricmp(inputFile, outputFile) == 0) 81 88 error("infile and outfile are the same file"); 82 process( argv[argc - 2], argv[argc - 1]);89 process(inputFile, outputFile); 83 90 return 0; 84 91 } 85 92 86 93 static void showhelp(const char *exename) { 87 printf("\nUsage: %s <params> infile outfile\n", exename);94 printf("\nUsage: %s [params] <inputfile> <inputdir> <outputdir>\n", exename); 88 95 89 96 printf("\nParams:\n"); 90 97 printf(" --mp3 encode to MP3 format (default)\n"); … … 109 116 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 110 117 111 118 printf("\nFlac mode params:\n"); 112 printf(" [params] optional arguments passed directly to the encoder\n"); 113 printf(" recommended is: --best -b 1152\n"); 119 printf(" --fast FLAC uses compresion level 0\n"); 120 printf(" --best FLAC uses compresion level 8\n"); 121 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 122 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 123 printf(" --verify files are encoded and then decoded to check accuracy\n"); 124 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 114 125 115 126 printf("\n --help this help message\n"); 116 127 … … 136 147 return; 137 148 if (!output.loadFile(0, false)) 138 149 return; 139 150 140 151 PAKFile::cFileList *list = input.getFileList(); 141 152 char outputName[32]; 142 153 for (; list; list = list->next) { … … 150 161 151 162 input.outputFileAs(list->filename, TEMPFILE); 152 163 strncpy(outputName, list->filename, 32); 153 164 154 165 FILE *tempFile = fopen(TEMPFILE, "rb"); 155 166 fseek(tempFile, 26, SEEK_CUR); 156 167 extractAndEncodeVOC(TEMP_RAW, tempFile, gCompMode); 157 168 fclose(tempFile); 158 169 159 170 char *vocStart = strstr(outputName, ".VOC"); 160 171 for (unsigned int i = 0; i < strlen(outputExt); ++i) 161 172 vocStart[i] = outputExt[i]; 162 173 output.addFile(outputName, tempEncoded); 163 174 164 175 unlink(TEMPFILE); 165 176 unlink(TEMP_RAW); 166 177 unlink(tempEncoded); 167 178 } 168 179 169 180 if (output.getFileList()) { 170 181 output.saveFile(outfile); 171 182 } else { -
compress_queen.c
20 20 * 21 21 */ 22 22 23 #include " util.h"23 #include "compress.h" 24 24 25 25 static const uint32 QTBL = 'QTBL'; 26 static CompressMode gCompMode = kMP3Mode; 26 27 27 28 #define INPUT_TBL "queen.tbl" 28 29 #define FINAL_OUT "queen.1c" … … 31 32 #define TEMP_TBL "tempfile.tbl" 32 33 #define TEMP_SB "tempfile.sb" 33 34 34 #define TEMP_MP3 "tempfile.mp3"35 #define TEMP_OGG "tempfile.ogg"36 #define TEMP_FLAC "tempfile.fla"37 38 const char *tempEncoded;39 40 35 #define CURRENT_TBL_VERSION 2 41 36 #define EXTRA_TBL_HEADER 8 42 37 #define SB_HEADER_SIZE_V104 110 … … 126 121 127 122 void showhelp(char *exename) 128 123 { 129 printf("\nUsage: %s [--mp3/--vorbis/--flac <args>] queen.1\n", exename); 124 printf("\nUsage: %s <params> queen.1\n", exename); 125 130 126 printf("\nParams:\n"); 131 printf(" --mp3 <args> encode to MP3 format\n"); 132 printf(" --vorbis <args> encode to Ogg Vorbis Format\n"); 133 printf(" --flac <args> encode to Flac Format\n"); 134 printf(" (Optional: <args> are passed on to the encoder)\n"); 135 printf("\nExample: %s --mp3 -q 5 queen.1\n", exename); 127 128 printf(" --mp3 encode to MP3 format (default)\n"); 129 printf(" --vorbis encode to Ogg Vorbis format\n"); 130 printf(" --flac encode to Flac format\n"); 131 printf("(If one of these is specified, it must be the first parameter.)\n"); 132 133 printf("\nMP3 mode params:\n"); 134 printf(" -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef); 135 printf(" -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef); 136 printf(" --vbr LAME uses the VBR mode (default)\n"); 137 printf(" --abr LAME uses the ABR mode\n"); 138 printf(" -V <value> specifies the value (0 - 9) of VBR quality (0=best) (default:%d)\n", vbrqualDef); 139 printf(" -q <value> specifies the MPEG algorithm quality (0-9; 0=best) (default:%d)\n", algqualDef); 140 printf(" --silent the output of LAME is hidden (default:disabled)\n"); 141 142 printf("\nVorbis mode params:\n"); 143 printf(" -b <rate> <rate> is the nominal bitrate (default:unset)\n"); 144 printf(" -m <rate> <rate> is the minimum bitrate (default:unset)\n"); 145 printf(" -M <rate> <rate> is the maximum bitrate (default:unset)\n"); 146 printf(" -q <value> specifies the value (0 - 10) of VBR quality (10=best) (default:%d)\n", oggqualDef); 147 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 148 149 printf("\nFlac mode params:\n"); 150 printf(" --fast FLAC uses compresion level 0\n"); 151 printf(" --best FLAC uses compresion level 8\n"); 152 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 153 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 154 printf(" --verify files are encoded and then decoded to check accuracy\n"); 155 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 156 157 printf("\n --help this help message\n"); 158 159 printf("\n\nIf a parameter is not given the default value is used\n"); 160 printf("If using VBR mode for MP3 -b and -B must be multiples of 8; the maximum is 160!\n"); 136 161 exit(2); 137 162 } 138 163 … … 219 244 FILE *inputData, *inputTbl, *outputTbl, *outputData, *tmpFile, *compFile; 220 245 uint8 compressionType = COMPRESSION_NONE; 221 246 char tmp[5]; 222 char sysBuf[1024];223 char *ptr = sysBuf;224 247 int size, i = 1; 225 248 uint32 prevOffset; 226 249 … … 228 251 if (argc < 2) 229 252 showhelp(argv[0]); 230 253 254 /* compression mode */ 255 compressionType = COMPRESSION_MP3; 256 gCompMode = kMP3Mode; 257 231 258 if (strcmp(argv[1], "--mp3") == 0) { 232 259 compressionType = COMPRESSION_MP3; 233 tempEncoded = TEMP_MP3;260 gCompMode = kMP3Mode; 234 261 i++; 235 ptr += sprintf(ptr, "lame -r -h -s 11 --bitwidth 8 -m m ");236 for (; i < (argc - 1); i++) {237 /* Append optional encoder arguments */238 ptr += sprintf(ptr, "%s ", argv[i]);239 }240 ptr += sprintf(ptr, "%s %s", TEMP_SB, tempEncoded);241 262 } else if (strcmp(argv[1], "--vorbis") == 0) { 242 263 compressionType = COMPRESSION_OGG; 243 tempEncoded = TEMP_OGG;264 gCompMode = kVorbisMode; 244 265 i++; 245 ptr += sprintf(ptr, "oggenc -r -B 8 -C 1 -R 11025 %s -o %s ", TEMP_SB, tempEncoded);246 for (; i < (argc - 1); i++) {247 /* Append optional encoder arguments */248 ptr += sprintf(ptr, "%s ", argv[i]);249 }250 266 } else if (strcmp(argv[1], "--flac") == 0) { 251 267 compressionType = COMPRESSION_FLAC; 252 tempEncoded = TEMP_FLAC;268 gCompMode = kFlacMode; 253 269 i++; 254 ptr += sprintf(ptr, "flac --force-raw-format --endian=little --sign=unsigned --bps=8 --channels=1 --sample-rate=11025 " ); 255 ptr += sprintf(ptr, "--no-padding --lax --no-seektable --no-ogg " ); 256 for (; i < (argc - 1); i++) { 257 /* Append optional encoder arguments */ 258 ptr += sprintf(ptr, "%s ", argv[i]); 259 } 270 } 260 271 261 ptr += sprintf(ptr, "-o %s %s", tempEncoded, TEMP_SB ); 262 } else { 263 showhelp(argv[0]); 272 switch (gCompMode) { 273 case kMP3Mode: 274 tempEncoded = TEMP_MP3; 275 if (!process_mp3_parms(argc, argv, i)) 276 showhelp(argv[0]); 277 break; 278 case kVorbisMode: 279 tempEncoded = TEMP_OGG; 280 if (!process_ogg_parms(argc, argv, i)) 281 showhelp(argv[0]); 282 break; 283 case kFlacMode: 284 tempEncoded = TEMP_FLAC; 285 if (!process_flac_parms(argc, argv, i)) 286 showhelp(argv[0]); 287 break; 264 288 } 265 289 266 290 /* Open input file (QUEEN.1) */ … … 342 366 fclose(tmpFile); 343 367 344 368 /* Invoke encoder */ 345 if (system(sysBuf)) { 346 printf("Got error from encoder. (check your parameters)\n"); 347 unlink(TEMP_SB); 348 exit(-1); 349 } 369 setRawAudioType(false, false, 8); 370 encodeAudio(TEMP_SB, true, 11025, tempEncoded, gCompMode); 350 371 351 372 /* Append MP3/OGG to data file */ 352 373 compFile = fopen(tempEncoded, "rb"); -
compress_saga.cpp
19 19 * 20 20 * $URL$ 21 21 * $Id$ 22 * 22 * 23 23 */ 24 24 25 25 #include "compress.h" … … 194 194 uint32 size; 195 195 char fbuf[2048]; 196 196 FILE * tempf; 197 197 198 198 tempf = fopen(fromFileName, "rb"); 199 199 if (tempf == NULL) 200 200 error("Unable to open %s", fromFileName); … … 211 211 uint32 size; 212 212 char fbuf[2048]; 213 213 FILE * tempf; 214 214 215 215 tempf = fopen(toFileName, "wb"); 216 216 if (tempf == NULL) 217 217 error("Unable to open %s", toFileName); … … 228 228 229 229 void writeBufferToFile(uint8* data, uint32 inputSize, const char* toFileName) { 230 230 FILE * tempf; 231 231 232 232 tempf = fopen(toFileName, "wb"); 233 233 if (tempf == NULL) 234 234 error("Unable to open %s", toFileName); … … 248 248 Common::File inputFileStream(inputFile); 249 249 int rate, size; 250 250 byte flags; 251 251 252 252 if (currentFileDescription->resourceType == kSoundVOC) { 253 253 inputData = Audio::loadVOCFromStream(inputFileStream, size, rate); 254 254 sampleSize = size; … … 259 259 free(inputData); 260 260 writeHeader(outputFile); 261 261 262 setRawAudioType( true, false, !isSigned,8);262 setRawAudioType( true, false, 8); 263 263 encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode); 264 264 return copyFile(tempEncoded, outputFile) + HEADER_SIZE; 265 265 } … … 271 271 sampleStereo = currentFileDescription->stereo; 272 272 writeHeader(outputFile); 273 273 274 setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, !isSigned,sampleBits);274 setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, sampleBits); 275 275 encodeAudio(TEMP_RAW, true, currentFileDescription->frequency, tempEncoded, gCompMode); 276 276 return copyFile(tempEncoded, outputFile) + HEADER_SIZE; 277 277 } … … 287 287 288 288 copyFile(inputFile, size, TEMP_RAW); 289 289 290 setRawAudioType( true, sampleStereo != 0, !isSigned,sampleBits);290 setRawAudioType( true, sampleStereo != 0, sampleBits); 291 291 encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode); 292 292 return copyFile(tempEncoded, outputFile) + HEADER_SIZE; 293 293 } … … 302 302 sampleStereo = currentFileDescription->stereo; 303 303 writeHeader(outputFile); 304 304 305 setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, !isSigned,sampleBits);305 setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, sampleBits); 306 306 encodeAudio(TEMP_RAW, true, currentFileDescription->frequency, tempEncoded, gCompMode); 307 307 return copyFile(tempEncoded, outputFile) + HEADER_SIZE; 308 308 */ … … 348 348 error("Something's wrong with your resource file"); 349 349 } 350 350 351 // Go to beginning of the table 351 // Go to beginning of the table 352 352 fseek(inputFile, resTableOffset, SEEK_SET); 353 353 354 354 inputTable = (Record*)malloc(resTableCount * sizeof(Record)); 355 355 356 // Put offsets of all the records in a table 356 // Put offsets of all the records in a table 357 357 for (i = 0; i < resTableCount; i++) { 358 358 359 359 if (!currentFileDescription->swapEndian) { … … 365 365 } 366 366 367 367 printf("Record: %ul, offset: %ul, size: %ul\n", i, inputTable[i].offset, inputTable[i].size); 368 368 369 369 if ((inputTable[i].offset > inputFileSize) || 370 370 (inputTable[i].offset + inputTable[i].size > inputFileSize)) { 371 371 error("The offset points outside the file"); … … 374 374 } 375 375 outputTable = (Record*)malloc(resTableCount * sizeof(Record)); 376 376 377 sprintf(outputFileNameWithExt, "%s.cmp", inputFileName); 377 sprintf(outputFileNameWithExt, "%s.cmp", inputFileName); 378 378 outputFile = fopen(outputFileNameWithExt, "wb"); 379 379 380 380 for (i = 0; i < resTableCount; i++) { 381 381 fseek(inputFile, inputTable[i].offset, SEEK_SET); 382 382 outputTable[i].offset = ftell(outputFile); 383 383 384 384 outputTable[i].size = encodeEntry(inputFile, inputTable[i].size, outputFile); 385 385 } 386 386 fclose(inputFile); … … 391 391 writeUint32LE(outputFile, outputTable[i].size); 392 392 } 393 393 writeUint32LE(outputFile, resTableOffset); 394 writeUint32LE(outputFile, resTableCount); // Should be the same number of entries 394 writeUint32LE(outputFile, resTableCount); // Should be the same number of entries 395 395 396 396 fclose(outputFile); 397 397 398 398 free(inputTable); 399 399 free(outputTable); 400 400 401 401 // Cleanup 402 402 unlink(TEMP_RAW); 403 403 unlink(tempEncoded); … … 406 406 } 407 407 408 408 void showhelp(char *exename) { 409 printf("\nUsage: %s <params> [<file> | mac]\n", exename);409 printf("\nUsage: %s [params] <file>\n", exename); 410 410 411 411 printf("\nParams:\n"); 412 412 … … 432 432 printf("--silent the output of oggenc is hidden (default:disabled)\n"); 433 433 434 434 printf("\nFlac mode params:\n"); 435 printf("[params] optional Arguments passed to the Encoder\n"); 436 printf(" recommended is: --best -b 1152\n"); 435 printf(" --fast FLAC uses compresion level 0\n"); 436 printf(" --best FLAC uses compresion level 8\n"); 437 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 438 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 439 printf(" --verify files are encoded and then decoded to check accuracy\n"); 440 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 437 441 438 442 printf("\n--help this help message\n"); 439 443 -
compress_scumm_bun.cpp
614 614 } 615 615 616 616 void showhelp(char *exename) { 617 printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);617 printf("\nUsage: %s [--vorbis] [params] <inputfile> <inputdir> <outputdir>\n", exename); 618 618 printf("\nMP3 mode params:\n"); 619 619 printf(" -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef); 620 620 printf(" -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef); … … 1064 1064 uint32 tag; 1065 1065 int32 numFiles, offset, i; 1066 1066 1067 strcpy(inputFilename, argv[ 1]);1068 strcpy(inputDir, argv[ 2]);1069 strcpy(outputDir, argv[ 3]);1067 strcpy(inputFilename, argv[argc - 3]); 1068 strcpy(inputDir, argv[argc - 2]); 1069 strcpy(outputDir, argv[argc - 1]); 1070 1070 1071 1071 if (argc > 4) { 1072 i = 4; 1072 int result; 1073 i = 1; 1073 1074 1074 if (strcmp(argv[i], "-- ogg") == 0) {1075 if (strcmp(argv[i], "--vorbis") == 0) { 1075 1076 _oggMode = true; 1076 1077 i++; 1077 1078 } 1078 1079 1079 if (argc > i) { 1080 // HACK: The functions in compress.c expect the last 1081 // argument to be a filename. As we don't expect one, 1082 // we simply add a dummy argument to the list. 1083 char **args = (char **)malloc((argc + 1) * sizeof(char *)); 1084 char dummyName[] = "dummy"; 1085 int j; 1080 if (_oggMode) 1081 result = process_ogg_parms(argc - 2, argv, i); 1082 else 1083 result = process_mp3_parms(argc - 2, argv, i); 1086 1084 1087 for (j = 0; j < argc; j++) 1088 args[j] = argv[j]; 1089 args[j] = dummyName; 1090 1091 int result; 1092 1093 if (_oggMode) 1094 result = process_ogg_parms(argc + 1, args, i); 1095 else 1096 result = process_mp3_parms(argc + 1, args, i); 1097 1098 if (!result) 1099 showhelp(argv[0]); 1100 1101 free(args); 1102 } 1085 if (!result) 1086 showhelp(argv[0]); 1103 1087 } 1104 1088 1105 1089 char *index = strrchr(inputFilename, '.'); … … 1141 1125 char filename[13], c; 1142 1126 int z = 0; 1143 1127 int z2; 1144 1128 1145 1129 for (z2 = 0; z2 < 8; z2++) 1146 1130 if ((c = readByte(input)) != 0) 1147 1131 filename[z++] = c; … … 1181 1165 fclose(input); 1182 1166 1183 1167 printf("compression done.\n"); 1184 1168 1185 1169 return 0; 1186 1170 } -
compress_scumm_san.cpp
24 24 #include "zlib.h" 25 25 26 26 void showhelp(char *exename) { 27 printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);27 printf("\nUsage: %s [--vorbis] [encoder params] <inputfile> <inputdir> <outputdir>\n", exename); 28 28 printf("\nMP3 mode params:\n"); 29 29 printf(" -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef); 30 30 printf(" -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef); … … 643 643 char inputFilename[200]; 644 644 char tmpPath[200]; 645 645 646 strcpy(inputFilename, argv[ 1]);647 strcpy(inputDir, argv[ 2]);648 strcpy(outputDir, argv[ 3]);646 strcpy(inputFilename, argv[argc - 3]); 647 strcpy(inputDir, argv[argc - 2]); 648 strcpy(outputDir, argv[argc - 1]); 649 649 650 650 if (argc > 4) { 651 int i = 4;651 int i = 1; 652 652 653 if (strcmp(argv[ i], "--ogg") == 0) {653 if (strcmp(argv[1], "--vorbis") == 0) { 654 654 _oggMode = true; 655 655 i++; 656 656 } 657 657 658 if (argc > i) { 659 // HACK: The functions in compress.c expect the last 660 // argument to be a filename. As we don't expect one, 661 // we simply add a dummy argument to the list. 662 char **args = (char **)malloc((argc + 1) * sizeof(char *)); 663 char dummyName[] = "dummy"; 664 int j; 658 int result; 665 659 666 for (j = 0; j < argc; j++) 667 args[j] = argv[j]; 668 args[j] = dummyName; 669 670 int result; 660 if (_oggMode) 661 result = process_ogg_parms(argc - 2, argv, i); 662 else 663 result = process_mp3_parms(argc - 2, argv, i); 671 664 672 if (_oggMode) 673 result = process_ogg_parms(argc + 1, args, i); 674 else 675 result = process_mp3_parms(argc + 1, args, i); 676 677 if (!result) 678 showhelp(argv[0]); 679 680 free(args); 681 } 665 if (!result) 666 showhelp(argv[0]); 682 667 } 683 668 684 669 char *index = strrchr(inputFilename, '.'); … … 903 888 } 904 889 905 890 free(frameInfo); 906 891 907 892 fclose(output); 908 893 909 894 printf("compression done.\n"); 910 895 911 896 return 0; 912 897 } -
compress_scumm_sou.c
72 72 unlink(TEMP_DAT); 73 73 unlink(TEMP_RAW); 74 74 unlink(tempEncoded); 75 75 76 76 exit(-1); 77 77 } 78 78 … … 130 130 131 131 /* Conver the VOC data */ 132 132 extractAndEncodeVOC(TEMP_RAW, input, gCompMode); 133 133 134 134 /* Append the converted data to the master output file */ 135 135 sprintf(outname, tempEncoded); 136 136 f = fopen(outname, "rb"); … … 171 171 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 172 172 173 173 printf("\nFlac mode params:\n"); 174 printf(" [params] optional arguments passed directly to the encoder\n"); 175 printf(" recommended is: --best -b 1152\n"); 174 printf(" --fast FLAC uses compresion level 0\n"); 175 printf(" --best FLAC uses compresion level 8\n"); 176 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 177 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 178 printf(" --verify files are encoded and then decoded to check accuracy\n"); 179 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 176 180 177 181 printf("\n --help this help message\n"); 178 182 … … 242 246 printf("Can't open file " TEMP_DAT " for write!\n"); 243 247 exit(-1); 244 248 } 245 249 246 250 /* Get the 'SOU ....' header */ 247 251 fread(buf, 1, 8, input); 248 252 if (strncmp(buf, f_hdr, 8)) { -
compress_sword1.c
116 116 { "2M26", false }, 117 117 { "3M7", false }, 118 118 { "3M8", false }, 119 { "3M9", true }, 119 { "3M9", true }, 120 120 { "3M10", false }, 121 121 { "2M13", false }, 122 122 { "3M12", false }, … … 163 163 { "4M31", false }, 164 164 { "4M32", false }, 165 165 { "5M1", false }, 166 { "5M2", true }, 166 { "5M2", true }, 167 167 { "5M3", false }, 168 168 { "5M4", false }, 169 169 { "5M5", false }, … … 275 275 { "11M4", false }, 276 276 { "11M7", false }, 277 277 { "11M8", false }, 278 { "11M9", true }, 278 { "11M9", true }, 279 279 { "12M1", false }, 280 280 { "11M2", false }, 281 281 { "SPM2", false }, … … 308 308 }; 309 309 310 310 void showhelp(char *exename) { 311 printf("\nUsage: %s <params>\n", exename);311 printf("\nUsage: %s [params]\n", exename); 312 312 313 313 printf("\nParams:\n"); 314 314 printf(" --mp3 encode to MP3 format (default)\n"); … … 337 337 printf(" (default:%d)\n", oggqualDef); 338 338 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 339 339 340 printf("\nFlac mode params:\n"); 341 printf(" --fast FLAC uses compresion level 0\n"); 342 printf(" --best FLAC uses compresion level 8\n"); 343 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 344 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 345 printf(" --verify files are encoded and then decoded to check accuracy\n"); 346 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 347 340 348 printf("\n --help this help message\n"); 341 349 342 350 printf("\nIf a parameter is not given the default value is used\n"); … … 438 446 } 439 447 cl3Index = (uint32*)malloc(numSamples * 8); 440 448 memset(cl3Index, 0, numSamples * 8); 441 449 442 450 sampleIndex = cowHeader + numRooms + 1; 443 451 /* This points to the sample index table. 8 bytes each (4 bytes size and then 4 bytes file index) */ 444 452 … … 446 454 447 455 for (cnt = 0; cnt < numSamples; cnt++) { 448 456 if (sampleIndex[cnt << 1] | sampleIndex[(cnt << 1) | 1]) { 449 printf("sample %5d: ", cnt);457 printf("sample %5d: \n", cnt); 450 458 smpData = (uint8*)uncompressSpeech(clu, sampleIndex[cnt << 1] + headerSize, sampleIndex[(cnt << 1) | 1], &smpSize); 451 459 if ((!smpData) || (!smpSize)) 452 460 error("unable to handle speech sample %d!\n", cnt); … … 475 483 int i; 476 484 char cluName[256], outName[256]; 477 485 478 setRawAudioType(true, false, false,16);486 setRawAudioType(true, false, 16); 479 487 for (i = 1; i <= 2; i++) { 480 488 sprintf(cluName, "SPEECH/SPEECH%d.CLU", i); 481 489 clu = fopen(cluName, "rb"); … … 670 678 compressSpeech(compMode); 671 679 if (compMusic) 672 680 compressMusic(compMode); 673 681 674 682 return EXIT_SUCCESS; 675 683 } 676 684 -
compress_sword2.c
31 31 32 32 void showhelp(char *exename) 33 33 { 34 printf("\nUsage: %s <params> file.clu\n", exename);34 printf("\nUsage: %s [params] <file>\n", exename); 35 35 36 36 printf("\nParams:\n"); 37 37 printf(" --mp3 encode to MP3 format (default)\n"); … … 56 56 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 57 57 58 58 printf("\nFlac mode params:\n"); 59 printf(" [params] optional arguments passed directly to the encoder\n"); 60 printf(" recommended is: --best -b 1152\n"); 59 printf(" --fast FLAC uses compresion level 0\n"); 60 printf(" --best FLAC uses compresion level 8\n"); 61 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 62 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 63 printf(" --verify files are encoded and then decoded to check accuracy\n"); 64 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 61 65 62 66 printf("\n --help this help message\n"); 63 67 … … 104 108 uint32 indexSize; 105 109 uint32 totalSize; 106 110 uint32 length; 107 111 108 112 if (argc < 2) 109 113 showhelp(argv[0]); 110 114 i = 1; -
compress_touche.c
158 158 } 159 159 160 160 static void showhelp(const char *exename) { 161 printf("\nUsage: %s <params> input_directory\n", exename);161 printf("\nUsage: %s [params] <inputdir>\n", exename); 162 162 163 163 printf("\nParams:\n"); 164 164 165 printf(" --mp3 encode to MP3 format (default)\n"); 165 166 printf(" --vorbis encode to Vorbis format\n"); 166 167 printf(" --flac encode to Flac format\n"); … … 183 184 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 184 185 185 186 printf("\nFlac mode params:\n"); 186 printf(" [params] optional arguments passed directly to the encoder\n"); 187 printf(" recommended is: --best -b 1152\n"); 187 printf(" --fast FLAC uses compresion level 0\n"); 188 printf(" --best FLAC uses compresion level 8\n"); 189 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 190 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 191 printf(" --verify files are encoded and then decoded to check accuracy\n"); 192 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 188 193 189 194 printf("\n --help this help message\n"); 190 195 -
encode_dxa.cpp
699 699 } 700 700 701 701 void showhelp(char *exename) { 702 printf("\nUsage: %s < inputfile>\n", exename);702 printf("\nUsage: %s <params> <file>\n", exename); 703 703 704 704 printf("\nParams:\n"); 705 705 printf(" --mp3 encode to MP3 format (default)\n"); … … 724 724 printf(" --silent the output of oggenc is hidden (default:disabled)\n"); 725 725 726 726 printf("\nFlac mode params:\n"); 727 printf(" [params] optional arguments passed directly to the encoder\n"); 728 printf(" recommended is: --best -b 1152\n"); 727 printf(" --fast FLAC uses compresion level 0\n"); 728 printf(" --best FLAC uses compresion level 8\n"); 729 printf(" -<value> specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef); 730 printf(" -b <value> specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef); 731 printf(" --verify files are encoded and then decoded to check accuracy\n"); 732 printf(" --silent the output of FLAC is hidden (default:disabled)\n"); 729 733 730 734 printf("\n --help this help message\n"); 731 735 732 736 printf("\n\nIf a parameter is not given the default value is used\n"); 733 737 printf("If using VBR mode for MP3 -b and -B must be multiples of 8; the maximum is 160!\n"); 734 printf("Use the `mac' option instead of a filename if converting simon2mac sounds\n");735 738 exit(2); 736 739 } 737 740 -
kyra_pak.h
24 24 #define KYRA_PAK_H 25 25 26 26 #include "util.h" 27 #include <string.h>28 27 29 28 class PAKFile { 30 29 public: … … 34 33 bool loadFile(const char *file, const bool isAmiga); 35 34 bool saveFile(const char *file); 36 35 void clearFile() { delete _fileList; _fileList = 0; } 37 36 38 37 const uint32 getFileSize() const { return _fileList->getTableSize()+5+4+_fileList->getFileSize(); } 39 38 40 39 void drawFileList(); … … 47 46 48 47 bool addFile(const char *name, const char *file); 49 48 bool addFile(const char *name, uint8 *data, uint32 size); 50 49 51 50 bool removeFile(const char *name); 52 51 public: 53 52 struct FileList { … … 57 56 delete [] data; 58 57 delete next; 59 58 } 60 59 61 60 FileList *findEntry(const char *f) { 62 61 for (FileList *cur = this; cur; cur = cur->next) { 63 62 if (scumm_stricmp(cur->filename, f) != 0) … … 66 65 } 67 66 return 0; 68 67 } 69 68 70 69 const FileList *findEntry(const char *f) const { 71 70 for (const FileList *cur = this; cur; cur = cur->next) { 72 71 if (scumm_stricmp(cur->filename, f) != 0) … … 92 91 char *filename; 93 92 uint32 size; 94 93 uint8 *data; 95 94 96 95 FileList *next; 97 96 }; 98 97 99 98 typedef const FileList cFileList; 100 99 101 100 cFileList *getFileList() const { return _fileList; } 102 101 private: 103 102 FileList *_fileList; -
Makefile
51 51 all: $(TARGETS) 52 52 53 53 compress_agos$(EXEEXT): compress_agos.o compress.o util.o 54 $(CC) $(LDFLAGS) -o $@ $+ 54 $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 55 55 56 56 compress_kyra$(EXEEXT): compress_kyra.o kyra_pak.o compress.o util.o 57 $(CXX) $(LDFLAGS) -o $@ $+ 57 $(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 58 58 59 compress_queen$(EXEEXT): compress_queen.o util.o60 $(CC) $(LDFLAGS) -o $@ $+ 59 compress_queen$(EXEEXT): compress_queen.o compress.o util.o 60 $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 61 61 62 62 compress_saga$(EXEEXT): compress_saga.o compress.o util.o $(UTILS) 63 $(CXX) $(LDFLAGS) -o $@ $+ 63 $(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 64 64 65 65 compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o 66 $(CXX) $(LDFLAGS) -o $@ $+ 66 $(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 67 67 68 68 compress_scumm_san$(EXEEXT): compress_scumm_san.o compress.o util.o 69 $(CXX) $(LDFLAGS) -o $@ $+ -lz 69 $(CXX) $(LDFLAGS) -o $@ $+ -lz -lvorbis -logg -lvorbisenc -lFLAC 70 70 71 71 compress_scumm_sou$(EXEEXT): compress_scumm_sou.o compress.o util.o 72 $(CC) $(LDFLAGS) -o $@ $+ 72 $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 73 73 74 74 compress_sword1$(EXEEXT): compress_sword1.o compress.o util.o 75 $(CC) $(LDFLAGS) -o $@ $+ 75 $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 76 76 77 77 compress_sword2$(EXEEXT): compress_sword2.o compress.o util.o 78 $(CC) $(LDFLAGS) -o $@ $+ 78 $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 79 79 80 80 compress_touche$(EXEEXT): compress_touche.o compress.o util.o 81 $(CC) $(LDFLAGS) -o $@ $+ 81 $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC 82 82 83 83 dekyra$(EXEEXT): dekyra.o dekyra_v1.o util.o 84 84 $(CXX) $(LDFLAGS) -o $@ $+ … … 90 90 $(CXX) $(LDFLAGS) -o $@ $+ 91 91 92 92 encode_dxa$(EXEEXT): encode_dxa.o compress.o util.o 93 $(CXX) $(LDFLAGS) -o $@ $+ -lpng -lz 93 $(CXX) $(LDFLAGS) -o $@ $+ -lpng -lz -lvorbis -logg -lvorbisenc -lFLAC 94 94 95 95 extract_agos$(EXEEXT): extract_agos.o 96 96 $(CC) $(LDFLAGS) -o $@ $+ … … 122 122 123 123 descumm.o descumm6.o descumm-common.o descumm-tool.o: descumm.h 124 124 125 # Most compress_* tools (except for compress_queen)use compress.h125 # All compress_* tools use compress.h 126 126 compress_agos.o compress_saga.o compress_scumm_sou.o \ 127 127 compress_scumm_bun.o compress_sword1.o compress_sword2.o \ 128 compress_kyra.o compress .o encode_dxa.o: compress.h128 compress_kyra.o compress_queen.o compress.o encode_dxa.o: compress.h 129 129 130 130 # extract_parallaction.h 131 131 extract_parallaction.o: extract_parallaction.h -
README
7 7 example. 8 8 9 9 Extraction Tools: 10 11 12 10 extract_agos 11 Extracts the packed files used in the Amiga and AtariST 12 versions of Elvira 1/2, Waxworks and Simon the Sorcerer 1. 13 13 14 15 14 extract_kyra 15 Unpacks .PAK files from Kyrandia games. 16 16 17 18 19 20 21 22 17 extract_scumm_mac 18 Extracts Macintosh "single file" SCUMM games into their 19 component parts, for use with ScummVM. 20 This is required for ScummVM up to version 0.6.x; all 21 later versions directly support reading this file 22 format. 23 23 24 25 26 27 24 extract_loom_tg16 25 Extracts data files from the PC-Engine version of Loom. 26 Use the dumpcd utility at http://www.zeograd.com/misc_download.php 27 to dump the code tracks on the CD. 28 28 29 30 31 29 extract_mm_apple 30 Extracts data files from the Apple II version of Maniac 31 Mansion. 32 32 33 34 35 33 extract_mm_c64 34 Extracts data files from the Commodore 64 version of Maniac 35 Mansion. 36 36 37 38 37 extract_mm_nes 38 Extracts data files from the NES version of Maniac Mansion. 39 39 40 41 40 extract_parallaction 41 Extracts the contents of archives used by Nippon Safes 42 42 43 44 45 43 extract_zak_c64 44 Extracts data files from the Commodore 64 version of Zak 45 McKracken. 46 46 47 47 Compression Tools: 48 49 50 48 compress_scumm_sou 49 Used to compress .sou files to .so3 (MP3), .sog (Vorbis), 50 or .sof (FLAC). 51 51 52 compress_agos 53 Used to compress the Feeble Files or Simon 1/2 voc/wav files 54 to MP3, Vorbis or FLAC. 52 Example of usage: 53 compress_scumm_sou [params] monster.sou 55 54 56 compress_queen 57 Used to rebuild the datafile of Flight of the Amazon Queen, 58 and allow optional MP3, Vorbis or FLAC compression.55 compress_agos 56 Used to compress the Feeble Files or Simon 1/2 voc/wav files 57 to MP3, Vorbis or FLAC. 59 58 60 compress_saga 61 Used to compress SAGA engine digital sound files to MP3, Vorbis 62 or FLAC. 59 Example of usage: 60 compress_agos [params] [<file> | mac] 63 61 64 Example of usage: 65 compress_saga <flags here> <file> 62 compress_queen 63 Used to rebuild the datafile of Flight of the Amazon Queen, 64 and allow optional MP3, Vorbis or FLAC compression. 66 65 67 Where <file> is the sound file you with to compress, without the 68 extension. 66 Example of usage: 67 compress_queen <params> queen.1 69 68 70 For Inherit the Earth, the digital music (music.rsc), speech 71 (voices.rsc or "inherit the earth voices") and sound effects 72 (sounds.rsc) files can be compressed. For I have no mouth, the 73 speech (voices*.res) and sound effects (sfx.res) files can be 74 compressed. 75 76 The compressed files have the ".cmp" extension. Once compressed, 77 you only need the respective .cmp files. 78 79 Only the files of the full game versions can be compressed, the 80 demo versions are not supported. 81 82 The MacBinary files (*.bin) of the Mac CD Guild version of Inherit 83 the Earth are not currently supported. Finally, there is no support 84 for compressed sounds in I have no mouth yet. 69 compress_saga 70 Used to compress SAGA engine digital sound files to MP3, Vorbis 71 or FLAC. 85 72 86 compress_sword1 87 Used to compress Broken Sword 1's music and speech files to 88 MP3 or Vorbis or FLAC. 73 Example of usage: 74 compress_saga [params] <file> 89 75 90 compress_sword2 91 Used to compress Broken Sword 2's music and speech .clu 92 files to .cl3 (MP3), .clg (Vorbis) or .clf (FLAC). 76 Where <file> is the sound file you with to compress, without the 77 extension. 93 78 94 Please note that FLAC compression will produce a larger file 95 than the original! This is because the original files already 96 use lossy compression. 79 For Inherit the Earth, the digital music (music.rsc), speech 80 (voices.rsc or "inherit the earth voices") and sound effects 81 (sounds.rsc) files can be compressed. For I have no mouth, the 82 speech (voices*.res) and sound effects (sfx.res) files can be 83 compressed. 97 84 98 compress_touche 99 Used to compress and pack Touche speech files ('Vxxx' and 100 'OBJ') to MP3, Vorbis or FLAC to a single file named 101 TOUCHE.SO3/.SOG/.SOF depending on the sound compression. Once 102 compressed, only TOUCHE.DAT and TOUCHE.SOx files are required 103 to play the game under ScummVM. 85 The compressed files have the ".cmp" extension. Once compressed, 86 you only need the respective .cmp files. 104 87 105 compress_scumm_san <inputfile> <inputdir> <outputdir> [--ogg] 106 Compresses '.san' smush animation files. It uses lossless 107 zlib for compressing FOBJ gfx chunks inside a san file. 108 It also can create a separate Ogg file with the audio track. 88 Only the files of the full game versions can be compressed, the 89 demo versions are not supported. 109 90 110 Example of usage: 111 compress_scumm_san opening.san uncomp comp 91 The MacBinary files (*.bin) of the Mac CD Guild version of Inherit 92 the Earth are not currently supported. Finally, there is no support 93 for compressed sounds in I have no mouth yet. 112 94 113 In order to use such compressed files, your ScummVM binary 114 must have been built with zlib support enabled (you can find 115 out whether that's the case by looking at the About dialog). 116 For the Ogg or MP3 compression feature, your ScummVM binary 117 naturally must have been built with Ogg or MP3 support enabled. 95 compress_sword1 96 Used to compress Broken Sword 1's music and speech .clu 97 files to .cl3 (MP3), .clg (Vorbis) or .clf (FLAC). 118 98 119 NOTE: For some '.san' files there is a corresponding '.flu' 120 file, which contains offsets into the '.san' file. Hence, the 121 compress_scumm_san has to modify the '.flu' file. This happens 122 automatically, if the '.san' and '.flu' files are in the 123 same directory (which is normally the case). If you want to 124 move the '.san' files before compressing them, make sure to 125 move the '.flu' files, too! 99 Example of usage: 100 compress_sword1 [params] 126 101 127 compress_scumm_bun <inputfile> <inputdir> <outputdir> [--ogg] 102 compress_sword2 103 Used to compress Broken Sword 2's music and speech .clu 104 files to .cl3 (MP3), .clg (Vorbis) or .clf (FLAC). 128 105 129 Compresses '.bun' music/voice files. 106 Please note that FLAC compression will produce a larger file 107 than the original! This is because the original files already 108 use lossy compression. 130 109 131 132 compress_scumm.bun digmusic.bun uncomp comp 110 Example of usage: 111 compress_sword2 [params] <file> 133 112 134 For the Ogg or MP3 compression feature, your ScummVM binary 135 naturally must have been built with Ogg or MP3 support enabled. 113 compress_touche 114 Used to compress and pack Touche speech files ('Vxxx' and 115 'OBJ') to MP3, Vorbis or FLAC to a single file named 116 TOUCHE.SO3 (MP3), TOUCHE.SOG (Vorbis), or TOUCHE.SOF (FLAC). 136 117 137 compress_kyra 138 Used to compress The Legend of Kyrandia's speech files with 139 MP3, Vorbis or FLAC. 118 Once compressed, only TOUCHE.DAT and TOUCHE.SOx files are 140 119 141 142 compress_kyra <flags here> input/GEMCUT.VRM output/GEMCUT.VRM 120 Example of usage: 121 comrpess_touche [params] <inputdir> 143 122 144 Note: You have to keep the VRM extension, else it will NOT work. 145 Use it like shown above, copy all *.VRM files to a directory 146 and let the tool put the output file in another directory. 123 compress_scumm_san 124 Compresses '.san' smush animation files. It uses lossless 125 zlib for compressing FOBJ gfx chunks inside a san file. 126 It also can create a separate Ogg file with the audio track. 147 127 128 In order to use such compressed files, your ScummVM binary 129 must have been built with zlib support enabled (you can find 130 out whether that's the case by looking at the About dialog). 131 For the Ogg or MP3 compression feature, your ScummVM binary 132 naturally must have been built with Ogg or MP3 support enabled. 133 134 NOTE: For some '.san' files there is a corresponding '.flu' 135 file, which contains offsets into the '.san' file. Hence, the 136 compress_scumm_san has to modify the '.flu' file. This happens 137 automatically, if the '.san' and '.flu' files are in the 138 same directory (which is normally the case). If you want to 139 move the '.san' files before compressing them, make sure to 140 move the '.flu' files, too! 141 142 Example of usage: 143 compress_scumm_bun [--vorbis] [params] <inputfile> <inputdir> <outputdir> 144 145 compress_scumm_bun 146 Compresses '.bun' music/voice files. 147 148 For the Ogg or MP3 compression feature, your ScummVM binary 149 naturally must have been built with Ogg or MP3 support enabled. 150 151 Example of usage: 152 compress_scumm_bun [--vorbis] [params] <inputfile> <inputdir> <outputdir> 153 154 compress_kyra 155 Used to compress The Legend of Kyrandia's speech files with 156 MP3, Vorbis or FLAC. 157 158 Example of usage: 159 compress_kyra [params] <inputfile> <inputdir> <outputdir> 160 148 161 Script Tools: 149 150 162 descumm 163 Decompiles SCUMM scripts 151 164 152 153 165 desword2 166 Disassembles Broken Sword II scripts 154 167 155 156 168 dekyra 169 Basic script disassembler for Legend of Kyrandia games 157 170 158 171 Encoder Tools: 159 172 encode_dxa <filename> 160 173 161 174 Creates DXA file out of extracted Smacker video. 162 175 163 164 176 To extract a video use RAD Game Tools and perform 2 passes 177 on it. For example, if your video is called 'intro.smk'. 165 178 166 167 168 169 179 1. Extract the video to PNG, 256 colors (choose PNG format 180 and tick the checkbox). It will create bunch of files named 181 'introXXX.png', where XXX is frame number. Make sure you have 182 extracted 256 colors PNGs, otherwise encode_dxa will complain. 170 183 171 172 184 2. Extract the audio to WAV format, you will get an 185 'intro.wav' file. 173 186 174 175 187 3. Put files 'intro.smk', 'intro.wav' and 'intro*.png' into a 188 single directory. 176 189 177 190 4. Run `encode_dxa intro.smk` in that directory 178 191 179 180 192 5. You will get an intro.dxa file and intro.flac/mp3/ogg file 193 in result. 181 194 182 183 184 185 186 195 Additionally you may use batch processing mode of SMK files in 196 RAD Game Tools. Just select more than one file and push the 197 'Convert' button. It will ask you either you want them 198 processed in batch mode and will do this for you. All buttons 199 and conversion options work the same. 187 200 188 189 201 convert_dxa.bat 202 convert_dxa_one.bat 190 203 191 192 204 To ease your life we also provide batch files to autoconvert 205 all files. It should work with any game version. 193 206 194 207 1. Copy *.smk files from all CDs to some directory 195 208 196 209 2. Edit paths in convert_dxa.bat file. 197 210 198 199 200 201 211 3. Run the batch. If you set everything correct, it will be 212 almost unattended conversion, just for several files there 213 are no audio, and RAD Game Tools converter will ask you to 214 press OK 202 215 203 216 convert_dxa.sh 204 217 205 206 218 Same as above convert_dxa.bat, just for *nix-based systems. 219 It uses Wine to run RAD Game Tools.