Index: /libmpcdec/branches/zorg/mpcdec/mpcdec.c
===================================================================
--- /libmpcdec/branches/zorg/mpcdec/mpcdec.c	(revision 74)
+++ /libmpcdec/branches/zorg/mpcdec/mpcdec.c	(revision 75)
@@ -36,4 +36,5 @@
 #include <time.h>
 #include <mpcdec/mpcdec.h>
+#include <libwaveformat.h>
 
 #ifdef WIN32
@@ -41,8 +42,20 @@
 #endif
 
+t_wav_uint32 mpc_wav_output_write(void* p_user_data, void const* p_buffer, t_wav_uint32 p_bytes)
+{
+    FILE* p_handle = (FILE*) p_user_data;
+    return (t_wav_uint32) fwrite(p_buffer, 1, p_bytes, p_handle);
+}
+
+t_wav_uint32 mpc_wav_output_seek(void* p_user_data, t_wav_uint32 p_position)
+{
+    FILE* p_handle = (FILE*) p_user_data;
+    return (t_wav_uint32) !fseek(p_handle, p_position, SEEK_SET);
+}
+
 static void
 usage(const char *exename)
 {
-    printf("Usage: %s <infile.mpc>\n", exename);
+    printf("Usage: %s <infile.mpc> [<outfile.wav>]\n", exename);
 }
 
@@ -52,7 +65,8 @@
     mpc_reader reader; mpc_streaminfo si; mpc_decoder* decoder; mpc_status err;
     MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
-    clock_t begin, end, sum; int total_samples;
+    clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output;
+    mpc_bool_t is_wav_output;
 
-    if(argc != 2)
+    if(3 < argc && argc < 2)
     {
         usage(argv[0]);
@@ -69,15 +83,34 @@
     if(err < 0) return !MPC_STATUS_OK;
 
+    is_wav_output = argc > 2;
+    if(is_wav_output)
+    {
+        t_wav_output_file_callback wavo_fc;
+        memset(&wav_output, 0, sizeof wav_output);
+        wavo_fc.m_seek      = mpc_wav_output_seek;
+        wavo_fc.m_write     = mpc_wav_output_write;
+        wavo_fc.m_user_data = fopen(argv[2], "wb");
+        if(!wavo_fc.m_user_data) return !MPC_STATUS_OK;
+        err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.pcm_samples * 2);
+        if(!err) return !MPC_STATUS_OK;
+    }
+
     sum = total_samples = 0;
     while(TRUE)
     {
         mpc_uint32_t samples;
-        begin = clock();
+
+        begin   = clock();
         samples = mpc_decoder_decode(decoder, sample_buffer, 0, 0);
-        end = clock();
+        end     = clock();
+
         if(samples <= 0) break;
-        if(!samples) break;
+        if(!samples)     break;
         total_samples += samples;
         sum           += end - begin;
+
+        if(is_wav_output)
+            if(waveformat_output_process_float32(&wav_output, sample_buffer, samples*2) < 0)
+                break;
     }
 
@@ -92,4 +125,9 @@
     mpc_decoder_exit(decoder);
     mpc_reader_exit_stdio(&reader);
+    if(is_wav_output)
+    {
+        waveformat_output_close(&wav_output);
+        fclose(wav_output.m_callback.m_user_data);
+    }
 
 #ifdef WIN32
Index: /libmpcdec/branches/zorg/win32/libmpcdec.sln
===================================================================
--- /libmpcdec/branches/zorg/win32/libmpcdec.sln	(revision 74)
+++ /libmpcdec/branches/zorg/win32/libmpcdec.sln	(revision 75)
@@ -8,4 +8,5 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcdec", "mpcdec.vcproj", "{A527175B-22A9-41AB-B2E8-580F573CCAFB}"
 	ProjectSection(ProjectDependencies) = postProject
+		{13D176A2-B6BB-403F-A816-AA1F388078B7} = {13D176A2-B6BB-403F-A816-AA1F388078B7}
 		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
 	EndProjectSection
Index: /libmpcdec/branches/zorg/win32/mpcdec.vcproj
===================================================================
--- /libmpcdec/branches/zorg/win32/mpcdec.vcproj	(revision 74)
+++ /libmpcdec/branches/zorg/win32/mpcdec.vcproj	(revision 75)
@@ -42,5 +42,5 @@
 				Optimization="0"
 				AdditionalIncludeDirectories="../include,../libwavformat"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
 				ExceptionHandling="0"
 				BasicRuntimeChecks="3"
@@ -63,5 +63,5 @@
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libmpcdec_d.lib"
+				AdditionalDependencies="libmpcdec_d.lib libwavformat_d.lib"
 				OutputFile="$(OutDir)\$(ProjectName)_d.exe"
 				AdditionalLibraryDirectories="../bin"
@@ -125,5 +125,5 @@
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="../include,../libwavformat"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
 				ExceptionHandling="0"
 				BufferSecurityCheck="false"
@@ -145,5 +145,5 @@
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libmpcdec.lib"
+				AdditionalDependencies="libmpcdec.lib libwavformat.lib"
 				AdditionalLibraryDirectories="../bin"
 				GenerateManifest="false"
