Updated MediaInfo binaries to v19.07 (2019-07-16), compiled with ICL 19.0 and MSVC...
[LameXP.git] / etc / Patches / Musepack-r475-MSVC10-UTF8+Progress.V1.diff
blobc353c30a2097a208e810131d0ca970dbbeb24a51
1 common/unicode_support.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++
2 common/unicode_support.h | 21 +++++++++++
3 libmpcdec/mpc_reader.c | 3 +-
4 mpcdec/mpcdec.c | 49 ++++++++++++++++++++++++--
5 win32/libcommon.vcproj | 11 +++++-
6 win32/libmpcdec.vcproj | 3 +-
7 win32/mpcenc.vcproj | 3 +-
8 win32/musepack.sln | 53 ++++++++-------------------
9 8 files changed, 185 insertions(+), 45 deletions(-)
11 diff --git a/common/unicode_support.c b/common/unicode_support.c
12 new file mode 100644
13 index 0000000..d823d9c
14 --- /dev/null
15 +++ b/common/unicode_support.c
16 @@ -0,0 +1,87 @@
17 +#include "unicode_support.h"
19 +#include <windows.h>
21 +char *utf16_to_utf8(const wchar_t *input)
23 + char *Buffer;
24 + int BuffSize, Result;
26 + BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
27 + Buffer = (char*) malloc(sizeof(char) * BuffSize);
28 + Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
30 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
33 +wchar_t *utf8_to_utf16(const char *input)
35 + wchar_t *Buffer;
36 + int BuffSize, Result;
38 + BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
39 + Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
40 + Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
42 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
45 +void init_commandline_arguments_utf8(int *argc, char ***argv)
47 + int i, nArgs;
48 + LPWSTR *szArglist;
50 + szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
52 + if(NULL == szArglist)
53 + {
54 + fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
55 + exit(-1);
56 + }
58 + *argv = malloc(sizeof(char*) * nArgs);
59 + *argc = nArgs;
61 + for(i = 0; i < nArgs; i++)
62 + {
63 + (*argv)[i] = utf16_to_utf8(szArglist[i]);
64 + }
66 + LocalFree(szArglist);
69 +void free_commandline_arguments_utf8(int *argc, char ***argv)
71 + int i = 0;
73 + if(*argv != NULL)
74 + {
75 + for(i = 0; i < *argc; i++)
76 + {
77 + if((*argv)[i] != NULL)
78 + {
79 + free((*argv)[i]);
80 + (*argv)[i] = NULL;
81 + }
82 + }
83 + free(*argv);
84 + *argv = NULL;
85 + }
88 +FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
90 + FILE *ret = NULL;
91 + wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
92 + wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
94 + if(filename_utf16 && mode_utf16)
95 + {
96 + ret = _wfopen(filename_utf16, mode_utf16);
97 + }
99 + if(filename_utf16) free(filename_utf16);
100 + if(mode_utf16) free(mode_utf16);
102 + return ret;
104 diff --git a/common/unicode_support.h b/common/unicode_support.h
105 new file mode 100644
106 index 0000000..97d639e
107 --- /dev/null
108 +++ b/common/unicode_support.h
109 @@ -0,0 +1,21 @@
110 +#ifndef UNICODE_SUPPORT_H_INCLUDED
111 +#define UNICODE_SUPPORT_H_INCLUDED
113 +#include <ctype.h>
114 +#include <stdio.h>
115 +#include <stdlib.h>
117 +#ifdef __cplusplus
118 +extern "C" {
119 +#endif
121 +char *utf16_to_utf8(const wchar_t *input);
122 +wchar_t *utf8_to_utf16(const char *input);
123 +void init_commandline_arguments_utf8(int *argc, char ***argv);
124 +void free_commandline_arguments_utf8(int *argc, char ***argv);
125 +FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8);
127 +#ifdef __cplusplus
129 +#endif
130 +#endif
131 \ No newline at end of file
132 diff --git a/libmpcdec/mpc_reader.c b/libmpcdec/mpc_reader.c
133 index 06aa49e..f59ffd4 100644
134 --- a/libmpcdec/mpc_reader.c
135 +++ b/libmpcdec/mpc_reader.c
136 @@ -36,6 +36,7 @@
137 #include <mpc/reader.h>
138 #include "internal.h"
139 #include <stdio.h>
140 +#include "../common/unicode_support.h"
142 #define STDIO_MAGIC 0xF34B963C ///< Just a random safe-check value...
143 typedef struct mpc_reader_stdio_t {
144 @@ -127,7 +128,7 @@ clean:
145 mpc_status
146 mpc_reader_init_stdio(mpc_reader *p_reader, const char *filename)
148 - FILE * stream = fopen(filename, "rb");
149 + FILE * stream = fopen_utf8(filename, "rb");
150 if (stream == NULL) return MPC_STATUS_FAIL;
151 return mpc_reader_init_stdio_stream(p_reader,stream);
153 diff --git a/mpcdec/mpcdec.c b/mpcdec/mpcdec.c
154 index b60483f..8fdb34b 100644
155 --- a/mpcdec/mpcdec.c
156 +++ b/mpcdec/mpcdec.c
157 @@ -37,8 +37,10 @@
158 #include <mpc/mpcdec.h>
159 #include "../libmpcdec/decoder.h"
160 #include "../libmpcdec/internal.h"
161 +#include "../common/unicode_support.h"
162 #include <libwaveformat.h>
163 #include <getopt.h>
164 +#include <string.h>
166 #ifdef _MSC_VER
167 #include <crtdbg.h>
168 @@ -114,7 +116,7 @@ usage(const char *exename)
172 -main(int argc, char **argv)
173 +mpcdec_main(int argc, char **argv)
175 mpc_reader reader;
176 mpc_demux* demux;
177 @@ -122,12 +124,13 @@ main(int argc, char **argv)
178 mpc_status err;
179 mpc_bool_t info = MPC_FALSE, is_wav_output = MPC_FALSE, check = MPC_FALSE;
180 MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
181 - clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output;
182 + clock_t begin, end, sum; int total_samples, max_samples; t_wav_output_file wav_output;
183 + mpc_bool_t verbose_output = MPC_FALSE;
184 int c;
186 fprintf(stderr, About);
188 - while ((c = getopt(argc , argv, "ihc")) != -1) {
189 + while ((c = getopt(argc , argv, "ihcv")) != -1) {
190 switch (c) {
191 case 'i':
192 info = MPC_TRUE;
193 @@ -135,6 +138,9 @@ main(int argc, char **argv)
194 case 'c':
195 check = MPC_TRUE;
196 break;
197 + case 'v':
198 + verbose_output = MPC_TRUE;
199 + break;
200 case 'h':
201 usage(argv[0]);
202 return 0;
203 @@ -177,13 +183,15 @@ main(int argc, char **argv)
204 SET_BINARY_MODE(stdout);
205 wavo_fc.m_user_data = stdout;
206 } else
207 - wavo_fc.m_user_data = fopen(argv[optind + 1], "wb");
208 + wavo_fc.m_user_data = fopen_utf8(argv[optind + 1], "wb");
209 if(!wavo_fc.m_user_data) return !MPC_STATUS_OK;
210 err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.samples * si.channels);
211 if(!err) return !MPC_STATUS_OK;
214 sum = total_samples = 0;
215 + max_samples = (int) mpc_streaminfo_get_length_samples(&si);
217 while(MPC_TRUE)
219 mpc_frame_info frame;
220 @@ -199,6 +207,12 @@ main(int argc, char **argv)
221 total_samples += frame.samples;
222 sum += end - begin;
224 + if(verbose_output)
226 + fprintf(stderr, "Decoding progress: %3.1f%%\r", (((float)total_samples) / ((float)max_samples)) * 100.0f);
227 + fflush(stderr);
230 if(is_wav_output) {
231 #ifdef MPC_FIXED_POINT
232 mpc_int16_t tmp_buff[MPC_DECODER_BUFFER_LENGTH];
233 @@ -217,6 +231,19 @@ main(int argc, char **argv)
237 + if(verbose_output)
239 + if(err == MPC_STATUS_OK)
241 + fprintf(stderr, "Decoding progress: %3.1f%%\n", 100.0f);
243 + else
245 + fprintf(stderr, "\n");
247 + fflush(stderr);
250 if (err != MPC_STATUS_OK)
251 fprintf(stderr, "An error occured while decoding\n");
252 else if (check)
253 @@ -247,3 +274,17 @@ main(int argc, char **argv)
254 #endif
255 return err;
258 +int
259 +main(int __argc, char **__argv)
261 + int argc;
262 + char **argv;
263 + int exit_code;
265 + init_commandline_arguments_utf8(&argc, &argv);
266 + exit_code = mpcdec_main(argc, argv);
267 + free_commandline_arguments_utf8(&argc, &argv);
269 + return exit_code;
271 diff --git a/win32/libcommon.vcproj b/win32/libcommon.vcproj
272 index 0acf049..567671a 100644
273 --- a/win32/libcommon.vcproj
274 +++ b/win32/libcommon.vcproj
275 @@ -1,7 +1,7 @@
276 <?xml version="1.0" encoding="UTF-8"?>
277 <VisualStudioProject
278 ProjectType="Visual C++"
279 - Version="9.00"
280 + Version="9,00"
281 Name="libcommon"
282 ProjectGUID="{49A26D14-0AD0-497E-A982-42BFD4D992FC}"
283 RootNamespace="libcommon"
284 @@ -112,6 +112,7 @@
285 ExceptionHandling="0"
286 BufferSecurityCheck="false"
287 EnableFunctionLevelLinking="true"
288 + EnableEnhancedInstructionSet="0"
289 FloatingPointModel="2"
290 WarningLevel="3"
291 CompileAs="1"
292 @@ -170,6 +171,10 @@
293 RelativePath="..\common\tags.c"
295 </File>
296 + <File
297 + RelativePath="..\common\unicode_support.c"
299 + </File>
300 </Filter>
301 <Filter
302 Name="headers"
303 @@ -178,6 +183,10 @@
304 RelativePath=".\getopt.h"
306 </File>
307 + <File
308 + RelativePath="..\common\unicode_support.h"
310 + </File>
311 </Filter>
312 </Files>
313 <Globals>
314 diff --git a/win32/libmpcdec.vcproj b/win32/libmpcdec.vcproj
315 index 16db2c3..3abf055 100644
316 --- a/win32/libmpcdec.vcproj
317 +++ b/win32/libmpcdec.vcproj
318 @@ -1,7 +1,7 @@
319 <?xml version="1.0" encoding="Windows-1252"?>
320 <VisualStudioProject
321 ProjectType="Visual C++"
322 - Version="9.00"
323 + Version="9,00"
324 Name="libmpcdec"
325 ProjectGUID="{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
326 RootNamespace="libmpcdec"
327 @@ -113,6 +113,7 @@
328 ExceptionHandling="0"
329 BufferSecurityCheck="false"
330 EnableFunctionLevelLinking="true"
331 + EnableEnhancedInstructionSet="0"
332 FloatingPointModel="2"
333 WarningLevel="3"
334 CompileAs="1"
335 diff --git a/win32/mpcenc.vcproj b/win32/mpcenc.vcproj
336 index fe03c93..7193e4f 100644
337 --- a/win32/mpcenc.vcproj
338 +++ b/win32/mpcenc.vcproj
339 @@ -1,7 +1,7 @@
340 <?xml version="1.0" encoding="Windows-1252"?>
341 <VisualStudioProject
342 ProjectType="Visual C++"
343 - Version="9.00"
344 + Version="9,00"
345 Name="mpcenc"
346 ProjectGUID="{15082E34-9324-469F-8423-F995B4814A37}"
347 RootNamespace="mppenc"
348 @@ -128,6 +128,7 @@
349 ExceptionHandling="0"
350 BufferSecurityCheck="false"
351 EnableFunctionLevelLinking="true"
352 + EnableEnhancedInstructionSet="0"
353 FloatingPointModel="2"
354 WarningLevel="3"
355 CompileAs="1"
356 diff --git a/win32/musepack.sln b/win32/musepack.sln
357 index 35729b4..1a04a6f 100644
358 --- a/win32/musepack.sln
359 +++ b/win32/musepack.sln
360 @@ -1,53 +1,38 @@
362 -Microsoft Visual Studio Solution File, Format Version 10.00
363 -# Visual Studio 2008
364 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcenc", "mpcenc.vcproj", "{15082E34-9324-469F-8423-F995B4814A37}"
365 - ProjectSection(ProjectDependencies) = postProject
366 - {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
367 - {7CF31624-B40E-466F-9107-785816C787C4} = {7CF31624-B40E-466F-9107-785816C787C4}
368 - {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96} = {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}
369 - EndProjectSection
370 +Microsoft Visual Studio Solution File, Format Version 11.00
371 +# Visual Studio 2010
372 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcenc", "mpcenc.vcxproj", "{15082E34-9324-469F-8423-F995B4814A37}"
373 EndProject
374 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "libcommon.vcproj", "{49A26D14-0AD0-497E-A982-42BFD4D992FC}"
375 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "libcommon.vcxproj", "{49A26D14-0AD0-497E-A982-42BFD4D992FC}"
376 EndProject
377 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcpsy", "libmpcpsy.vcproj", "{7CF31624-B40E-466F-9107-785816C787C4}"
378 -EndProject
379 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcenc", "libmpcenc.vcproj", "{44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}"
380 -EndProject
381 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcdec", "mpcdec.vcproj", "{A527175B-22A9-41AB-B2E8-580F573CCAFB}"
382 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcpsy", "libmpcpsy.vcxproj", "{7CF31624-B40E-466F-9107-785816C787C4}"
383 ProjectSection(ProjectDependencies) = postProject
384 {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
385 - {13D176A2-B6BB-403F-A816-AA1F388078B7} = {13D176A2-B6BB-403F-A816-AA1F388078B7}
386 - {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
387 EndProjectSection
388 EndProject
389 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpccut", "mpccut.vcproj", "{ABBF9DD7-650F-48A8-9810-B76F233520F3}"
390 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcenc", "libmpcenc.vcxproj", "{44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}"
391 ProjectSection(ProjectDependencies) = postProject
392 - {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96} = {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}
393 {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
394 - {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
395 EndProjectSection
396 EndProject
397 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpc2sv8", "mpc2sv8.vcproj", "{36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}"
398 - ProjectSection(ProjectDependencies) = postProject
399 - {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
400 - {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96} = {44EC1266-D2EE-47B8-ACFC-8BD52E7FFF96}
401 - {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
402 - EndProjectSection
403 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcdec", "mpcdec.vcxproj", "{A527175B-22A9-41AB-B2E8-580F573CCAFB}"
404 EndProject
405 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcdec", "libmpcdec.vcproj", "{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
406 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpccut", "mpccut.vcxproj", "{ABBF9DD7-650F-48A8-9810-B76F233520F3}"
407 EndProject
408 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwavformat", "libwavformat.vcproj", "{13D176A2-B6BB-403F-A816-AA1F388078B7}"
409 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpc2sv8", "mpc2sv8.vcxproj", "{36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}"
410 EndProject
411 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libreplaygain", "..\..\..\libreplaygain\libreplaygain.vcproj", "{CB7A02E8-393A-481B-BD18-E7D041D8C6B1}"
412 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcdec", "libmpcdec.vcxproj", "{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
413 + ProjectSection(ProjectDependencies) = postProject
414 + {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
415 + EndProjectSection
416 EndProject
417 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcgain", "mpcgain.vcproj", "{76CBB7D4-0524-4569-9150-34BDE4235D04}"
418 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwavformat", "libwavformat.vcxproj", "{13D176A2-B6BB-403F-A816-AA1F388078B7}"
419 ProjectSection(ProjectDependencies) = postProject
420 {49A26D14-0AD0-497E-A982-42BFD4D992FC} = {49A26D14-0AD0-497E-A982-42BFD4D992FC}
421 - {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
422 - {CB7A02E8-393A-481B-BD18-E7D041D8C6B1} = {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}
423 EndProjectSection
424 EndProject
425 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcgain", "mpcgain.vcxproj", "{76CBB7D4-0524-4569-9150-34BDE4235D04}"
426 +EndProject
427 Global
428 GlobalSection(SolutionConfigurationPlatforms) = preSolution
429 Debug|Win32 = Debug|Win32
430 @@ -81,7 +66,6 @@ Global
431 {36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Debug|Win32.ActiveCfg = Debug|Win32
432 {36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Debug|Win32.Build.0 = Debug|Win32
433 {36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Release|Win32.ActiveCfg = Release|Win32
434 - {36225C6A-FFA3-4E70-928E-1F69F7A3FCE1}.Release|Win32.Build.0 = Release|Win32
435 {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Debug|Win32.ActiveCfg = Debug|Win32
436 {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Debug|Win32.Build.0 = Debug|Win32
437 {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Release|Win32.ActiveCfg = Release|Win32
438 @@ -90,14 +74,9 @@ Global
439 {13D176A2-B6BB-403F-A816-AA1F388078B7}.Debug|Win32.Build.0 = Debug|Win32
440 {13D176A2-B6BB-403F-A816-AA1F388078B7}.Release|Win32.ActiveCfg = Release|Win32
441 {13D176A2-B6BB-403F-A816-AA1F388078B7}.Release|Win32.Build.0 = Release|Win32
442 - {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Debug|Win32.ActiveCfg = Debug|Win32
443 - {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Debug|Win32.Build.0 = Debug|Win32
444 - {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Release|Win32.ActiveCfg = Release|Win32
445 - {CB7A02E8-393A-481B-BD18-E7D041D8C6B1}.Release|Win32.Build.0 = Release|Win32
446 {76CBB7D4-0524-4569-9150-34BDE4235D04}.Debug|Win32.ActiveCfg = Debug|Win32
447 {76CBB7D4-0524-4569-9150-34BDE4235D04}.Debug|Win32.Build.0 = Debug|Win32
448 {76CBB7D4-0524-4569-9150-34BDE4235D04}.Release|Win32.ActiveCfg = Release|Win32
449 - {76CBB7D4-0524-4569-9150-34BDE4235D04}.Release|Win32.Build.0 = Release|Win32
450 EndGlobalSection
451 GlobalSection(SolutionProperties) = preSolution
452 HideSolutionNode = FALSE