Changeset 339


Ignore:
Timestamp:
06/30/07 20:18:26 (17 years ago)
Author:
r2d
Message:

added check stream option to mpcdec

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/mpcdec/mpcdec.c

    r328 r339  
    3636#include <time.h>
    3737#include <mpc/mpcdec.h>
     38#include "../libmpcdec/decoder.h"
     39#include "../libmpcdec/internal.h"
    3840#include <libwaveformat.h>
    3941#include <getopt.h>
     
    8688    printf("Usage: %s [-i] [-h] <infile.mpc> [<outfile.wav>]\n"
    8789                        "-i : print file information on stdout\n"
     90                        "-c : check the file for stream errors\n"
     91                        "     (doesn't fully decode, outfile will be ignored)\n"
    8892                        "-h : print this help\n", exename);
    8993}
     
    96100        mpc_streaminfo si;
    97101        mpc_status err;
    98         mpc_bool_t info = MPC_FALSE;
     102        mpc_bool_t info = MPC_FALSE, is_wav_output = MPC_FALSE, check = MPC_FALSE;
    99103    MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
    100104    clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output;
    101         mpc_bool_t is_wav_output;
    102105        int c;
    103106
    104107    printf("mpcdec - musepack (mpc) decoder sample application\n");
    105108
    106         while ((c = getopt(argc , argv, "ih")) != -1) {
     109        while ((c = getopt(argc , argv, "ihc")) != -1) {
    107110                switch (c) {
    108111                        case 'i':
    109112                                info = MPC_TRUE;
     113                                break;
     114                        case 'c':
     115                                check = MPC_TRUE;
    110116                                break;
    111117                        case 'h':
     
    135141        }
    136142
    137         is_wav_output = argc - optind > 1;
     143        if (!check)
     144                is_wav_output = argc - optind > 1;
    138145    if(is_wav_output)
    139146    {
     
    154161
    155162        frame.buffer = sample_buffer;
     163            if (check)
     164                    demux->d->samples_to_skip = MPC_FRAME_LENGTH + MPC_DECODER_SYNTH_DELAY;
    156165        begin        = clock();
    157166        err = mpc_demux_decode(demux, &frame);
     
    182191        if (err != MPC_STATUS_OK)
    183192                printf("An error occured while decoding\n");
    184 
    185     printf("%u samples ", total_samples);
    186         if (sum <= 0) sum = 1;
    187         total_samples = (mpc_uint32_t) ((mpc_uint64_t) total_samples * CLOCKS_PER_SEC * 100 / ((mpc_uint64_t)si.sample_freq * sum));
    188     printf("decoded in %u ms (%u.%02ux)\n",
    189                    (unsigned int) (sum * 1000 / CLOCKS_PER_SEC),
    190            total_samples / 100,
    191            total_samples % 100
    192            );
     193        else if (check)
     194                printf("No error found\n");
     195
     196        if (!check) {
     197                printf("%u samples ", total_samples);
     198                if (sum <= 0) sum = 1;
     199                total_samples = (mpc_uint32_t) ((mpc_uint64_t) total_samples * CLOCKS_PER_SEC * 100 / ((mpc_uint64_t)si.sample_freq * sum));
     200                printf("decoded in %u ms (%u.%02ux)\n",
     201                        (unsigned int) (sum * 1000 / CLOCKS_PER_SEC),
     202                        total_samples / 100,
     203                        total_samples % 100
     204                        );
     205        }
    193206
    194207    mpc_demux_exit(demux);
Note: See TracChangeset for help on using the changeset viewer.