Changeset 356 for libmpc/trunk/mpcdec/mpcdec.c
- Timestamp:
- 09/27/07 12:54:04 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/mpcdec/mpcdec.c
r353 r356 47 47 #define MPCDEC_MAJOR 0 48 48 #define MPCDEC_MINOR 9 49 #define MPCDEC_BUILD 049 #define MPCDEC_BUILD 1 50 50 51 51 #define _cat(a,b,c) #a"."#b"."#c … … 74 74 int seconds = time % 60; 75 75 76 printf("file: %s\n", filename);77 printf("stream version %d\n", info->stream_version);78 printf("encoder: %s\n", info->encoder);79 printf("profile: %s (q=%0.2f)\n", info->profile_name, info->profile - 5);80 printf("PNS: %s\n", info->pns == 0xFF ? "unknow" : info->pns ? "on" : "off");81 printf("mid/side stereo: %s\n", info->ms ? "on" : "off");82 printf("gapless: %s\n", info->is_true_gapless ? "on" : "off");83 printf("average bitrate: %6.1f kbps\n", info->average_bitrate * 1.e-3);84 printf("samplerate: %d Hz\n", info->sample_freq);85 printf("channels: %d\n", info->channels);86 printf("length: %d:%.2d (%u samples)\n", minutes, seconds, (mpc_uint32_t)mpc_streaminfo_get_length_samples(info));87 printf("file size: %d Bytes\n", info->total_file_length);88 printf("track peak: %2.2f dB\n", info->peak_title / 256.f);89 printf("track gain: %2.2f dB / %2.2f dB\n", info->gain_title / 256.f, info->gain_title == 0 ? 0 : 64.82f - info->gain_title / 256.f);90 printf("album peak: %2.2f dB\n", info->peak_album / 256.f);91 printf("album gain: %2.2f dB / %2.2f dB\n", info->gain_album / 256.f, info->gain_album == 0 ? 0 : 64.82f - info->gain_album / 256.f);92 printf("\n");76 fprintf(stderr, "file: %s\n", filename); 77 fprintf(stderr, "stream version %d\n", info->stream_version); 78 fprintf(stderr, "encoder: %s\n", info->encoder); 79 fprintf(stderr, "profile: %s (q=%0.2f)\n", info->profile_name, info->profile - 5); 80 fprintf(stderr, "PNS: %s\n", info->pns == 0xFF ? "unknow" : info->pns ? "on" : "off"); 81 fprintf(stderr, "mid/side stereo: %s\n", info->ms ? "on" : "off"); 82 fprintf(stderr, "gapless: %s\n", info->is_true_gapless ? "on" : "off"); 83 fprintf(stderr, "average bitrate: %6.1f kbps\n", info->average_bitrate * 1.e-3); 84 fprintf(stderr, "samplerate: %d Hz\n", info->sample_freq); 85 fprintf(stderr, "channels: %d\n", info->channels); 86 fprintf(stderr, "length: %d:%.2d (%u samples)\n", minutes, seconds, (mpc_uint32_t)mpc_streaminfo_get_length_samples(info)); 87 fprintf(stderr, "file size: %d Bytes\n", info->total_file_length); 88 fprintf(stderr, "track peak: %2.2f dB\n", info->peak_title / 256.f); 89 fprintf(stderr, "track gain: %2.2f dB / %2.2f dB\n", info->gain_title / 256.f, info->gain_title == 0 ? 0 : 64.82f - info->gain_title / 256.f); 90 fprintf(stderr, "album peak: %2.2f dB\n", info->peak_album / 256.f); 91 fprintf(stderr, "album gain: %2.2f dB / %2.2f dB\n", info->gain_album / 256.f, info->gain_album == 0 ? 0 : 64.82f - info->gain_album / 256.f); 92 fprintf(stderr, "\n"); 93 93 94 94 } … … 97 97 usage(const char *exename) 98 98 { 99 printf("Usage: %s [-i] [-h] <infile.mpc> [<outfile.wav>]\n"99 fprintf(stderr, "Usage: %s [-i] [-h] <infile.mpc> [<outfile.wav>]\n" 100 100 "-i : print file information on stdout\n" 101 101 "-c : check the file for stream errors\n" 102 102 " (doesn't fully decode, outfile will be ignored)\n" 103 "-h : print this help\n", exename); 103 "-h : print this help\n" 104 "you can use stdin and stdout as resp. <infile.mpc> and\n" 105 "<outfile.wav> replacing the file name by \"-\"\n", exename); 104 106 } 105 107 … … 116 118 int c; 117 119 118 printf(About);120 fprintf(stderr, About); 119 121 120 122 while ((c = getopt(argc , argv, "ihc")) != -1) { … … 138 140 } 139 141 140 err = mpc_reader_init_stdio(&reader, argv[optind]); 142 if (strcmp(argv[optind], "-") == 0) 143 err = mpc_reader_init_stdio_stream(& reader, stdin); 144 else 145 err = mpc_reader_init_stdio(&reader, argv[optind]); 141 146 if(err < 0) return !MPC_STATUS_OK; 142 147 … … 160 165 wavo_fc.m_seek = mpc_wav_output_seek; 161 166 wavo_fc.m_write = mpc_wav_output_write; 162 wavo_fc.m_user_data = fopen(argv[optind + 1], "wb"); 167 if (strcmp(argv[optind + 1], "-") == 0) 168 wavo_fc.m_user_data = stdout; 169 else 170 wavo_fc.m_user_data = fopen(argv[optind + 1], "wb"); 163 171 if(!wavo_fc.m_user_data) return !MPC_STATUS_OK; 164 172 err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.samples * 2); … … 201 209 202 210 if (err != MPC_STATUS_OK) 203 printf("An error occured while decoding\n");211 fprintf(stderr, "An error occured while decoding\n"); 204 212 else if (check) 205 printf("No error found\n");213 fprintf(stderr, "No error found\n"); 206 214 207 215 if (!check) { 208 printf("%u samples ", total_samples);216 fprintf(stderr, "%u samples ", total_samples); 209 217 if (sum <= 0) sum = 1; 210 218 total_samples = (mpc_uint32_t) ((mpc_uint64_t) total_samples * CLOCKS_PER_SEC * 100 / ((mpc_uint64_t)si.sample_freq * sum)); 211 printf("decoded in %u ms (%u.%02ux)\n",219 fprintf(stderr, "decoded in %u ms (%u.%02ux)\n", 212 220 (unsigned int) (sum * 1000 / CLOCKS_PER_SEC), 213 221 total_samples / 100,
Note: See TracChangeset
for help on using the changeset viewer.