Changeset 339 for libmpc/trunk/mpcdec/mpcdec.c
- Timestamp:
- 06/30/07 20:18:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/mpcdec/mpcdec.c
r328 r339 36 36 #include <time.h> 37 37 #include <mpc/mpcdec.h> 38 #include "../libmpcdec/decoder.h" 39 #include "../libmpcdec/internal.h" 38 40 #include <libwaveformat.h> 39 41 #include <getopt.h> … … 86 88 printf("Usage: %s [-i] [-h] <infile.mpc> [<outfile.wav>]\n" 87 89 "-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" 88 92 "-h : print this help\n", exename); 89 93 } … … 96 100 mpc_streaminfo si; 97 101 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; 99 103 MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH]; 100 104 clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output; 101 mpc_bool_t is_wav_output;102 105 int c; 103 106 104 107 printf("mpcdec - musepack (mpc) decoder sample application\n"); 105 108 106 while ((c = getopt(argc , argv, "ih ")) != -1) {109 while ((c = getopt(argc , argv, "ihc")) != -1) { 107 110 switch (c) { 108 111 case 'i': 109 112 info = MPC_TRUE; 113 break; 114 case 'c': 115 check = MPC_TRUE; 110 116 break; 111 117 case 'h': … … 135 141 } 136 142 137 is_wav_output = argc - optind > 1; 143 if (!check) 144 is_wav_output = argc - optind > 1; 138 145 if(is_wav_output) 139 146 { … … 154 161 155 162 frame.buffer = sample_buffer; 163 if (check) 164 demux->d->samples_to_skip = MPC_FRAME_LENGTH + MPC_DECODER_SYNTH_DELAY; 156 165 begin = clock(); 157 166 err = mpc_demux_decode(demux, &frame); … … 182 191 if (err != MPC_STATUS_OK) 183 192 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 } 193 206 194 207 mpc_demux_exit(demux);
Note: See TracChangeset
for help on using the changeset viewer.