Ticket #8707: SoC Tools Update.patch

File SoC Tools Update.patch, 60.8 KB (added by SF/lightcast, 17 years ago)
  • compress.c

     
    3535        int nominalBitr;
    3636        int minBitr;
    3737        int maxBitr;
    38         int quality;
     38        float quality;
    3939        bool silent;
    4040} oggencparams;
    4141
    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 the
    44  encoder.
    45 */
    4642typedef struct {
    47         char * const* argv;
    48         int numArgs;
     43        int compressionLevel;
     44        int blocksize;
     45        bool verify;
     46        bool silent;
    4947} flaccparams;
    5048
    5149typedef struct {
    52         bool isLittleEndian;
    53         bool isStereo;
    54         bool isUnsigned;
     50        bool isLittleEndian, isStereo;
    5551        uint8 bitsPerSample;
    5652} rawtype;
    5753
    5854lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0 };
    5955oggencparams oggparms = { -1, -1, -1, oggqualDef, 0 };
    60 flaccparams flacparms;
    61 rawtype rawAudioType = { false, false, false, 8 };
     56flaccparams flacparms = { flacCompressDef, flacBlocksizeDef, false, false };
     57rawtype rawAudioType = { false, false, 8 };
    6258
    6359const char *tempEncoded = TEMP_MP3;
    6460
    65 void setRawAudioType(bool isLittleEndian, bool isStereo, bool isUnsigned, uint8 bitsPerSample) {
     61void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample) {
    6662        rawAudioType.isLittleEndian = isLittleEndian;
    6763        rawAudioType.isStereo = isStereo;
    68         rawAudioType.isUnsigned = isUnsigned;
    6964        rawAudioType.bitsPerSample = bitsPerSample;
    7065}
    7166
     
    105100}
    106101
    107102void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode) {
    108         char fbuf[2048];
    109         char *tmp = fbuf;
    110         int i;
    111         bool err = false;
     103        if ((compmode == kVorbisMode) || (compmode == kFlacMode)) {
     104                if (rawInput) {
     105                        FILE *inputRaw;
     106                        long length;
     107                        char *rawData;
    112108
    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));
     109                        inputRaw = fopen(inname, "rb");
     110                        length = fileSize(inputRaw);
     111                        rawData = (char *)malloc(length);
     112                        fread(rawData, 1, length, inputRaw);
     113
     114                        encodeRaw(rawData, length, rawSamplerate, outname, compmode);
     115
     116                        fclose(inputRaw);
     117                        free(rawData);
     118                } else {
     119                        FILE *inputWav;
     120                        int fmtHeaderSize, length, numChannels, sampleRate, bitsPerSample;
     121                        char *wavData;
     122
     123                        inputWav = fopen(inname, "rb");
     124
     125                        /* Standard PCM fmt header is 16 bits, but at least Simon 1 and 2 use 18 bits */
     126                        fseek(inputWav, 16, SEEK_SET);
     127                        fmtHeaderSize = readUint32LE(inputWav);
     128
     129                        fseek(inputWav, 22, SEEK_SET);
     130                        numChannels = readUint16LE(inputWav);
     131                        sampleRate = readUint32LE(inputWav);
     132
     133                        fseek(inputWav, 34, SEEK_SET);
     134                        bitsPerSample = readUint16LE(inputWav);
     135
     136                        /* The size of the raw audio is after the RIFF chunk (12 bytes), fmt chunk (8 + fmtHeaderSize bytes), and data chunk id (4 bytes) */
     137                        fseek(inputWav, 24 + fmtHeaderSize, SEEK_SET);
     138                        length = readUint32LE(inputWav);
     139
     140                        wavData = (char *)malloc(length);
     141                        fread(wavData, 1, length, inputWav);
     142
     143                        printf(" - length = %d\n", length);
     144                        printf(" - channels = %d\n", numChannels);
     145                        printf(" - sample rate = %d\n", sampleRate);
     146                        printf(" - compression = %dbits\n", bitsPerSample);
     147
     148                        setRawAudioType(true, numChannels == 2, bitsPerSample);
     149                        encodeRaw(wavData, length, sampleRate, outname, compmode);
     150
     151                        fclose(inputWav);
     152                        free (wavData);
    122153                }
     154        } else if (compmode == kMP3Mode) {
     155                bool err = false;
     156                char fbuf[2048];
     157                char *tmp = fbuf;
    123158
    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:
    139159                tmp += sprintf(tmp, "lame -t ");
    140160                if (rawInput) {
    141161                        tmp += sprintf(tmp, "-r ");
    142162                        tmp += sprintf(tmp, "--bitwidth %d ", rawAudioType.bitsPerSample);
    143                         if (rawAudioType.isLittleEndian)
     163                        if (rawAudioType.isLittleEndian) {
    144164                                tmp += sprintf(tmp, "-x ");
     165                        }
    145166                        tmp += sprintf(tmp, (rawAudioType.isStereo ? "-m j " : "-m m "));
    146167                        tmp += sprintf(tmp, "-s %d ", rawSamplerate);
    147168                }
    148169
    149                 if (encparms.abr)
     170                if (encparms.abr) {
    150171                        tmp += sprintf(tmp, "--abr %d ", encparms.minBitr);
    151                 else
     172                } else {
    152173                        tmp += sprintf(tmp, "--vbr-new -b %d ", encparms.minBitr);
     174                }
    153175
    154176                /* Explicitly specify a target sample rate, to work around a bug (?)
    155                  * in newer lame versions (>= 3.95) which causes it to malfunction
    156                  * for odd sample rates when in VBR mode. See also bug #934026.
    157                  * We essentially duplicate the old behaviour of lame (found in e.g.
    158                  * version 3.93.1): we round the input sample rate up to the next
    159                  * higher valid MP3 sample rate, with a margin of 3%.
    160                  */
    161                 if (rawSamplerate != -1)
     177                * in newer lame versions (>= 3.95) which causes it to malfunction
     178                * for odd sample rates when in VBR mode. See also bug #934026.
     179                * We essentially duplicate the old behaviour of lame (found in e.g.
     180                * version 3.93.1): we round the input sample rate up to the next
     181                * higher valid MP3 sample rate, with a margin of 3%.
     182                */
     183                if (rawSamplerate != -1) {
    162184                        tmp += sprintf(tmp, "--resample %d ", map2MP3Frequency(97 * rawSamplerate / 100));
     185                }
    163186
    164                 if (encparms.silent)
     187                if (encparms.silent) {
    165188                        tmp += sprintf(tmp, " --silent ");
     189                }
     190
    166191                tmp += sprintf(tmp, "-q %d ", encparms.algqual);
    167192                tmp += sprintf(tmp, "-V %d ", encparms.vbrqual);
    168193                tmp += sprintf(tmp, "-B %d ", encparms.maxBitr);
    169194                tmp += sprintf(tmp, "\"%s\" \"%s\" ", inname, outname);
     195
    170196                err = system(fbuf) != 0;
    171                 break;
    172197
    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 ");
     198                if (err) {
     199                        printf("Got error from encoder. (check your parameters)\n");
     200                        printf("Encoder Commandline: %s\n", fbuf );
     201                        exit(-1);
     202                }
     203        }
     204}
    177205
    178                 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"));
     206void encodeRaw(char *rawData, int length, int samplerate, const char *outname, CompressMode compmode) {
     207        if (compmode == kVorbisMode) {
     208                FILE *outputOgg;
     209                char outputString[256] = "";
     210                int numChannels = (rawAudioType.isStereo ? 2 : 1);
     211                int totalSamples = length / ((rawAudioType.bitsPerSample / 8) * numChannels);
     212                int samplesLeft = totalSamples;
     213                int eos = 0;
     214                int totalBytes = 0;
     215
     216                vorbis_info vi;
     217                vorbis_comment vc;
     218                vorbis_dsp_state vd;
     219                vorbis_block vb;
     220
     221                ogg_stream_state os;
     222                ogg_page og;
     223                ogg_packet op;
     224
     225                ogg_packet header;
     226                ogg_packet header_comm;
     227                ogg_packet header_code;
     228
     229                outputOgg = fopen(outname,"wb");
     230
     231                vorbis_info_init(&vi);
     232
     233                if (oggparms.nominalBitr > 0) {
     234                        int result = 0;
     235
     236                        /* Input is in kbps, function takes bps */
     237                        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));
     238
     239                        if (result == OV_EFAULT) {
     240                                printf("Error: Internal Logic Fault.\n\n");
     241                                vorbis_info_clear(&vi);
     242                                exit(-1);
     243                        } else if ((result == OV_EINVAL) || (result == OV_EIMPL)) {
     244                                printf("Error: Invalid bitrate parameters.\n\n");
     245                                vorbis_info_clear(&vi);
     246                                exit(-1);
     247                        }
     248
     249                        if (!oggparms.silent) {
     250                                sprintf(outputString, "Encoding to\n         \"%s\"\nat average bitrate %i kbps (", outname, oggparms.nominalBitr);
     251
     252                                if (oggparms.minBitr > 0) {
     253                                        sprintf(outputString + strlen(outputString), "min %i kbps, ", oggparms.minBitr);
     254                                } else {
     255                                        sprintf(outputString + strlen(outputString), "no min, ");
     256                                }
     257
     258                                if (oggparms.maxBitr > 0) {
     259                                        sprintf(outputString + strlen(outputString), "max %i kbps),\nusing full bitrate management engine\nSet optional hard quality restrictions\n", oggparms.maxBitr);
     260                                } else {
     261                                        sprintf(outputString + strlen(outputString), "no max),\nusing full bitrate management engine\nSet optional hard quality restrictions\n");
     262                                }
     263                        }
     264                } else {
     265                        int result = 0;
     266
     267                        /* Quality input is 1 - 10, function takes -0.1 through 1.0 */
     268                        result = vorbis_encode_setup_vbr(&vi, numChannels, samplerate, oggparms.quality * 0.1);
     269
     270                        if (result == OV_EFAULT) {
     271                                printf("Error: Internal Logic Fault.\n\n");
     272                                vorbis_info_clear(&vi);
     273                                exit(-1);
     274                        } else if ((result == OV_EINVAL) || (result == OV_EIMPL)) {
     275                                printf("Error: Invalid bitrate parameters.\n\n");
     276                                vorbis_info_clear(&vi);
     277                                exit(-1);
     278                        }
     279
     280                        if (!oggparms.silent) {
     281                                sprintf(outputString, "Encoding to\n         \"%s\"\nat quality %2.2f", outname, oggparms.quality);
     282                        }
     283
     284                        if ((oggparms.minBitr > 0) || (oggparms.maxBitr > 0)) {
     285                                struct ovectl_ratemanage_arg extraParam;
     286                                vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_GET, &extraParam);
     287
     288                                extraParam.bitrate_hard_min = (oggparms.minBitr > 0 ? (1000 * oggparms.minBitr) : -1);
     289                                extraParam.bitrate_hard_max = (oggparms.maxBitr > 0 ? (1000 * oggparms.maxBitr) : -1);
     290                                extraParam.management_active = 1;
     291
     292                                vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, &extraParam);
     293
     294                                if (!oggparms.silent) {
     295                                        sprintf(outputString + strlen(outputString), " using constrained VBR (");
     296
     297                                        if (oggparms.minBitr != -1) {
     298                                                sprintf(outputString + strlen(outputString), "min %i kbps, ", oggparms.minBitr);
     299                                        } else {
     300                                                sprintf(outputString + strlen(outputString), "no min, ");
     301                                        }
     302
     303                                        if (oggparms.maxBitr != -1) {
     304                                                sprintf(outputString + strlen(outputString), "max %i kbps)\nSet optional hard quality restrictions\n", oggparms.maxBitr);
     305                                        } else {
     306                                                sprintf(outputString + strlen(outputString), "no max)\nSet optional hard quality restrictions\n");
     307                                        }
     308                                }
     309                        } else {
     310                                sprintf(outputString + strlen(outputString), "\n");
     311                        }
    185312                }
    186313
    187                 for (i = 0; i < flacparms.numArgs; i++) {
    188                         /* Append optional encoder arguments */
    189                         tmp += sprintf(tmp, "%s ", flacparms.argv[i]);
     314                printf(outputString);
     315
     316                vorbis_encode_setup_init(&vi);
     317                vorbis_comment_init(&vc);
     318                vorbis_analysis_init(&vd, &vi);
     319                vorbis_block_init(&vd, &vb);
     320                ogg_stream_init(&os, 0);
     321                vorbis_analysis_headerout(&vd, &vc, &header, &header_comm, &header_code);
     322
     323                ogg_stream_packetin(&os, &header);
     324                ogg_stream_packetin(&os, &header_comm);
     325                ogg_stream_packetin(&os, &header_code);
     326
     327                while (!eos) {
     328                        int result = ogg_stream_flush(&os,&og);
     329
     330                        if (result == 0) {
     331                                break;
     332                        }
     333
     334                        fwrite(og.header, 1, og.header_len, outputOgg);
     335                        fwrite(og.body, 1, og.body_len, outputOgg);
    190336                }
    191337
    192                 tmp += sprintf(tmp, "-o \"%s\" ", outname);
    193                 tmp += sprintf(tmp, "\"%s\" ", inname);
     338                while (!eos) {
     339                        int i, j;
     340                        int numSamples = ((samplesLeft < 2048) ? samplesLeft : 2048);
     341                        float **buffer = vorbis_analysis_buffer(&vd, numSamples);
    194342
    195                 err = system(fbuf) != 0;
    196                 break;
    197         }
     343                        /* We must tell the encoder that we have reached the end of the stream */
     344                        if (numSamples == 0) {
     345                                vorbis_analysis_wrote(&vd, 0);
     346                        } else {
     347                                /* Adapted from oggenc 1.1.1 */
     348                                if (rawAudioType.bitsPerSample == 8) {
     349                                        unsigned char *rawDataUnsigned = (unsigned char *)rawData;
     350                                        for (i = 0; i < numSamples; i++) {
     351                                                for (j = 0; j < numChannels; j++) {
     352                                                        buffer[j][i] = ((int)(rawDataUnsigned[i * numChannels + j]) - 128) / 128.0f;
     353                                                }
     354                                        }
     355                                } else if(rawAudioType.bitsPerSample == 16) {
     356                                        if(rawAudioType.isLittleEndian) {
     357                                                for(i = 0; i < numSamples; i++) {
     358                                                        for(j = 0; j < numChannels; j++) {
     359                                                                buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j) + 1] << 8) | (rawData[(i * 2 * numChannels) + (2 * j)] & 0xff)) / 32768.0f;
     360                                                        }
     361                                                }
     362                                        }
     363                                        else {
     364                                                for(i = 0; i < numSamples; i++) {
     365                                                        for(j = 0; j < numChannels; j++) {
     366                                                                buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j)] << 8) | (rawData[(i * 2 * numChannels) + (2 * j) + 1] & 0xff)) / 32768.0f;
     367                                                        }
     368                                                }
     369                                        }
     370                                }
    198371
    199         if (err) {
    200                 printf("Got error from encoder. (check your parameters)\n");
    201                 printf("Encoder Commandline: %s\n", fbuf );
    202                 exit(-1);
     372                                vorbis_analysis_wrote(&vd, numSamples);
     373                        }
     374
     375                        while (vorbis_analysis_blockout(&vd, &vb) == 1) {
     376                                vorbis_analysis(&vb, NULL);
     377                                vorbis_bitrate_addblock(&vb);
     378
     379                                while (vorbis_bitrate_flushpacket(&vd, &op)) {
     380                                        ogg_stream_packetin(&os, &op);
     381
     382                                        while (!eos) {
     383                                                int result = ogg_stream_pageout(&os, &og);
     384
     385                                                if(result == 0) {
     386                                                        break;
     387                                                }
     388
     389                                                totalBytes += fwrite(og.header, 1, og.header_len, outputOgg);
     390                                                totalBytes += fwrite(og.body, 1, og.body_len, outputOgg);
     391
     392                                                if(ogg_page_eos(&og)) {
     393                                                        eos = 1;
     394                                                }
     395                                        }
     396                                }
     397                        }
     398
     399                        rawData += 2048 * (rawAudioType.bitsPerSample / 8) * numChannels;
     400                        samplesLeft -= 2048;
     401                }
     402
     403                ogg_stream_clear(&os);
     404                vorbis_block_clear(&vb);
     405                vorbis_dsp_clear(&vd);
     406                vorbis_info_clear(&vi);
     407
     408                fclose(outputOgg);
     409
     410                if (!oggparms.silent) {
     411                        printf("\nDone encoding file \"%s\"\n", outname);
     412                        printf("\n\tFile length:  %dm %ds\n", (int)(totalSamples / samplerate / 60), (totalSamples / samplerate % 60));
     413                        printf("\tAverage bitrate: %.1f kb/s\n\n", (8.0 * (double)totalBytes / 1000.0) / ((double)totalSamples / (double)samplerate));
     414                }
     415        } else if (compmode == kFlacMode) {
     416                int i;
     417                int numChannels = (rawAudioType.isStereo ? 2 : 1);
     418                int samplesPerChannel = length / ((rawAudioType.bitsPerSample / 8) * numChannels);
     419                FLAC__StreamEncoder *encoder;
     420                FLAC__StreamEncoderInitStatus initStatus;
     421                FLAC__int32 *flacData;
     422
     423                flacData = (FLAC__int32 *)malloc(samplesPerChannel * numChannels * sizeof(FLAC__int32));
     424                if (rawAudioType.bitsPerSample == 8) {
     425                        for (i = 0; i < samplesPerChannel * numChannels; i++) {
     426                                FLAC__uint8 *rawDataUnsigned;
     427                                rawDataUnsigned = (FLAC__uint8 *)rawData;
     428                                flacData[i] = (FLAC__int32)rawDataUnsigned[i] - 0x80;
     429                        }
     430                } else if (rawAudioType.bitsPerSample == 16) {
     431                        /* The rawData pointer is an 8-bit char so we must create a new pointer to access 16-bit samples */
     432                        FLAC__int16 *rawData16;
     433                        rawData16 = (FLAC__int16 *)rawData;
     434                        for (i = 0; i < samplesPerChannel * numChannels; i++) {
     435                                flacData[i] = (FLAC__int32)rawData16[i];
     436                        }
     437                }
     438
     439                if (!flacparms.silent) {
     440                        printf("Encoding to\n         \"%s\"\nat compression level %d using blocksize %d\n\n", outname, flacparms.compressionLevel, flacparms.blocksize);
     441                }
     442
     443                encoder = FLAC__stream_encoder_new();
     444
     445                FLAC__stream_encoder_set_bits_per_sample(encoder, rawAudioType.bitsPerSample);
     446                FLAC__stream_encoder_set_blocksize(encoder, flacparms.blocksize);
     447                FLAC__stream_encoder_set_channels(encoder, numChannels);
     448                FLAC__stream_encoder_set_compression_level(encoder, flacparms.compressionLevel);
     449                FLAC__stream_encoder_set_sample_rate(encoder, samplerate);
     450                FLAC__stream_encoder_set_streamable_subset(encoder, false);
     451                FLAC__stream_encoder_set_total_samples_estimate(encoder, samplesPerChannel);
     452                FLAC__stream_encoder_set_verify(encoder, flacparms.verify);
     453
     454                initStatus = FLAC__stream_encoder_init_file(encoder, outname, NULL, NULL);
     455
     456                if (initStatus != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
     457                        printf("Got error from encoder. (check your paramters)\n");
     458                        printf("FLAC error: %s\n\n", FLAC__StreamEncoderInitStatusString[initStatus]);
     459                        exit(-1);
     460                } else {
     461                        FLAC__stream_encoder_process_interleaved(encoder, flacData, samplesPerChannel);
     462                }
     463
     464                FLAC__stream_encoder_finish(encoder);
     465                FLAC__stream_encoder_delete(encoder);
     466
     467                free(flacData);
     468
     469                if (!flacparms.silent) {
     470                        printf("\nDone encoding file \"%s\"\n", outname);
     471                        printf("\n\tFile length:  %dm %ds\n\n", (int)(samplesPerChannel / samplerate / 60), (samplesPerChannel / samplerate % 60));
     472                }
     473
    203474        }
    204475}
    205476
    206477void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode) {
    207478        int length;
    208         FILE *f;
    209         char fbuf[2048];
    210         size_t size;
    211479
    212480        fseek(input, -4, SEEK_CUR);
    213481        length = readUint32LE(input);
    214482        length += 8;
    215483        fseek(input, -8, SEEK_CUR);
    216484
    217         /* Copy the WAV data to a temporary file */
    218         f = fopen(outName, "wb");
    219         while (length > 0) {
    220                 size = fread(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : length, input);
    221                 if (size <= 0)
    222                         break;
    223                 length -= (int)size;
    224                 fwrite(fbuf, 1, size, f);
     485        if (compMode == kVorbisMode || compMode == kFlacMode) {
     486                char *rawData;
     487                int fmtHeaderSize, rawLength, numChannels, sampleRate, bitsPerSample;
     488
     489                /* Standard PCM fmt header is 16 bits, but at least Simon 1 and 2 use 18 bits */
     490                fseek(input, 16, SEEK_CUR);
     491                fmtHeaderSize = readUint32LE(input);
     492
     493                fseek(input, 2, SEEK_CUR);
     494                numChannels = readUint16LE(input);
     495                sampleRate = readUint32LE(input);
     496
     497                fseek(input, 6, SEEK_CUR);
     498                bitsPerSample = readUint16LE(input);
     499
     500                /* The size of the raw audio is 4 bytes after SEEK_CUR
     501                 * plus the difference between fmtHeaderSizer and
     502                 * the standard size of 16 bytes.
     503                 */
     504                fseek(input, fmtHeaderSize - 12, SEEK_CUR);
     505                rawLength = readUint32LE(input);
     506
     507                rawData = (char *)malloc(rawLength);
     508                fread(rawData, 1, rawLength, input);
     509
     510                printf(" - length = %d\n", rawLength);
     511                printf(" - channels = %d\n", numChannels);
     512                printf(" - sample rate = %d\n", sampleRate);
     513                printf(" - compression = %dbits\n", bitsPerSample);
     514
     515                setRawAudioType(true, numChannels == 2, bitsPerSample);
     516                encodeRaw(rawData, rawLength, sampleRate, tempEncoded, compMode);
     517
     518                free(rawData);
     519        } else {
     520                FILE *f;
     521                char fbuf[2048];
     522                size_t size;
     523
     524                /* Copy the WAV data to a temporary file */
     525                f = fopen(outName, "wb");
     526                while (length > 0) {
     527                        size = fread(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : length, input);
     528                        if (size <= 0)
     529                                break;
     530                        length -= (int)size;
     531                        fwrite(fbuf, 1, size, f);
     532                }
     533                fclose(f);
     534
     535                /* Convert the WAV temp file to OGG/MP3 */
     536                encodeAudio(outName, false, -1, tempEncoded, compMode);
    225537        }
    226         fclose(f);
    227 
    228         /* Convert the WAV temp file to OGG/MP3 */
    229         encodeAudio(outName, false, -1, tempEncoded, compMode);
    230538}
    231539
    232540void extractAndEncodeVOC(const char *outName, FILE *input, CompressMode compMode) {
     
    261569                length = fgetc(input);
    262570                length |= fgetc(input) << 8;
    263571                length |= fgetc(input) << 16;
     572
    264573                if (blocktype == 1) {
    265574                        length -= 2;
    266575                        sample_rate = fgetc(input);
     
    287596                                  (comp == 3 ? "2bits"   :
    288597                                                                "Multi")))), comp);
    289598
    290                 if (comp != 0)
     599                if (comp != 0) {
    291600                        error("Cannot handle compressed VOC data");
     601                }
    292602
    293603                /* Copy the raw data to a temporary file */
    294604                while (length > 0) {
    295605                        size = fread(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : (uint32)length, input);
    296                         if (size <= 0)
     606
     607                        if (size <= 0) {
    297608                                break;
     609                        }
     610
    298611                        length -= (int)size;
    299612                        fwrite(fbuf, 1, size, f);
    300613                }
     
    304617
    305618        assert(real_samplerate != -1);
    306619
    307         setRawAudioType(false, false, true, 8);
     620        setRawAudioType(false, false, 8);
    308621
    309622        /* Convert the raw temp file to OGG/MP3 */
    310623        encodeAudio(outName, true, real_samplerate, tempEncoded, compMode);
     
    318631                        encparms.abr=1;
    319632                } else if (strcmp(argv[i], "-b") == 0) {
    320633                        encparms.minBitr = atoi(argv[i + 1]);
    321                         if ((encparms.minBitr % 8) != 0)
     634
     635                        if ((encparms.minBitr % 8) != 0) {
    322636                                encparms.minBitr -= encparms.minBitr % 8;
    323                         if (encparms.minBitr >160)
     637                        }
     638
     639                        if (encparms.minBitr >160) {
    324640                                encparms.minBitr = 160;
    325                         if (encparms.minBitr < 8)
    326                                 encparms.minBitr=8;
     641                        }
     642
     643                        if (encparms.minBitr < 8) {
     644                                encparms.minBitr = 8;
     645                        }
     646
    327647                        i++;
    328648                } else if (strcmp(argv[i], "-B") == 0) {
    329649                        encparms.maxBitr = atoi(argv[i + 1]);
    330                         if ((encparms.maxBitr % 8) != 0)
     650
     651                        if ((encparms.maxBitr % 8) != 0) {
    331652                                encparms.maxBitr -= encparms.maxBitr % 8;
    332                         if (encparms.maxBitr > 160)
     653                        }
     654
     655                        if (encparms.maxBitr > 160) {
    333656                                encparms.maxBitr = 160;
    334                         if (encparms.maxBitr < 8)
     657                        }
     658
     659                        if (encparms.maxBitr < 8) {
    335660                                encparms.maxBitr = 8;
     661                        }
     662
    336663                        i++;
    337664                } else if (strcmp(argv[i], "-V") == 0) {
    338665                        encparms.vbrqual = atoi(argv[i + 1]);
    339                         if(encparms.vbrqual < 0)
     666
     667                        if(encparms.vbrqual < 0) {
    340668                                encparms.vbrqual = 0;
    341                         if(encparms.vbrqual > 9)
     669                        }
     670
     671                        if(encparms.vbrqual > 9) {
    342672                                encparms.vbrqual = 9;
     673                        }
     674
    343675                        i++;
    344676                } else if (strcmp(argv[i], "-q") == 0) {
    345677                        encparms.algqual = atoi(argv[i + 1]);
    346                         if (encparms.algqual < 0)
     678
     679                        if (encparms.algqual < 0) {
    347680                                encparms.algqual = 0;
    348                         if (encparms.algqual > 9)
     681                        }
     682
     683                        if (encparms.algqual > 9) {
    349684                                encparms.algqual = 9;
     685                        }
     686
    350687                        i++;
    351688                } else if (strcmp(argv[i], "--silent") == 0) {
    352689                        encparms.silent = 1;
     
    358695                        break;
    359696                }
    360697        }
     698
    361699        if (i != (argc - 1)) {
    362700                return 0;
    363701        }
     702
    364703        return 1;
    365704}
    366705
     
    368707        for (; i < argc; i++) {
    369708                if (strcmp(argv[i], "-b") == 0) {
    370709                        oggparms.nominalBitr = atoi(argv[i + 1]);
     710
     711                        if ((oggparms.nominalBitr % 8) != 0) {
     712                                oggparms.nominalBitr -= oggparms.nominalBitr % 8;
     713                        }
     714
     715                        if (oggparms.nominalBitr >160) {
     716                                oggparms.nominalBitr = 160;
     717                        }
     718
     719                        if (oggparms.nominalBitr < 8) {
     720                                oggparms.nominalBitr = 8;
     721                        }
     722
    371723                        i++;
    372                 }
    373                 else if (strcmp(argv[i], "-m") == 0) {
     724                } else if (strcmp(argv[i], "-m") == 0) {
    374725                        oggparms.minBitr = atoi(argv[i + 1]);
     726
     727                        if ((oggparms.minBitr % 8) != 0) {
     728                                oggparms.minBitr -= oggparms.minBitr % 8;
     729                        }
     730
     731                        if (oggparms.minBitr >160) {
     732                                oggparms.minBitr = 160;
     733                        }
     734
     735                        if (oggparms.minBitr < 8) {
     736                                oggparms.minBitr = 8;
     737                        }
     738
    375739                        i++;
    376740                }
    377741                else if (strcmp(argv[i], "-M") == 0) {
    378742                        oggparms.maxBitr = atoi(argv[i + 1]);
     743
     744                        if ((oggparms.maxBitr % 8) != 0) {
     745                                oggparms.maxBitr -= encparms.minBitr % 8;
     746                        }
     747
     748                        if (oggparms.maxBitr >160) {
     749                                oggparms.maxBitr = 160;
     750                        }
     751
     752                        if (oggparms.maxBitr < 8) {
     753                                oggparms.maxBitr = 8;
     754                        }
     755
    379756                        i++;
    380757                }
    381758                else if (strcmp(argv[i], "-q") == 0) {
     
    391768                else if (argv[i][0] == '-') {
    392769                        return 0;
    393770                }
    394                 else
     771                else {
    395772                        break;
     773                }
    396774        }
    397         if (i != argc - 1)
     775
     776        if (i != argc - 1) {
    398777                return 0;
     778        }
     779
    399780        return 1;
    400781}
    401782
    402783int process_flac_parms(int argc, char *argv[], int i){
    403         flacparms.argv = &argv[i];
    404         flacparms.numArgs = argc - 1 - i;
     784        for (; i < argc; i++) {
     785                if (strcmp(argv[i], "-b") == 0) {
     786                        flacparms.blocksize = atoi(argv[i + 1]);
     787                        i++;
     788                }
     789                else if (strcmp(argv[i], "--fast") == 0) {
     790                        flacparms.compressionLevel = 0;
     791                }
     792                else if (strcmp(argv[i], "--best") == 0) {
     793                        flacparms.compressionLevel = 8;
     794                }
     795                else if (strcmp(argv[i], "-0") == 0) {
     796                        flacparms.compressionLevel = 0;
     797                }
     798                else if (strcmp(argv[i], "-1") == 0) {
     799                        flacparms.compressionLevel = 1;
     800                }
     801                else if (strcmp(argv[i], "-2") == 0) {
     802                        flacparms.compressionLevel = 2;
     803                }
     804                else if (strcmp(argv[i], "-3") == 0) {
     805                        flacparms.compressionLevel = 3;
     806                }
     807                else if (strcmp(argv[i], "-4") == 0) {
     808                        flacparms.compressionLevel = 4;
     809                }
     810                else if (strcmp(argv[i], "-5") == 0) {
     811                        flacparms.compressionLevel = 5;
     812                }
     813                else if (strcmp(argv[i], "-6") == 0) {
     814                        flacparms.compressionLevel = 6;
     815                }
     816                else if (strcmp(argv[i], "-7") == 0) {
     817                        flacparms.compressionLevel = 7;
     818                }
     819                else if (strcmp(argv[i], "-8") == 0) {
     820                        flacparms.compressionLevel = 8;
     821                }
     822                else if (strcmp(argv[i], "--verify") == 0) {
     823                        flacparms.verify = true;
     824                }
     825                else if (strcmp(argv[i], "--silent") == 0) {
     826                        flacparms.silent = true;
     827                }
     828                else if (strcmp(argv[i], "--help") == 0) {
     829                        return 0;
     830                }
     831                else if (argv[i][0] == '-') {
     832                        return 0;
     833                }
     834                else {
     835                        break;
     836                }
     837        }
    405838
    406         if (i >= argc)
     839        if (i != argc - 1) {
    407840                return 0;
     841        }
     842
    408843        return 1;
    409844}
  • compress.h

     
    2424#define EXTRACT_H
    2525
    2626#include "util.h"
     27#include <vorbis/vorbisenc.h>
     28#include <FLAC/stream_encoder.h>
    2729
    2830#if defined(__cplusplus)
    2931extern "C" {
     
    3840/* The default for oggenc invocation is to use the --quality option only */
    3941#define oggqualDef 3
    4042
     43/* These are the default parameters for the FLAC invocation */
     44#define flacCompressDef 8
     45#define flacBlocksizeDef 1152
     46
    4147#define TEMP_WAV        "tempfile.wav"
    4248#define TEMP_RAW        "tempfile.raw"
    4349#define TEMP_MP3        "tempfile.mp3"
     
    6066extern void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode);
    6167
    6268extern 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);
     69extern void encodeRaw(char *rawData, int length, int samplerate, const char *outname, CompressMode compmode);
     70extern void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample);
    6471
    6572#if defined(__cplusplus)
    6673}
  • compress_agos.c

     
    7474        unlink(TEMP_RAW);
    7575        unlink(tempEncoded);
    7676        unlink(TEMP_WAV);
    77        
     77
    7878        exit(0);
    7979}
    8080
    81        
     81
    8282static int get_offsets(uint32 filenums[], uint32 offsets[])
    8383{
    8484        int i;
     
    173173        printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
    174174
    175175        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");
    178182
    179183        printf("\n --help     this help message\n");
    180184
     
    253257        char tmp[256];
    254258        uint32 filenums[32768];
    255259        uint32 offsets[32768];
    256        
     260
    257261        sprintf(infile_base, "simon2");
    258262
    259263        input = fopen("voices.idx", "rb");
     
    295299                        sprintf(tmp, "voices%d.dat", filenums[i]);
    296300                        if (input)
    297301                                fclose(input);
    298                         input = fopen(tmp, "rb"); 
     302                        input = fopen(tmp, "rb");
    299303                        if (!input) {
    300304                                printf("Cannot open file: %s\n", tmp);
    301305                                exit(-1);
     
    311315int main(int argc, char *argv[])
    312316{
    313317        int i;
    314        
     318
    315319        if (argc < 2)
    316320                showhelp(argv[0]);
    317321
  • compress_kyra.cpp

     
    3939        if (argc < 3)
    4040                showhelp(argv[0]);
    4141
     42        char inputFile[256];
     43        char outputFile[256];
    4244        int i = 0;
     45
    4346        /* Compression mode */
    4447        gCompMode = kMP3Mode;
    4548        i = 1;
     49
    4650        if (strcmp(argv[1], "--mp3") == 0) {
    4751                gCompMode = kMP3Mode;
    4852                i++;
     
    6064        case kMP3Mode:
    6165                outputExt = OUTPUT_MP3;
    6266                tempEncoded = TEMP_MP3;
    63                 if (!process_mp3_parms(argc - 1, argv, i))
     67                if (!process_mp3_parms(argc - 2, argv, i))
    6468                        showhelp(argv[0]);
    6569                break;
    6670        case kVorbisMode:
    6771                outputExt = OUTPUT_OGG;
    6872                tempEncoded = TEMP_OGG;
    69                 if (!process_ogg_parms(argc - 1, argv, i))
     73                if (!process_ogg_parms(argc - 2, argv, i))
    7074                        showhelp(argv[0]);
    7175                break;
    7276        case kFlacMode:
    7377                outputExt = OUTPUT_FLAC;
    7478                tempEncoded = TEMP_FLAC;
    75                 if (!process_flac_parms(argc - 1, argv, i))
     79                if (!process_flac_parms(argc - 2, argv, i))
    7680                        showhelp(argv[0]);
    7781                break;
    7882        }
    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)
    8188                error("infile and outfile are the same file");
    82         process(argv[argc - 2], argv[argc - 1]);
     89        process(inputFile, outputFile);
    8390        return 0;
    8491}
    8592
    8693static void showhelp(const char *exename) {
    87         printf("\nUsage: %s <params> infile outfile\n", exename);
     94        printf("\nUsage: %s [params] <inputfile> <inputdir> <outputdir>\n", exename);
    8895
    8996        printf("\nParams:\n");
    9097        printf(" --mp3        encode to MP3 format (default)\n");
     
    109116        printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
    110117
    111118        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");
    114125
    115126        printf("\n --help     this help message\n");
    116127
     
    136147                return;
    137148        if (!output.loadFile(0, false))
    138149                return;
    139                
     150
    140151        PAKFile::cFileList *list = input.getFileList();
    141152        char outputName[32];
    142153        for (; list; list = list->next) {
     
    150161
    151162                input.outputFileAs(list->filename, TEMPFILE);
    152163                strncpy(outputName, list->filename, 32);
    153                
     164
    154165                FILE *tempFile = fopen(TEMPFILE, "rb");
    155166                fseek(tempFile, 26, SEEK_CUR);
    156167                extractAndEncodeVOC(TEMP_RAW, tempFile, gCompMode);
    157168                fclose(tempFile);
    158                
     169
    159170                char *vocStart = strstr(outputName, ".VOC");
    160171                for (unsigned int i = 0; i < strlen(outputExt); ++i)
    161172                        vocStart[i] = outputExt[i];
    162173                output.addFile(outputName, tempEncoded);
    163                
     174
    164175                unlink(TEMPFILE);
    165176                unlink(TEMP_RAW);
    166177                unlink(tempEncoded);
    167178        }
    168        
     179
    169180        if (output.getFileList()) {
    170181                output.saveFile(outfile);
    171182        } else {
  • compress_queen.c

     
    2020 *
    2121 */
    2222
    23 #include "util.h"
     23#include "compress.h"
    2424
    2525static const uint32 QTBL = 'QTBL';
     26static CompressMode gCompMode = kMP3Mode;
    2627
    2728#define INPUT_TBL       "queen.tbl"
    2829#define FINAL_OUT       "queen.1c"
     
    3132#define TEMP_TBL        "tempfile.tbl"
    3233#define TEMP_SB         "tempfile.sb"
    3334
    34 #define TEMP_MP3        "tempfile.mp3"
    35 #define TEMP_OGG        "tempfile.ogg"
    36 #define TEMP_FLAC       "tempfile.fla"
    37 
    38 const char *tempEncoded;
    39 
    4035#define CURRENT_TBL_VERSION     2
    4136#define EXTRA_TBL_HEADER 8
    4237#define SB_HEADER_SIZE_V104 110
     
    126121
    127122void showhelp(char *exename)
    128123{
    129         printf("\nUsage: %s [--mp3/--vorbis/--flac <args>] queen.1\n", exename);
     124        printf("\nUsage: %s <params> queen.1\n", exename);
     125
    130126        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");
    136161        exit(2);
    137162}
    138163
     
    219244        FILE *inputData, *inputTbl, *outputTbl, *outputData, *tmpFile, *compFile;
    220245        uint8 compressionType = COMPRESSION_NONE;
    221246        char tmp[5];
    222         char sysBuf[1024];
    223         char *ptr = sysBuf;
    224247        int size, i = 1;
    225248        uint32 prevOffset;
    226249
     
    228251        if (argc < 2)
    229252                showhelp(argv[0]);
    230253
     254        /* compression mode */
     255        compressionType = COMPRESSION_MP3;
     256        gCompMode = kMP3Mode;
     257
    231258        if (strcmp(argv[1], "--mp3") == 0) {
    232259                compressionType = COMPRESSION_MP3;
    233                 tempEncoded = TEMP_MP3;
     260                gCompMode = kMP3Mode;
    234261                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);
    241262        } else if (strcmp(argv[1], "--vorbis") == 0) {
    242263                compressionType = COMPRESSION_OGG;
    243                 tempEncoded = TEMP_OGG;
     264                gCompMode = kVorbisMode;
    244265                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                 }
    250266        } else if (strcmp(argv[1], "--flac") == 0) {
    251267                compressionType = COMPRESSION_FLAC;
    252                 tempEncoded = TEMP_FLAC;
     268                gCompMode = kFlacMode;
    253269                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        }
    260271
    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;
    264288        }
    265289
    266290        /* Open input file (QUEEN.1) */
     
    342366                        fclose(tmpFile);
    343367
    344368                        /* 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);
    350371
    351372                        /* Append MP3/OGG to data file */
    352373                        compFile = fopen(tempEncoded, "rb");
  • compress_saga.cpp

     
    1919 *
    2020 * $URL$
    2121 * $Id$
    22  * 
     22 *
    2323 */
    2424
    2525#include "compress.h"
     
    150150
    151151GameDescription *currentGameDescription = NULL;
    152152GameFileDescription *currentFileDescription = NULL;
    153 bool isSigned = true;
    154153
    155154uint16 sampleRate;
    156155uint32 sampleSize;
     
    194193        uint32 size;
    195194        char fbuf[2048];
    196195        FILE * tempf;
    197        
     196
    198197        tempf = fopen(fromFileName, "rb");
    199198        if (tempf == NULL)
    200199                error("Unable to open %s", fromFileName);
     
    211210        uint32 size;
    212211        char fbuf[2048];
    213212        FILE * tempf;
    214        
     213
    215214        tempf = fopen(toFileName, "wb");
    216215        if (tempf == NULL)
    217216                error("Unable to open %s", toFileName);
     
    228227
    229228void writeBufferToFile(uint8* data, uint32 inputSize, const char* toFileName) {
    230229        FILE * tempf;
    231        
     230
    232231        tempf = fopen(toFileName, "wb");
    233232        if (tempf == NULL)
    234233                error("Unable to open %s", toFileName);
     
    248247        Common::File inputFileStream(inputFile);
    249248        int rate, size;
    250249        byte flags;
    251        
     250
    252251        if (currentFileDescription->resourceType == kSoundVOC) {
    253252                inputData = Audio::loadVOCFromStream(inputFileStream, size, rate);
    254253                sampleSize = size;
     
    259258                free(inputData);
    260259                writeHeader(outputFile);
    261260
    262                 setRawAudioType( true, false, !isSigned, 8);
     261                setRawAudioType( true, false, 8);
    263262                encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
    264263                return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
    265264        }
     
    271270                sampleStereo = currentFileDescription->stereo;
    272271                writeHeader(outputFile);
    273272
    274                 setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, !isSigned, sampleBits);
     273                setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, sampleBits);
    275274                encodeAudio(TEMP_RAW, true, currentFileDescription->frequency, tempEncoded, gCompMode);
    276275                return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
    277276        }
     
    287286
    288287                copyFile(inputFile, size, TEMP_RAW);
    289288
    290                 setRawAudioType( true, sampleStereo != 0, !isSigned, sampleBits);
     289                setRawAudioType( true, sampleStereo != 0, sampleBits);
    291290                encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
    292291                return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
    293292        }
     
    302301                sampleStereo = currentFileDescription->stereo;
    303302                writeHeader(outputFile);
    304303
    305                 setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, !isSigned, sampleBits);
     304                setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, sampleBits);
    306305                encodeAudio(TEMP_RAW, true, currentFileDescription->frequency, tempEncoded, gCompMode);
    307306                return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
    308307                */
     
    348347                error("Something's wrong with your resource file");
    349348        }
    350349
    351         // Go to beginning of the table 
     350        // Go to beginning of the table
    352351        fseek(inputFile, resTableOffset, SEEK_SET);
    353352
    354353        inputTable = (Record*)malloc(resTableCount * sizeof(Record));
    355354
    356         // Put offsets of all the records in a table 
     355        // Put offsets of all the records in a table
    357356        for (i = 0; i < resTableCount; i++) {
    358357
    359358        if (!currentFileDescription->swapEndian) {
     
    365364        }
    366365
    367366                 printf("Record: %ul, offset: %ul, size: %ul\n", i, inputTable[i].offset, inputTable[i].size);
    368        
     367
    369368                if ((inputTable[i].offset > inputFileSize) ||
    370369                    (inputTable[i].offset + inputTable[i].size > inputFileSize)) {
    371370                        error("The offset points outside the file");
     
    374373        }
    375374        outputTable = (Record*)malloc(resTableCount * sizeof(Record));
    376375
    377         sprintf(outputFileNameWithExt, "%s.cmp", inputFileName);       
     376        sprintf(outputFileNameWithExt, "%s.cmp", inputFileName);
    378377        outputFile = fopen(outputFileNameWithExt, "wb");
    379378
    380379        for (i = 0; i < resTableCount; i++) {
    381380                fseek(inputFile, inputTable[i].offset, SEEK_SET);
    382381                outputTable[i].offset = ftell(outputFile);
    383                
     382
    384383                outputTable[i].size = encodeEntry(inputFile, inputTable[i].size, outputFile);
    385384        }
    386385        fclose(inputFile);
     
    391390                writeUint32LE(outputFile, outputTable[i].size);
    392391        }
    393392        writeUint32LE(outputFile, resTableOffset);
    394         writeUint32LE(outputFile, resTableCount);       // Should be the same number of entries 
     393        writeUint32LE(outputFile, resTableCount);       // Should be the same number of entries
    395394
    396395        fclose(outputFile);
    397396
    398397        free(inputTable);
    399398        free(outputTable);
    400        
     399
    401400        // Cleanup
    402401        unlink(TEMP_RAW);
    403402        unlink(tempEncoded);
     
    406405}
    407406
    408407void showhelp(char *exename) {
    409         printf("\nUsage: %s <params> [<file> | mac]\n", exename);
     408        printf("\nUsage: %s <params> <file>\n", exename);
    410409
    411410        printf("\nParams:\n");
    412411
     
    432431        printf("--silent     the output of oggenc is hidden (default:disabled)\n");
    433432
    434433        printf("\nFlac mode params:\n");
    435         printf("[params]     optional Arguments passed to the Encoder\n");
    436         printf("             recommended is: --best -b 1152\n");
     434        printf(" --fast       FLAC uses compresion level 0\n");
     435        printf(" --best       FLAC uses compresion level 8\n");
     436        printf(" -<value>     specifies the value (0 - 8) of compresion (8=best)(default:%d)\n", flacCompressDef);
     437        printf(" -b <value>   specifies a blocksize of <value> samples (default:%d)\n", flacBlocksizeDef);
     438        printf(" --verify     files are encoded and then decoded to check accuracy\n");
     439        printf(" --silent     the output of FLAC is hidden (default:disabled)\n");
    437440
    438441        printf("\n--help     this help message\n");
    439442
     
    501504                                // Check for MacBinary
    502505                                sprintf(inputFileNameWithExt, "%s.bin", inputFileName);
    503506                                if (detectFile(inputFileNameWithExt)) {
    504                                         isSigned = false;
    505507                                        sagaEncode(inputFileName);
    506508                                }
    507509                        }
  • compress_scumm_bun.cpp

     
    614614}
    615615
    616616void showhelp(char *exename) {
    617         printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);
     617        printf("\nUsage: %s [--vorbis] [encoder params] <inputfile> <inputdir> <outputdir>\n", exename);
    618618        printf("\nMP3 mode params:\n");
    619619        printf(" -b <rate>    <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
    620620        printf(" -B <rate>    <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
     
    10641064        uint32 tag;
    10651065        int32 numFiles, offset, i;
    10661066
    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]);
    10701070
    10711071        if (argc > 4) {
    1072                 i = 4;
     1072                int result;
     1073                i = 1;
    10731074
    1074                 if (strcmp(argv[i], "--ogg") == 0) {
     1075                if (strcmp(argv[i], "--vorbis") == 0) {
    10751076                        _oggMode = true;
    10761077                        i++;
    10771078                }
    10781079
    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);
    10861084
    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]);
    11031087        }
    11041088
    11051089        char *index = strrchr(inputFilename, '.');
     
    11411125                char filename[13], c;
    11421126                int z = 0;
    11431127                int z2;
    1144                        
     1128
    11451129                for (z2 = 0; z2 < 8; z2++)
    11461130                        if ((c = readByte(input)) != 0)
    11471131                                filename[z++] = c;
     
    11811165        fclose(input);
    11821166
    11831167        printf("compression done.\n");
    1184                
     1168
    11851169        return 0;
    11861170}
  • compress_scumm_san.cpp

     
    2424#include "zlib.h"
    2525
    2626void 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);
    2828        printf("\nMP3 mode params:\n");
    2929        printf(" -b <rate>    <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
    3030        printf(" -B <rate>    <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
     
    643643        char inputFilename[200];
    644644        char tmpPath[200];
    645645
    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]);
    649649
    650650        if (argc > 4) {
    651                 int i = 4;
     651                int i = 1;
    652652
    653                 if (strcmp(argv[i], "--ogg") == 0) {
     653                if (strcmp(argv[1], "--vorbis") == 0) {
    654654                        _oggMode = true;
    655655                        i++;
    656656                }
    657657
    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;
    665659
    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);
    671664
    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]);
    682667        }
    683668
    684669        char *index = strrchr(inputFilename, '.');
  • compress_scumm_sou.c

     
    7272        unlink(TEMP_DAT);
    7373        unlink(TEMP_RAW);
    7474        unlink(tempEncoded);
    75        
     75
    7676        exit(-1);
    7777}
    7878
     
    130130
    131131        /* Conver the VOC data */
    132132        extractAndEncodeVOC(TEMP_RAW, input, gCompMode);
    133        
     133
    134134        /* Append the converted data to the master output file */
    135135        sprintf(outname, tempEncoded);
    136136        f = fopen(outname, "rb");
     
    171171        printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
    172172
    173173        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");
    176180
    177181        printf("\n --help     this help message\n");
    178182
     
    242246                printf("Can't open file " TEMP_DAT " for write!\n");
    243247                exit(-1);
    244248        }
    245        
     249
    246250        /* Get the 'SOU ....' header */
    247251        fread(buf, 1, 8, input);
    248252        if (strncmp(buf, f_hdr, 8)) {
  • compress_sword1.c

     
    116116        { "2M26", false },
    117117        { "3M7", false },
    118118        { "3M8", false },
    119         { "3M9", true }, 
     119        { "3M9", true },
    120120        { "3M10", false },
    121121        { "2M13", false },
    122122        { "3M12", false },
     
    163163        { "4M31", false },
    164164        { "4M32", false },
    165165        { "5M1", false },
    166         { "5M2", true }, 
     166        { "5M2", true },
    167167        { "5M3", false },
    168168        { "5M4", false },
    169169        { "5M5", false },
     
    275275        { "11M4", false },
    276276        { "11M7", false },
    277277        { "11M8", false },
    278         { "11M9", true }, 
     278        { "11M9", true },
    279279        { "12M1", false },
    280280        { "11M2", false },
    281281        { "SPM2", false },
     
    337337        printf("                (default:%d)\n", oggqualDef);
    338338        printf(" --silent       the output of oggenc is hidden (default:disabled)\n");
    339339
     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
    340348        printf("\n --help         this help message\n");
    341349
    342350        printf("\nIf a parameter is not given the default value is used\n");
     
    438446        }
    439447        cl3Index = (uint32*)malloc(numSamples * 8);
    440448        memset(cl3Index, 0, numSamples * 8);
    441        
     449
    442450        sampleIndex = cowHeader + numRooms + 1;
    443451        /* This points to the sample index table. 8 bytes each (4 bytes size and then 4 bytes file index) */
    444452
     
    446454
    447455        for (cnt = 0; cnt < numSamples; cnt++) {
    448456                if (sampleIndex[cnt << 1] | sampleIndex[(cnt << 1) | 1]) {
    449                         printf("sample %5d: ", cnt);
     457                        printf("sample %5d: \n", cnt);
    450458                        smpData = (uint8*)uncompressSpeech(clu, sampleIndex[cnt << 1] + headerSize, sampleIndex[(cnt << 1) | 1], &smpSize);
    451459                        if ((!smpData) || (!smpSize))
    452460                                error("unable to handle speech sample %d!\n", cnt);
     
    475483        int i;
    476484        char cluName[256], outName[256];
    477485
    478         setRawAudioType(true, false, false, 16);
     486        setRawAudioType(true, false, 16);
    479487        for (i = 1; i <= 2; i++) {
    480488                sprintf(cluName, "SPEECH/SPEECH%d.CLU", i);
    481489                clu = fopen(cluName, "rb");
     
    670678                compressSpeech(compMode);
    671679        if (compMusic)
    672680                compressMusic(compMode);
    673        
     681
    674682        return EXIT_SUCCESS;
    675683}
    676684
  • compress_sword2.c

     
    3131
    3232void showhelp(char *exename)
    3333{
    34         printf("\nUsage: %s <params> file.clu\n", exename);
     34        printf("\nUsage: %s <params> <file>\n", exename);
    3535
    3636        printf("\nParams:\n");
    3737        printf(" --mp3        encode to MP3 format (default)\n");
     
    5656        printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
    5757
    5858        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");
    6165
    6266        printf("\n --help     this help message\n");
    6367
     
    104108        uint32 indexSize;
    105109        uint32 totalSize;
    106110        uint32 length;
    107        
     111
    108112        if (argc < 2)
    109113                showhelp(argv[0]);
    110114        i = 1;
  • compress_touche.c

     
    161161        printf("\nUsage: %s <params> input_directory\n", exename);
    162162
    163163        printf("\nParams:\n");
     164
    164165        printf(" --mp3        encode to MP3 format (default)\n");
    165166        printf(" --vorbis     encode to Vorbis format\n");
    166167        printf(" --flac       encode to Flac format\n");
     
    183184        printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
    184185
    185186        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");
    188193
    189194        printf("\n --help     this help message\n");
    190195
  • encode_dxa.cpp

     
    699699}
    700700
    701701void showhelp(char *exename) {
    702         printf("\nUsage: %s <inputfile> \n", exename);
     702        printf("\nUsage: %s <params> <file>\n", exename);
    703703
    704704        printf("\nParams:\n");
    705705        printf(" --mp3        encode to MP3 format (default)\n");
     
    724724        printf(" --silent     the output of oggenc is hidden (default:disabled)\n");
    725725
    726726        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");
    729733
    730734        printf("\n --help     this help message\n");
    731735
    732736        printf("\n\nIf a parameter is not given the default value is used\n");
    733737        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");
    735738        exit(2);
    736739}
    737740
  • kyra_pak.h

     
    2424#define KYRA_PAK_H
    2525
    2626#include "util.h"
    27 #include <string.h>
    2827
    2928class PAKFile {
    3029public:
     
    3433        bool loadFile(const char *file, const bool isAmiga);
    3534        bool saveFile(const char *file);
    3635        void clearFile() { delete _fileList; _fileList = 0; }
    37        
     36
    3837        const uint32 getFileSize() const { return _fileList->getTableSize()+5+4+_fileList->getFileSize(); }
    3938
    4039        void drawFileList();
     
    4746
    4847        bool addFile(const char *name, const char *file);
    4948        bool addFile(const char *name, uint8 *data, uint32 size);
    50        
     49
    5150        bool removeFile(const char *name);
    5251public:
    5352        struct FileList {
     
    5756                        delete [] data;
    5857                        delete next;
    5958                }
    60                
     59
    6160                FileList *findEntry(const char *f) {
    6261                        for (FileList *cur = this; cur; cur = cur->next) {
    6362                                if (scumm_stricmp(cur->filename, f) != 0)
     
    6665                        }
    6766                        return 0;
    6867                }
    69                
     68
    7069                const FileList *findEntry(const char *f) const {
    7170                        for (const FileList *cur = this; cur; cur = cur->next) {
    7271                                if (scumm_stricmp(cur->filename, f) != 0)
     
    9291                char *filename;
    9392                uint32 size;
    9493                uint8 *data;
    95                
     94
    9695                FileList *next;
    9796        };
    9897
    9998        typedef const FileList cFileList;
    100        
     99
    101100        cFileList *getFileList() const { return _fileList; }
    102101private:
    103102        FileList *_fileList;
  • Makefile

     
    5151all: $(TARGETS)
    5252
    5353compress_agos$(EXEEXT): compress_agos.o compress.o util.o
    54         $(CC) $(LDFLAGS) -o $@ $+
     54        $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    5555
    5656compress_kyra$(EXEEXT): compress_kyra.o kyra_pak.o compress.o util.o
    57         $(CXX) $(LDFLAGS) -o $@ $+
     57        $(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    5858
    59 compress_queen$(EXEEXT): compress_queen.o util.o
    60         $(CC) $(LDFLAGS) -o $@ $+
     59compress_queen$(EXEEXT): compress_queen.o compress.o util.o
     60        $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    6161
    6262compress_saga$(EXEEXT): compress_saga.o compress.o util.o $(UTILS)
    63         $(CXX) $(LDFLAGS) -o $@ $+
     63        $(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    6464
    6565compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o
    66         $(CXX) $(LDFLAGS) -o $@ $+
     66        $(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    6767
    6868compress_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
    7070
    7171compress_scumm_sou$(EXEEXT): compress_scumm_sou.o compress.o util.o
    72         $(CC) $(LDFLAGS) -o $@ $+
     72        $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    7373
    7474compress_sword1$(EXEEXT): compress_sword1.o compress.o util.o
    75         $(CC) $(LDFLAGS) -o $@ $+
     75        $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    7676
    7777compress_sword2$(EXEEXT): compress_sword2.o compress.o util.o
    78         $(CC) $(LDFLAGS) -o $@ $+
     78        $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    7979
    8080compress_touche$(EXEEXT): compress_touche.o compress.o util.o
    81         $(CC) $(LDFLAGS) -o $@ $+
     81        $(CC) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
    8282
    8383dekyra$(EXEEXT): dekyra.o dekyra_v1.o util.o
    8484        $(CXX) $(LDFLAGS) -o $@ $+
     
    9090        $(CXX) $(LDFLAGS) -o $@ $+
    9191
    9292encode_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
    9494
    9595extract_agos$(EXEEXT): extract_agos.o
    9696        $(CC) $(LDFLAGS) -o $@ $+
     
    122122
    123123descumm.o descumm6.o descumm-common.o descumm-tool.o: descumm.h
    124124
    125 # Most compress_* tools (except for compress_queen) use compress.h
     125# All compress_* tools use compress.h
    126126compress_agos.o compress_saga.o compress_scumm_sou.o \
    127127compress_scumm_bun.o compress_sword1.o compress_sword2.o \
    128 compress_kyra.o compress.o encode_dxa.o: compress.h
     128compress_kyra.o compress_queen.o compress.o encode_dxa.o: compress.h
    129129
    130130# extract_parallaction.h
    131131extract_parallaction.o: extract_parallaction.h
  • README

     
    8484                for compressed sounds in I have no mouth yet.
    8585
    8686        compress_sword1
    87                 Used to compress Broken Sword 1's music and speech files to
    88                 MP3 or Vorbis or FLAC.
     87                Used to compress Broken Sword 1's music and speech .clu
     88                files to .cl3 (MP3), .clg (Vorbis) or .clf (FLAC).
    8989
     90                Please note that FLAC compression will produce a larger file
     91                than the original! This is because the original files already
     92                use lossy compression.
     93
    9094        compress_sword2
    9195                Used to compress Broken Sword 2's music and speech .clu
    9296                files to .cl3 (MP3), .clg (Vorbis) or .clf (FLAC).
     
    98102        compress_touche
    99103                Used to compress and pack Touche speech files ('Vxxx' and
    100104                '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.
     105                TOUCHE.SO3 (MP3), TOUCHE.SOG (Vorbis), or TOUCHE.SOF (FLAC).
     106               
     107                Once compressed, only TOUCHE.DAT and TOUCHE.SOx files are
    104108
    105         compress_scumm_san <inputfile> <inputdir> <outputdir> [--ogg]
     109        compress_scumm_san
    106110                Compresses '.san' smush animation files. It uses lossless
    107111                zlib for compressing FOBJ gfx chunks inside a san file.
    108112                It also can create a separate Ogg file with the audio track.
    109113
    110                 Example of usage:
    111                 compress_scumm_san opening.san uncomp comp
    112 
    113114                In order to use such compressed files, your ScummVM binary
    114115                must have been built with zlib support enabled (you can find
    115116                out whether that's the case by looking at the About dialog).
     
    124125                move the '.san' files before compressing them, make sure to
    125126                move the '.flu' files, too!
    126127
    127         compress_scumm_bun <inputfile> <inputdir> <outputdir> [--ogg]
     128        compress_scumm_bun
    128129
    129130                Compresses '.bun' music/voice files.
    130131
    131                 Example of usage:
    132                 compress_scumm.bun digmusic.bun uncomp comp
    133 
    134132                For the Ogg or MP3 compression feature, your ScummVM binary
    135133                naturally must have been built with Ogg or MP3 support enabled.
    136134
     
    138136                Used to compress The Legend of Kyrandia's speech files with
    139137                MP3, Vorbis or FLAC.
    140138
    141                 Example of usage:
    142                 compress_kyra <flags here> input/GEMCUT.VRM output/GEMCUT.VRM
    143 
    144139                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.
    147 
    148140Script Tools:
    149141        descumm
    150142                Decompiles SCUMM scripts