Bump version.
[LameXP.git] / etc / Patches / deprecated / AC3Filter-valdec-UTF8+FlushProgress+NoDShow.V2.diff
blob6f1a812a2bfbcd101038b668c7f01316f28f2a31
1 tools/Release/valdec.exe | Bin 5513728 -> 5512704 bytes
2 tools/valdec.cpp | 140 +++++++++++++++---------
3 tools/valdec.sln | 17 +--
4 tools/valdec.suo | Bin 11776 -> 31744 bytes
5 valib/3rdparty/faad/decoder.c | 14 +--
6 valib/3rdparty/faad/drm_dec.c | 8 +-
7 valib/3rdparty/faad/filtbank.c | 10 +-
8 valib/3rdparty/faad/huffman.c | 10 +-
9 valib/3rdparty/faad/mdct.c | 4 +-
10 valib/3rdparty/faad/ps_dec.c | 42 +++----
11 valib/3rdparty/faad/rvlc.c | 18 +--
12 valib/3rdparty/faad/sbr_dec.c | 8 +-
13 valib/3rdparty/faad/sbr_fbt.c | 46 ++++----
14 valib/3rdparty/faad/sbr_syntax.c | 38 +++----
15 valib/3rdparty/faad/specrec.c | 36 +++---
16 valib/3rdparty/faad/syntax.c | 54 ++++-----
17 valib/3rdparty/faad/tns.c | 4 +-
18 valib/3rdparty/libmpg123/icy2utf8.c | 2 +-
19 valib/3rdparty/libmpg123/optimize.c | 4 +-
20 valib/valib/auto_file.cpp | 3 +-
21 valib/valib/auto_file.h | 4 +-
22 valib/valib/log.cpp | 2 +-
23 valib/valib/sink/sink_dsound.cpp | 2 +-
24 valib/valib/version.h | 4 -
25 valib/valib/win32/unicode_support.c | 199 ++++++++++++++++++++++++++++++++++
26 valib/valib/win32/unicode_support.cpp | 86 +++++++++++++++
27 valib/valib/win32/unicode_support.h | 57 ++++++++++
28 27 files changed, 592 insertions(+), 220 deletions(-)
30 diff --git a/tools/Release/valdec.exe b/tools/Release/valdec.exe
31 index 995954e..12b8e8f 100644
32 Binary files a/tools/Release/valdec.exe and b/tools/Release/valdec.exe differ
33 diff --git a/tools/valdec.cpp b/tools/valdec.cpp
34 index 5582c8d..965e201 100644
35 --- a/tools/valdec.cpp
36 +++ b/tools/valdec.cpp
37 @@ -23,6 +23,7 @@
39 // other
40 #include "win32/cpu.h"
41 +#include "win32/unicode_support.h"
42 #include "vargs.h"
44 #include "valdec_usage.txt.h"
45 @@ -94,12 +95,12 @@ const enum_opt format_tbl[] =
46 { "7", FORMAT_PCMDOUBLE },
49 -int valdec(int argc, const char *argv[])
50 +int valdec(int argc, const char **argv)
52 using std::string;
53 if (argc < 2)
55 - printf(usage);
56 + fprintf(stderr, usage);
57 return 1;
60 @@ -179,7 +180,7 @@ int valdec(int argc, const char *argv[])
62 if (parser)
64 - printf("-ac3 : ambiguous parser\n");
65 + fprintf(stderr, "-ac3 : ambiguous parser\n");
66 return 1;
69 @@ -192,7 +193,7 @@ int valdec(int argc, const char *argv[])
71 if (parser)
73 - printf("-dts : ambiguous parser\n");
74 + fprintf(stderr, "-dts : ambiguous parser\n");
75 return 1;
78 @@ -205,7 +206,7 @@ int valdec(int argc, const char *argv[])
80 if (parser)
82 - printf("-mpa : ambiguous parser\n");
83 + fprintf(stderr, "-mpa : ambiguous parser\n");
84 return 1;
87 @@ -223,7 +224,7 @@ int valdec(int argc, const char *argv[])
88 int new_mask;
89 if (!arg_enum(argv[iarg], new_mask, mask_tbl, array_size(mask_tbl)))
91 - printf("-spk : unknown channel layout: %s\n", arg_text(argv[iarg]));
92 + fprintf(stderr, "-spk : unknown channel layout: %s\n", arg_text(argv[iarg]));
93 return 1;
95 mask |= new_mask;
96 @@ -235,7 +236,7 @@ int valdec(int argc, const char *argv[])
98 if (!arg_enum(argv[iarg], format, format_tbl, array_size(format_tbl)))
100 - printf("-fmt : unknown sample format: %s\n", arg_text(argv[iarg]));
101 + fprintf(stderr, "-fmt : unknown sample format: %s\n", arg_text(argv[iarg]));
102 return 1;
104 continue;
105 @@ -257,7 +258,7 @@ int valdec(int argc, const char *argv[])
107 if (sink)
109 - printf("-decode : ambiguous output mode\n");
110 + fprintf(stderr, "-decode : ambiguous output mode\n");
111 return 1;
114 @@ -273,7 +274,7 @@ int valdec(int argc, const char *argv[])
116 if (sink)
118 - printf("-play : ambiguous output mode\n");
119 + fprintf(stderr, "-play : ambiguous output mode\n");
120 return 1;
123 @@ -289,12 +290,12 @@ int valdec(int argc, const char *argv[])
125 if (sink)
127 - printf("-raw : ambiguous output mode\n");
128 + fprintf(stderr, "-raw : ambiguous output mode\n");
129 return 1;
131 if (argc - iarg < 1)
133 - printf("-raw : specify a file name\n");
134 + fprintf(stderr, "-raw : specify a file name\n");
135 return 1;
138 @@ -311,12 +312,12 @@ int valdec(int argc, const char *argv[])
140 if (sink)
142 - printf("-wav : ambiguous output mode\n");
143 + fprintf(stderr, "-wav : ambiguous output mode\n");
144 return 1;
146 if (argc - iarg < 1)
148 - printf("-wav : specify a file name\n");
149 + fprintf(stderr, "-wav : specify a file name\n");
150 return 1;
153 @@ -333,7 +334,7 @@ int valdec(int argc, const char *argv[])
155 if (sink)
157 - printf("-nothing : ambiguous output mode\n");
158 + fprintf(stderr, "-nothing : ambiguous output mode\n");
159 return 1;
162 @@ -541,7 +542,7 @@ int valdec(int argc, const char *argv[])
164 if (have_delay) continue;
166 - printf("Error: unknown option: %s\n", argv[iarg]);
167 + fprintf(stderr, "Error: unknown option: %s\n", argv[iarg]);
168 return 1;
171 @@ -554,13 +555,13 @@ int valdec(int argc, const char *argv[])
173 if (!file.open(input_filename, parser, 1000000))
175 - printf("Error: Cannot open file '%s'\n", input_filename);
176 + fprintf(stderr, "Error: Cannot open file '%s'\n", input_filename);
177 return 1;
180 if (!file.stats() || !file.probe())
182 - printf("Error: Cannot detect input file format\n", input_filename);
183 + fprintf(stderr, "Error: Cannot detect input file format\n", input_filename);
184 return 1;
187 @@ -570,8 +571,8 @@ int valdec(int argc, const char *argv[])
189 if (print_info)
191 - printf("%s\n", file.file_info().c_str());
192 - printf("%s", file.stream_info().c_str());
193 + fprintf(stderr, "%s\n", file.file_info().c_str());
194 + fprintf(stderr, "%s", file.stream_info().c_str());
197 if (mode == mode_nothing)
198 @@ -592,14 +593,14 @@ int valdec(int argc, const char *argv[])
199 Speakers user_spk(format, mask, sample_rate);
200 if (!dvd_graph.set_user(user_spk))
202 - printf("Error: unsupported user format %s\n", user_spk.print());
203 + fprintf(stderr, "Error: unsupported user format %s\n", user_spk.print());
204 return 1;
207 Speakers in_spk = file.get_output();
208 if (!dvd_graph.open(in_spk))
210 - printf("Error: unsupported file format %s\n", in_spk.print());
211 + fprintf(stderr, "Error: unsupported file format %s\n", in_spk.print());
212 return 1;
215 @@ -633,7 +634,7 @@ int valdec(int argc, const char *argv[])
216 case mode_raw:
217 if (!out_filename || !raw.open_file(out_filename))
219 - printf("Error: failed to open output file '%s'\n", out_filename);
220 + fprintf(stderr, "Error: failed to open output file '%s'\n", out_filename);
221 return 1;
223 break;
224 @@ -641,7 +642,7 @@ int valdec(int argc, const char *argv[])
225 case mode_wav:
226 if (!out_filename || !wav.open_file(out_filename))
228 - printf("Error: failed to open output file '%s'\n", out_filename);
229 + fprintf(stderr, "Error: failed to open output file '%s'\n", out_filename);
230 return 1;
232 break;
233 @@ -649,7 +650,7 @@ int valdec(int argc, const char *argv[])
234 case mode_play:
235 if (!dsound.open_dsound(0))
237 - printf("Error: failed to init DirectSound\n");
238 + fprintf(stderr, "Error: failed to init DirectSound\n");
239 return 1;
241 break;
242 @@ -681,7 +682,7 @@ int valdec(int argc, const char *argv[])
244 file.seek(0);
246 - #define PRINT_STAT \
247 + #define PRINT_STAT do \
249 if (control) \
251 @@ -698,10 +699,16 @@ int valdec(int argc, const char *argv[])
252 int(value2db(level)), \
253 int(file.get_frames() / time), \
254 cpu_current.usage() * 100); \
256 + fflush(stderr); \
257 + } \
258 + while(0)
260 - #define DROP_STAT \
261 - fprintf(stderr, " \r");
262 + #define DROP_STAT do \
263 + { \
264 + fprintf(stderr, " \r"); \
265 + fflush(stderr); \
266 + } \
267 + while(0)
269 while (file.get_chunk(chunk))
271 @@ -714,7 +721,7 @@ int valdec(int argc, const char *argv[])
272 PRINT_STAT;
274 if (streams > 0 && print_info)
275 - printf("\n\n%s", file.stream_info().c_str());
276 + fprintf(stderr, "\n\n%s", file.stream_info().c_str());
278 streams++;
279 if (mode == mode_nothing)
280 @@ -729,11 +736,11 @@ int valdec(int argc, const char *argv[])
281 if (sink->open(new_spk))
283 DROP_STAT;
284 - printf("Opening audio output %s...\n", new_spk.print().c_str());
285 + fprintf(stderr, "Opening audio output %s...\n", new_spk.print().c_str());
287 else
289 - printf("\nOutput format %s is unsupported\n", new_spk.print().c_str());
290 + fprintf(stderr, "\nOutput format %s is unsupported\n", new_spk.print().c_str());
291 return 1;
294 @@ -760,11 +767,11 @@ int valdec(int argc, const char *argv[])
295 if (sink->open(new_spk))
297 DROP_STAT;
298 - printf("Opening audio output %s...\n", new_spk.print().c_str());
299 + fprintf(stderr, "Opening audio output %s...\n", new_spk.print().c_str());
301 else
303 - printf("\nOutput format %s is unsupported\n", new_spk.print().c_str());
304 + fprintf(stderr, "\nOutput format %s is unsupported\n", new_spk.print().c_str());
305 return 1;
308 @@ -783,13 +790,13 @@ int valdec(int argc, const char *argv[])
309 // Final statistics
311 PRINT_STAT;
312 - printf("\n---------------------------------------\n");
313 + fprintf(stderr, "\n---------------------------------------\n");
314 if (streams > 1)
315 - printf("Streams found: %i\n", streams);
316 - printf("Frames: %i\n", file.get_frames());
317 - printf("System time: %ims\n", int(cpu_total.get_system_time() * 1000));
318 - printf("Process time: %ims\n", int(cpu_total.get_thread_time() * 1000 ));
319 - printf("Approx. %.2f%% realtime CPU usage\n", double(cpu_total.get_thread_time() * 100) / file.get_size(file.time));
320 + fprintf(stderr, "Streams found: %i\n", streams);
321 + fprintf(stderr, "Frames: %i\n", file.get_frames());
322 + fprintf(stderr, "System time: %ims\n", int(cpu_total.get_system_time() * 1000));
323 + fprintf(stderr, "Process time: %ims\n", int(cpu_total.get_thread_time() * 1000 ));
324 + fprintf(stderr, "Approx. %.2f%% realtime CPU usage\n", double(cpu_total.get_thread_time() * 100) / file.get_size(file.time));
326 /////////////////////////////////////////////////////////
327 // Print levels histogram
328 @@ -806,27 +813,27 @@ int valdec(int argc, const char *argv[])
329 max_level = dvd_graph.proc.get_max_level();
330 dbpb = dvd_graph.proc.get_dbpb();
332 - printf("\nHistogram:\n");
333 - printf("------------------------------------------------------------------------------\n");
334 + fprintf(stderr, "\nHistogram:\n");
335 + fprintf(stderr, "------------------------------------------------------------------------------\n");
336 for (i = 0; i*dbpb < 100 && i < MAX_HISTOGRAM; i++)
338 - printf("%2idB: %4.1f ", i * dbpb, hist[i] * 100);
339 + fprintf(stderr, "%2idB: %4.1f ", i * dbpb, hist[i] * 100);
340 for (j = 0; j < 67 && j < hist[i] * 67; j++)
341 - printf("*");
342 - printf("\n");
343 + fprintf(stderr, "*");
344 + fprintf(stderr, "\n");
346 - printf("------------------------------------------------------------------------------\n");
347 - printf("max_level;%f\ndbpb;%i\nhistogram;", max_level, dbpb);
348 + fprintf(stderr, "------------------------------------------------------------------------------\n");
349 + fprintf(stderr, "max_level;%f\ndbpb;%i\nhistogram;", max_level, dbpb);
350 for (i = 0; i < MAX_HISTOGRAM; i++)
351 - printf("%.4f;", hist[i]);
352 - printf("\n");
353 - printf("------------------------------------------------------------------------------\n");
354 + fprintf(stderr, "%.4f;", hist[i]);
355 + fprintf(stderr, "\n");
356 + fprintf(stderr, "------------------------------------------------------------------------------\n");
359 return 0;
362 -int main(int argc, const char *argv[])
363 +int valdec_main(int argc, const char **argv)
367 @@ -834,8 +841,39 @@ int main(int argc, const char *argv[])
369 catch (ValibException &e)
371 - printf("Processing error: %s\n", boost::diagnostic_information(e).c_str());
372 + fprintf(stderr, "Processing error: %s\n", boost::diagnostic_information(e).c_str());
373 return -1;
375 return 0;
378 +int main(int argc, char *argv[])
380 + int argc_utf8;
381 + char **argv_utf8;
382 + int exit_code;
384 + __try
386 + init_console_utf8();
387 + init_commandline_arguments_utf8(&argc_utf8, &argv_utf8);
389 + __except(1)
391 + __noop();
394 + exit_code = valdec_main(argc_utf8, const_cast<const char**>(argv_utf8));
396 + __try
398 + uninit_console_utf8();
399 + free_commandline_arguments_utf8(&argc_utf8, &argv_utf8);
401 + __except(1)
403 + __noop();
406 + return exit_code;
408 diff --git a/tools/valdec.sln b/tools/valdec.sln
409 index 22b4d5b..3e76282 100644
410 --- a/tools/valdec.sln
411 +++ b/tools/valdec.sln
412 @@ -1,18 +1,13 @@
413 
414 -Microsoft Visual Studio Solution File, Format Version 10.00
415 -# Visual Studio 2008
416 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "valdec", "valdec.vcproj", "{871889DF-6EF7-461F-AC1B-7DA682CB79A0}"
417 - ProjectSection(ProjectDependencies) = postProject
418 - {30FCD216-1CAD-48FD-BF4B-337572F7EC9C} = {30FCD216-1CAD-48FD-BF4B-337572F7EC9C}
419 - {11F10C24-A2EC-4514-AD78-85CF2FEF698D} = {11F10C24-A2EC-4514-AD78-85CF2FEF698D}
420 - {B8D9A742-1BED-4B8D-BC46-3D1669F3405E} = {B8D9A742-1BED-4B8D-BC46-3D1669F3405E}
421 - EndProjectSection
422 +Microsoft Visual Studio Solution File, Format Version 11.00
423 +# Visual Studio 2010
424 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "valdec", "valdec.vcxproj", "{871889DF-6EF7-461F-AC1B-7DA682CB79A0}"
425 EndProject
426 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "valib", "..\valib\lib\valib.vcproj", "{30FCD216-1CAD-48FD-BF4B-337572F7EC9C}"
427 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "valib", "..\valib\lib\valib.vcxproj", "{30FCD216-1CAD-48FD-BF4B-337572F7EC9C}"
428 EndProject
429 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpa", "..\valib\lib\mpa.vcproj", "{11F10C24-A2EC-4514-AD78-85CF2FEF698D}"
430 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpa", "..\valib\lib\mpa.vcxproj", "{11F10C24-A2EC-4514-AD78-85CF2FEF698D}"
431 EndProject
432 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aac", "..\valib\lib\aac.vcproj", "{B8D9A742-1BED-4B8D-BC46-3D1669F3405E}"
433 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aac", "..\valib\lib\aac.vcxproj", "{B8D9A742-1BED-4B8D-BC46-3D1669F3405E}"
434 EndProject
435 Global
436 GlobalSection(SolutionConfigurationPlatforms) = preSolution
437 diff --git a/tools/valdec.suo b/tools/valdec.suo
438 index 90eaeea..a9bc645 100644
439 Binary files a/tools/valdec.suo and b/tools/valdec.suo differ
440 diff --git a/valib/3rdparty/faad/decoder.c b/valib/3rdparty/faad/decoder.c
441 index 85dd423..1dbc040 100644
442 --- a/valib/3rdparty/faad/decoder.c
443 +++ b/valib/3rdparty/faad/decoder.c
444 @@ -512,11 +512,11 @@ void NEAACDECAPI NeAACDecClose(NeAACDecHandle hpDecoder)
445 return;
447 #ifdef PROFILE
448 - printf("AAC decoder total: %I64d cycles\n", hDecoder->cycles);
449 - printf("requant: %I64d cycles\n", hDecoder->requant_cycles);
450 - printf("spectral_data: %I64d cycles\n", hDecoder->spectral_cycles);
451 - printf("scalefactors: %I64d cycles\n", hDecoder->scalefac_cycles);
452 - printf("output: %I64d cycles\n", hDecoder->output_cycles);
453 + fprintf(stderr, "AAC decoder total: %I64d cycles\n", hDecoder->cycles);
454 + fprintf(stderr, "requant: %I64d cycles\n", hDecoder->requant_cycles);
455 + fprintf(stderr, "spectral_data: %I64d cycles\n", hDecoder->spectral_cycles);
456 + fprintf(stderr, "scalefactors: %I64d cycles\n", hDecoder->scalefac_cycles);
457 + fprintf(stderr, "output: %I64d cycles\n", hDecoder->output_cycles);
458 #endif
460 for (i = 0; i < MAX_CHANNELS; i++)
461 @@ -852,7 +852,7 @@ static void* aac_frame_decode(NeAACDecStruct *hDecoder,
464 #if 0
465 - printf("%d\n", buffer_size*8);
466 + fprintf(stderr, "%d\n", buffer_size*8);
467 #endif
469 frame_len = hDecoder->frameLength;
470 @@ -901,7 +901,7 @@ static void* aac_frame_decode(NeAACDecStruct *hDecoder,
471 buf = faad_getbitbuffer(&ld, 32);
472 //temp = getdword((void*)buf);
473 temp = *((uint32_t*)buf);
474 - printf("0x%.8X\n", temp);
475 + fprintf(stderr, "0x%.8X\n", temp);
476 free(buf);
478 faad_endbits(&ld);
479 diff --git a/valib/3rdparty/faad/drm_dec.c b/valib/3rdparty/faad/drm_dec.c
480 index 61cb818..0a72fce 100644
481 --- a/valib/3rdparty/faad/drm_dec.c
482 +++ b/valib/3rdparty/faad/drm_dec.c
483 @@ -522,11 +522,11 @@ static int8_t huff_dec(bitfile *ld, drm_ps_huff_tab huff)
484 static int8_t sa_delta_clip(drm_ps_info *ps, int8_t i)
486 if (i < 0) {
487 - /* printf(" SAminclip %d", i); */
488 + /* fprintf(stderr, " SAminclip %d", i); */
489 ps->sa_decode_error = 1;
490 return 0;
491 } else if (i > 7) {
492 - /* printf(" SAmaxclip %d", i); */
493 + /* fprintf(stderr, " SAmaxclip %d", i); */
494 ps->sa_decode_error = 1;
495 return 7;
496 } else
497 @@ -536,11 +536,11 @@ static int8_t sa_delta_clip(drm_ps_info *ps, int8_t i)
498 static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i)
500 if (i < -7) {
501 - /* printf(" PANminclip %d", i); */
502 + /* fprintf(stderr, " PANminclip %d", i); */
503 ps->pan_decode_error = 1;
504 return -7;
505 } else if (i > 7) {
506 - /* printf(" PANmaxclip %d", i); */
507 + /* fprintf(stderr, " PANmaxclip %d", i); */
508 ps->pan_decode_error = 1;
509 return 7;
510 } else
511 diff --git a/valib/3rdparty/faad/filtbank.c b/valib/3rdparty/faad/filtbank.c
512 index 1b1464b..8665c27 100644
513 --- a/valib/3rdparty/faad/filtbank.c
514 +++ b/valib/3rdparty/faad/filtbank.c
515 @@ -97,7 +97,7 @@ void filter_bank_end(fb_info *fb)
516 if (fb != NULL)
518 #ifdef PROFILE
519 - printf("FB: %I64d cycles\n", fb->cycles);
520 + fprintf(stderr, "FB: %I64d cycles\n", fb->cycles);
521 #endif
523 faad_mdct_end(fb->mdct256);
524 @@ -203,12 +203,12 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
525 #if 0
526 for (i = 0; i < 1024; i++)
528 - printf("%d\n", freq_in[i]);
529 + fprintf(stderr, "%d\n", freq_in[i]);
531 #endif
533 #if 0
534 - printf("%d %d\n", window_sequence, window_shape);
535 + fprintf(stderr, "%d %d\n", window_sequence, window_shape);
536 #endif
538 switch (window_sequence)
539 @@ -319,8 +319,8 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
540 #if 0
541 for (i = 0; i < 1024; i++)
543 - printf("%d\n", time_out[i]);
544 - //printf("0x%.8X\n", time_out[i]);
545 + fprintf(stderr, "%d\n", time_out[i]);
546 + //fprintf(stderr, "0x%.8X\n", time_out[i]);
548 #endif
550 diff --git a/valib/3rdparty/faad/huffman.c b/valib/3rdparty/faad/huffman.c
551 index e2656c0..44b08f7 100644
552 --- a/valib/3rdparty/faad/huffman.c
553 +++ b/valib/3rdparty/faad/huffman.c
554 @@ -67,7 +67,7 @@ int8_t huffman_scale_factor(bitfile *ld)
556 if (offset > 240)
558 - /* printf("ERROR: offset into hcb_sf = %d >240!\n", offset); */
559 + /* fprintf(stderr, "ERROR: offset into hcb_sf = %d >240!\n", offset); */
560 return -1;
563 @@ -179,7 +179,7 @@ static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp)
565 if (offset > hcb_2_quad_table_size[cb])
567 - /* printf("ERROR: offset into hcb_2_quad_table = %d >%d!\n", offset,
568 + /* fprintf(stderr, "ERROR: offset into hcb_2_quad_table = %d >%d!\n", offset,
569 hcb_2_quad_table_size[cb]); */
570 return 10;
572 @@ -222,7 +222,7 @@ static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp)
574 if (offset > hcb_2_pair_table_size[cb])
576 - /* printf("ERROR: offset into hcb_2_pair_table = %d >%d!\n", offset,
577 + /* fprintf(stderr, "ERROR: offset into hcb_2_pair_table = %d >%d!\n", offset,
578 hcb_2_pair_table_size[cb]); */
579 return 10;
581 @@ -254,7 +254,7 @@ static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp)
583 if (offset > hcb_bin_table_size[cb])
585 - /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
586 + /* fprintf(stderr, "ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
587 hcb_bin_table_size[cb]); */
588 return 10;
590 @@ -288,7 +288,7 @@ static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp)
592 if (offset > hcb_bin_table_size[cb])
594 - /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
595 + /* fprintf(stderr, "ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
596 hcb_bin_table_size[cb]); */
597 return 10;
599 diff --git a/valib/3rdparty/faad/mdct.c b/valib/3rdparty/faad/mdct.c
600 index 247691e..9756f84 100644
601 --- a/valib/3rdparty/faad/mdct.c
602 +++ b/valib/3rdparty/faad/mdct.c
603 @@ -109,8 +109,8 @@ void faad_mdct_end(mdct_info *mdct)
604 if (mdct != NULL)
606 #ifdef PROFILE
607 - printf("MDCT[%.4d]: %I64d cycles\n", mdct->N, mdct->cycles);
608 - printf("CFFT[%.4d]: %I64d cycles\n", mdct->N/4, mdct->fft_cycles);
609 + fprintf(stderr, "MDCT[%.4d]: %I64d cycles\n", mdct->N, mdct->cycles);
610 + fprintf(stderr, "CFFT[%.4d]: %I64d cycles\n", mdct->N/4, mdct->fft_cycles);
611 #endif
613 cfftu(mdct->cfft);
614 diff --git a/valib/3rdparty/faad/ps_dec.c b/valib/3rdparty/faad/ps_dec.c
615 index 6d9c7be..ec73230 100644
616 --- a/valib/3rdparty/faad/ps_dec.c
617 +++ b/valib/3rdparty/faad/ps_dec.c
618 @@ -643,8 +643,8 @@ static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev,
619 //int8_t tmp2;
620 //int8_t tmp = index[i];
622 - //printf("%d %d\n", index_prev[i*stride], index[i]);
623 - //printf("%d\n", index[i]);
624 + //fprintf(stderr, "%d %d\n", index_prev[i*stride], index[i]);
625 + //fprintf(stderr, "%d\n", index[i]);
627 index[i] = index_prev[i*stride] + index[i];
628 //tmp2 = index[i];
629 @@ -654,7 +654,7 @@ static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev,
631 // if (index[i] == 7)
632 // {
633 - // printf("%d %d %d\n", index_prev[i*stride], tmp, tmp2);
634 + // fprintf(stderr, "%d %d %d\n", index_prev[i*stride], tmp, tmp2);
635 // }
638 @@ -991,41 +991,41 @@ static void ps_data_decode(ps_info *ps)
639 #if 0
640 for (env = 0; env < ps->num_env; env++)
642 - printf("iid[env:%d]:", env);
643 + fprintf(stderr, "iid[env:%d]:", env);
644 for (bin = 0; bin < 34; bin++)
646 - printf(" %d", ps->iid_index[env][bin]);
647 + fprintf(stderr, " %d", ps->iid_index[env][bin]);
649 - printf("\n");
650 + fprintf(stderr, "\n");
652 for (env = 0; env < ps->num_env; env++)
654 - printf("icc[env:%d]:", env);
655 + fprintf(stderr, "icc[env:%d]:", env);
656 for (bin = 0; bin < 34; bin++)
658 - printf(" %d", ps->icc_index[env][bin]);
659 + fprintf(stderr, " %d", ps->icc_index[env][bin]);
661 - printf("\n");
662 + fprintf(stderr, "\n");
664 for (env = 0; env < ps->num_env; env++)
666 - printf("ipd[env:%d]:", env);
667 + fprintf(stderr, "ipd[env:%d]:", env);
668 for (bin = 0; bin < 17; bin++)
670 - printf(" %d", ps->ipd_index[env][bin]);
671 + fprintf(stderr, " %d", ps->ipd_index[env][bin]);
673 - printf("\n");
674 + fprintf(stderr, "\n");
676 for (env = 0; env < ps->num_env; env++)
678 - printf("opd[env:%d]:", env);
679 + fprintf(stderr, "opd[env:%d]:", env);
680 for (bin = 0; bin < 17; bin++)
682 - printf(" %d", ps->opd_index[env][bin]);
683 + fprintf(stderr, " %d", ps->opd_index[env][bin]);
685 - printf("\n");
686 + fprintf(stderr, "\n");
688 - printf("\n");
689 + fprintf(stderr, "\n");
690 #endif
693 @@ -1109,9 +1109,9 @@ static void ps_decorrelate(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][
694 for (bk = 0; bk < 34; bk++)
696 #ifdef FIXED_POINT
697 - printf("%d %d: %d\n", n, bk, P[n][bk] /*/(float)REAL_PRECISION*/);
698 + fprintf(stderr, "%d %d: %d\n", n, bk, P[n][bk] /*/(float)REAL_PRECISION*/);
699 #else
700 - printf("%d %d: %f\n", n, bk, P[n][bk]/1024.0);
701 + fprintf(stderr, "%d %d: %f\n", n, bk, P[n][bk]/1024.0);
702 #endif
705 @@ -1154,9 +1154,9 @@ static void ps_decorrelate(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][
706 for (bk = 0; bk < 34; bk++)
708 #ifdef FIXED_POINT
709 - printf("%d %d: %f\n", n, bk, G_TransientRatio[n][bk]/(float)REAL_PRECISION);
710 + fprintf(stderr, "%d %d: %f\n", n, bk, G_TransientRatio[n][bk]/(float)REAL_PRECISION);
711 #else
712 - printf("%d %d: %f\n", n, bk, G_TransientRatio[n][bk]);
713 + fprintf(stderr, "%d %d: %f\n", n, bk, G_TransientRatio[n][bk]);
714 #endif
717 @@ -1506,7 +1506,7 @@ static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64
718 beta = alpha * ( c_1 - c_2 ) / sqrt(2.0);
721 - //printf("%d\n", ps->iid_index[env][bk]);
722 + //fprintf(stderr, "%d\n", ps->iid_index[env][bk]);
724 /* calculate the scalefactors c_1 and c_2 from the intensity differences */
725 c_1 = sf_iid[no_iid_steps + ps->iid_index[env][bk]];
726 diff --git a/valib/3rdparty/faad/rvlc.c b/valib/3rdparty/faad/rvlc.c
727 index 73619c6..9df7f2a 100644
728 --- a/valib/3rdparty/faad/rvlc.c
729 +++ b/valib/3rdparty/faad/rvlc.c
730 @@ -179,7 +179,7 @@ static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *l
731 int16_t noise_energy = ics->global_gain - 90 - 256;
733 #ifdef PRINT_RVLC
734 - printf("\nglobal_gain: %d\n", ics->global_gain);
735 + fprintf(stderr, "\nglobal_gain: %d\n", ics->global_gain);
736 #endif
738 for (g = 0; g < ics->num_window_groups; g++)
739 @@ -237,7 +237,7 @@ static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *l
740 break;
742 #ifdef PRINT_RVLC
743 - printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
744 + fprintf(stderr, "%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
745 ics->scale_factors[g][sfb]);
746 #endif
747 if (t == 99)
748 @@ -248,7 +248,7 @@ static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *l
751 #ifdef PRINT_RVLC
752 - printf("\n\n");
753 + fprintf(stderr, "\n\n");
754 #endif
756 return 0;
757 @@ -268,14 +268,14 @@ static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *l
758 int16_t noise_energy = ics->rev_global_gain;
760 #ifdef PRINT_RVLC
761 - printf("\nrev_global_gain: %d\n", ics->rev_global_gain);
762 + fprintf(stderr, "\nrev_global_gain: %d\n", ics->rev_global_gain);
763 #endif
765 if (intensity_used)
767 is_position = rvlc_huffman_sf(ld_sf, ld_esc, -1);
768 #ifdef PRINT_RVLC
769 - printf("is_position: %d\n", is_position);
770 + fprintf(stderr, "is_position: %d\n", is_position);
771 #endif
774 @@ -340,7 +340,7 @@ static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *l
775 break;
777 #ifdef PRINT_RVLC
778 - printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
779 + fprintf(stderr, "%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
780 ics->scale_factors[g][sfb]);
781 #endif
782 if (t == 99)
783 @@ -352,7 +352,7 @@ static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *l
786 #ifdef PRINT_RVLC
787 - printf("\n\n");
788 + fprintf(stderr, "\n\n");
789 #endif
791 return 0;
792 @@ -483,7 +483,7 @@ static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
793 return 99;
794 index += esc;
795 #ifdef PRINT_RVLC
796 - printf("esc: %d - ", esc);
797 + fprintf(stderr, "esc: %d - ", esc);
798 #endif
800 if (index == -ESC_VAL)
801 @@ -493,7 +493,7 @@ static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
802 return 99;
803 index -= esc;
804 #ifdef PRINT_RVLC
805 - printf("esc: %d - ", esc);
806 + fprintf(stderr, "esc: %d - ", esc);
807 #endif
810 diff --git a/valib/3rdparty/faad/sbr_dec.c b/valib/3rdparty/faad/sbr_dec.c
811 index 0705ddd..1aefdf0 100644
812 --- a/valib/3rdparty/faad/sbr_dec.c
813 +++ b/valib/3rdparty/faad/sbr_dec.c
814 @@ -324,7 +324,7 @@ static uint8_t sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[M
815 int i;
816 for (i = 0; i < 1024; i++)
818 - printf("%d\n", channel_buf[i]);
819 + fprintf(stderr, "%d\n", channel_buf[i]);
822 #endif
823 @@ -516,11 +516,11 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_cha
824 int i;
825 for (i = 0; i < 2048; i++)
827 - printf("%d\n", left_chan[i]);
828 + fprintf(stderr, "%d\n", left_chan[i]);
830 for (i = 0; i < 2048; i++)
832 - printf("%d\n", right_chan[i]);
833 + fprintf(stderr, "%d\n", right_chan[i]);
836 #endif
837 @@ -587,7 +587,7 @@ uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
838 int i;
839 for (i = 0; i < 2048; i++)
841 - printf("%d\n", channel[i]);
842 + fprintf(stderr, "%d\n", channel[i]);
845 #endif
846 diff --git a/valib/3rdparty/faad/sbr_fbt.c b/valib/3rdparty/faad/sbr_fbt.c
847 index 5919c7b..edd11eb 100644
848 --- a/valib/3rdparty/faad/sbr_fbt.c
849 +++ b/valib/3rdparty/faad/sbr_fbt.c
850 @@ -245,12 +245,12 @@ uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
851 sbr->N_master = (min(sbr->N_master, 64));
853 #if 0
854 - printf("f_master[%d]: ", nrBands);
855 + fprintf(stderr, "f_master[%d]: ", nrBands);
856 for (k = 0; k <= nrBands; k++)
858 - printf("%d ", sbr->f_master[k]);
859 + fprintf(stderr, "%d ", sbr->f_master[k]);
861 - printf("\n");
862 + fprintf(stderr, "\n");
863 #endif
865 return 0;
866 @@ -492,12 +492,12 @@ uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
869 #if 0
870 - printf("f_master[%d]: ", sbr->N_master);
871 + fprintf(stderr, "f_master[%d]: ", sbr->N_master);
872 for (k = 0; k <= sbr->N_master; k++)
874 - printf("%d ", sbr->f_master[k]);
875 + fprintf(stderr, "%d ", sbr->f_master[k]);
877 - printf("\n");
878 + fprintf(stderr, "\n");
879 #endif
881 return 0;
882 @@ -544,22 +544,22 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
885 #if 0
886 - printf("bs_freq_scale: %d\n", sbr->bs_freq_scale);
887 - printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
888 - printf("f_table_res[HI_RES][%d]: ", sbr->N_high);
889 + fprintf(stderr, "bs_freq_scale: %d\n", sbr->bs_freq_scale);
890 + fprintf(stderr, "bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
891 + fprintf(stderr, "f_table_res[HI_RES][%d]: ", sbr->N_high);
892 for (k = 0; k <= sbr->N_high; k++)
894 - printf("%d ", sbr->f_table_res[HI_RES][k]);
895 + fprintf(stderr, "%d ", sbr->f_table_res[HI_RES][k]);
897 - printf("\n");
898 + fprintf(stderr, "\n");
899 #endif
900 #if 0
901 - printf("f_table_res[LO_RES][%d]: ", sbr->N_low);
902 + fprintf(stderr, "f_table_res[LO_RES][%d]: ", sbr->N_low);
903 for (k = 0; k <= sbr->N_low; k++)
905 - printf("%d ", sbr->f_table_res[LO_RES][k]);
906 + fprintf(stderr, "%d ", sbr->f_table_res[LO_RES][k]);
908 - printf("\n");
909 + fprintf(stderr, "\n");
910 #endif
912 sbr->N_Q = 0;
913 @@ -603,12 +603,12 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
916 #if 0
917 - printf("f_table_noise[%d]: ", sbr->N_Q);
918 + fprintf(stderr, "f_table_noise[%d]: ", sbr->N_Q);
919 for (k = 0; k <= sbr->N_Q; k++)
921 - printf("%d ", sbr->f_table_noise[k] - sbr->kx);
922 + fprintf(stderr, "%d ", sbr->f_table_noise[k] - sbr->kx);
924 - printf("\n");
925 + fprintf(stderr, "\n");
926 #endif
928 return 0;
929 @@ -639,12 +639,12 @@ void limiter_frequency_table(sbr_info *sbr)
930 sbr->N_L[0] = 1;
932 #if 0
933 - printf("f_table_lim[%d][%d]: ", 0, sbr->N_L[0]);
934 + fprintf(stderr, "f_table_lim[%d][%d]: ", 0, sbr->N_L[0]);
935 for (k = 0; k <= sbr->N_L[0]; k++)
937 - printf("%d ", sbr->f_table_lim[0][k]);
938 + fprintf(stderr, "%d ", sbr->f_table_lim[0][k]);
940 - printf("\n");
941 + fprintf(stderr, "\n");
942 #endif
944 for (s = 1; s < 4; s++)
945 @@ -751,12 +751,12 @@ restart:
948 #if 0
949 - printf("f_table_lim[%d][%d]: ", s, sbr->N_L[s]);
950 + fprintf(stderr, "f_table_lim[%d][%d]: ", s, sbr->N_L[s]);
951 for (k = 0; k <= sbr->N_L[s]; k++)
953 - printf("%d ", sbr->f_table_lim[s][k]);
954 + fprintf(stderr, "%d ", sbr->f_table_lim[s][k]);
956 - printf("\n");
957 + fprintf(stderr, "\n");
958 #endif
961 diff --git a/valib/3rdparty/faad/sbr_syntax.c b/valib/3rdparty/faad/sbr_syntax.c
962 index 6c9b97c..44372ad 100644
963 --- a/valib/3rdparty/faad/sbr_syntax.c
964 +++ b/valib/3rdparty/faad/sbr_syntax.c
965 @@ -68,12 +68,12 @@ static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch);
966 static void sbr_reset(sbr_info *sbr)
968 #if 0
969 - printf("%d\n", sbr->bs_start_freq_prev);
970 - printf("%d\n", sbr->bs_stop_freq_prev);
971 - printf("%d\n", sbr->bs_freq_scale_prev);
972 - printf("%d\n", sbr->bs_alter_scale_prev);
973 - printf("%d\n", sbr->bs_xover_band_prev);
974 - printf("%d\n\n", sbr->bs_noise_bands_prev);
975 + fprintf(stderr, "%d\n", sbr->bs_start_freq_prev);
976 + fprintf(stderr, "%d\n", sbr->bs_stop_freq_prev);
977 + fprintf(stderr, "%d\n", sbr->bs_freq_scale_prev);
978 + fprintf(stderr, "%d\n", sbr->bs_alter_scale_prev);
979 + fprintf(stderr, "%d\n", sbr->bs_xover_band_prev);
980 + fprintf(stderr, "%d\n\n", sbr->bs_noise_bands_prev);
981 #endif
983 /* if these are different from the previous frame: Reset = 1 */
984 @@ -325,24 +325,24 @@ static void sbr_header(bitfile *ld, sbr_info *sbr)
986 #if 0
987 /* print the header to screen */
988 - printf("bs_amp_res: %d\n", sbr->bs_amp_res);
989 - printf("bs_start_freq: %d\n", sbr->bs_start_freq);
990 - printf("bs_stop_freq: %d\n", sbr->bs_stop_freq);
991 - printf("bs_xover_band: %d\n", sbr->bs_xover_band);
992 + fprintf(stderr, "bs_amp_res: %d\n", sbr->bs_amp_res);
993 + fprintf(stderr, "bs_start_freq: %d\n", sbr->bs_start_freq);
994 + fprintf(stderr, "bs_stop_freq: %d\n", sbr->bs_stop_freq);
995 + fprintf(stderr, "bs_xover_band: %d\n", sbr->bs_xover_band);
996 if (bs_header_extra_1)
998 - printf("bs_freq_scale: %d\n", sbr->bs_freq_scale);
999 - printf("bs_alter_scale: %d\n", sbr->bs_alter_scale);
1000 - printf("bs_noise_bands: %d\n", sbr->bs_noise_bands);
1001 + fprintf(stderr, "bs_freq_scale: %d\n", sbr->bs_freq_scale);
1002 + fprintf(stderr, "bs_alter_scale: %d\n", sbr->bs_alter_scale);
1003 + fprintf(stderr, "bs_noise_bands: %d\n", sbr->bs_noise_bands);
1005 if (bs_header_extra_2)
1007 - printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
1008 - printf("bs_limiter_gains: %d\n", sbr->bs_limiter_gains);
1009 - printf("bs_interpol_freq: %d\n", sbr->bs_interpol_freq);
1010 - printf("bs_smoothing_mode: %d\n", sbr->bs_smoothing_mode);
1011 + fprintf(stderr, "bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
1012 + fprintf(stderr, "bs_limiter_gains: %d\n", sbr->bs_limiter_gains);
1013 + fprintf(stderr, "bs_interpol_freq: %d\n", sbr->bs_interpol_freq);
1014 + fprintf(stderr, "bs_smoothing_mode: %d\n", sbr->bs_smoothing_mode);
1016 - printf("\n");
1017 + fprintf(stderr, "\n");
1018 #endif
1021 @@ -806,7 +806,7 @@ static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
1022 #if 0
1023 for (env = 0; env < bs_num_env; env++)
1025 - printf("freq_res[ch:%d][env:%d]: %d\n", ch, env, sbr->f[ch][env]);
1026 + fprintf(stderr, "freq_res[ch:%d][env:%d]: %d\n", ch, env, sbr->f[ch][env]);
1028 #endif
1030 diff --git a/valib/3rdparty/faad/specrec.c b/valib/3rdparty/faad/specrec.c
1031 index 011b80b..e601d0c 100644
1032 --- a/valib/3rdparty/faad/specrec.c
1033 +++ b/valib/3rdparty/faad/specrec.c
1034 @@ -455,8 +455,8 @@ static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
1036 //#define IQUANT_PRINT
1037 #ifdef IQUANT_PRINT
1038 - //printf("0x%.8X\n", sgn * tab[q]);
1039 - printf("%d\n", sgn * tab[q]);
1040 + //fprintf(stderr, "0x%.8X\n", sgn * tab[q]);
1041 + fprintf(stderr, "%d\n", sgn * tab[q]);
1042 #endif
1043 return sgn * tab[q];
1045 @@ -656,14 +656,14 @@ static uint8_t quant_to_spec(NeAACDecStruct *hDecoder,
1047 //#define SCFS_PRINT
1048 #ifdef SCFS_PRINT
1049 - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+0]);
1050 - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+1]);
1051 - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+2]);
1052 - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+3]);
1053 - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+0]);
1054 - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+1]);
1055 - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+2]);
1056 - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+3]);
1057 + fprintf(stderr, "%d\n", spec_data[gindex+(win*win_inc)+j+bin+0]);
1058 + fprintf(stderr, "%d\n", spec_data[gindex+(win*win_inc)+j+bin+1]);
1059 + fprintf(stderr, "%d\n", spec_data[gindex+(win*win_inc)+j+bin+2]);
1060 + fprintf(stderr, "%d\n", spec_data[gindex+(win*win_inc)+j+bin+3]);
1061 + //fprintf(stderr, "0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+0]);
1062 + //fprintf(stderr, "0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+1]);
1063 + //fprintf(stderr, "0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+2]);
1064 + //fprintf(stderr, "0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+3]);
1065 #endif
1066 #endif
1068 @@ -1152,13 +1152,13 @@ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_s
1069 int i;
1070 for (i = 0; i < 1024; i++)
1072 - //printf("%d\n", spec_coef1[i]);
1073 - printf("0x%.8X\n", spec_coef1[i]);
1074 + //fprintf(stderr, "%d\n", spec_coef1[i]);
1075 + fprintf(stderr, "0x%.8X\n", spec_coef1[i]);
1077 for (i = 0; i < 1024; i++)
1079 - //printf("%d\n", spec_coef2[i]);
1080 - printf("0x%.8X\n", spec_coef2[i]);
1081 + //fprintf(stderr, "%d\n", spec_coef2[i]);
1082 + fprintf(stderr, "0x%.8X\n", spec_coef2[i]);
1085 #endif
1086 @@ -1171,13 +1171,13 @@ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_s
1087 int i;
1088 for (i = 0; i < 1024; i++)
1090 - printf("%d\n", spec_coef1[i]);
1091 - //printf("0x%.8X\n", spec_coef1[i]);
1092 + fprintf(stderr, "%d\n", spec_coef1[i]);
1093 + //fprintf(stderr, "0x%.8X\n", spec_coef1[i]);
1095 for (i = 0; i < 1024; i++)
1097 - printf("%d\n", spec_coef2[i]);
1098 - //printf("0x%.8X\n", spec_coef2[i]);
1099 + fprintf(stderr, "%d\n", spec_coef2[i]);
1100 + //fprintf(stderr, "0x%.8X\n", spec_coef2[i]);
1103 #endif
1104 diff --git a/valib/3rdparty/faad/syntax.c b/valib/3rdparty/faad/syntax.c
1105 index f8e808c..185b8d2 100644
1106 --- a/valib/3rdparty/faad/syntax.c
1107 +++ b/valib/3rdparty/faad/syntax.c
1108 @@ -903,12 +903,12 @@ static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld)
1109 pul->pulse_offset[i] = (uint8_t)faad_getbits(ld, 5
1110 DEBUGVAR(1,58,"pulse_data(): pulse_offset"));
1111 #if 0
1112 - printf("%d\n", pul->pulse_offset[i]);
1113 + fprintf(stderr, "%d\n", pul->pulse_offset[i]);
1114 #endif
1115 pul->pulse_amp[i] = (uint8_t)faad_getbits(ld, 4
1116 DEBUGVAR(1,59,"pulse_data(): pulse_amp"));
1117 #if 0
1118 - printf("%d\n", pul->pulse_amp[i]);
1119 + fprintf(stderr, "%d\n", pul->pulse_amp[i]);
1120 #endif
1123 @@ -1089,7 +1089,7 @@ static uint8_t fill_element(NeAACDecStruct *hDecoder, bitfile *ld, drc_info *drc
1124 #if 0
1125 if (hDecoder->sbr[sbr_ele]->ret > 0)
1127 - printf("%s\n", NeAACDecGetErrorMessage(hDecoder->sbr[sbr_ele]->ret));
1128 + fprintf(stderr, "%s\n", NeAACDecGetErrorMessage(hDecoder->sbr[sbr_ele]->ret));
1130 #endif
1132 @@ -1661,8 +1661,8 @@ static uint8_t section_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *l
1133 sect_esc_val = (1<<sect_bits) - 1;
1135 #if 0
1136 - printf("\ntotal sfb %d\n", ics->max_sfb);
1137 - printf(" sect top cb\n");
1138 + fprintf(stderr, "\ntotal sfb %d\n", ics->max_sfb);
1139 + fprintf(stderr, " sect top cb\n");
1140 #endif
1142 for (g = 0; g < ics->num_window_groups; g++)
1143 @@ -1697,7 +1697,7 @@ static uint8_t section_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *l
1144 return 32;
1146 #if 0
1147 - printf("%d\n", ics->sect_cb[g][i]);
1148 + fprintf(stderr, "%d\n", ics->sect_cb[g][i]);
1149 #endif
1151 #ifndef DRM
1152 @@ -1744,10 +1744,10 @@ static uint8_t section_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *l
1153 ics->sect_end[g][i] = k + sect_len;
1155 #if 0
1156 - printf("%d\n", ics->sect_start[g][i]);
1157 + fprintf(stderr, "%d\n", ics->sect_start[g][i]);
1158 #endif
1159 #if 0
1160 - printf("%d\n", ics->sect_end[g][i]);
1161 + fprintf(stderr, "%d\n", ics->sect_end[g][i]);
1162 #endif
1164 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
1165 @@ -1767,12 +1767,12 @@ static uint8_t section_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *l
1167 ics->sfb_cb[g][sfb] = ics->sect_cb[g][i];
1168 #if 0
1169 - printf("%d\n", ics->sfb_cb[g][sfb]);
1170 + fprintf(stderr, "%d\n", ics->sfb_cb[g][sfb]);
1171 #endif
1174 #if 0
1175 - printf(" %6d %6d %6d\n",
1176 + fprintf(stderr, " %6d %6d %6d\n",
1178 ics->sect_end[g][i],
1179 ics->sect_cb[g][i]);
1180 @@ -1790,12 +1790,12 @@ static uint8_t section_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *l
1181 return 32;
1183 #if 0
1184 - printf("%d\n", ics->num_sec[g]);
1185 + fprintf(stderr, "%d\n", ics->num_sec[g]);
1186 #endif
1189 #if 0
1190 - printf("\n");
1191 + fprintf(stderr, "\n");
1192 #endif
1194 return 0;
1195 @@ -1832,7 +1832,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
1196 ics->scale_factors[g][sfb] = 0;
1197 //#define SF_PRINT
1198 #ifdef SF_PRINT
1199 - printf("%d\n", ics->scale_factors[g][sfb]);
1200 + fprintf(stderr, "%d\n", ics->scale_factors[g][sfb]);
1201 #endif
1202 break;
1203 case INTENSITY_HCB: /* intensity books */
1204 @@ -1843,7 +1843,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
1205 is_position += (t - 60);
1206 ics->scale_factors[g][sfb] = is_position;
1207 #ifdef SF_PRINT
1208 - printf("%d\n", ics->scale_factors[g][sfb]);
1209 + fprintf(stderr, "%d\n", ics->scale_factors[g][sfb]);
1210 #endif
1212 break;
1213 @@ -1863,7 +1863,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
1214 noise_energy += t;
1215 ics->scale_factors[g][sfb] = noise_energy;
1216 #ifdef SF_PRINT
1217 - printf("%d\n", ics->scale_factors[g][sfb]);
1218 + fprintf(stderr, "%d\n", ics->scale_factors[g][sfb]);
1219 #endif
1220 #else
1221 /* PNS not allowed in DRM */
1222 @@ -1884,7 +1884,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
1223 return 4;
1224 ics->scale_factors[g][sfb] = scale_factor;
1225 #ifdef SF_PRINT
1226 - printf("%d\n", ics->scale_factors[g][sfb]);
1227 + fprintf(stderr, "%d\n", ics->scale_factors[g][sfb]);
1228 #endif
1230 break;
1231 @@ -1946,7 +1946,7 @@ static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
1232 tns->n_filt[w] = (uint8_t)faad_getbits(ld, n_filt_bits
1233 DEBUGVAR(1,74,"tns_data(): n_filt"));
1234 #if 0
1235 - printf("%d\n", tns->n_filt[w]);
1236 + fprintf(stderr, "%d\n", tns->n_filt[w]);
1237 #endif
1239 if (tns->n_filt[w])
1240 @@ -1959,7 +1959,7 @@ static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
1241 start_coef_bits = 3;
1243 #if 0
1244 - printf("%d\n", tns->coef_res[w]);
1245 + fprintf(stderr, "%d\n", tns->coef_res[w]);
1246 #endif
1249 @@ -1968,24 +1968,24 @@ static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
1250 tns->length[w][filt] = (uint8_t)faad_getbits(ld, length_bits
1251 DEBUGVAR(1,76,"tns_data(): length"));
1252 #if 0
1253 - printf("%d\n", tns->length[w][filt]);
1254 + fprintf(stderr, "%d\n", tns->length[w][filt]);
1255 #endif
1256 tns->order[w][filt] = (uint8_t)faad_getbits(ld, order_bits
1257 DEBUGVAR(1,77,"tns_data(): order"));
1258 #if 0
1259 - printf("%d\n", tns->order[w][filt]);
1260 + fprintf(stderr, "%d\n", tns->order[w][filt]);
1261 #endif
1262 if (tns->order[w][filt])
1264 tns->direction[w][filt] = faad_get1bit(ld
1265 DEBUGVAR(1,78,"tns_data(): direction"));
1266 #if 0
1267 - printf("%d\n", tns->direction[w][filt]);
1268 + fprintf(stderr, "%d\n", tns->direction[w][filt]);
1269 #endif
1270 tns->coef_compress[w][filt] = faad_get1bit(ld
1271 DEBUGVAR(1,79,"tns_data(): coef_compress"));
1272 #if 0
1273 - printf("%d\n", tns->coef_compress[w][filt]);
1274 + fprintf(stderr, "%d\n", tns->coef_compress[w][filt]);
1275 #endif
1277 coef_bits = start_coef_bits - tns->coef_compress[w][filt];
1278 @@ -1994,7 +1994,7 @@ static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
1279 tns->coef[w][filt][i] = (uint8_t)faad_getbits(ld, coef_bits
1280 DEBUGVAR(1,80,"tns_data(): coef"));
1281 #if 0
1282 - printf("%d\n", tns->coef[w][filt][i]);
1283 + fprintf(stderr, "%d\n", tns->coef[w][filt][i]);
1284 #endif
1287 @@ -2104,20 +2104,20 @@ static uint8_t spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *
1288 int j;
1289 for (j = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; j < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; j++)
1291 - printf("%d\n", 0);
1292 + fprintf(stderr, "%d\n", 0);
1295 #endif
1296 //#define SFBO_PRINT
1297 #ifdef SFBO_PRINT
1298 - printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
1299 + fprintf(stderr, "%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
1300 #endif
1301 p += (ics->sect_sfb_offset[g][ics->sect_end[g][i]] -
1302 ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
1303 break;
1304 default:
1305 #ifdef SFBO_PRINT
1306 - printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
1307 + fprintf(stderr, "%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
1308 #endif
1309 for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]];
1310 k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc)
1311 @@ -2129,7 +2129,7 @@ static uint8_t spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *
1312 int j;
1313 for (j = p; j < p+inc; j++)
1315 - printf("%d\n", spectral_data[j]);
1316 + fprintf(stderr, "%d\n", spectral_data[j]);
1319 #endif
1320 diff --git a/valib/3rdparty/faad/tns.c b/valib/3rdparty/faad/tns.c
1321 index 6118652..bcaf661 100644
1322 --- a/valib/3rdparty/faad/tns.c
1323 +++ b/valib/3rdparty/faad/tns.c
1324 @@ -265,8 +265,8 @@ static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l
1326 //#define TNS_PRINT
1327 #ifdef TNS_PRINT
1328 - //printf("%d\n", y);
1329 - printf("0x%.8X\n", y);
1330 + //fprintf(stderr, "%d\n", y);
1331 + fprintf(stderr, "0x%.8X\n", y);
1332 #endif
1335 diff --git a/valib/3rdparty/libmpg123/icy2utf8.c b/valib/3rdparty/libmpg123/icy2utf8.c
1336 index 4e72162..abba33b 100644
1337 --- a/valib/3rdparty/libmpg123/icy2utf8.c
1338 +++ b/valib/3rdparty/libmpg123/icy2utf8.c
1339 @@ -428,7 +428,7 @@ main(void)
1340 return (1);
1343 - printf("Result is:\t\343\200\214%s\343\200\215\n"
1344 + fprintf(stderr, "Result is:\t\343\200\214%s\343\200\215\n"
1345 "\t\t\343\200\214%s\343\200\215\n", t, t2);
1347 free(t);
1348 diff --git a/valib/3rdparty/libmpg123/optimize.c b/valib/3rdparty/libmpg123/optimize.c
1349 index d5aae4c..1d8e9cd 100644
1350 --- a/valib/3rdparty/libmpg123/optimize.c
1351 +++ b/valib/3rdparty/libmpg123/optimize.c
1352 @@ -893,8 +893,8 @@ void check_decoders(void )
1353 getcpuflags(&cpu_flags);
1354 if(cpu_i586(cpu_flags))
1356 - /* not yet: if(cpu_sse2(cpu_flags)) printf(" SSE2");
1357 - if(cpu_sse3(cpu_flags)) printf(" SSE3"); */
1358 + /* not yet: if(cpu_sse2(cpu_flags)) fprintf(stderr, " SSE2");
1359 + if(cpu_sse3(cpu_flags)) fprintf(stderr, " SSE3"); */
1360 #ifdef OPT_SSE
1361 if(cpu_sse(cpu_flags)) *(d++) = decname[sse];
1362 #endif
1363 diff --git a/valib/valib/auto_file.cpp b/valib/valib/auto_file.cpp
1364 index a07ef3b..9fe23e2 100644
1365 --- a/valib/valib/auto_file.cpp
1366 +++ b/valib/valib/auto_file.cpp
1367 @@ -1,5 +1,6 @@
1368 #include <limits>
1369 #include "auto_file.h"
1370 +#include "win32/unicode_support.h"
1372 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
1374 @@ -39,7 +40,7 @@ bool
1375 AutoFile::open(const char *filename, const char *mode)
1377 if (f) close();
1378 - f = fopen(filename, mode);
1379 + f = fopen_utf8(filename, mode);
1380 if (f)
1382 filesize = bad_size;
1383 diff --git a/valib/valib/auto_file.h b/valib/valib/auto_file.h
1384 index 189d082..4f0d4eb 100644
1385 --- a/valib/valib/auto_file.h
1386 +++ b/valib/valib/auto_file.h
1387 @@ -51,7 +51,7 @@
1389 \fn AutoFile::AutoFile(const char *filename, const char *mode = "rb")
1390 \param filename File name to open
1391 - \param mode Open mode (equivalent to the mode at fopen()).
1392 + \param mode Open mode (equivalent to the mode at fopen_utf8()).
1394 Create and open a file. In case of failure, is_open() reports false.
1396 @@ -67,7 +67,7 @@
1398 \fn bool AutoFile::open(const char *filename, const char *mode = "rb")
1399 \param filename File name to open
1400 - \param mode Open mode (equivalent to the mode at fopen()).
1401 + \param mode Open mode (equivalent to the mode at fopen_utf8()).
1402 \return Returns true on success and false otherwise.
1404 Open the file.
1405 diff --git a/valib/valib/log.cpp b/valib/valib/log.cpp
1406 index f087760..6638e5c 100644
1407 --- a/valib/valib/log.cpp
1408 +++ b/valib/valib/log.cpp
1409 @@ -261,7 +261,7 @@ Log::clear_status()
1410 // erase status line (if it is)
1411 if (istatus)
1413 - printf(" \r");
1414 + fprintf(stderr, " \r");
1415 istatus = 0;
1418 diff --git a/valib/valib/sink/sink_dsound.cpp b/valib/valib/sink/sink_dsound.cpp
1419 index f22104d..8d8fcf7 100644
1420 --- a/valib/valib/sink/sink_dsound.cpp
1421 +++ b/valib/valib/sink/sink_dsound.cpp
1422 @@ -47,7 +47,7 @@ DSoundSink::open_dsound(HWND _hwnd, int _buf_size_ms, int _preload_ms, LPCGUID _
1424 // Open DirectSound
1426 - if FAILED(DirectSoundCreate(_device, &ds, 0))
1427 + if (1); //FAILED(DirectSoundCreate(_device, &ds, 0))
1428 return false;
1430 if (!_hwnd) _hwnd = GetForegroundWindow();
1431 diff --git a/valib/valib/version.h b/valib/valib/version.h
1432 index 1b119dd..e69de29 100644
1433 --- a/valib/valib/version.h
1434 +++ b/valib/valib/version.h
1435 @@ -1,4 +0,0 @@
1436 -#define VALIB_HG_REVISION 1675
1437 -#define VALIB_HG_LOCAL_MODIFICATIONS 1
1438 -#define VALIB_HG_CHANGESET "217ad09860f6eb4acc7b0e53cdcbe8b99df2ed56"
1439 -#define VALIB_HG_CHANGESET_SHORT "217ad09860f6"
1440 diff --git a/valib/valib/win32/unicode_support.c b/valib/valib/win32/unicode_support.c
1441 new file mode 100644
1442 index 0000000..f2a0a9e
1443 --- /dev/null
1444 +++ b/valib/valib/win32/unicode_support.c
1445 @@ -0,0 +1,199 @@
1446 +/* Copyright (c) 2004-2012 LoRd_MuldeR <mulder2@gmx.de>
1447 + File: unicode_support.c
1449 + This file was originally part of a patch included with LameXP,
1450 + released under the same license as the original audio tools.
1452 + Redistribution and use in source and binary forms, with or without
1453 + modification, are permitted provided that the following conditions
1454 + are met:
1456 + - Redistributions of source code must retain the above copyright
1457 + notice, this list of conditions and the following disclaimer.
1459 + - Redistributions in binary form must reproduce the above copyright
1460 + notice, this list of conditions and the following disclaimer in the
1461 + documentation and/or other materials provided with the distribution.
1463 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1464 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1465 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1466 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
1467 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1468 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1469 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1470 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1471 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1472 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1473 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1475 +#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
1477 +#include "unicode_support.h"
1479 +#include <windows.h>
1480 +#include <io.h>
1482 +static UINT g_old_output_cp = ((UINT)-1);
1484 +char *utf16_to_utf8(const wchar_t *input)
1486 + char *Buffer;
1487 + int BuffSize = 0, Result = 0;
1489 + BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
1490 + Buffer = (char*) malloc(sizeof(char) * BuffSize);
1491 + if(Buffer)
1493 + Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
1496 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1499 +char *utf16_to_ansi(const wchar_t *input)
1501 + char *Buffer;
1502 + int BuffSize = 0, Result = 0;
1504 + BuffSize = WideCharToMultiByte(CP_ACP, 0, input, -1, NULL, 0, NULL, NULL);
1505 + Buffer = (char*) malloc(sizeof(char) * BuffSize);
1506 + if(Buffer)
1508 + Result = WideCharToMultiByte(CP_ACP, 0, input, -1, Buffer, BuffSize, NULL, NULL);
1511 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1514 +wchar_t *utf8_to_utf16(const char *input)
1516 + wchar_t *Buffer;
1517 + int BuffSize = 0, Result = 0;
1519 + BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
1520 + Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
1521 + if(Buffer)
1523 + Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
1526 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1529 +void init_commandline_arguments_utf8(int *argc, char ***argv)
1531 + int i, nArgs;
1532 + LPWSTR *szArglist;
1534 + szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
1536 + if(NULL == szArglist)
1538 + fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
1539 + exit(-1);
1542 + *argv = (char**) malloc(sizeof(char*) * nArgs);
1543 + *argc = nArgs;
1545 + if(NULL == *argv)
1547 + fprintf(stderr, "\nFATAL: Malloc failed\n\n");
1548 + exit(-1);
1551 + for(i = 0; i < nArgs; i++)
1553 + (*argv)[i] = utf16_to_utf8(szArglist[i]);
1554 + if(NULL == (*argv)[i])
1556 + fprintf(stderr, "\nFATAL: utf16_to_utf8 failed\n\n");
1557 + exit(-1);
1561 + LocalFree(szArglist);
1564 +void free_commandline_arguments_utf8(int *argc, char ***argv)
1566 + int i = 0;
1568 + if(*argv != NULL)
1570 + for(i = 0; i < *argc; i++)
1572 + if((*argv)[i] != NULL)
1574 + free((*argv)[i]);
1575 + (*argv)[i] = NULL;
1578 + free(*argv);
1579 + *argv = NULL;
1583 +FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
1585 + FILE *ret = NULL;
1586 + wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
1587 + wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
1589 + if(filename_utf16 && mode_utf16)
1591 + FILE *fh = NULL;
1592 + int err = _wfopen_s(&fh, filename_utf16, mode_utf16);
1593 + if(err == 0) ret = fh;
1596 + if(filename_utf16) free(filename_utf16);
1597 + if(mode_utf16) free(mode_utf16);
1599 + return ret;
1602 +int stat_utf8(const char *path_utf8, struct _stat *buf)
1604 + int ret = -1;
1606 + wchar_t *path_utf16 = utf8_to_utf16(path_utf8);
1607 + if(path_utf16)
1609 + ret = _wstat(path_utf16, buf);
1610 + free(path_utf16);
1613 + return ret;
1616 +int unlink_utf8(const char *path_utf8)
1618 + int ret = -1;
1620 + wchar_t *path_utf16 = utf8_to_utf16(path_utf8);
1621 + if(path_utf16)
1623 + ret = _wunlink(path_utf16);
1624 + free(path_utf16);
1627 + return ret;
1630 +void init_console_utf8(void)
1632 + g_old_output_cp = GetConsoleOutputCP();
1633 + SetConsoleOutputCP(CP_UTF8);
1636 +void uninit_console_utf8(void)
1638 + if(g_old_output_cp != ((UINT)-1))
1640 + SetConsoleOutputCP(g_old_output_cp);
1644 +#endif
1645 \ No newline at end of file
1646 diff --git a/valib/valib/win32/unicode_support.cpp b/valib/valib/win32/unicode_support.cpp
1647 new file mode 100644
1648 index 0000000..13f89ba
1649 --- /dev/null
1650 +++ b/valib/valib/win32/unicode_support.cpp
1651 @@ -0,0 +1,86 @@
1652 +#include "unicode_support.h"
1654 +#include <windows.h>
1656 +char *utf16_to_utf8(const wchar_t *input)
1658 + char *Buffer;
1659 + int BuffSize, Result;
1661 + BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
1662 + Buffer = new char[BuffSize]; //(char*) malloc(sizeof(char) * BuffSize);
1663 + Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
1665 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1668 +wchar_t *utf8_to_utf16(const char *input)
1670 + wchar_t *Buffer;
1671 + int BuffSize, Result;
1673 + BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
1674 + Buffer = new wchar_t[BuffSize]; //(wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
1675 + Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
1677 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1680 +void init_commandline_arguments_utf8(int *argc, char ***argv)
1682 + int i, nArgs;
1683 + LPWSTR *szArglist;
1685 + szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
1687 + if(NULL == szArglist)
1689 + fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
1690 + exit(-1);
1693 + *argv = new char*[nArgs]; //malloc(sizeof(char*) * nArgs);
1694 + *argc = nArgs;
1696 + for(i = 0; i < nArgs; i++)
1698 + (*argv)[i] = utf16_to_utf8(szArglist[i]);
1701 + LocalFree(szArglist);
1704 +void free_commandline_arguments_utf8(int *argc, char ***argv)
1706 + if(*argv != NULL)
1708 + for(int i = 0; i < *argc; i++)
1710 + if((*argv)[i] != NULL)
1712 + delete [] ((*argv)[i]);
1713 + (*argv)[i] = NULL;
1716 + delete [] (*argv);
1717 + *argv = NULL;
1721 +FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
1723 + FILE *ret = NULL;
1725 + wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
1726 + wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
1728 + if(filename_utf16 && mode_utf16)
1730 + ret = _wfopen(filename_utf16, mode_utf16);
1733 + if(filename_utf16) delete [] filename_utf16;
1734 + if(mode_utf16) delete [] mode_utf16;
1736 + return ret;
1738 diff --git a/valib/valib/win32/unicode_support.h b/valib/valib/win32/unicode_support.h
1739 new file mode 100644
1740 index 0000000..41c2783
1741 --- /dev/null
1742 +++ b/valib/valib/win32/unicode_support.h
1743 @@ -0,0 +1,57 @@
1744 +/* Copyright (c) 2004-2012 LoRd_MuldeR <mulder2@gmx.de>
1745 + File: unicode_support.h
1747 + This file was originally part of a patch included with LameXP,
1748 + released under the same license as the original audio tools.
1750 + Redistribution and use in source and binary forms, with or without
1751 + modification, are permitted provided that the following conditions
1752 + are met:
1754 + - Redistributions of source code must retain the above copyright
1755 + notice, this list of conditions and the following disclaimer.
1757 + - Redistributions in binary form must reproduce the above copyright
1758 + notice, this list of conditions and the following disclaimer in the
1759 + documentation and/or other materials provided with the distribution.
1761 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1762 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1763 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1764 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
1765 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1766 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1767 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1768 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1769 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1770 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1771 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1773 +#ifndef UNICODE_SUPPORT_H_INCLUDED
1774 +#define UNICODE_SUPPORT_H_INCLUDED
1776 +#include <stdio.h>
1777 +#include <sys/stat.h>
1779 +#define WIN_UNICODE 1
1781 +#ifdef __cplusplus
1782 +extern "C" {
1783 +#endif
1785 +char *utf16_to_utf8(const wchar_t *input);
1786 +char *utf16_to_ansi(const wchar_t *input);
1787 +wchar_t *utf8_to_utf16(const char *input);
1788 +void init_commandline_arguments_utf8(int *argc, char ***argv);
1789 +void free_commandline_arguments_utf8(int *argc, char ***argv);
1790 +FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8);
1791 +int stat_utf8(const char *path_utf8, struct _stat *buf);
1792 +int unlink_utf8(const char *path_utf8);
1793 +void init_console_utf8(void);
1794 +void uninit_console_utf8(void);
1796 +#ifdef __cplusplus
1798 +#endif
1800 +#endif
1801 \ No newline at end of file