Added patch collection.

This commit is contained in:
LoRd_MuldeR 2012-02-28 16:11:28 +01:00
parent 55c76059d8
commit c3cfe577b0
8 changed files with 8777 additions and 0 deletions

14
etc/Patches/!_Readme.txt Normal file
View File

@ -0,0 +1,14 @@
LameXP third-party patches
--------------------------
This directory contains the modifications (as Unified Diff's) that have been applied to third-party audio tools as part of the development of LameXP.
Most of these modifications were required to fix Unicode support on the Windows platform and/or to properly flush the STDOUT for "real-time" progress updates.
Other modifications were required to make the third-party audio tools compile+link properly in the build environment used in the development of LameXP.
All the patches provided here are Copyright (c) LoRd_MuldeR <mulder2@gmx.de> 2004-2012; they are released under the same license as the original audio tools.
Please note that the patches provided here have NOT been approved by the original developers of the third-party audio tools - use them at your own risk!
They are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of FITNESS FOR A PARTICULAR PURPOSE.

View File

@ -0,0 +1,997 @@
tools/unicode_support.cpp | 86 ++++++++++++++++++
tools/unicode_support.h | 21 +++++
tools/valdec.cpp | 180 ++++++++++++++++++++++++--------------
tools/valdec.sln | 50 +++++++----
tools/valdec.vcproj | 61 +++++++------
valib/lib/valib.vcproj | 19 ++++-
valib/valib/auto_file.cpp | 3 +-
valib/valib/sink/sink_dsound.cpp | 4 +-
valib/valib/sink/sink_stdout.h | 93 ++++++++++++++++++++
9 files changed, 402 insertions(+), 115 deletions(-)
diff --git a/tools/unicode_support.cpp b/tools/unicode_support.cpp
new file mode 100644
index 0000000..13f89ba
--- /dev/null
+++ b/tools/unicode_support.cpp
@@ -0,0 +1,86 @@
+#include "unicode_support.h"
+
+#include <windows.h>
+
+char *utf16_to_utf8(const wchar_t *input)
+{
+ char *Buffer;
+ int BuffSize, Result;
+
+ BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
+ Buffer = new char[BuffSize]; //(char*) malloc(sizeof(char) * BuffSize);
+ Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
+
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+wchar_t *utf8_to_utf16(const char *input)
+{
+ wchar_t *Buffer;
+ int BuffSize, Result;
+
+ BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
+ Buffer = new wchar_t[BuffSize]; //(wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
+ Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
+
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+void init_commandline_arguments_utf8(int *argc, char ***argv)
+{
+ int i, nArgs;
+ LPWSTR *szArglist;
+
+ szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
+
+ if(NULL == szArglist)
+ {
+ fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
+ exit(-1);
+ }
+
+ *argv = new char*[nArgs]; //malloc(sizeof(char*) * nArgs);
+ *argc = nArgs;
+
+ for(i = 0; i < nArgs; i++)
+ {
+ (*argv)[i] = utf16_to_utf8(szArglist[i]);
+ }
+
+ LocalFree(szArglist);
+}
+
+void free_commandline_arguments_utf8(int *argc, char ***argv)
+{
+ if(*argv != NULL)
+ {
+ for(int i = 0; i < *argc; i++)
+ {
+ if((*argv)[i] != NULL)
+ {
+ delete [] ((*argv)[i]);
+ (*argv)[i] = NULL;
+ }
+ }
+ delete [] (*argv);
+ *argv = NULL;
+ }
+}
+
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
+{
+ FILE *ret = NULL;
+
+ wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
+ wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
+
+ if(filename_utf16 && mode_utf16)
+ {
+ ret = _wfopen(filename_utf16, mode_utf16);
+ }
+
+ if(filename_utf16) delete [] filename_utf16;
+ if(mode_utf16) delete [] mode_utf16;
+
+ return ret;
+}
diff --git a/tools/unicode_support.h b/tools/unicode_support.h
new file mode 100644
index 0000000..9ad3173
--- /dev/null
+++ b/tools/unicode_support.h
@@ -0,0 +1,21 @@
+#ifndef UNICODE_SUPPORT_H_INCLUDED
+#define UNICODE_SUPPORT_H_INCLUDED
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *utf16_to_utf8(const wchar_t *input);
+wchar_t *utf8_to_utf16(const char *input);
+void init_commandline_arguments_utf8(int *argc, char ***argv);
+void free_commandline_arguments_utf8(int *argc, char ***argv);
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/tools/valdec.cpp b/tools/valdec.cpp
index 6b24ecf..b5fe15d 100644
--- a/tools/valdec.cpp
+++ b/tools/valdec.cpp
@@ -15,6 +15,7 @@
#include "sink\sink_raw.h"
#include "sink\sink_wav.h"
#include "sink\sink_dsound.h"
+#include "sink\sink_stdout.h"
// filters
#include "filters\dvd_graph.h"
@@ -22,6 +23,7 @@
// other
#include "win32\cpu.h"
#include "vargs.h"
+#include "unicode_support.h"
#define bool2str(v) ((v)? "true": "false")
@@ -65,7 +67,7 @@ const sample_t level_tbl[] =
1.0
};
-int main(int argc, char *argv[])
+int valdec_main(int argc, char *argv[])
{
if (argc < 2)
{
@@ -77,6 +79,7 @@ int main(int argc, char *argv[])
"\n"
"This utility is a part of AC3Filter project (http://ac3filter.net)\n"
"Copyright (c) 2006-2009 by Alexander Vigovsky\n"
+"Support for Unicode file names and STDOUT output added by LoRd_MuldeR\n"
"\n"
"Usage:\n"
" valdec some_file [options]\n"
@@ -91,6 +94,7 @@ int main(int argc, char *argv[])
" -r[aw] file.raw - decode to RAW file\n"
" -w[av] file.wav - decode to WAV file\n"
" -n[othing] - do nothing (to be used with -i option)\n"
+" -s[td] - decode to RAW and write to STDOUT\n"
" \n"
" output options:\n"
//" -spdif - spdif output (no other options will work in this mode)\n"
@@ -184,12 +188,13 @@ int main(int argc, char *argv[])
/////////////////////////////////////////////////////////
// Sinks
- enum { mode_undefined, mode_nothing, mode_play, mode_raw, mode_wav, mode_decode } mode = mode_undefined;
+ enum { mode_undefined, mode_nothing, mode_play, mode_raw, mode_wav, mode_decode, mode_stdout } mode = mode_undefined;
const char *out_filename = 0;
RAWSink raw;
WAVSink wav;
DSoundSink dsound;
+ StdOutSink stdsnk;
NullSink null;
Sink *sink = 0;
@@ -216,7 +221,7 @@ int main(int argc, char *argv[])
{
if (parser)
{
- printf("-ac3 : ambigous parser\n");
+ fprintf(stderr, "-ac3 : ambigous parser\n");
return 1;
}
@@ -229,7 +234,7 @@ int main(int argc, char *argv[])
{
if (parser)
{
- printf("-dts : ambigous parser\n");
+ fprintf(stderr, "-dts : ambigous parser\n");
return 1;
}
@@ -242,7 +247,7 @@ int main(int argc, char *argv[])
{
if (parser)
{
- printf("-mpa : ambigous parser\n");
+ fprintf(stderr, "-mpa : ambigous parser\n");
return 1;
}
@@ -268,7 +273,7 @@ int main(int argc, char *argv[])
if (imask < 0 || imask > array_size(mask_tbl))
{
- printf("-spk : incorrect speaker configuration\n");
+ fprintf(stderr, "-spk : incorrect speaker configuration\n");
return 1;
}
continue;
@@ -280,7 +285,7 @@ int main(int argc, char *argv[])
iformat = int(arg_num(argv[iarg]));
if (iformat < 0 || iformat > array_size(format_tbl))
{
- printf("-fmt : incorrect sample format");
+ fprintf(stderr, "-fmt : incorrect sample format");
return 1;
}
continue;
@@ -296,7 +301,7 @@ int main(int argc, char *argv[])
{
if (sink)
{
- printf("-decode : ambigous output mode\n");
+ fprintf(stderr, "-decode : ambigous output mode\n");
return 1;
}
@@ -312,7 +317,7 @@ int main(int argc, char *argv[])
{
if (sink)
{
- printf("-play : ambigous output mode\n");
+ fprintf(stderr, "-play : ambigous output mode\n");
return 1;
}
@@ -328,12 +333,12 @@ int main(int argc, char *argv[])
{
if (sink)
{
- printf("-raw : ambigous output mode\n");
+ fprintf(stderr, "-raw : ambigous output mode\n");
return 1;
}
if (argc - iarg < 1)
{
- printf("-raw : specify a file name\n");
+ fprintf(stderr, "-raw : specify a file name\n");
return 1;
}
@@ -343,19 +348,40 @@ int main(int argc, char *argv[])
mode = mode_raw;
continue;
}
+
+ // -s[td] - RAW output to STDOUT
+ if (is_arg(argv[iarg], "s", argt_exist) ||
+ is_arg(argv[iarg], "std", argt_exist))
+ {
+ if (sink)
+ {
+ fprintf(stderr, "-std : ambigous output mode\n");
+ return 1;
+ }
+ if (argc - iarg < 1)
+ {
+ fprintf(stderr, "-std : specify a file name\n");
+ return 1;
+ }
+ //out_filename = argv[++iarg];
+ sink = &stdsnk;
+ control = 0;
+ mode = mode_stdout;
+ continue;
+ }
// -w[av] - WAV output
if (is_arg(argv[iarg], "w", argt_exist) ||
is_arg(argv[iarg], "wav", argt_exist))
{
if (sink)
{
- printf("-wav : ambigous output mode\n");
+ fprintf(stderr, "-wav : ambigous output mode\n");
return 1;
}
if (argc - iarg < 1)
{
- printf("-wav : specify a file name\n");
+ fprintf(stderr, "-wav : specify a file name\n");
return 1;
}
@@ -372,7 +398,7 @@ int main(int argc, char *argv[])
{
if (sink)
{
- printf("-nothing : ambigous output mode\n");
+ fprintf(stderr, "-nothing : ambigous output mode\n");
return 1;
}
@@ -614,7 +640,7 @@ int main(int argc, char *argv[])
continue;
}
- printf("Error: unknown option: %s\n", argv[iarg]);
+ fprintf(stderr, "Error: unknown option: %s\n", argv[iarg]);
return 1;
}
@@ -627,13 +653,13 @@ int main(int argc, char *argv[])
if (!file.open(input_filename, parser, 1000000))
{
- printf("Error: Cannot open file '%s'\n", input_filename);
+ fprintf(stderr, "Error: Cannot open file '%s'\n", input_filename);
return 1;
}
if (!file.stats())
{
- printf("Error: Cannot detect input file format\n", input_filename);
+ fprintf(stderr, "Error: Cannot detect input file format\n", input_filename);
return 1;
}
@@ -643,7 +669,7 @@ int main(int argc, char *argv[])
if (!file.is_frame_loaded())
{
- printf("Error: Cannot load the first frame\n");
+ fprintf(stderr, "Error: Cannot load the first frame\n");
return 1;
}
@@ -655,9 +681,9 @@ int main(int argc, char *argv[])
{
char info[1024];
file.file_info(info, sizeof(info));
- printf("%s\n", info);
+ fprintf(stderr, "%s\n", info);
file.stream_info(info, sizeof(info));
- printf("%s", info);
+ fprintf(stderr, "%s", info);
}
if (mode == mode_nothing)
@@ -678,7 +704,7 @@ int main(int argc, char *argv[])
Speakers user_spk(format_tbl[iformat], mask_tbl[imask], 0, level_tbl[iformat]);
if (!dvd_graph.set_user(user_spk))
{
- printf("Error: unsupported user format (%s %s %i)\n",
+ fprintf(stderr, "Error: unsupported user format (%s %s %i)\n",
user_spk.format_text(), user_spk.mode_text(), user_spk.sample_rate);
return 1;
}
@@ -686,7 +712,7 @@ int main(int argc, char *argv[])
Speakers in_spk = file.get_spk();
if (!dvd_graph.set_input(in_spk))
{
- printf("Error: unsupported input format (%s %s %i)\n",
+ fprintf(stderr, "Error: unsupported input format (%s %s %i)\n",
in_spk.format_text(), in_spk.mode_text(), in_spk.sample_rate);
return 1;
}
@@ -718,10 +744,18 @@ int main(int argc, char *argv[])
switch (mode)
{
+ case mode_stdout:
+ if (!stdsnk.is_open())
+ {
+ fprintf(stderr, "Error: failed to open standard output handle.\n");
+ return 1;
+ }
+ break;
+
case mode_raw:
if (!out_filename || !raw.open(out_filename))
{
- printf("Error: failed to open output file '%s'\n", out_filename);
+ fprintf(stderr, "Error: failed to open output file '%s'\n", out_filename);
return 1;
}
break;
@@ -729,7 +763,7 @@ int main(int argc, char *argv[])
case mode_wav:
if (!out_filename || !wav.open(out_filename))
{
- printf("Error: failed to open output file '%s'\n", out_filename);
+ fprintf(stderr, "Error: failed to open output file '%s'\n", out_filename);
return 1;
}
break;
@@ -737,7 +771,7 @@ int main(int argc, char *argv[])
case mode_play:
if (!dsound.open_dsound(0))
{
- printf("Error: failed to init DirectSound\n");
+ fprintf(stderr, "Error: failed to init DirectSound\n");
return 1;
}
break;
@@ -765,27 +799,28 @@ int main(int argc, char *argv[])
int streams = 0;
-// fprintf(stderr, " 0.0%% Frs: 0 Err: 0 Time: 0:00.000i Level: 0dB FPS: 0 CPU: 0%%\r");
+// ffprintf(stderr, stderr, " 0.0%% Frs: 0 Err: 0 Time: 0:00.000i Level: 0dB FPS: 0 CPU: 0%%\r");
file.seek(0);
- #define PRINT_STAT \
- { \
- if (control) \
- { \
- dvd_graph.proc.get_output_levels(control->get_playback_time(), levels); \
- level = levels[0]; \
- for (i = 1; i < NCHANNELS; i++) \
- if (levels[i] > level) \
- level = levels[i]; \
- } \
- fprintf(stderr, "%4.1f%% Frs: %-6i Err: %-i Time: %3i:%02i.%03i Level: %-4idB FPS: %-4i CPU: %.1f%% \r", \
- file.get_pos(file.relative) * 100, \
- file.get_frames(), dvd_graph.dec.get_errors(), \
- int(time/60), int(time) % 60, int(time * 1000) % 1000, \
- int(value2db(level)), \
- int(file.get_frames() / time), \
- cpu_current.usage() * 100); \
+ #define PRINT_STAT \
+ { \
+ if (control) \
+ { \
+ dvd_graph.proc.get_output_levels(control->get_playback_time(), levels); \
+ level = levels[0]; \
+ for (i = 1; i < NCHANNELS; i++) \
+ if (levels[i] > level) \
+ level = levels[i]; \
+ } \
+ fprintf(stderr, "[%4.1f%%] Frs: %-6i Err: %-i Time: %3i:%02i.%03i Level: %-4idB FPS: %-4i CPU: %.1f%% \r", \
+ file.get_pos(file.relative) * 100, \
+ file.get_frames(), dvd_graph.dec.get_errors(), \
+ int(time/60), int(time) % 60, int(time * 1000) % 1000, \
+ int(value2db(level)), \
+ int(file.get_frames() / time), \
+ cpu_current.usage() * 100); \
+ fflush(stderr); \
}
#define DROP_STAT \
@@ -811,7 +846,7 @@ int main(int argc, char *argv[])
{
char info[1024];
file.stream_info(info, sizeof(info));
- printf("\n\n%s", info);
+ fprintf(stderr, "\n\n%s", info);
}
streams++;
@@ -825,7 +860,7 @@ int main(int argc, char *argv[])
chunk.set_rawdata(file.get_spk(), file.get_frame(), file.get_frame_size());
if (!dvd_graph.process(&chunk))
{
- printf("\nError in dvd_graph.process()\n");
+ fprintf(stderr, "\nError in dvd_graph.process()\n");
return 1;
}
@@ -833,7 +868,7 @@ int main(int argc, char *argv[])
{
if (!dvd_graph.get_chunk(&chunk))
{
- printf("\nError in dvd_graph.get_chunk()\n");
+ fprintf(stderr, "\nError in dvd_graph.get_chunk()\n");
return 1;
}
@@ -847,12 +882,12 @@ int main(int argc, char *argv[])
if (sink->query_input(chunk.spk))
{
DROP_STAT;
- printf("Opening audio output %s %s %i...\n",
+ fprintf(stderr, "Opening audio output %s %s %i...\n",
chunk.spk.format_text(), chunk.spk.mode_text(), chunk.spk.sample_rate);
}
else
{
- printf("\nOutput format %s %s %i is unsupported\n",
+ fprintf(stderr, "\nOutput format %s %s %i is unsupported\n",
chunk.spk.format_text(), chunk.spk.mode_text(), chunk.spk.sample_rate);
return 1;
}
@@ -860,7 +895,7 @@ int main(int argc, char *argv[])
if (!sink->process(&chunk))
{
- printf("\nError in sink->process()\n");
+ fprintf(stderr, "\nError in sink->process()\n");
return 1;
}
}
@@ -893,7 +928,7 @@ int main(int argc, char *argv[])
if (!dvd_graph.process_to(&chunk, sink))
{
- printf("\nProcessing error!\n");
+ fprintf(stderr, "\nProcessing error!\n");
return 1;
}
@@ -907,13 +942,13 @@ int main(int argc, char *argv[])
// Final statistics
PRINT_STAT;
- printf("\n---------------------------------------\n");
+ fprintf(stderr, "\n---------------------------------------\n");
if (streams > 1)
- printf("Streams found: %i\n", streams);
- printf("Frames/errors: %i/%i\n", file.get_frames(), dvd_graph.dec.get_errors());
- printf("System time: %ims\n", int(cpu_total.get_system_time() * 1000));
- printf("Process time: %ims\n", int(cpu_total.get_thread_time() * 1000 ));
- printf("Approx. %.2f%% realtime CPU usage\n", double(cpu_total.get_thread_time() * 100) / file.get_size(file.time));
+ fprintf(stderr, "Streams found: %i\n", streams);
+ fprintf(stderr, "Frames/errors: %i/%i\n", file.get_frames(), dvd_graph.dec.get_errors());
+ fprintf(stderr, "System time: %ims\n", int(cpu_total.get_system_time() * 1000));
+ fprintf(stderr, "Process time: %ims\n", int(cpu_total.get_thread_time() * 1000 ));
+ fprintf(stderr, "Approx. %.2f%% realtime CPU usage\n", double(cpu_total.get_thread_time() * 100) / file.get_size(file.time));
/////////////////////////////////////////////////////////
// Print levels histogram
@@ -930,22 +965,35 @@ int main(int argc, char *argv[])
max_level = dvd_graph.proc.get_max_level();
dbpb = dvd_graph.proc.get_dbpb();
- printf("\nHistogram:\n");
- printf("------------------------------------------------------------------------------\n");
+ fprintf(stderr, "\nHistogram:\n");
+ fprintf(stderr, "------------------------------------------------------------------------------\n");
for (i = 0; i*dbpb < 100 && i < MAX_HISTOGRAM; i++)
{
- printf("%2idB: %4.1f ", i * dbpb, hist[i] * 100);
+ fprintf(stderr, "%2idB: %4.1f ", i * dbpb, hist[i] * 100);
for (j = 0; j < 67 && j < hist[i] * 67; j++)
- printf("*");
- printf("\n");
+ fprintf(stderr, "*");
+ fprintf(stderr, "\n");
}
- printf("------------------------------------------------------------------------------\n");
- printf("max_level;%f\ndbpb;%i\nhistogram;", max_level, dbpb);
+ fprintf(stderr, "------------------------------------------------------------------------------\n");
+ fprintf(stderr, "max_level;%f\ndbpb;%i\nhistogram;", max_level, dbpb);
for (i = 0; i < MAX_HISTOGRAM; i++)
- printf("%.4f;", hist[i]);
- printf("\n");
- printf("------------------------------------------------------------------------------\n");
+ fprintf(stderr, "%.4f;", hist[i]);
+ fprintf(stderr, "\n");
+ fprintf(stderr, "------------------------------------------------------------------------------\n");
}
return 0;
}
+
+int main(int argc, char *argv[])
+{
+ int argc_utf8;
+ char **argv_utf8;
+ int exit_code;
+
+ init_commandline_arguments_utf8(&argc_utf8, &argv_utf8);
+ exit_code = valdec_main(argc_utf8, argv_utf8);
+ free_commandline_arguments_utf8(&argc_utf8, &argv_utf8);
+
+ return exit_code;
+}
diff --git a/tools/valdec.sln b/tools/valdec.sln
index 9120b95..8b0cf39 100644
--- a/tools/valdec.sln
+++ b/tools/valdec.sln
@@ -1,12 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "valdec", "valdec.vcproj", "{871889DF-6EF7-461F-AC1B-7DA682CB79A0}"
+Project("{EAF909A5-FA59-4C3D-9431-0FCC20D5BCF9}") = "valdec", "valdec.icproj", "{EB870031-881E-455A-A1E2-5FD222F92D61}"
ProjectSection(ProjectDependencies) = postProject
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C} = {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1} = {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "valib", "..\valib\lib\valib.vcproj", "{30FCD216-1CAD-48FD-BF4B-337572F7EC9C}"
+Project("{EAF909A5-FA59-4C3D-9431-0FCC20D5BCF9}") = "valib", "..\valib\lib\valib.icproj", "{C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -16,22 +16,38 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|Win32.ActiveCfg = Debug|Win32
- {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|Win32.Build.0 = Debug|Win32
- {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|x64.ActiveCfg = Debug|x64
- {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|x64.Build.0 = Debug|x64
- {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Release|Win32.ActiveCfg = Release|Win32
- {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Release|Win32.Build.0 = Release|Win32
- {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Release|x64.ActiveCfg = Release|x64
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Debug|Win32.Build.0 = Debug|Win32
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Debug|x64.ActiveCfg = Debug|x64
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Debug|x64.Build.0 = Debug|x64
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Release|Win32.ActiveCfg = Release|Win32
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Release|Win32.Build.0 = Release|Win32
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Release|x64.ActiveCfg = Release|x64
+ {EB870031-881E-455A-A1E2-5FD222F92D61}.Release|x64.Build.0 = Release|x64
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Debug|Win32.Build.0 = Debug|Win32
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Debug|x64.ActiveCfg = Debug|x64
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Debug|x64.Build.0 = Debug|x64
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Release|Win32.ActiveCfg = Release|Win32
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Release|Win32.Build.0 = Release|Win32
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Release|x64.ActiveCfg = Release|x64
+ {C9AE46F3-AA5D-421B-99DF-3BBA26AEF6B1}.Release|x64.Build.0 = Release|x64
{871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Release|x64.Build.0 = Release|x64
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|Win32.ActiveCfg = Debug|Win32
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|Win32.Build.0 = Debug|Win32
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|x64.ActiveCfg = Debug|x64
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|x64.Build.0 = Debug|x64
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Release|Win32.ActiveCfg = Release|Win32
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Release|Win32.Build.0 = Release|Win32
- {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Release|x64.ActiveCfg = Release|x64
+ {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Release|x64.ActiveCfg = Release|x64
+ {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Release|Win32.Build.0 = Release|Win32
+ {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Release|Win32.ActiveCfg = Release|Win32
+ {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|x64.Build.0 = Debug|x64
+ {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|x64.ActiveCfg = Debug|x64
+ {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|Win32.Build.0 = Debug|Win32
+ {871889DF-6EF7-461F-AC1B-7DA682CB79A0}.Debug|Win32.ActiveCfg = Debug|Win32
{30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Release|x64.Build.0 = Release|x64
+ {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Release|x64.ActiveCfg = Release|x64
+ {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Release|Win32.Build.0 = Release|Win32
+ {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Release|Win32.ActiveCfg = Release|Win32
+ {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|x64.Build.0 = Debug|x64
+ {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|x64.ActiveCfg = Debug|x64
+ {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|Win32.Build.0 = Debug|Win32
+ {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}.Debug|Win32.ActiveCfg = Debug|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/tools/valdec.vcproj b/tools/valdec.vcproj
index d6a6b98..4d3056b 100644
--- a/tools/valdec.vcproj
+++ b/tools/valdec.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="valdec"
ProjectGUID="{871889DF-6EF7-461F-AC1B-7DA682CB79A0}"
RootNamespace="valdec"
@@ -93,12 +93,11 @@
/>
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="1"
- WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -114,15 +113,16 @@
/>
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
+ Optimization="0"
AdditionalIncludeDirectories="..\valib\valib"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
@@ -139,12 +139,10 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dsound.lib"
- LinkIncremental="1"
+ LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -169,11 +167,12 @@
/>
</Configuration>
<Configuration
- Name="Debug|x64"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\$(ProjectName)"
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -189,19 +188,21 @@
/>
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ Optimization="2"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\valib\valib"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
UsePrecompiledHeader="0"
WarningLevel="3"
- DebugInformationFormat="3"
+ DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -214,11 +215,13 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="dsound.lib"
- LinkIncremental="2"
+ AdditionalDependencies="LIBIOMP5MT.lib"
+ LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
- TargetMachine="17"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -324,6 +327,10 @@
</References>
<Files>
<File
+ RelativePath=".\unicode_support.cpp"
+ >
+ </File>
+ <File
RelativePath=".\valdec.cpp"
>
</File>
diff --git a/valib/lib/valib.vcproj b/valib/lib/valib.vcproj
index a30826e..3b04d9f 100644
--- a/valib/lib/valib.vcproj
+++ b/valib/lib/valib.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="valib"
ProjectGUID="{30FCD216-1CAD-48FD-BF4B-337572F7EC9C}"
RootNamespace="valib"
@@ -164,12 +164,15 @@
<Tool
Name="VCCLCompilerTool"
Optimization="2"
+ InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
PreprocessorDefinitions="NDEBUG"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
WarningLevel="3"
- DebugInformationFormat="3"
+ DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -939,6 +942,14 @@
<File
RelativePath="..\valib\sink\sink_dshow.cpp"
>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\valib\sink\sink_dshow.h"
@@ -957,6 +968,10 @@
>
</File>
<File
+ RelativePath="..\valib\sink\sink_stdout.h"
+ >
+ </File>
+ <File
RelativePath="..\valib\sink\sink_wav.cpp"
>
</File>
diff --git a/valib/valib/auto_file.cpp b/valib/valib/auto_file.cpp
index 235ad1d..8d99c91 100644
--- a/valib/valib/auto_file.cpp
+++ b/valib/valib/auto_file.cpp
@@ -1,5 +1,6 @@
#include <limits.h>
#include "auto_file.h"
+#include "..\..\tools\unicode_support.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
@@ -40,7 +41,7 @@ AutoFile::open(const char *filename, const char *mode)
{
if (f) close();
filesize = max_size;
- f = fopen(filename, mode);
+ f = fopen_utf8(filename, mode);
if (f)
{
if (portable_seek(f, 0, SEEK_END) == 0)
diff --git a/valib/valib/sink/sink_dsound.cpp b/valib/valib/sink/sink_dsound.cpp
index 542d31f..c5aa132 100644
--- a/valib/valib/sink/sink_dsound.cpp
+++ b/valib/valib/sink/sink_dsound.cpp
@@ -47,8 +47,8 @@ DSoundSink::open_dsound(HWND _hwnd, int _buf_size_ms, int _preload_ms, LPCGUID _
// Open DirectSound
- if FAILED(DirectSoundCreate(_device, &ds, 0))
- return false;
+ //if FAILED(DirectSoundCreate(_device, &ds, 0))
+ return false;
if (!_hwnd) _hwnd = GetForegroundWindow();
if (!_hwnd) _hwnd = GetDesktopWindow();
diff --git a/valib/valib/sink/sink_stdout.h b/valib/valib/sink/sink_stdout.h
new file mode 100644
index 0000000..3112531
--- /dev/null
+++ b/valib/valib/sink/sink_stdout.h
@@ -0,0 +1,93 @@
+/*
+ RAW file output audio renderer
+*/
+
+#ifndef VALIB_SINK_STDOUT_H
+#define VALIB_SINK_STDOUT_H
+
+#include "filter.h"
+#include "auto_file.h"
+
+class StdOutSink : public Sink
+{
+protected:
+ Speakers spk;
+ HANDLE h;
+ //AutoFile f;
+
+public:
+ StdOutSink():
+ h(GetStdHandle(STD_OUTPUT_HANDLE))
+ {}
+
+ StdOutSink(const char *_filename):
+ h(GetStdHandle(STD_OUTPUT_HANDLE))
+ {}
+
+ StdOutSink(FILE *_f):
+ h(GetStdHandle(STD_OUTPUT_HANDLE))
+ {}
+
+ /////////////////////////////////////////////////////////
+ // RAWSink interface
+
+ bool open(const char *_filename)
+ {
+ return true; //f.open(_filename, "wb");
+ }
+
+ bool open(FILE *_f)
+ {
+ return true; //f.open(_f);
+ }
+
+ void close()
+ {
+ //f.close();
+ spk = spk_unknown;
+ }
+
+ bool is_open() const
+ {
+ return ((h != INVALID_HANDLE_VALUE) && (h != 0)); //f.is_open();
+ }
+
+ /////////////////////////////////////////////////////////
+ // Sink interface
+
+ virtual bool query_input(Speakers _spk) const
+ {
+ // cannot write linear format
+ return /*f.is_open() &&*/ _spk.format != FORMAT_LINEAR;
+ }
+
+ virtual bool set_input(Speakers _spk)
+ {
+ if (!query_input(_spk))
+ return false;
+
+ spk = _spk;
+ return true;
+ }
+
+ virtual Speakers get_input() const
+ {
+ return spk;
+ }
+
+ // data write
+ virtual bool process(const Chunk *_chunk)
+ {
+ if (_chunk->is_dummy())
+ return true;
+
+ if (spk != _chunk->spk)
+ if (!set_input(_chunk->spk))
+ return false;
+
+ DWORD bytesWritten = 0;
+ return WriteFile(h, _chunk->rawdata, _chunk->size, &bytesWritten, NULL); //f.write(_chunk->rawdata, _chunk->size) == _chunk->size;
+ }
+};
+
+#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,591 @@
common/mp4ff/mp4ff.vcproj | 6 ++-
frontend/audio.c | 12 +++++-
frontend/faad.sln | 14 ++----
frontend/faad.vcproj | 22 ++++++----
frontend/main.c | 82 +++++++++++++++++++++++++++++-------
frontend/unicode_support.c | 98 ++++++++++++++++++++++++++++++++++++++++++++
frontend/unicode_support.h | 21 +++++++++
libfaad/common.h | 1 +
libfaad/libfaad.sln | 6 +-
libfaad/libfaad.vcproj | 11 ++++-
10 files changed, 230 insertions(+), 43 deletions(-)
diff --git a/common/mp4ff/mp4ff.vcproj b/common/mp4ff/mp4ff.vcproj
index 70fd4a0..7ed6158 100644
--- a/common/mp4ff/mp4ff.vcproj
+++ b/common/mp4ff/mp4ff.vcproj
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8,00"
+ Version="9,00"
Name="mp4ff"
ProjectGUID="{F470BB4A-7675-4D6A-B310-41F33AC6F987}"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -44,8 +45,9 @@
InlineFunctionExpansion="1"
PreprocessorDefinitions="USE_TAGGING"
StringPooling="true"
- RuntimeLibrary="2"
+ RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Release/mp4ff.pch"
AssemblerListingLocation=".\Release/"
diff --git a/frontend/audio.c b/frontend/audio.c
index 067ac20..ad92118 100644
--- a/frontend/audio.c
+++ b/frontend/audio.c
@@ -36,12 +36,16 @@
#include <fcntl.h>
#include <math.h>
#include <neaacdec.h>
+
#include "audio.h"
+#include "unicode_support.h"
audio_file *open_audio_file(char *infile, int samplerate, int channels,
int outputFormat, int fileType, long channelMask)
{
+ wchar_t *fileNameW;
+
audio_file *aufile = malloc(sizeof(audio_file));
aufile->outputFormat = outputFormat;
@@ -78,7 +82,13 @@ audio_file *open_audio_file(char *infile, int samplerate, int channels,
aufile->toStdio = 1;
} else {
aufile->toStdio = 0;
- aufile->sndfile = fopen(infile, "wb");
+ aufile->sndfile = NULL;
+ fileNameW = utf8_to_utf16(infile);
+ if(fileNameW)
+ {
+ aufile->sndfile = _wfopen(fileNameW, L"wb");
+ free(fileNameW);
+ }
}
if (aufile->sndfile == NULL)
diff --git a/frontend/faad.sln b/frontend/faad.sln
index a47200b..3ccdf0f 100644
--- a/frontend/faad.sln
+++ b/frontend/faad.sln
@@ -1,15 +1,11 @@

-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "faad", "faad.vcproj", "{2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}"
- ProjectSection(ProjectDependencies) = postProject
- {F470BB4A-7675-4D6A-B310-41F33AC6F987} = {F470BB4A-7675-4D6A-B310-41F33AC6F987}
- {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114} = {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}
- EndProjectSection
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "faad", "faad.vcxproj", "{2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaad", "..\libfaad\libfaad.vcproj", "{BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaad", "..\libfaad\libfaad.vcxproj", "{BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4ff", "..\common\mp4ff\mp4ff.vcproj", "{F470BB4A-7675-4D6A-B310-41F33AC6F987}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4ff", "..\common\mp4ff\mp4ff.vcxproj", "{F470BB4A-7675-4D6A-B310-41F33AC6F987}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/frontend/faad.vcproj b/frontend/faad.vcproj
index b187293..185f64c 100644
--- a/frontend/faad.vcproj
+++ b/frontend/faad.vcproj
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="9,00"
Name="faad"
ProjectGUID="{2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -78,6 +79,8 @@
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/faad.pdb"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -98,9 +101,6 @@
Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -133,15 +133,16 @@
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
- Optimization="1"
+ Optimization="3"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../include,../common/mp4ff,../common/faad"
PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
StringPooling="true"
- RuntimeLibrary="2"
+ RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Release/faad.pch"
AssemblerListingLocation=".\Release/"
@@ -170,6 +171,8 @@
LinkIncremental="1"
SuppressStartupBanner="true"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -190,9 +193,6 @@
Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -216,6 +216,10 @@
RelativePath=".\main.c"
>
</File>
+ <File
+ RelativePath=".\unicode_support.c"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
diff --git a/frontend/main.c b/frontend/main.c
index a3bb68d..8aa9bfa 100644
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -47,6 +47,7 @@
#include <mp4ff.h>
#include "audio.h"
+#include "unicode_support.h"
#ifndef min
#define min(a,b) ( (a) < (b) ? (a) : (b) )
@@ -69,6 +70,8 @@ static void faad_fprintf(FILE *stream, const char *fmt, ...)
vfprintf(stream, fmt, ap);
va_end(ap);
+
+ fflush(stream);
}
}
@@ -427,11 +430,19 @@ static int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_std
aac_buffer b;
+ wchar_t *fileNameW;
+
memset(&b, 0, sizeof(aac_buffer));
if (adts_out)
{
- adtsFile = fopen(adts_fn, "wb");
+ adtsFile = NULL;
+ fileNameW = utf8_to_utf16(adts_fn);
+ if(fileNameW)
+ {
+ adtsFile = _wfopen(fileNameW, L"wb");
+ free(fileNameW);
+ }
if (adtsFile == NULL)
{
faad_fprintf(stderr, "Error opening file: %s\n", adts_fn);
@@ -439,7 +450,13 @@ static int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_std
}
}
- b.infile = fopen(aacfile, "rb");
+ b.infile = NULL;
+ fileNameW = utf8_to_utf16(aacfile);
+ if(fileNameW)
+ {
+ b.infile = _wfopen(fileNameW, L"rb");
+ free(fileNameW);
+ }
if (b.infile == NULL)
{
/* unable to open file */
@@ -634,7 +651,7 @@ static int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_std
if (percent > old_percent)
{
old_percent = percent;
- sprintf(percents, "%d%% decoding %s.", percent, aacfile);
+ sprintf(percents, "[%d%%] decoding %s.", percent, aacfile);
faad_fprintf(stderr, "%s\r", percents);
#ifdef _WIN32
SetConsoleTitle(percents);
@@ -746,11 +763,19 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std
unsigned int framesize;
unsigned long timescale;
+ wchar_t *fileNameW;
/* initialise the callback structure */
mp4ff_callback_t *mp4cb = malloc(sizeof(mp4ff_callback_t));
- mp4File = fopen(mp4file, "rb");
+ mp4File = NULL;
+ fileNameW = utf8_to_utf16(mp4file);
+ if(fileNameW)
+ {
+ mp4File = _wfopen(fileNameW, L"rb");
+ free(fileNameW);
+ }
+
mp4cb->read = read_callback;
mp4cb->seek = seek_callback;
mp4cb->user_data = mp4File;
@@ -767,7 +792,13 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std
if (adts_out)
{
- adtsFile = fopen(adts_fn, "wb");
+ adtsFile = NULL;
+ fileNameW = utf8_to_utf16(adts_fn);
+ if(fileNameW)
+ {
+ adtsFile = _wfopen(fileNameW, L"wb");
+ free(fileNameW);
+ }
if (adtsFile == NULL)
{
faad_fprintf(stderr, "Error opening file: %s\n", adts_fn);
@@ -973,8 +1004,9 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std
if (percent > old_percent)
{
old_percent = percent;
- sprintf(percents, "%d%% decoding %s.", percent, mp4file);
+ sprintf(percents, "[%d%%] decoding %s.", percent, mp4file);
faad_fprintf(stderr, "%s\r", percents);
+
#ifdef _WIN32
SetConsoleTitle(percents);
#endif
@@ -1011,7 +1043,7 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std
return frameInfo.error;
}
-int main(int argc, char *argv[])
+int faad_main(int argc, char *argv[])
{
int result;
int infoOnly = 0;
@@ -1028,12 +1060,13 @@ int main(int argc, char *argv[])
int mp4file = 0;
int noGapless = 0;
char *fnp;
- char aacFileName[255];
- char audioFileName[255];
- char adtsFileName[255];
+ char *aacFileName = NULL; //[255];
+ char *audioFileName = NULL; //[255];
+ char *adtsFileName = NULL; //[255];
unsigned char header[8];
float length = 0;
FILE *hMP4File;
+ wchar_t *fileNameW;
/* System dependant types */
#ifdef _WIN32
@@ -1044,7 +1077,6 @@ int main(int argc, char *argv[])
unsigned long cap = NeAACDecGetCapabilities();
-
/* begin process command line */
progName = argv[0];
while (1) {
@@ -1078,14 +1110,14 @@ int main(int argc, char *argv[])
if (optarg)
{
outfile_set = 1;
- strcpy(audioFileName, optarg);
+ audioFileName = strdup(optarg);
}
break;
case 'a':
if (optarg)
{
adts_out = 1;
- strcpy(adtsFileName, optarg);
+ adtsFileName = strdup(optarg);
}
break;
case 's':
@@ -1205,7 +1237,7 @@ int main(int argc, char *argv[])
#endif
/* point to the specified file name */
- strcpy(aacFileName, argv[optind]);
+ aacFileName = strdup(argv[optind]);
#ifdef _WIN32
begin = GetTickCount();
@@ -1218,7 +1250,7 @@ int main(int argc, char *argv[])
*/
if(!writeToStdio && !outfile_set)
{
- strcpy(audioFileName, aacFileName);
+ audioFileName = strdup(aacFileName);
fnp = (char *)strrchr(audioFileName,'.');
@@ -1230,7 +1262,13 @@ int main(int argc, char *argv[])
/* check for mp4 file */
mp4file = 0;
- hMP4File = fopen(aacFileName, "rb");
+ hMP4File = NULL;
+ fileNameW = utf8_to_utf16(aacFileName);
+ if(fileNameW)
+ {
+ hMP4File = _wfopen(fileNameW, L"rb");
+ free(fileNameW);
+ }
if (!hMP4File)
{
faad_fprintf(stderr, "Error opening file: %s\n", aacFileName);
@@ -1268,3 +1306,15 @@ int main(int argc, char *argv[])
return 0;
}
+
+int wmain(int argc, wchar_t **argv_utf16)
+{
+ int result = 0;
+ char **argv_utf8 = NULL;
+
+ init_commandline_arguments_utf8(argc, &argv_utf8, argv_utf16);
+ result = faad_main(argc, argv_utf8);
+ free_commandline_arguments_utf8(argc, &argv_utf8);
+
+ return result;
+}
diff --git a/frontend/unicode_support.c b/frontend/unicode_support.c
new file mode 100644
index 0000000..21ecd5c
--- /dev/null
+++ b/frontend/unicode_support.c
@@ -0,0 +1,98 @@
+#include "unicode_support.h"
+
+#include <stdio.h>
+#include <windows.h>
+
+char *utf16_to_utf8(const wchar_t *input)
+{
+ char *Buffer;
+ int BuffSize, Result;
+
+ BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
+ Buffer = (char*) malloc(sizeof(char) * BuffSize);
+
+ if(!Buffer)
+ {
+ fprintf(stderr, "Error in utf16_to_utf8: Memory allocation failed!\n");
+ return NULL;
+ }
+
+ Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+wchar_t *utf8_to_utf16(const char *input)
+{
+ wchar_t *Buffer;
+ int BuffSize, Result;
+
+ BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
+ Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
+
+ if(!Buffer)
+ {
+ fprintf(stderr, "Error in utf8_to_utf16: Memory allocation failed!\n");
+ return NULL;
+ }
+
+ Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+void init_commandline_arguments_utf8(int argc, char ***argv_utf8, wchar_t **argv_utf16)
+{
+ int i = 0;
+
+ *argv_utf8 = (char**) malloc(argc * sizeof(char*));
+ if(!(*argv_utf8))
+ {
+ fprintf(stderr, "Error in init_commandline_arguments_utf8: Memory allocation failed!\n");
+ exit(-1);
+ }
+
+ for(i = 0; i < argc; i++)
+ {
+ (*argv_utf8)[i] = utf16_to_utf8(argv_utf16[i]);
+ if(!(*argv_utf8)[i])
+ {
+ fprintf(stderr, "Error in init_commandline_arguments_utf8: Memory allocation failed!\n");
+ exit(-1);
+ }
+ }
+}
+
+void free_commandline_arguments_utf8(int argc, char ***argv_utf8)
+{
+ int i = 0;
+
+ if(*argv_utf8 != NULL)
+ {
+ for(i = 0; i < argc; i++)
+ {
+ if((*argv_utf8)[i] != NULL)
+ {
+ free((*argv_utf8)[i]);
+ (*argv_utf8)[i] = NULL;
+ }
+ }
+ free(*argv_utf8);
+ *argv_utf8 = NULL;
+ }
+}
+
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
+{
+ FILE *ret = NULL;
+ wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
+ wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
+
+ if(filename_utf16 && mode_utf16)
+ {
+ ret = _wfopen(filename_utf16, mode_utf16);
+ }
+
+ if(filename_utf16) free(filename_utf16);
+ if(mode_utf16) free(mode_utf16);
+
+ return ret;
+}
diff --git a/frontend/unicode_support.h b/frontend/unicode_support.h
new file mode 100644
index 0000000..cc13fd9
--- /dev/null
+++ b/frontend/unicode_support.h
@@ -0,0 +1,21 @@
+#ifndef UNICODE_SUPPORT_H_INCLUDED
+#define UNICODE_SUPPORT_H_INCLUDED
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *utf16_to_utf8(const wchar_t *input);
+wchar_t *utf8_to_utf16(const char *input);
+void init_commandline_arguments_utf8(int argc, char ***argv_utf8, wchar_t **argv_utf16);
+void free_commandline_arguments_utf8(int argc, char ***argv_utf8);
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
\ No newline at end of file
diff --git a/libfaad/common.h b/libfaad/common.h
index d3b21c3..6796ded 100644
--- a/libfaad/common.h
+++ b/libfaad/common.h
@@ -346,6 +346,7 @@ char *strchr(), *strrchr();
#ifdef __ICL /* only Intel C compiler has fmath ??? */
+ #error Deine Mudda!
#include <mathf.h>
#define sin sinf
diff --git a/libfaad/libfaad.sln b/libfaad/libfaad.sln
index 88087f6..a22c0f4 100644
--- a/libfaad/libfaad.sln
+++ b/libfaad/libfaad.sln
@@ -1,6 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaad", "libfaad.vcproj", "{BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}"
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaad", "libfaad.vcxproj", "{BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/libfaad/libfaad.vcproj b/libfaad/libfaad.vcproj
index 6401c9b..2adcf81 100644
--- a/libfaad/libfaad.vcproj
+++ b/libfaad/libfaad.vcproj
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="9,00"
Name="libfaad"
ProjectGUID="{BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}"
+ RootNamespace="libfaad"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -41,13 +43,16 @@
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
- Optimization="2"
+ Optimization="3"
InlineFunctionExpansion="1"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../include"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB"
StringPooling="true"
- RuntimeLibrary="2"
+ RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Release/libfaad.pch"
AssemblerListingLocation=".\Release/"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
Source/Console/Console.cpp | 1 +
Source/MACLib/Assembly/Assembly.obj | Bin 836 -> 836 bytes
2 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/Source/Console/Console.cpp b/Source/Console/Console.cpp
index 7d7c8c4..3a3179b 100644
--- a/Source/Console/Console.cpp
+++ b/Source/Console/Console.cpp
@@ -63,6 +63,7 @@ void CALLBACK ProgressCallback(int nPercentageDone)
// output the progress
_ftprintf(stderr, _T("Progress: %.1f%% (%.1f seconds remaining, %.1f seconds total) \r"),
dProgress * 100, dRemaining, dElapsed);
+ fflush(stderr);
}
/***************************************************************************************
diff --git a/Source/MACLib/Assembly/Assembly.obj b/Source/MACLib/Assembly/Assembly.obj
index b38feba..2289e97 100644
Binary files a/Source/MACLib/Assembly/Assembly.obj and b/Source/MACLib/Assembly/Assembly.obj differ

View File

@ -0,0 +1,452 @@
common/unicode_support.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++
common/unicode_support.h | 21 +++++++++++
libmpcdec/mpc_reader.c | 3 +-
mpcdec/mpcdec.c | 49 ++++++++++++++++++++++++--
win32/libcommon.vcproj | 11 +++++-
win32/libmpcdec.vcproj | 3 +-
win32/mpcenc.vcproj | 3 +-
win32/musepack.sln | 53 ++++++++-------------------
8 files changed, 185 insertions(+), 45 deletions(-)
diff --git a/common/unicode_support.c b/common/unicode_support.c
new file mode 100644
index 0000000..d823d9c
--- /dev/null
+++ b/common/unicode_support.c
@@ -0,0 +1,87 @@
+#include "unicode_support.h"
+
+#include <windows.h>
+
+char *utf16_to_utf8(const wchar_t *input)
+{
+ char *Buffer;
+ int BuffSize, Result;
+
+ BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
+ Buffer = (char*) malloc(sizeof(char) * BuffSize);
+ Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
+
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+wchar_t *utf8_to_utf16(const char *input)
+{
+ wchar_t *Buffer;
+ int BuffSize, Result;
+
+ BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
+ Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
+ Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
+
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+void init_commandline_arguments_utf8(int *argc, char ***argv)
+{
+ int i, nArgs;
+ LPWSTR *szArglist;
+
+ szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
+
+ if(NULL == szArglist)
+ {
+ fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
+ exit(-1);
+ }
+
+ *argv = malloc(sizeof(char*) * nArgs);
+ *argc = nArgs;
+
+ for(i = 0; i < nArgs; i++)
+ {
+ (*argv)[i] = utf16_to_utf8(szArglist[i]);
+ }
+
+ LocalFree(szArglist);
+}
+
+void free_commandline_arguments_utf8(int *argc, char ***argv)
+{
+ int i = 0;
+
+ if(*argv != NULL)
+ {
+ for(i = 0; i < *argc; i++)
+ {
+ if((*argv)[i] != NULL)
+ {
+ free((*argv)[i]);
+ (*argv)[i] = NULL;
+ }
+ }
+ free(*argv);
+ *argv = NULL;
+ }
+}
+
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
+{
+ FILE *ret = NULL;
+ wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
+ wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
+
+ if(filename_utf16 && mode_utf16)
+ {
+ ret = _wfopen(filename_utf16, mode_utf16);
+ }
+
+ if(filename_utf16) free(filename_utf16);
+ if(mode_utf16) free(mode_utf16);
+
+ return ret;
+}
diff --git a/common/unicode_support.h b/common/unicode_support.h
new file mode 100644
index 0000000..97d639e
--- /dev/null
+++ b/common/unicode_support.h
@@ -0,0 +1,21 @@
+#ifndef UNICODE_SUPPORT_H_INCLUDED
+#define UNICODE_SUPPORT_H_INCLUDED
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *utf16_to_utf8(const wchar_t *input);
+wchar_t *utf8_to_utf16(const char *input);
+void init_commandline_arguments_utf8(int *argc, char ***argv);
+void free_commandline_arguments_utf8(int *argc, char ***argv);
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
\ No newline at end of file
diff --git a/libmpcdec/mpc_reader.c b/libmpcdec/mpc_reader.c
index 06aa49e..f59ffd4 100644
--- a/libmpcdec/mpc_reader.c
+++ b/libmpcdec/mpc_reader.c
@@ -36,6 +36,7 @@
#include <mpc/reader.h>
#include "internal.h"
#include <stdio.h>
+#include "../common/unicode_support.h"
#define STDIO_MAGIC 0xF34B963C ///< Just a random safe-check value...
typedef struct mpc_reader_stdio_t {
@@ -127,7 +128,7 @@ clean:
mpc_status
mpc_reader_init_stdio(mpc_reader *p_reader, const char *filename)
{
- FILE * stream = fopen(filename, "rb");
+ FILE * stream = fopen_utf8(filename, "rb");
if (stream == NULL) return MPC_STATUS_FAIL;
return mpc_reader_init_stdio_stream(p_reader,stream);
}
diff --git a/mpcdec/mpcdec.c b/mpcdec/mpcdec.c
index b60483f..8fdb34b 100644
--- a/mpcdec/mpcdec.c
+++ b/mpcdec/mpcdec.c
@@ -37,8 +37,10 @@
#include <mpc/mpcdec.h>
#include "../libmpcdec/decoder.h"
#include "../libmpcdec/internal.h"
+#include "../common/unicode_support.h"
#include <libwaveformat.h>
#include <getopt.h>
+#include <string.h>
#ifdef _MSC_VER
#include <crtdbg.h>
@@ -114,7 +116,7 @@ usage(const char *exename)
}
int
-main(int argc, char **argv)
+mpcdec_main(int argc, char **argv)
{
mpc_reader reader;
mpc_demux* demux;
@@ -122,12 +124,13 @@ main(int argc, char **argv)
mpc_status err;
mpc_bool_t info = MPC_FALSE, is_wav_output = MPC_FALSE, check = MPC_FALSE;
MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
- clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output;
+ clock_t begin, end, sum; int total_samples, max_samples; t_wav_output_file wav_output;
+ mpc_bool_t verbose_output = MPC_FALSE;
int c;
fprintf(stderr, About);
- while ((c = getopt(argc , argv, "ihc")) != -1) {
+ while ((c = getopt(argc , argv, "ihcv")) != -1) {
switch (c) {
case 'i':
info = MPC_TRUE;
@@ -135,6 +138,9 @@ main(int argc, char **argv)
case 'c':
check = MPC_TRUE;
break;
+ case 'v':
+ verbose_output = MPC_TRUE;
+ break;
case 'h':
usage(argv[0]);
return 0;
@@ -177,13 +183,15 @@ main(int argc, char **argv)
SET_BINARY_MODE(stdout);
wavo_fc.m_user_data = stdout;
} else
- wavo_fc.m_user_data = fopen(argv[optind + 1], "wb");
+ wavo_fc.m_user_data = fopen_utf8(argv[optind + 1], "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.samples * si.channels);
if(!err) return !MPC_STATUS_OK;
}
sum = total_samples = 0;
+ max_samples = (int) mpc_streaminfo_get_length_samples(&si);
+
while(MPC_TRUE)
{
mpc_frame_info frame;
@@ -199,6 +207,12 @@ main(int argc, char **argv)
total_samples += frame.samples;
sum += end - begin;
+ if(verbose_output)
+ {
+ fprintf(stderr, "Decoding progress: %3.1f%%\r", (((float)total_samples) / ((float)max_samples)) * 100.0f);
+ fflush(stderr);
+ }
+
if(is_wav_output) {
#ifdef MPC_FIXED_POINT
mpc_int16_t tmp_buff[MPC_DECODER_BUFFER_LENGTH];
@@ -217,6 +231,19 @@ main(int argc, char **argv)
}
}
+ if(verbose_output)
+ {
+ if(err == MPC_STATUS_OK)
+ {
+ fprintf(stderr, "Decoding progress: %3.1f%%\n", 100.0f);
+ }
+ else
+ {
+ fprintf(stderr, "\n");
+ }
+ fflush(stderr);
+ }
+
if (err != MPC_STATUS_OK)
fprintf(stderr, "An error occured while decoding\n");
else if (check)
@@ -247,3 +274,17 @@ main(int argc, char **argv)
#endif
return err;
}
+
+int
+main(int __argc, char **__argv)
+{
+ int argc;
+ char **argv;
+ int exit_code;
+
+ init_commandline_arguments_utf8(&argc, &argv);
+ exit_code = mpcdec_main(argc, argv);
+ free_commandline_arguments_utf8(&argc, &argv);
+
+ return exit_code;
+}
diff --git a/win32/libcommon.vcproj b/win32/libcommon.vcproj
index 0acf049..567671a 100644
--- a/win32/libcommon.vcproj
+++ b/win32/libcommon.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="libcommon"
ProjectGUID="{49A26D14-0AD0-497E-A982-42BFD4D992FC}"
RootNamespace="libcommon"
@@ -112,6 +112,7 @@
ExceptionHandling="0"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
WarningLevel="3"
CompileAs="1"
@@ -170,6 +171,10 @@
RelativePath="..\common\tags.c"
>
</File>
+ <File
+ RelativePath="..\common\unicode_support.c"
+ >
+ </File>
</Filter>
<Filter
Name="headers"
@@ -178,6 +183,10 @@
RelativePath=".\getopt.h"
>
</File>
+ <File
+ RelativePath="..\common\unicode_support.h"
+ >
+ </File>
</Filter>
</Files>
<Globals>
diff --git a/win32/libmpcdec.vcproj b/win32/libmpcdec.vcproj
index 16db2c3..3abf055 100644
--- a/win32/libmpcdec.vcproj
+++ b/win32/libmpcdec.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="libmpcdec"
ProjectGUID="{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
RootNamespace="libmpcdec"
@@ -113,6 +113,7 @@
ExceptionHandling="0"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
WarningLevel="3"
CompileAs="1"
diff --git a/win32/mpcenc.vcproj b/win32/mpcenc.vcproj
index fe03c93..7193e4f 100644
--- a/win32/mpcenc.vcproj
+++ b/win32/mpcenc.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="mpcenc"
ProjectGUID="{15082E34-9324-469F-8423-F995B4814A37}"
RootNamespace="mppenc"
@@ -128,6 +128,7 @@
ExceptionHandling="0"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
WarningLevel="3"
CompileAs="1"
diff --git a/win32/musepack.sln b/win32/musepack.sln
index 35729b4..1a04a6f 100644
--- a/win32/musepack.sln
+++ b/win32/musepack.sln
@@ -1,53 +1,38 @@

-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcenc", "mpcenc.vcproj", "{15082E34-9324-469F-8423-F995B4814A37}"
- ProjectSection(ProjectDependencies) = postProject
- {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
- {7CF31624-B40E-466F-9107-785816C787C4} = {7CF31624-B40E-466F-9107-785816C787C4}
- {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96} = {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}
- EndProjectSection
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcenc", "mpcenc.vcxproj", "{15082E34-9324-469F-8423-F995B4814A37}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "libcommon.vcproj", "{49A26D14-0AD0-497E-A982-42BFD4D992FC}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "libcommon.vcxproj", "{49A26D14-0AD0-497E-A982-42BFD4D992FC}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcpsy", "libmpcpsy.vcproj", "{7CF31624-B40E-466F-9107-785816C787C4}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcenc", "libmpcenc.vcproj", "{44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcdec", "mpcdec.vcproj", "{A527175B-22A9-41AB-B2E8-580F573CCAFB}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcpsy", "libmpcpsy.vcxproj", "{7CF31624-B40E-466F-9107-785816C787C4}"
ProjectSection(ProjectDependencies) = postProject
{49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
- {13D176A2-B6BB-403F-A816-AA1F388078B7} = {13D176A2-B6BB-403F-A816-AA1F388078B7}
- {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpccut", "mpccut.vcproj", "{ABBF9DD7-650F-48A8-9810-B76F233520F3}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcenc", "libmpcenc.vcxproj", "{44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}"
ProjectSection(ProjectDependencies) = postProject
- {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96} = {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}
{49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
- {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpc2sv8", "mpc2sv8.vcproj", "{36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}"
- ProjectSection(ProjectDependencies) = postProject
- {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
- {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96} = {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}
- {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
- EndProjectSection
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcdec", "mpcdec.vcxproj", "{A527175B-22A9-41AB-B2E8-580F573CCAFB}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcdec", "libmpcdec.vcproj", "{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpccut", "mpccut.vcxproj", "{ABBF9DD7-650F-48A8-9810-B76F233520F3}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwavformat", "libwavformat.vcproj", "{13D176A2-B6BB-403F-A816-AA1F388078B7}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpc2sv8", "mpc2sv8.vcxproj", "{36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libreplaygain", "..\..\..\libreplaygain\libreplaygain.vcproj", "{CB7A02E8-393A-481B-BD18-E7D041D8C6B1}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcdec", "libmpcdec.vcxproj", "{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
+ ProjectSection(ProjectDependencies) = postProject
+ {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
+ EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcgain", "mpcgain.vcproj", "{76CBB7D4-0524-4569-9150-34BDE4235D04}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwavformat", "libwavformat.vcxproj", "{13D176A2-B6BB-403F-A816-AA1F388078B7}"
ProjectSection(ProjectDependencies) = postProject
{49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
- {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
- {CB7A02E8-393A-481B-BD18-E7D041D8C6B1} = {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcgain", "mpcgain.vcxproj", "{76CBB7D4-0524-4569-9150-34BDE4235D04}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -81,7 +66,6 @@ Global
{36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Debug|Win32.ActiveCfg = Debug|Win32
{36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Debug|Win32.Build.0 = Debug|Win32
{36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Release|Win32.ActiveCfg = Release|Win32
- {36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Release|Win32.Build.0 = Release|Win32
{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Debug|Win32.ActiveCfg = Debug|Win32
{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Debug|Win32.Build.0 = Debug|Win32
{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Release|Win32.ActiveCfg = Release|Win32
@@ -90,14 +74,9 @@ Global
{13D176A2-B6BB-403F-A816-AA1F388078B7}.Debug|Win32.Build.0 = Debug|Win32
{13D176A2-B6BB-403F-A816-AA1F388078B7}.Release|Win32.ActiveCfg = Release|Win32
{13D176A2-B6BB-403F-A816-AA1F388078B7}.Release|Win32.Build.0 = Release|Win32
- {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Debug|Win32.ActiveCfg = Debug|Win32
- {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Debug|Win32.Build.0 = Debug|Win32
- {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Release|Win32.ActiveCfg = Release|Win32
- {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Release|Win32.Build.0 = Release|Win32
{76CBB7D4-0524-4569-9150-34BDE4235D04}.Debug|Win32.ActiveCfg = Debug|Win32
{76CBB7D4-0524-4569-9150-34BDE4235D04}.Debug|Win32.Build.0 = Debug|Win32
{76CBB7D4-0524-4569-9150-34BDE4235D04}.Release|Win32.ActiveCfg = Release|Win32
- {76CBB7D4-0524-4569-9150-34BDE4235D04}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,466 @@
src/8svx.c | 3 +-
src/adpcm.c | 1 +
src/effects_i.c | 3 +-
src/formats.c | 9 ++-
src/libsox.c | 2 +
src/libsox_i.c | 7 +-
src/noiseprof.c | 3 +-
src/sox.c | 33 ++++++++---
src/unicode_support.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++
src/unicode_support.h | 16 +++++
src/util.h | 5 ++
11 files changed, 211 insertions(+), 19 deletions(-)
diff --git a/src/8svx.c b/src/8svx.c
index 63c30e6..fd712f4 100644
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -1,6 +1,7 @@
/* Amiga 8SVX format handler: W V Neisius, February 1992 */
#include "sox_i.h"
+#include "unicode_support.h"
#include <errno.h>
#include <string.h>
@@ -161,7 +162,7 @@ static int startread(sox_format_t * ft)
chan1_pos = lsx_tell(ft);
for (i = 1; i < channels; i++) {
- if ((p->ch[i] = fopen(ft->filename, "rb")) == NULL)
+ if ((p->ch[i] = fopen_utf8(ft->filename, "rb")) == NULL)
{
lsx_fail_errno(ft,errno,"Can't open channel file '%s'",
ft->filename);
diff --git a/src/adpcm.c b/src/adpcm.c
index 2e13867..15c27c2 100644
--- a/src/adpcm.c
+++ b/src/adpcm.c
@@ -33,6 +33,7 @@
#include "sox_i.h"
#include "adpcm.h"
+#include "unicode_support.h"
#include <sys/types.h>
#include <stdio.h>
diff --git a/src/effects_i.c b/src/effects_i.c
index 7d72166..65d6a0b 100644
--- a/src/effects_i.c
+++ b/src/effects_i.c
@@ -20,6 +20,7 @@
#define LSX_EFF_ALIAS
#include "sox_i.h"
+#include "unicode_support.h"
#include <string.h>
#include <ctype.h>
@@ -355,7 +356,7 @@ FILE * lsx_open_input_file(sox_effect_t * effp, char const * filename)
effp->global_info->global_info->stdin_in_use_by = effp->handler.name;
file = stdin;
}
- else if (!(file = fopen(filename, "r"))) {
+ else if (!(file = fopen_utf8(filename, "r"))) {
lsx_fail("couldn't open file %s: %s", filename, strerror(errno));
return NULL;
}
diff --git a/src/formats.c b/src/formats.c
index cac686c..1baa213 100644
--- a/src/formats.c
+++ b/src/formats.c
@@ -19,6 +19,7 @@
*/
#include "sox_i.h"
+#include "unicode_support.h"
#include <assert.h>
#include <ctype.h>
@@ -396,7 +397,7 @@ static FILE * xfopen(char const * identifier, char const * mode, lsx_io_type * i
#endif
return f;
}
- return fopen(identifier, mode);
+ return fopen_utf8(identifier, mode);
}
/* Hack to rewind pipes (a small amount).
@@ -847,8 +848,8 @@ static sox_format_t * open_write(
ft->fp = stdout;
}
else {
- struct stat st;
- if (!stat(path, &st) && (st.st_mode & S_IFMT) == S_IFREG &&
+ struct _stat st;
+ if (!stat_utf8(path, &st) && (st.st_mode & S_IFMT) == S_IFREG &&
(overwrite_permitted && !overwrite_permitted(path))) {
lsx_fail("permission to overwrite `%s' denied", path);
goto error;
@@ -858,7 +859,7 @@ static sox_format_t * open_write(
buffer? fmemopen(buffer, buffer_size, "w+b") :
buffer_ptr? open_memstream(buffer_ptr, buffer_size_ptr) :
#endif
- fopen(path, "w+b");
+ fopen_utf8(path, "w+b");
if (ft->fp == NULL) {
lsx_fail("can't open output file `%s': %s", path, strerror(errno));
goto error;
diff --git a/src/libsox.c b/src/libsox.c
index 75354e4..a766aa9 100644
--- a/src/libsox.c
+++ b/src/libsox.c
@@ -19,6 +19,8 @@
*/
#include "sox_i.h"
+#include "unicode_support.h"
+
#include <string.h>
const char *sox_version(void)
diff --git a/src/libsox_i.c b/src/libsox_i.c
index 8a7074a..b498cc0 100644
--- a/src/libsox_i.c
+++ b/src/libsox_i.c
@@ -20,6 +20,7 @@
#include "sox_i.h"
+#include "unicode_support.h"
#ifdef HAVE_IO_H
#include <io.h>
@@ -48,8 +49,8 @@
#ifdef WIN32
static int check_dir(char * buf, size_t buflen, char const * name)
{
- struct stat st;
- if (!name || stat(name, &st) || (st.st_mode & S_IFMT) != S_IFDIR)
+ struct _stat st;
+ if (!name || stat_utf8(name, &st) || (st.st_mode & S_IFMT) != S_IFDIR)
{
return 0;
}
@@ -102,7 +103,7 @@ FILE * lsx_tmpfile(void)
fildes = mkstemp(name);
#ifdef HAVE_UNISTD_H
lsx_debug(FAKE_MKSTEMP "mkstemp, name=%s (unlinked)", name);
- unlink(name);
+ unlink_utf8(name);
#else
lsx_debug(FAKE_MKSTEMP "mkstemp, name=%s (O_TEMPORARY)", name);
#endif
diff --git a/src/noiseprof.c b/src/noiseprof.c
index 603402f..d46c280 100644
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -19,6 +19,7 @@
*/
#include "noisered.h"
+#include "unicode_support.h"
#include <assert.h>
#include <string.h>
@@ -75,7 +76,7 @@ static int sox_noiseprof_start(sox_effect_t * effp)
effp->global_info->global_info->stdout_in_use_by = effp->handler.name;
data->output_file = stdout;
}
- else if ((data->output_file = fopen(data->output_filename, "w")) == NULL) {
+ else if ((data->output_file = fopen_utf8(data->output_filename, "w")) == NULL) {
lsx_fail("Couldn't open profile file %s: %s", data->output_filename, strerror(errno));
return SOX_EOF;
}
diff --git a/src/sox.c b/src/sox.c
index 665149b..da43424 100644
--- a/src/sox.c
+++ b/src/sox.c
@@ -24,6 +24,7 @@
#include "soxconfig.h"
#include "sox.h"
#include "util.h"
+#include "unicode_support.h"
#include <ctype.h>
#include <errno.h>
@@ -236,12 +237,12 @@ static void cleanup(void)
if (file_count) {
if (ofile->ft) {
if (!success && ofile->ft->fp) { /* If we failed part way through */
- struct stat st; /* writing a normal file, remove it. */
- if (!stat(ofile->ft->filename, &st) &&
+ struct _stat st; /* writing a normal file, remove it. */
+ if (!stat_utf8(ofile->ft->filename, &st) &&
(st.st_mode & S_IFMT) == S_IFREG)
- unlink(ofile->ft->filename);
+ unlink_utf8(ofile->ft->filename);
}
- sox_close(ofile->ft); /* Assume we can unlink a file before closing it. */
+ sox_close(ofile->ft); /* Assume we can unlink_utf8 a file before closing it. */
}
free(ofile->filename);
free(ofile);
@@ -293,8 +294,8 @@ static char const * str_time(double seconds)
static char const * size_and_bitrate(sox_format_t * ft, char const * * text)
{
- struct stat st; /* ft->fp may validly be NULL, so stat not fstat */
- if (stat(ft->filename, &st) || (st.st_mode & S_IFMT) != S_IFREG)
+ struct _stat st; /* ft->fp may validly be NULL, so stat not fstat */
+ if (stat_utf8(ft->filename, &st) || (st.st_mode & S_IFMT) != S_IFREG)
return NULL;
if (ft->signal.length && ft->signal.channels && ft->signal.rate && text) {
double secs = ft->signal.length / ft->signal.channels / ft->signal.rate;
@@ -906,7 +907,7 @@ static char * * strtoargv(char * s, int * argc)
static void read_user_effects(char const *filename)
{
- FILE *file = fopen(filename, "rt");
+ FILE *file = fopen_utf8(filename, "rt");
const size_t buffer_size_step = 1024;
size_t buffer_size = buffer_size_step;
char *s = lsx_malloc(buffer_size); /* buffer for one input line */
@@ -1269,6 +1270,7 @@ static void display_status(sox_bool all_done)
lsx_sigfigs3((double)output_samples),
vu(0), vu(1), headroom(), lsx_sigfigs3((double)total_clips()));
}
+ fflush(stderr);
if (all_done)
fputc('\n', stderr);
}
@@ -2123,7 +2125,7 @@ static void read_comment_file(sox_comments_t * comments, char const * const file
int c;
size_t text_length = 100;
char * text = lsx_malloc(text_length + 1);
- FILE * file = fopen(filename, "rt");
+ FILE * file = fopen_utf8(filename, "rt");
if (file == NULL) {
lsx_fail("Cannot open comment file `%s'", filename);
@@ -2830,7 +2832,7 @@ static sox_bool cmp_comment_text(char const * c1, char const * c2)
return c1 && c2 && !strcasecmp(c1, c2);
}
-int main(int argc, char **argv)
+static int sox_main(int argc, char **argv)
{
size_t i;
char mybase[6];
@@ -3032,3 +3034,16 @@ int main(int argc, char **argv)
return 0;
}
+
+int main( int argc, char **argv )
+{
+ int sox_argc;
+ char **sox_argv;
+ int exit_code;
+
+ init_commandline_arguments_utf8(&sox_argc, &sox_argv);
+ exit_code = sox_main(sox_argc, sox_argv);
+ free_commandline_arguments_utf8(&sox_argc, &sox_argv);
+
+ return exit_code;
+}
diff --git a/src/unicode_support.c b/src/unicode_support.c
new file mode 100644
index 0000000..e0cbbc9
--- /dev/null
+++ b/src/unicode_support.c
@@ -0,0 +1,148 @@
+#include "unicode_support.h"
+
+#include <windows.h>
+#include <io.h>
+
+char *utf16_to_utf8(const wchar_t *input)
+{
+ char *Buffer;
+ int BuffSize = 0, Result = 0;
+
+ BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
+ Buffer = (char*) malloc(sizeof(char) * BuffSize);
+ if(Buffer)
+ {
+ Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
+ }
+
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+char *utf16_to_ansi(const wchar_t *input)
+{
+ char *Buffer;
+ int BuffSize = 0, Result = 0;
+
+ BuffSize = WideCharToMultiByte(CP_ACP, 0, input, -1, NULL, 0, NULL, NULL);
+ Buffer = (char*) malloc(sizeof(char) * BuffSize);
+ if(Buffer)
+ {
+ Result = WideCharToMultiByte(CP_ACP, 0, input, -1, Buffer, BuffSize, NULL, NULL);
+ }
+
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+wchar_t *utf8_to_utf16(const char *input)
+{
+ wchar_t *Buffer;
+ int BuffSize = 0, Result = 0;
+
+ BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
+ Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
+ if(Buffer)
+ {
+ Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
+ }
+
+ return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
+}
+
+void init_commandline_arguments_utf8(int *argc, char ***argv)
+{
+ int i, nArgs;
+ LPWSTR *szArglist;
+
+ szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
+
+ if(NULL == szArglist)
+ {
+ fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
+ exit(-1);
+ }
+
+ *argv = (char**) malloc(sizeof(char*) * nArgs);
+ *argc = nArgs;
+
+ if(NULL == *argv)
+ {
+ fprintf(stderr, "\nFATAL: Malloc failed\n\n");
+ exit(-1);
+ }
+
+ for(i = 0; i < nArgs; i++)
+ {
+ (*argv)[i] = utf16_to_utf8(szArglist[i]);
+ if(NULL == (*argv)[i])
+ {
+ fprintf(stderr, "\nFATAL: utf16_to_utf8 failed\n\n");
+ exit(-1);
+ }
+ }
+
+ LocalFree(szArglist);
+}
+
+void free_commandline_arguments_utf8(int *argc, char ***argv)
+{
+ int i = 0;
+
+ if(*argv != NULL)
+ {
+ for(i = 0; i < *argc; i++)
+ {
+ if((*argv)[i] != NULL)
+ {
+ free((*argv)[i]);
+ (*argv)[i] = NULL;
+ }
+ }
+ free(*argv);
+ *argv = NULL;
+ }
+}
+
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
+{
+ FILE *ret = NULL;
+ wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
+ wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
+
+ if(filename_utf16 && mode_utf16)
+ {
+ ret = _wfopen(filename_utf16, mode_utf16);
+ }
+
+ if(filename_utf16) free(filename_utf16);
+ if(mode_utf16) free(mode_utf16);
+
+ return ret;
+}
+
+int stat_utf8(const char *path_utf8, struct _stat *buf)
+{
+ int ret = -1;
+
+ wchar_t *path_utf16 = utf8_to_utf16(path_utf8);
+ if(path_utf16)
+ {
+ ret = _wstat(path_utf16, buf);
+ free(path_utf16);
+ }
+
+ return ret;
+}
+
+int unlink_utf8(const char *path_utf8)
+{
+ int ret = -1;
+
+ wchar_t *path_utf16 = utf8_to_utf16(path_utf8);
+ if(path_utf16)
+ {
+ ret = _wunlink(path_utf16);
+ free(path_utf16);
+ }
+
+ return ret;
+}
diff --git a/src/unicode_support.h b/src/unicode_support.h
new file mode 100644
index 0000000..6775e00
--- /dev/null
+++ b/src/unicode_support.h
@@ -0,0 +1,16 @@
+#ifndef UNICODE_SUPPORT_H_INCLUDED
+#define UNICODE_SUPPORT_H_INCLUDED
+
+#include <stdio.h>
+#include <sys/stat.h>
+
+char *utf16_to_utf8(const wchar_t *input);
+char *utf16_to_ansi(const wchar_t *input);
+wchar_t *utf8_to_utf16(const char *input);
+void init_commandline_arguments_utf8(int *argc, char ***argv);
+void free_commandline_arguments_utf8(int *argc, char ***argv);
+FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8);
+int stat_utf8(const char *path_utf8, struct _stat *buf);
+int unlink_utf8(const char *path_utf8);
+
+#endif
\ No newline at end of file
diff --git a/src/util.h b/src/util.h
index f10b676..4a835f0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -91,6 +91,10 @@
#ifdef _MSC_VER
+#define inline __inline
+#define snprintf _snprintf
+
+/*
#define __STDC__ 1
#define O_BINARY _O_BINARY
#define O_CREAT _O_CREAT
@@ -141,6 +145,7 @@
#define off_t __int64
#define HAVE_FSEEKO 1
#endif
+*/
#elif defined(__MINGW32__)