Changeset 75 for libmpcdec/branches/zorg
- Timestamp:
- 10/12/06 23:34:50 (18 years ago)
- Location:
- libmpcdec/branches/zorg
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpcdec/branches/zorg/mpcdec/mpcdec.c
r70 r75 36 36 #include <time.h> 37 37 #include <mpcdec/mpcdec.h> 38 #include <libwaveformat.h> 38 39 39 40 #ifdef WIN32 … … 41 42 #endif 42 43 44 t_wav_uint32 mpc_wav_output_write(void* p_user_data, void const* p_buffer, t_wav_uint32 p_bytes) 45 { 46 FILE* p_handle = (FILE*) p_user_data; 47 return (t_wav_uint32) fwrite(p_buffer, 1, p_bytes, p_handle); 48 } 49 50 t_wav_uint32 mpc_wav_output_seek(void* p_user_data, t_wav_uint32 p_position) 51 { 52 FILE* p_handle = (FILE*) p_user_data; 53 return (t_wav_uint32) !fseek(p_handle, p_position, SEEK_SET); 54 } 55 43 56 static void 44 57 usage(const char *exename) 45 58 { 46 printf("Usage: %s <infile.mpc> \n", exename);59 printf("Usage: %s <infile.mpc> [<outfile.wav>]\n", exename); 47 60 } 48 61 … … 52 65 mpc_reader reader; mpc_streaminfo si; mpc_decoder* decoder; mpc_status err; 53 66 MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH]; 54 clock_t begin, end, sum; int total_samples; 67 clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output; 68 mpc_bool_t is_wav_output; 55 69 56 if( argc !=2)70 if(3 < argc && argc < 2) 57 71 { 58 72 usage(argv[0]); … … 69 83 if(err < 0) return !MPC_STATUS_OK; 70 84 85 is_wav_output = argc > 2; 86 if(is_wav_output) 87 { 88 t_wav_output_file_callback wavo_fc; 89 memset(&wav_output, 0, sizeof wav_output); 90 wavo_fc.m_seek = mpc_wav_output_seek; 91 wavo_fc.m_write = mpc_wav_output_write; 92 wavo_fc.m_user_data = fopen(argv[2], "wb"); 93 if(!wavo_fc.m_user_data) return !MPC_STATUS_OK; 94 err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.pcm_samples * 2); 95 if(!err) return !MPC_STATUS_OK; 96 } 97 71 98 sum = total_samples = 0; 72 99 while(TRUE) 73 100 { 74 101 mpc_uint32_t samples; 75 begin = clock(); 102 103 begin = clock(); 76 104 samples = mpc_decoder_decode(decoder, sample_buffer, 0, 0); 77 end = clock(); 105 end = clock(); 106 78 107 if(samples <= 0) break; 79 if(!samples) break;108 if(!samples) break; 80 109 total_samples += samples; 81 110 sum += end - begin; 111 112 if(is_wav_output) 113 if(waveformat_output_process_float32(&wav_output, sample_buffer, samples*2) < 0) 114 break; 82 115 } 83 116 … … 92 125 mpc_decoder_exit(decoder); 93 126 mpc_reader_exit_stdio(&reader); 127 if(is_wav_output) 128 { 129 waveformat_output_close(&wav_output); 130 fclose(wav_output.m_callback.m_user_data); 131 } 94 132 95 133 #ifdef WIN32 -
libmpcdec/branches/zorg/win32/libmpcdec.sln
r70 r75 8 8 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcdec", "mpcdec.vcproj", "{A527175B-22A9-41AB-B2E8-580F573CCAFB}" 9 9 ProjectSection(ProjectDependencies) = postProject 10 {13D176A2-B6BB-403F-A816-AA1F388078B7} = {13D176A2-B6BB-403F-A816-AA1F388078B7} 10 11 {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} 11 12 EndProjectSection -
libmpcdec/branches/zorg/win32/mpcdec.vcproj
r70 r75 42 42 Optimization="0" 43 43 AdditionalIncludeDirectories="../include,../libwavformat" 44 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE "44 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE" 45 45 ExceptionHandling="0" 46 46 BasicRuntimeChecks="3" … … 63 63 <Tool 64 64 Name="VCLinkerTool" 65 AdditionalDependencies="libmpcdec_d.lib "65 AdditionalDependencies="libmpcdec_d.lib libwavformat_d.lib" 66 66 OutputFile="$(OutDir)\$(ProjectName)_d.exe" 67 67 AdditionalLibraryDirectories="../bin" … … 125 125 Name="VCCLCompilerTool" 126 126 AdditionalIncludeDirectories="../include,../libwavformat" 127 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE "127 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE" 128 128 ExceptionHandling="0" 129 129 BufferSecurityCheck="false" … … 145 145 <Tool 146 146 Name="VCLinkerTool" 147 AdditionalDependencies="libmpcdec.lib "147 AdditionalDependencies="libmpcdec.lib libwavformat.lib" 148 148 AdditionalLibraryDirectories="../bin" 149 149 GenerateManifest="false"
Note: See TracChangeset
for help on using the changeset viewer.