Changeset 315
- Timestamp:
- 05/10/07 00:01:35 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/mpcdec/mpcdec.c
r299 r315 37 37 #include <mpc/mpcdec.h> 38 38 #include <libwaveformat.h> 39 #include <unistd.h> 39 40 40 41 #ifdef WIN32 … … 54 55 } 55 56 57 static void print_info(mpc_streaminfo * info, char * filename) 58 { 59 int time = (int) mpc_streaminfo_get_length(info); 60 int minutes = time / 60; 61 int seconds = time % 60; 62 63 printf("file: %s\n", filename); 64 printf("stream version %d\n", info->stream_version); 65 printf("encoder: \%s\n", info->encoder); 66 printf("profile: \%s (q=%0.2f)\n", info->profile_name, info->profile - 5); 67 printf("PNS: \%s\n", info->pns == 0xFF ? "unknow" : info->pns ? "on" : "off"); 68 printf("mid/side stereo: %s\n", info->ms ? "on" : "off"); 69 printf("gapless: \%s\n", info->is_true_gapless ? "on" : "off"); 70 printf("average bitrate: \%6.1f kbps\n", info->average_bitrate * 1.e-3); 71 printf("samplerate: \%d Hz\n", info->sample_freq); 72 printf("channels: \%d\n", info->channels); 73 printf("length: \%d:\%.2d (%u samples)\n", minutes, seconds, (mpc_uint32_t)mpc_streaminfo_get_length_samples(info)); 74 printf("file size: \%d Bytes\n", info->total_file_length); 75 printf("track peak: \%2.2f dB\n", info->peak_title / 256.); 76 printf("track gain: \%2.2f dB\n", info->gain_title / 256.); 77 printf("album peak: \%2.2f dB\n", info->peak_album / 256.); 78 printf("album gain: \%2.2f dB\n", info->gain_album / 256.); 79 printf("\n"); 80 81 } 82 56 83 static void 57 84 usage(const char *exename) 58 85 { 59 printf("Usage: %s <infile.mpc> [<outfile.wav>]\n", exename); 86 printf("Usage: %s [-i] [-h] <infile.mpc> [<outfile.wav>]\n" 87 "-i : print file information on stdout\n" 88 "-h : print this help\n", exename); 60 89 } 61 90 … … 67 96 mpc_streaminfo si; 68 97 mpc_status err; 98 mpc_bool_t info = MPC_FALSE; 69 99 MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH]; 70 100 clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output; 71 mpc_bool_t is_wav_output; 101 mpc_bool_t is_wav_output; 102 int c; 103 extern char * optarg; 104 extern int optind; 72 105 73 106 printf("mpcdec - musepack (mpc) decoder sample application\n"); 74 if(3 < argc && argc < 2) 107 108 while ((c = getopt(argc , argv, "ih")) != -1) { 109 switch (c) { 110 case 'i': 111 info = MPC_TRUE; 112 break; 113 case 'h': 114 usage(argv[0]); 115 return 0; 116 } 117 } 118 119 if(2 < argc - optind && argc - optind < 1) 75 120 { 76 121 usage(argv[0]); … … 78 123 } 79 124 80 err = mpc_reader_init_stdio(&reader, argv[1]);125 err = mpc_reader_init_stdio(&reader, argv[optind]); 81 126 if(err < 0) return !MPC_STATUS_OK; 82 127 … … 85 130 mpc_demux_get_info(demux, &si); 86 131 87 is_wav_output = argc > 2; 132 if (info == MPC_TRUE) { 133 print_info(&si, argv[optind]); 134 mpc_demux_exit(demux); 135 mpc_reader_exit_stdio(&reader); 136 return 0; 137 } 138 139 is_wav_output = argc - optind > 1; 88 140 if(is_wav_output) 89 141 { … … 92 144 wavo_fc.m_seek = mpc_wav_output_seek; 93 145 wavo_fc.m_write = mpc_wav_output_write; 94 wavo_fc.m_user_data = fopen(argv[2], "wb");146 wavo_fc.m_user_data = fopen(argv[optind + 1], "wb"); 95 147 if(!wavo_fc.m_user_data) return !MPC_STATUS_OK; 96 148 err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.samples * 2);
Note: See TracChangeset
for help on using the changeset viewer.