Updated Opus encoder/decoder libraries to v1.3 (2018-10-17) and Opus-Tools to v0...
[LameXP.git] / etc / Patches / DcaEnc-r720af20-MSVC10-UTF8+Progress+VariousImprovements.V1.diff
blob6dc091d2999c857fa1510b46766b78602a556af6
1 .gitignore | 7 +
2 Makefile.am | 26 +-
3 compiler_info.h | 61 ++++
4 config_msvc.h | 101 +++++++
5 configure.ac | 20 +-
6 dcaenc.c | 88 ++++--
7 dcaenc.h | 24 ++-
8 delphi/DcaEncAPI.pas | 44 +++
9 delphi/DcaEncTest.cfg | 38 +++
10 delphi/DcaEncTest.dof | 136 +++++++++
11 delphi/DcaEncTest.dpr | 15 +
12 delphi/DcaEncTest.res | Bin 0 -> 876 bytes
13 delphi/DcaEncTestForm.dfm | 35 +++
14 delphi/DcaEncTestForm.pas | 111 +++++++
15 dllmain.cpp | 19 ++
16 main.c | 371 +++++++++++++++++++++--
17 math_tables.h | 10 +-
18 unicode_support.c | 225 ++++++++++++++
19 unicode_support.h | 51 ++++
20 vc_solution/dcadll_vc2010.vcxproj | 126 ++++++++
21 vc_solution/dcadll_vc2010.vcxproj.filters | 48 +++
22 vc_solution/dcadll_vc2010.vcxproj.user | 3 +
23 vc_solution/dcaenc_vc2010.sln | 59 ++++
24 vc_solution/dcaenc_vc2010.vcxproj | 206 +++++++++++++
25 vc_solution/dcaenc_vc2010.vcxproj.filters | 48 +++
26 vc_solution/dcaenc_vc2010.vcxproj.user | 3 +
27 vc_solution/dcalib_vc2010.vcxproj | 114 +++++++
28 vc_solution/dcalib_vc2010.vcxproj.filters | 45 +++
29 vc_solution/dcalib_vc2010.vcxproj.user | 3 +
30 vc_solution/gentables.vcxproj | 125 ++++++++
31 vc_solution/gentables.vcxproj.filters | 33 ++
32 vc_solution/lib/EncodePointer.lib | Bin 0 -> 1058 bytes
33 vc_solution/lib/msvcrt_vc6.lib | Bin 0 -> 235942 bytes
34 wavfile.c | 467 +++++++++++++++++++----------
35 wavfile.h | 6 +-
36 xgetopt.c | 206 +++++++++++++
37 xgetopt.h | 29 ++
38 37 files changed, 2644 insertions(+), 259 deletions(-)
40 diff --git a/.gitignore b/.gitignore
41 index 2f63d9a..de6fa6a 100644
42 --- a/.gitignore
43 +++ b/.gitignore
44 @@ -29,3 +29,10 @@ libtool
45 ltmain.sh
46 missing
47 stamp-h1
48 +vc_solution/ipch/
49 +vc_solution/Win32/
50 +vc_solution/x64/
51 +vc_solution/*.opensdf
52 +vc_solution/*.sdf
53 +vc_solution/*.vcxproj.user
54 +vc_solution/*.suo
55 diff --git a/Makefile.am b/Makefile.am
56 index f89fe04..7e21572 100644
57 --- a/Makefile.am
58 +++ b/Makefile.am
59 @@ -14,19 +14,19 @@ nodist_libdcaenc_la_SOURCES = math_tables.c
60 libdcaenc_la_LDFLAGS = -version-info 0:0:0 \
61 -export-symbols $(top_srcdir)/dcaenc.sym
63 -if HAVE_ALSA
64 -plugin_LTLIBRARIES = libasound_module_pcm_dca.la
65 -plugindir = $(libdir)/alsa-lib
67 -libasound_module_pcm_dca_la_SOURCES = alsaplugin.c dcaenc.h
68 -libasound_module_pcm_dca_la_LIBADD = libdcaenc.la @ALSA_LIBS@
69 -libasound_module_pcm_dca_la_LDFLAGS = -no-undefined -avoid-version
71 -alsaconfdir = $(datadir)/alsa/pcm
72 -alsaconf_DATA = dca.conf
73 -endif
75 -dcaenc_SOURCES = main.c wavfile.c dcaenc.h wavfile.h
76 +#if HAVE_ALSA
77 +#plugin_LTLIBRARIES = libasound_module_pcm_dca.la
78 +#plugindir = $(libdir)/alsa-lib
80 +#libasound_module_pcm_dca_la_SOURCES = alsaplugin.c dcaenc.h
81 +#libasound_module_pcm_dca_la_LIBADD = libdcaenc.la @ALSA_LIBS@
82 +#libasound_module_pcm_dca_la_LDFLAGS = -no-undefined -avoid-version
84 +#alsaconfdir = $(datadir)/alsa/pcm
85 +#alsaconf_DATA = dca.conf
86 +#endif
88 +dcaenc_SOURCES = main.c wavfile.c unicode_support.c xgetopt.c dcaenc.h wavfile.h unicode_support.h xgetopt.h
89 dcaenc_LDADD = libdcaenc.la
91 gentables_SOURCES = gentables.c \
92 diff --git a/compiler_info.h b/compiler_info.h
93 new file mode 100644
94 index 0000000..01b1cc9
95 --- /dev/null
96 +++ b/compiler_info.h
97 @@ -0,0 +1,61 @@
98 +/*
99 + * This file is part of dcaenc.
101 + * Copyright (c) 2008-2011 Alexander E. Patrakov <patrakov@gmail.com>
103 + * dcaenc is free software; you can redistribute it and/or
104 + * modify it under the terms of the GNU Lesser General Public
105 + * License as published by the Free Software Foundation; either
106 + * version 2.1 of the License, or (at your option) any later version.
108 + * dcaenc is distributed in the hope that it will be useful,
109 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
110 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
111 + * Lesser General Public License for more details.
113 + * You should have received a copy of the GNU Lesser General Public
114 + * License along with dcaenc; if not, write to the Free Software
115 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
116 + */
118 +#ifndef COMPILER_INFO_H
119 +#define COMPILER_INFO_H
121 +#ifndef _T
122 +#define __T(X) #X
123 +#define _T(X) __T(X)
124 +#endif
126 +#if defined(__INTEL_COMPILER)
127 + #if (__INTEL_COMPILER >= 1200)
128 + #define __COMPILER__ "ICL 12.x"
129 + #elif (__INTEL_COMPILER >= 1100)
130 + #define __COMPILER__ = "ICL 11.x"
131 + #elif (__INTEL_COMPILER >= 1000)
132 + #define __COMPILER__ = "ICL 10.x"
133 + #else
134 + #define __COMPILER__ "ICL Unknown"
135 + #endif
136 +#elif defined(_MSC_VER)
137 + #if (_MSC_VER == 1600)
138 + #if (_MSC_FULL_VER >= 160040219)
139 + #define __COMPILER__ "MSVC 2010-SP1"
140 + #else
141 + #define __COMPILER__ "MSVC 2010"
142 + #endif
143 + #elif (_MSC_VER == 1500)
144 + #if (_MSC_FULL_VER >= 150030729)
145 + #define __COMPILER__ "MSVC 2008-SP1"
146 + #else
147 + #define __COMPILER__ "MSVC 2008"
148 + #endif
149 + #else
150 + #define __COMPILER__ "MSVC Unknown"
151 + #endif
152 +#elif defined(__GNUC__)
153 + #define __COMPILER__ "GNU GCC " _T(__GNUC__) "." _T(__GNUC_MINOR__)
154 +#else
155 + #define __COMPILER__ "Unknown"
156 +#endif
158 +#endif
159 diff --git a/config_msvc.h b/config_msvc.h
160 new file mode 100644
161 index 0000000..d72ce68
162 --- /dev/null
163 +++ b/config_msvc.h
164 @@ -0,0 +1,101 @@
165 +/* config.h. Generated from config.h.in by configure. */
166 +/* config.h.in. Generated from configure.ac by autoheader. */
168 +/* Define to 1 if you have the <dlfcn.h> header file. */
169 +/* #undef HAVE_DLFCN_H */
171 +/* Define to 1 if you have the <inttypes.h> header file. */
172 +/* #undef HAVE_INTTYPES_H */
174 +/* Define to 1 if you have the `asound' library (-lasound). */
175 +/* #undef HAVE_LIBASOUND */
177 +/* Define to 1 if you have the <memory.h> header file. */
178 +#define HAVE_MEMORY_H 1
180 +/* Define to 1 if you have the <stdint.h> header file. */
181 +#define HAVE_STDINT_H 1
183 +/* Define to 1 if you have the <stdlib.h> header file. */
184 +#define HAVE_STDLIB_H 1
186 +/* Define to 1 if you have the <strings.h> header file. */
187 +/* #undef HAVE_STRINGS_H */
189 +/* Define to 1 if you have the <string.h> header file. */
190 +#define HAVE_STRING_H 1
192 +/* Define to 1 if you have the <sys/stat.h> header file. */
193 +#define HAVE_SYS_STAT_H 1
195 +/* Define to 1 if you have the <sys/types.h> header file. */
196 +#define HAVE_SYS_TYPES_H 1
198 +/* Define to 1 if you have the <unistd.h> header file. */
199 +/* #undef HAVE_UNISTD_H */
201 +/* Define to the sub-directory in which libtool stores uninstalled libraries.
202 + */
203 +#define LT_OBJDIR ".libs/"
205 +/* Name of package */
206 +#define PACKAGE "dcaenc"
208 +/* Define to the address where bug reports for this package should be sent. */
209 +#define PACKAGE_BUGREPORT "patrakov@gmail.com"
211 +/* Define to the full name of this package. */
212 +#define PACKAGE_NAME "dcaenc"
214 +/* Define to the full name and version of this package. */
215 +#define PACKAGE_STRING "dcaenc 1"
217 +/* Define to the one symbol short name of this package. */
218 +#define PACKAGE_TARNAME "dcaenc"
220 +/* Define to the home page for this package. */
221 +#define PACKAGE_URL "http://aepatrakov.narod.ru/dcaenc/"
223 +/* Define to the version of this package. */
224 +#define PACKAGE_VERSION "1"
226 +/* Define to 1 if you have the ANSI C header files. */
227 +#define STDC_HEADERS 1
229 +/* Version number of package */
230 +#define VERSION "1"
232 +/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
233 + <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
234 + #define below would cause a syntax error. */
235 +/* #undef _UINT32_T */
237 +/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
238 + <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
239 + #define below would cause a syntax error. */
240 +/* #undef _UINT8_T */
242 +/* Define to `__inline__' or `__inline' if that's what the C compiler
243 + calls it, or to nothing if 'inline' is not supported under any name. */
244 +/* #ifndef __cplusplus */
245 +#define inline __inline
246 +/* #endif */
248 +/* Define to the type of a signed integer type of width exactly 32 bits if
249 + such a type exists and the standard includes do not define it. */
250 +/* #undef int32_t */
252 +/* Define to the type of a signed integer type of width exactly 64 bits if
253 + such a type exists and the standard includes do not define it. */
254 +/* #undef int64_t */
256 +/* Define to `unsigned int' if <sys/types.h> does not define. */
257 +/* #undef size_t */
259 +/* Define to the type of an unsigned integer type of width exactly 32 bits if
260 + such a type exists and the standard includes do not define it. */
261 +/* #undef uint32_t */
263 +/* Define to the type of an unsigned integer type of width exactly 8 bits if
264 + such a type exists and the standard includes do not define it. */
265 +/* #undef uint8_t */
266 diff --git a/configure.ac b/configure.ac
267 index db25f0a..78c0c07 100644
268 --- a/configure.ac
269 +++ b/configure.ac
270 @@ -13,7 +13,7 @@ LT_INIT([disable-static])
272 # Checks for programs.
273 AC_PROG_CC
274 -PKG_PROG_PKG_CONFIG
275 +#PKG_PROG_PKG_CONFIG
277 # Checks for libraries.
278 AC_ARG_ENABLE([alsa],
279 @@ -21,15 +21,15 @@ AC_ARG_ENABLE([alsa],
281 ac_save_LIBS="$LIBS"
283 -if test "x$enable_alsa" != "xno"; then
284 - PKG_CHECK_MODULES([ALSA], [alsa >= 1.0.11], [HAVE_ALSA=yes], [HAVE_ALSA=no])
285 - AC_CHECK_LIB(asound, snd_pcm_extplug_create,,
286 - [HAVE_ALSA=no], -ldl)
287 - if test "x$enable_alsa" = "xyes" -a "x$HAVE_ALSA" = "xno"; then
288 - AC_MSG_ERROR([ALSA libraries not found])
289 - fi
291 -AM_CONDITIONAL(HAVE_ALSA, test "x$enable_alsa" != "xno" -a "x$HAVE_ALSA" = "xyes")
292 +#if test "x$enable_alsa" != "xno"; then
293 +# PKG_CHECK_MODULES([ALSA], [alsa >= 1.0.11], [HAVE_ALSA=yes], [HAVE_ALSA=no])
294 +# AC_CHECK_LIB(asound, snd_pcm_extplug_create,,
295 +# [HAVE_ALSA=no], -ldl)
296 +# if test "x$enable_alsa" = "xyes" -a "x$HAVE_ALSA" = "xno"; then
297 +# AC_MSG_ERROR([ALSA libraries not found])
298 +# fi
299 +#fi
300 +#AM_CONDITIONAL(HAVE_ALSA, test "x$enable_alsa" != "xno" -a "x$HAVE_ALSA" = "xyes")
301 LIBS="$ac_save_LIBS"
303 # Checks for header files.
304 diff --git a/dcaenc.c b/dcaenc.c
305 index 5e762ce..bf0eacf 100644
306 --- a/dcaenc.c
307 +++ b/dcaenc.c
308 @@ -20,6 +20,7 @@
309 #include <stdio.h>
310 #include <stdlib.h>
311 #include <assert.h>
312 +#include "config.h"
313 #include "dcaenc.h"
314 #include "dcaenc_private.h"
315 #include "int_data.h"
316 @@ -30,10 +31,9 @@
317 #define div_round_up(a, b) (((a) + (b) - 1) / (b))
318 #define round_up(a, b) ((((a) + (b) - 1) / (b)) * (b))
320 -dcaenc_context dcaenc_create(int sample_rate, int channel_config,
321 - int approx_bitrate, int flags)
322 +dcaenc_context dcaenc_create(int sample_rate, int channel_config, int approx_bitrate, int flags)
324 - int i, frame_bits, bit_step, fir, useful_bitrate;
325 + int i, frame_bits, bit_step, fir, useful_bitrate, min_frame_bits;
326 dcaenc_context result;
328 i = 0;
329 @@ -60,7 +60,7 @@ dcaenc_context dcaenc_create(int sample_rate, int channel_config,
330 /* Round frame_bits up to the next permitted value */
331 frame_bits = round_up(frame_bits, bit_step);
333 - int min_frame_bits = 132 + (493 + 28 * 32) * channels_table[channel_config];
334 + min_frame_bits = 132 + (493 + 28 * 32) * channels_table[channel_config];
335 if (flags & DCAENC_FLAG_LFE)
336 min_frame_bits += 72;
338 @@ -108,19 +108,19 @@ int dcaenc_output_size(dcaenc_context c)
339 return c->frame_bits / ((c->flags & DCAENC_FLAG_28BIT) ? 7 : 8);
342 -static inline const int32_t *pcm_sample(dcaenc_context c,
343 - const int32_t *container,
344 - int sample, int channel)
345 +inline static const int32_t *pcm_sample(dcaenc_context c,
346 + const int32_t *container,
347 + int sample, int channel)
349 return &container[sample * c->channels + channel];
352 -static inline int32_t half32(int32_t a)
353 +inline static int32_t half32(int32_t a)
355 return (a + 1) >> 1;
358 -static inline int32_t mul32(int32_t a, int32_t b)
359 +inline static int32_t mul32(int32_t a, int32_t b)
361 int64_t r = (int64_t)a * b + 0x80000000ULL;
362 return r >> 32;
363 @@ -148,7 +148,7 @@ static void dcaenc_subband_transform(dcaenc_context c, const int32_t *input)
364 accum[i] = 0;
366 for (k = 0, i = hist_start, j = 0;
367 - i < 512; k = (k + 1) & 63, i++, j++)
368 + i < 512; k = (k + 1) & 63, i++, j++)
369 accum[k] += mul32(hist[i], c->band_interpolation[j]);
370 for (i = 0; i < hist_start; k = (k + 1) & 63, i++, j++)
371 accum[k] += mul32(hist[i], c->band_interpolation[j]);
372 @@ -204,7 +204,7 @@ static void dcaenc_lfe_downsample(dcaenc_context c, const int32_t *input)
373 /* Copy in 64 new samples from input */
374 for (i = 0; i < 64; i++)
375 hist[i + hist_start] = *pcm_sample(c, input,
376 - lfes * 64 + i, c->channels - 1);
377 + lfes * 64 + i, c->channels - 1);
379 hist_start = (hist_start + 64) & 511;
381 @@ -313,7 +313,7 @@ static int32_t add_cb(int32_t a, int32_t b)
383 /* accepts anything, out_cb[i] can only grow */
384 static void adjust_jnd(int samplerate_index,
385 - const int32_t in[512], int32_t out_cb[256])
386 + const int32_t in[512], int32_t out_cb[256])
388 int i, j;
389 int32_t power[256];
390 @@ -336,7 +336,7 @@ static void adjust_jnd(int samplerate_index,
391 denom = add_cb(denom, power[j] + auf[samplerate_index][i][j]);
392 for (j = 0; j < 256; j++)
393 out_cb_unnorm[j] = add_cb(out_cb_unnorm[j],
394 - -denom + auf[samplerate_index][i][j]);
395 + -denom + auf[samplerate_index][i][j]);
398 for (j = 0; j < 256; j++)
399 @@ -345,11 +345,11 @@ static void adjust_jnd(int samplerate_index,
402 typedef void (*walk_band_t)(dcaenc_context c, int band1, int band2, int f,
403 - int32_t spectrum1, int32_t spectrum2, int channel,
404 - int32_t * arg);
405 + int32_t spectrum1, int32_t spectrum2, int channel,
406 + int32_t * arg);
408 static void walk_band_low(dcaenc_context c, int band, int channel,
409 - walk_band_t walk, int32_t * arg)
410 + walk_band_t walk, int32_t * arg)
412 int f;
413 if (band == 0) {
414 @@ -358,12 +358,12 @@ static void walk_band_low(dcaenc_context c, int band, int channel,
415 } else {
416 for (f = 0; f < 8; f++)
417 walk(c, band, band - 1, 8 * band - 4 + f,
418 - c->band_spectrum[7 - f], c->band_spectrum[f], channel, arg);
419 + c->band_spectrum[7 - f], c->band_spectrum[f], channel, arg);
423 static void walk_band_high(dcaenc_context c, int band, int channel,
424 - walk_band_t walk, int32_t * arg)
425 + walk_band_t walk, int32_t * arg)
427 int f;
428 if (band == 31) {
429 @@ -372,12 +372,12 @@ static void walk_band_high(dcaenc_context c, int band, int channel,
430 } else {
431 for (f = 0; f < 8; f++)
432 walk(c, band, band + 1, 8 * band + 4 + f,
433 - c->band_spectrum[f], c->band_spectrum[7 - f], channel, arg);
434 + c->band_spectrum[f], c->band_spectrum[7 - f], channel, arg);
438 static void walk_whole_spectrum(dcaenc_context c, int channel,
439 - walk_band_t walk, int32_t * arg)
440 + walk_band_t walk, int32_t * arg)
442 int band;
443 for (band = 0; band < 32; band++)
444 @@ -453,10 +453,14 @@ static void dcaenc_find_peaks(dcaenc_context c)
447 static const int snr_fudge = 128;
448 +static const int USED_1ABITS = 1;
449 +static const int USED_NABITS = 2;
450 +static const int USED_26ABITS = 4;
452 -static void init_quantization_noise(dcaenc_context c, int noise)
453 +static int init_quantization_noise(dcaenc_context c, int noise)
455 int ch, band;
456 + int ret = 0;
458 c->consumed_bits = 132 + 493 * c->fullband_channels;
459 if (c->flags & DCAENC_FLAG_LFE)
460 @@ -472,10 +476,19 @@ static void init_quantization_noise(dcaenc_context c, int noise)
461 - c->band_masking_cb[band]
462 - noise;
464 - c->abits[band][ch] = (snr_cb >= 1312) ? 26
465 - : (snr_cb >= 222) ? (8 + mul32(snr_cb - 222, 69000000))
466 - : (snr_cb >= 0) ? (2 + mul32(snr_cb, 106000000))
467 - : 1;
468 + if (snr_cb >= 1312) {
469 + c->abits[band][ch] = 26;
470 + ret |= USED_26ABITS;
471 + } else if (snr_cb >= 222) {
472 + c->abits[band][ch] = 8 + mul32(snr_cb - 222, 69000000);
473 + ret |= USED_NABITS;
474 + } else if (snr_cb >= 0) {
475 + c->abits[band][ch] = 2 + mul32(snr_cb, 106000000);
476 + ret |= USED_NABITS;
477 + } else {
478 + c->abits[band][ch] = 1;
479 + ret |= USED_1ABITS;
484 @@ -484,36 +497,41 @@ static void init_quantization_noise(dcaenc_context c, int noise)
485 c->consumed_bits += bit_consumption[c->abits[band][ch]];
488 + return ret;
491 static void dcaenc_assign_bits(dcaenc_context c)
493 /* Find the bounds where the binary search should work */
494 - int low, high;
495 + int low, high, down, used_abits;
496 init_quantization_noise(c, c->worst_quantization_noise);
497 low = high = c->worst_quantization_noise;
498 + used_abits = 0;
499 if (c->consumed_bits > c->frame_bits) {
500 while (c->consumed_bits > c->frame_bits) {
501 + assert(("Too low bitrate should have been rejected in dcaenc_create", used_abits != USED_1ABITS));
502 low = high;
503 high += snr_fudge;
504 - init_quantization_noise(c, high);
505 + used_abits = init_quantization_noise(c, high);
507 } else {
508 while (c->consumed_bits <= c->frame_bits) {
509 high = low;
510 + if (used_abits == USED_26ABITS)
511 + goto out; /* The requested bitrate is too high, pad with zeros */
512 low -= snr_fudge;
513 - init_quantization_noise(c, low);
514 + used_abits = init_quantization_noise(c, low);
518 /* Now do a binary search between low and high to see what fits */
519 - int down;
520 for (down = snr_fudge >> 1; down; down >>= 1) {
521 init_quantization_noise(c, high - down);
522 if (c->consumed_bits <= c->frame_bits)
523 high -= down;
525 init_quantization_noise(c, high);
526 +out:
527 c->worst_quantization_noise = high;
528 if (high > c->worst_noise_ever)
529 c->worst_noise_ever = high;
530 @@ -538,8 +556,9 @@ static void bitstream_init(dcaenc_context c, uint8_t *output)
532 static void bitstream_put(dcaenc_context c, uint32_t bits, int nbits)
534 + int max_bits;
535 assert(bits < (1 << nbits));
536 - int max_bits = (c->flags & DCAENC_FLAG_28BIT) ? 28 : 32;
537 + max_bits = (c->flags & DCAENC_FLAG_28BIT) ? 28 : 32;
538 c->wrote += nbits;
539 bits &= ~(0xffffffff << nbits);
540 if (nbits + c->wbits >= max_bits) {
541 @@ -599,7 +618,7 @@ static int32_t dcaenc_quantize_value(int32_t value, softfloat quant)
542 static int32_t dcaenc_quantize(dcaenc_context c, int sample, int band, int ch)
544 int32_t result = dcaenc_quantize_value(c->subband_samples[sample][band][ch],
545 - c->quant[band][ch]);
546 + c->quant[band][ch]);
548 assert(result <= (quant_levels[c->abits[band][ch]] - 1) / 2);
549 assert(result >= -(quant_levels[c->abits[band][ch]] / 2));
550 @@ -608,11 +627,12 @@ static int32_t dcaenc_quantize(dcaenc_context c, int sample, int band, int ch)
552 static int dcaenc_calc_one_scale(int32_t peak_cb, int abits, softfloat *quant)
554 - assert(peak_cb <= 0);
555 - assert(peak_cb >= -2047);
556 - int32_t peak = cb_to_level[-peak_cb];
557 int our_nscale, try_remove;
558 + int32_t peak;
559 softfloat our_quant;
560 + assert(peak_cb <= 0);
561 + assert(peak_cb >= -2047);
562 + peak = cb_to_level[-peak_cb];
563 our_nscale = 127;
565 for (try_remove = 64; try_remove > 0; try_remove >>= 1) {
566 diff --git a/dcaenc.h b/dcaenc.h
567 index 17f01f3..f62a58b 100644
568 --- a/dcaenc.h
569 +++ b/dcaenc.h
570 @@ -48,11 +48,23 @@ typedef struct dcaenc_context_s *dcaenc_context;
571 #define DCAENC_CHANNELS_4FRONT_4REAR 14
572 #define DCAENC_CHANNELS_5FRONT_3REAR 15
574 -dcaenc_context dcaenc_create(int sample_rate, int channel_config, int approx_bitrate, int flags);
575 -int dcaenc_bitrate(dcaenc_context c);
576 -int dcaenc_input_size(dcaenc_context c);
577 -int dcaenc_output_size(dcaenc_context c);
578 -int dcaenc_convert_s32(dcaenc_context c, const int32_t *input, uint8_t *output);
579 -int dcaenc_destroy(dcaenc_context c, uint8_t *output);
580 +#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
581 + #if defined(DCADLL_VC2010_EXPORTS)
582 + #define MAKE_DLL __declspec(dllexport)
583 + #elif defined(DCADLL_VC2010_IMPORTS)
584 + #define MAKE_DLL __declspec(dllimport)
585 + #else
586 + #define MAKE_DLL
587 + #endif
588 +#else
589 + #define MAKE_DLL
590 +#endif
592 +MAKE_DLL dcaenc_context dcaenc_create(int sample_rate, int channel_config, int approx_bitrate, int flags);
593 +MAKE_DLL int dcaenc_bitrate(dcaenc_context c);
594 +MAKE_DLL int dcaenc_input_size(dcaenc_context c);
595 +MAKE_DLL int dcaenc_output_size(dcaenc_context c);
596 +MAKE_DLL int dcaenc_convert_s32(dcaenc_context c, const int32_t *input, uint8_t *output);
597 +MAKE_DLL int dcaenc_destroy(dcaenc_context c, uint8_t *output);
599 #endif
600 diff --git a/delphi/DcaEncAPI.pas b/delphi/DcaEncAPI.pas
601 new file mode 100644
602 index 0000000..7cc0735
603 --- /dev/null
604 +++ b/delphi/DcaEncAPI.pas
605 @@ -0,0 +1,44 @@
606 +unit DcaEncAPI;
608 +interface
610 +uses Windows, SysUtils;
612 +const
613 + DCAENC_FLAG_28BIT = 1;
614 + DCAENC_FLAG_BIGENDIAN = 2;
615 + DCAENC_FLAG_LFE = 4;
616 + DCAENC_FLAG_PERFECT_QMF = 8;
617 + DCAENC_FLAG_IEC_WRAP = 16;
619 + DCAENC_CHANNELS_MONO = 0;
620 + DCAENC_CHANNELS_DUAL_MONO = 1;
621 + DCAENC_CHANNELS_STEREO = 2;
622 + DCAENC_CHANNELS_STEREO_SUMDIFF = 3;
623 + DCAENC_CHANNELS_STEREO_TOTAL = 4;
624 + DCAENC_CHANNELS_3FRONT = 5;
625 + DCAENC_CHANNELS_2FRONT_1REAR = 6;
626 + DCAENC_CHANNELS_3FRONT_1REAR = 7;
627 + DCAENC_CHANNELS_2FRONT_2REAR = 8;
628 + DCAENC_CHANNELS_3FRONT_2REAR = 9;
629 + DCAENC_CHANNELS_4FRONT_2REAR = 10;
630 + DCAENC_CHANNELS_3FRONT_2REAR_1OV = 11;
631 + DCAENC_CHANNELS_3FRONT_3REAR = 12;
632 + DCAENC_CHANNELS_5FRONT_2REAR = 13;
633 + DCAENC_CHANNELS_4FRONT_4REAR = 14;
634 + DCAENC_CHANNELS_5FRONT_3REAR = 15;
636 +type
637 + TDcaEncContext = Pointer;
639 +function dcaenc_create(sample_rate, channel_config, approx_bitrate, flags: integer): TDcaEncContext; cdecl; external 'dcaenc-0.dll';
640 +function dcaenc_bitrate(c : TDcaEncContext): integer; cdecl; external 'dcaenc-0.dll';
641 +function dcaenc_input_size(c : TDcaEncContext): integer; cdecl; external 'dcaenc-0.dll';
642 +function dcaenc_output_size(c : TDcaEncContext): integer; cdecl; external 'dcaenc-0.dll';
643 +function dcaenc_convert_s32(c : TDcaEncContext; input: PLongInt; output: PByte): integer; cdecl; external 'dcaenc-0.dll';
644 +function dcaenc_destroy(c : TDcaEncContext; output: PByte): integer; cdecl; external 'dcaenc-0.dll';
646 +implementation
648 +end.
650 diff --git a/delphi/DcaEncTest.cfg b/delphi/DcaEncTest.cfg
651 new file mode 100644
652 index 0000000..30e6ed7
653 --- /dev/null
654 +++ b/delphi/DcaEncTest.cfg
655 @@ -0,0 +1,38 @@
656 +-$A8
657 +-$B-
658 +-$C+
659 +-$D+
660 +-$E-
661 +-$F-
662 +-$G+
663 +-$H+
664 +-$I+
665 +-$J-
666 +-$K-
667 +-$L+
668 +-$M-
669 +-$N+
670 +-$O+
671 +-$P+
672 +-$Q-
673 +-$R-
674 +-$S-
675 +-$T-
676 +-$U-
677 +-$V+
678 +-$W-
679 +-$X+
680 +-$YD
681 +-$Z1
682 +-cg
683 +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
684 +-H+
685 +-W+
687 +-$M16384,1048576
688 +-K$00400000
689 +-LE"e:\delphi 7\Projects\Bpl"
690 +-LN"e:\delphi 7\Projects\Bpl"
691 +-w-UNSAFE_TYPE
692 +-w-UNSAFE_CODE
693 +-w-UNSAFE_CAST
694 diff --git a/delphi/DcaEncTest.dof b/delphi/DcaEncTest.dof
695 new file mode 100644
696 index 0000000..2b75114
697 --- /dev/null
698 +++ b/delphi/DcaEncTest.dof
699 @@ -0,0 +1,136 @@
700 +[FileVersion]
701 +Version=7.0
702 +[Compiler]
703 +A=8
704 +B=0
705 +C=1
706 +D=1
707 +E=0
708 +F=0
709 +G=1
710 +H=1
711 +I=1
712 +J=0
713 +K=0
714 +L=1
715 +M=0
716 +N=1
717 +O=1
718 +P=1
719 +Q=0
720 +R=0
721 +S=0
722 +T=0
723 +U=0
724 +V=1
725 +W=0
726 +X=1
727 +Y=1
728 +Z=1
729 +ShowHints=1
730 +ShowWarnings=1
731 +UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
732 +NamespacePrefix=
733 +SymbolDeprecated=1
734 +SymbolLibrary=1
735 +SymbolPlatform=1
736 +UnitLibrary=1
737 +UnitPlatform=1
738 +UnitDeprecated=1
739 +HResultCompat=1
740 +HidingMember=1
741 +HiddenVirtual=1
742 +Garbage=1
743 +BoundsError=1
744 +ZeroNilCompat=1
745 +StringConstTruncated=1
746 +ForLoopVarVarPar=1
747 +TypedConstVarPar=1
748 +AsgToTypedConst=1
749 +CaseLabelRange=1
750 +ForVariable=1
751 +ConstructingAbstract=1
752 +ComparisonFalse=1
753 +ComparisonTrue=1
754 +ComparingSignedUnsigned=1
755 +CombiningSignedUnsigned=1
756 +UnsupportedConstruct=1
757 +FileOpen=1
758 +FileOpenUnitSrc=1
759 +BadGlobalSymbol=1
760 +DuplicateConstructorDestructor=1
761 +InvalidDirective=1
762 +PackageNoLink=1
763 +PackageThreadVar=1
764 +ImplicitImport=1
765 +HPPEMITIgnored=1
766 +NoRetVal=1
767 +UseBeforeDef=1
768 +ForLoopVarUndef=1
769 +UnitNameMismatch=1
770 +NoCFGFileFound=1
771 +MessageDirective=1
772 +ImplicitVariants=1
773 +UnicodeToLocale=1
774 +LocaleToUnicode=1
775 +ImagebaseMultiple=1
776 +SuspiciousTypecast=1
777 +PrivatePropAccessor=1
778 +UnsafeType=0
779 +UnsafeCode=0
780 +UnsafeCast=0
781 +[Linker]
782 +MapFile=0
783 +OutputObjs=0
784 +ConsoleApp=1
785 +DebugInfo=0
786 +RemoteSymbols=0
787 +MinStackSize=16384
788 +MaxStackSize=1048576
789 +ImageBase=4194304
790 +ExeDescription=
791 +[Directories]
792 +OutputDir=
793 +UnitOutputDir=
794 +PackageDLLOutputDir=
795 +PackageDCPOutputDir=
796 +SearchPath=
797 +Packages=vcl;rtl;vclx;indy;vclie;xmlrtl;inetdbbde;inet;inetdbxpress;dbrtl;soaprtl;dsnap;VclSmp;dbexpress;vcldb;dbxcds;inetdb;bdertl;vcldbx;adortl;teeui;teedb;tee;ibxpress;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;JclDeveloperTools;Jcl;JclVcl;JclContainers;JvCore;JvSystem;JvStdCtrls;JvAppFrm;JvBands;JvDB;JvDlgs;JvBDE;JvControls;JvCmp;JvCrypt;JvCustom;JvDocking;JvDotNetCtrls;JvGlobus;JvHMI;JvJans;JvManagedThreads;JvMM;JvNet;JvPageComps;JvPascalInterpreter;JvPluginSystem;JvPrintPreview;JvRuntimeDesign;JvTimeFramework;JvWizards;JvXPCtrls
798 +Conditionals=
799 +DebugSourceDirs=
800 +UsePackages=0
801 +[Parameters]
802 +RunParams=
803 +HostApplication=
804 +Launcher=
805 +UseLauncher=0
806 +DebugCWD=
807 +[Language]
808 +ActiveLang=
809 +ProjectLang=
810 +RootDir=
811 +[Version Info]
812 +IncludeVerInfo=0
813 +AutoIncBuild=0
814 +MajorVer=1
815 +MinorVer=0
816 +Release=0
817 +Build=0
818 +Debug=0
819 +PreRelease=0
820 +Special=0
821 +Private=0
822 +DLL=0
823 +Locale=1031
824 +CodePage=1252
825 +[Version Info Keys]
826 +CompanyName=
827 +FileDescription=
828 +FileVersion=1.0.0.0
829 +InternalName=
830 +LegalCopyright=
831 +LegalTrademarks=
832 +OriginalFilename=
833 +ProductName=
834 +ProductVersion=1.0.0.0
835 +Comments=
836 diff --git a/delphi/DcaEncTest.dpr b/delphi/DcaEncTest.dpr
837 new file mode 100644
838 index 0000000..613e628
839 --- /dev/null
840 +++ b/delphi/DcaEncTest.dpr
841 @@ -0,0 +1,15 @@
842 +program DcaEncTest;
844 +uses
845 + Forms,
846 + DcaEncTestForm in 'DcaEncTestForm.pas' {Form1},
847 + DcaEncAPI in 'DcaEncAPI.pas';
849 +{$R *.res}
851 +begin
852 + Application.Initialize;
853 + Application.Title := 'DCA Enc';
854 + Application.CreateForm(TForm1, Form1);
855 + Application.Run;
856 +end.
857 diff --git a/delphi/DcaEncTest.res b/delphi/DcaEncTest.res
858 new file mode 100644
859 index 0000000..1e4099b
860 Binary files /dev/null and b/delphi/DcaEncTest.res differ
861 diff --git a/delphi/DcaEncTestForm.dfm b/delphi/DcaEncTestForm.dfm
862 new file mode 100644
863 index 0000000..5fb08d1
864 --- /dev/null
865 +++ b/delphi/DcaEncTestForm.dfm
866 @@ -0,0 +1,35 @@
867 +object Form1: TForm1
868 + Left = 307
869 + Top = 231
870 + BorderIcons = [biSystemMenu, biMinimize]
871 + BorderStyle = bsDialog
872 + Caption = 'DCA Enc Test'
873 + ClientHeight = 74
874 + ClientWidth = 729
875 + Color = clBtnFace
876 + Font.Charset = DEFAULT_CHARSET
877 + Font.Color = clWindowText
878 + Font.Height = -11
879 + Font.Name = 'MS Sans Serif'
880 + Font.Style = []
881 + OldCreateOrder = False
882 + OnCloseQuery = FormCloseQuery
883 + PixelsPerInch = 96
884 + TextHeight = 13
885 + object Button1: TButton
886 + Left = 8
887 + Top = 8
888 + Width = 169
889 + Height = 25
890 + Caption = 'Begin Test'
891 + TabOrder = 0
892 + OnClick = Button1Click
893 + end
894 + object ProgressBar1: TProgressBar
895 + Left = 8
896 + Top = 48
897 + Width = 713
898 + Height = 17
899 + TabOrder = 1
900 + end
901 +end
902 diff --git a/delphi/DcaEncTestForm.pas b/delphi/DcaEncTestForm.pas
903 new file mode 100644
904 index 0000000..ae42a14
905 --- /dev/null
906 +++ b/delphi/DcaEncTestForm.pas
907 @@ -0,0 +1,111 @@
908 +unit DcaEncTestForm;
910 +interface
912 +uses
913 + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
914 + Dialogs, StdCtrls, DcaEncAPI, ComCtrls;
916 +type
917 + TForm1 = class(TForm)
918 + Button1: TButton;
919 + ProgressBar1: TProgressBar;
920 + procedure Button1Click(Sender: TObject);
921 + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
922 + private
923 + { Private-Deklarationen }
924 + public
925 + { Public-Deklarationen }
926 + end;
928 +var
929 + Form1: TForm1;
931 +implementation
933 +{$R *.dfm}
935 +procedure TForm1.Button1Click(Sender: TObject);
936 +var
937 + Context: TDcaEncContext;
938 + InputBuffer: array of LongInt;
939 + OutputBuffer: array of Byte;
940 + SamplesInInput: Integer;
941 + MaxBytesInOutput: Integer;
942 + BytesReturned: Cardinal;
943 + BytesWritten: Cardinal;
944 + i: Integer;
945 + h: THandle;
946 +const
947 + ChannelsInInput: Integer = 2;
948 + EncodeSteps: Integer = 10240;
949 +begin
950 + Button1.Enabled := False;
951 + ProgressBar1.Position := 0;
952 + Application.ProcessMessages;
954 + //Create DCA Enc context
955 + Context := dcaenc_create(44100, DCAENC_CHANNELS_STEREO, 768000, DCAENC_FLAG_BIGENDIAN);
957 + //Context created successfully?
958 + if(Context = nil) then
959 + begin
960 + ShowMessage('Failed to create context!');
961 + Exit;
962 + end;
964 + //Detect input/output size
965 + SamplesInInput := dcaenc_input_size(Context);
966 + MaxBytesInOutput := dcaenc_output_size(Context);
968 + //Some feedback
969 + ShowMessage('SamplesInInput = ' + IntToStr(SamplesInInput));
970 + ShowMessage('MaxBytesInOutput = ' + IntToStr(MaxBytesInOutput));
972 + //Allocate buffers
973 + SetLength(InputBuffer, SamplesInInput * ChannelsInInput);
974 + SetLength(OutputBuffer, MaxBytesInOutput);
976 + //ZeroBuffers
977 + ZeroMemory(@InputBuffer[0], SizeOf(LongInt) * SamplesInInput * ChannelsInInput);
978 + ZeroMemory(@OutputBuffer[0], SizeOf(Byte) * MaxBytesInOutput);
980 + //Create an output file
981 + h := CreateFile('Test.dts', GENERIC_WRITE, FILE_SHARE_READ, nil, CREATE_ALWAYS, 0, 0);
982 + if(h = INVALID_HANDLE_VALUE) then
983 + begin
984 + ShowMessage('Failed to create output file!');
985 + Exit;
986 + end;
988 + //Encode loop
989 + for i := 0 to EncodeSteps do
990 + begin
991 + // TODO: Load the next 'SamplesInInput' samples into 'InputBuffer' here!
992 + // Be aware that samples have to be 32-Bit Signed for DCAEnc.
994 + BytesReturned := dcaenc_convert_s32(Context, @InputBuffer[0], @OutputBuffer[0]);
995 + WriteFile(h, OutputBuffer[0], BytesReturned, BytesWritten, nil);
996 + ProgressBar1.Position := Round((i / EncodeSteps) * 100.0);
997 + Application.ProcessMessages;
998 + end;
1000 + //Finalize Encode
1001 + BytesReturned := dcaenc_destroy(Context, @OutputBuffer[0]);
1002 + WriteFile(h, OutputBuffer[0], BytesReturned, BytesWritten, nil);
1004 + //Close output
1005 + CloseHandle(h);
1007 + //We are done!
1008 + ShowMessage('Encode has completed :-)');
1009 + Button1.Enabled := True;
1010 + Application.ProcessMessages;
1011 +end;
1013 +procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
1014 +begin
1015 + CanClose := Button1.Enabled;
1016 +end;
1018 +end.
1019 diff --git a/dllmain.cpp b/dllmain.cpp
1020 new file mode 100644
1021 index 0000000..cd5e470
1022 --- /dev/null
1023 +++ b/dllmain.cpp
1024 @@ -0,0 +1,19 @@
1025 +// dllmain.cpp : Defines the entry point for the DLL application.
1026 +#include <Windows.h>
1028 +BOOL APIENTRY DllMain( HMODULE hModule,
1029 + DWORD ul_reason_for_call,
1030 + LPVOID lpReserved
1033 + switch (ul_reason_for_call)
1035 + case DLL_PROCESS_ATTACH:
1036 + case DLL_THREAD_ATTACH:
1037 + case DLL_THREAD_DETACH:
1038 + case DLL_PROCESS_DETACH:
1039 + break;
1041 + return TRUE;
1044 diff --git a/main.c b/main.c
1045 index dcc7034..829fd2b 100644
1046 --- a/main.c
1047 +++ b/main.c
1048 @@ -20,62 +20,373 @@
1050 #include <stdio.h>
1051 #include <stdlib.h>
1052 +#include <string.h>
1054 #include "config.h"
1056 #include "dcaenc.h"
1057 #include "wavfile.h"
1058 +#include "unicode_support.h"
1059 +#include "xgetopt.h"
1060 +#include "compiler_info.h"
1062 +//extern const int32_t prototype_filter[512];
1064 -extern const int32_t prototype_filter[512];
1065 +static char status[4] = {'|','/','-','\\'};
1066 +static const int AUTO_SELECT = -1;
1068 -int main(int argc, char *argv[])
1069 +#define BUFFSIZE_SPL 512
1070 +#define BUFFSIZE_CHN 6
1071 +#define BUFFSIZE_OUT 16384
1073 +static int dcaenc_main(int argc, char *argv[])
1075 dcaenc_context c;
1076 - int32_t data[512 * 6];
1077 - uint8_t output[16384];
1078 + int32_t data[BUFFSIZE_SPL * BUFFSIZE_CHN];
1079 + uint8_t output[BUFFSIZE_OUT];
1080 wavfile * f;
1081 FILE * outfile;
1082 + const char *error_msg;
1083 + unsigned int samples_total;
1084 + unsigned int samples_read;
1085 + unsigned int samples_read_total;
1086 + unsigned int current_pos;
1087 + double percent_done;
1088 int bitrate;
1089 int wrote;
1090 - int samples_total;
1091 + int counter;
1092 + int status_idx;
1093 + int show_ver;
1094 + int show_help;
1095 + int ignore_len;
1096 + int enc_flags;
1097 + int channel_config;
1098 + int has_lfe;
1099 + xgetopt_t opt;
1100 + char t;
1101 + char *file_input;
1102 + char *file_output;
1104 + static const int channel_map[6] = {DCAENC_CHANNELS_MONO, DCAENC_CHANNELS_STEREO, DCAENC_CHANNELS_3FRONT,
1105 + DCAENC_CHANNELS_2FRONT_2REAR, DCAENC_CHANNELS_3FRONT_2REAR, DCAENC_CHANNELS_3FRONT_2REAR};
1107 + fprintf(stderr, "%s-%s [%s]\n", PACKAGE_NAME, PACKAGE_VERSION, __DATE__);
1108 + fprintf(stderr, "Copyright (c) 2008-2011 Alexander E. Patrakov <patrakov@gmail.com>\n\n");
1109 + fprintf(stderr, "This program is free software: you can redistribute it and/or modify\n");
1110 + fprintf(stderr, "it under the terms of the GNU General Public License <http://www.gnu.org/>.\n");
1111 + fprintf(stderr, "Note that this program is distributed with ABSOLUTELY NO WARRANTY.\n\n");
1113 + // ----------------------------
1115 + file_input = NULL;
1116 + file_output = NULL;
1117 + bitrate = 0;
1118 + enc_flags = DCAENC_FLAG_BIGENDIAN;
1119 + channel_config = AUTO_SELECT;
1120 + has_lfe = 0;
1121 + show_ver = 0;
1122 + ignore_len = 0;
1123 + show_help = 0;
1125 + memset(&opt, 0, sizeof(xgetopt_t));
1126 + while((t = xgetopt(argc, argv, "i:o:b:c:fhlev", &opt)) != EOF)
1128 + switch(t)
1130 + case 'i':
1131 + file_input = opt.optarg;
1132 + break;
1133 + case 'o':
1134 + file_output = opt.optarg;
1135 + break;
1136 + case 'b':
1137 + bitrate = (int)(atof(opt.optarg) * 1000.0f);
1138 + if(bitrate > 6144000 || bitrate < 32000)
1140 + fprintf(stderr, "Bitrate must be between 32 and 6144 kbps!\n");
1141 + return 1;
1143 + break;
1144 + case 'c':
1145 + channel_config = atoi(opt.optarg) - 1;
1146 + if((channel_config < 0) || (channel_config > 15))
1148 + fprintf(stderr, "Bad channel configuration. Must be between 1 and 16!\n");
1149 + return 1;
1151 + break;
1152 + case 'f':
1153 + has_lfe = 1;
1154 + break;
1155 + case 'h':
1156 + show_help = 1;
1157 + break;
1158 + case 'l':
1159 + ignore_len = 1;
1160 + break;
1161 + case 'e':
1162 + enc_flags = enc_flags & (~DCAENC_FLAG_BIGENDIAN);
1163 + break;
1164 + case 'v':
1165 + show_ver = 1;
1166 + break;
1167 + case '?':
1168 + fprintf(stderr, "Unknown commandline option or missing argument: %s\n", argv[opt.optind-1]);
1169 + return 1;
1173 - static const int channel_map[6] = {DCAENC_CHANNELS_MONO, DCAENC_CHANNELS_STEREO, 0,
1174 - DCAENC_CHANNELS_2FRONT_2REAR, DCAENC_CHANNELS_3FRONT_2REAR, DCAENC_CHANNELS_3FRONT_2REAR };
1176 - if (argc != 4) {
1177 - if (argc == 2 && !strcmp(argv[1], "--version")) {
1178 - printf(PACKAGE_NAME "-" PACKAGE_VERSION "\n");
1179 - printf(PACKAGE_URL "\n");
1180 - return 0;
1181 - } else {
1182 - printf("Usage: dcaenc input.wav output.dts bits_per_second\n");
1183 - return 1;
1185 + // ----------------------------
1187 + if(!file_input || !file_output || bitrate < 1 || show_ver || show_help)
1189 + if(show_ver)
1191 + fprintf(stderr, PACKAGE_NAME "-" PACKAGE_VERSION "\n");
1192 + fprintf(stderr, "Compiled on " __DATE__ " at " __TIME__ " using " __COMPILER__ ".\n");
1193 + fprintf(stderr, PACKAGE_URL "\n");
1194 + return 0;
1196 + else if(show_help)
1198 + fprintf(stderr, "Usage:\n dcaenc -i <input.wav> -o <output.dts> -b <bitrate_kbps>\n\n");
1199 + fprintf(stderr, "Optional:\n");
1200 + fprintf(stderr, " -l Ignore input length, can be useful when reading from stdin\n");
1201 + fprintf(stderr, " -e Switch output endianess to Little Endian (default is: Big Endian)\n");
1202 + fprintf(stderr, " -h Print the help screen that your are looking at right now\n");
1203 + fprintf(stderr, " -c Overwrite the channel configuration (default is: Auto Selection)\n");
1204 + fprintf(stderr, " -f Add an additional LFE channel (default: used for 6ch input)\n");
1205 + fprintf(stderr, " -v Show version info\n\n");
1206 + fprintf(stderr, "Remarks:\n");
1207 + fprintf(stderr, " * Input or output file name can be \"-\" for stdin/stdout.\n");
1208 + fprintf(stderr, " * The bitrate is specified in kilobits per second and may be rounded up.\n");
1209 + fprintf(stderr, " - Use Float value for bitrates that are not a multiple of 1 kbps.\n");
1210 + fprintf(stderr, " * Supported input sample rates:\n");
1211 + fprintf(stderr, " - 32000\n");
1212 + fprintf(stderr, " - 44100\n");
1213 + fprintf(stderr, " - 48000\n");
1214 + fprintf(stderr, " - or those divided by 2 or 4\n");
1215 + fprintf(stderr, " * Supported channel modes:\n");
1216 + fprintf(stderr, " - 1: MONO\n");
1217 + fprintf(stderr, " - 2: DUAL_MONO\n");
1218 + fprintf(stderr, " - 3: STEREO\n");
1219 + fprintf(stderr, " - 4: STEREO_SUMDIFF\n");
1220 + fprintf(stderr, " - 5: STEREO_TOTAL\n");
1221 + fprintf(stderr, " - 6: 3FRONT\n");
1222 + fprintf(stderr, " - 7: 2FRONT_1REAR\n");
1223 + fprintf(stderr, " - 8: 3FRONT_1REAR\n");
1224 + fprintf(stderr, " - 9: 2FRONT_2REAR\n");
1225 + fprintf(stderr, " - 10: 3FRONT_2REAR\n");
1226 + fprintf(stderr, " - 11: 4FRONT_2REAR\n");
1227 + fprintf(stderr, " - 12: 3FRONT_2REAR_1OV\n");
1228 + fprintf(stderr, " - 13: 3FRONT_3REAR\n");
1229 + fprintf(stderr, " - 14: 5FRONT_2REAR\n");
1230 + fprintf(stderr, " - 15: 4FRONT_4REAR\n");
1231 + fprintf(stderr, " - 16: 5FRONT_3REAR\n");
1232 + fprintf(stderr, " * Supported bitrates:\n");
1233 + fprintf(stderr, " - mono @ 8 kHz: 32-2048 kbps\n");
1234 + fprintf(stderr, " - mono @ 12 kHz: 48-3072 kbps\n");
1235 + fprintf(stderr, " - mono @ 16 kHz: 48-3842 kbps\n");
1236 + fprintf(stderr, " - mono @ 22.05 kHz: 65-3842 kbps\n");
1237 + fprintf(stderr, " - mono @ 24 kHz: 71-3842 kbps\n");
1238 + fprintf(stderr, " - mono @ 32 kHz: 95-3842 kbps\n");
1239 + fprintf(stderr, " - mono @ 44.1 kHz: 130-3842 kbps\n");
1240 + fprintf(stderr, " - mono @ 48 kHz: 142-3842 kbps\n");
1241 + fprintf(stderr, " - stereo @ 8 kHz: 96-2048 kbps\n");
1242 + fprintf(stderr, " - stereo @ 12 kHz: 96-3842 kbps\n");
1243 + fprintf(stderr, " - stereo @ 16 kHz: 96-3842 kbps\n");
1244 + fprintf(stderr, " - stereo @ 22.05 kHz: 128-3842 kbps\n");
1245 + fprintf(stderr, " - stereo @ 24 kHz: 192-3842 kbps\n");
1246 + fprintf(stderr, " - stereo @ 32 kHz: 192-3842 kbps\n");
1247 + fprintf(stderr, " - stereo @ 44.1 kHz: 256-3842 kbps\n");
1248 + fprintf(stderr, " - stereo @ 48 kHz: 271-3842 kbps\n");
1249 + fprintf(stderr, " - 5.1 @ 8 kHz: 112-2048 kbps\n");
1250 + fprintf(stderr, " - 5.1 @ 12 kHz: 168-3072 kbps\n");
1251 + fprintf(stderr, " - 5.1 @ 16 kHz: 224-3842 kbps\n");
1252 + fprintf(stderr, " - 5.1 @ 22.05 kHz: 308-3842 kbps\n");
1253 + fprintf(stderr, " - 5.1 @ 32 kHz: 447-3842 kbps\n");
1254 + fprintf(stderr, " - 5.1 @ 44.1 kHz: 615-3842 kbps\n");
1255 + fprintf(stderr, " - 5.1 @ 48 kHz: 670-3842 kbps\n");
1257 + return 0;
1259 + else
1261 + fprintf(stderr, "Required arguments are missing. Use '-h' option for help!\n");
1262 + return 1;
1265 - f = wavfile_open(argv[1]);
1267 + fprintf(stderr, "Source: %s\n", file_input);
1268 + fprintf(stderr, "Output: %s\n", file_output);
1269 + fprintf(stderr, "KBit/s: %d.%03d\n\n", bitrate / 1000, bitrate % 1000);
1271 + // ----------------------------
1273 + f = wavfile_open(file_input, &error_msg, ignore_len);
1274 if (!f) {
1275 - printf("Could not open or parse %s\n", argv[1]);
1276 - return 1;
1277 + fprintf(stderr, "Could not open or parse \"%s\".\n", file_input);
1278 + fprintf(stderr, "Error: %s!\n", error_msg);
1279 + return 1;
1281 - bitrate = atoi(argv[3]);
1283 samples_total = f->samples_left;
1284 - c = dcaenc_create(f->sample_rate, channel_map[f->channels - 1], bitrate, f->channels == 6 ? DCAENC_FLAG_LFE : 0);
1286 + if(channel_config == AUTO_SELECT)
1288 + channel_config = channel_map[f->channels - 1];
1289 + if(f->channels == 6) has_lfe = 1;
1292 + if(has_lfe)
1294 + enc_flags = enc_flags | DCAENC_FLAG_LFE;
1297 + switch(f->channels - (has_lfe ? 1 : 0))
1299 + case 1:
1300 + if(!(channel_config == DCAENC_CHANNELS_MONO))
1302 + fprintf(stderr, "Invalid channel configuration for input audio!\n");
1303 + return 1;
1305 + break;
1306 + case 2:
1307 + if(!(channel_config == DCAENC_CHANNELS_DUAL_MONO || channel_config == DCAENC_CHANNELS_STEREO ||
1308 + channel_config == DCAENC_CHANNELS_STEREO_SUMDIFF || channel_config == DCAENC_CHANNELS_STEREO_TOTAL))
1310 + fprintf(stderr, "Invalid channel configuration for input audio!\n");
1311 + return 1;
1313 + break;
1314 + case 4:
1315 + if(!(channel_config == DCAENC_CHANNELS_3FRONT_1REAR || channel_config == DCAENC_CHANNELS_2FRONT_2REAR))
1317 + fprintf(stderr, "Invalid channel configuration for input audio!\n");
1318 + return 1;
1320 + break;
1321 + case 5:
1322 + if(!(channel_config == DCAENC_CHANNELS_3FRONT_2REAR))
1324 + fprintf(stderr, "Invalid channel configuration for input audio!\n");
1325 + return 1;
1327 + break;
1328 + case 6:
1329 + if(!(channel_config == DCAENC_CHANNELS_3FRONT_3REAR || channel_config == DCAENC_CHANNELS_4FRONT_2REAR ||
1330 + channel_config == DCAENC_CHANNELS_3FRONT_2REAR_1OV))
1332 + fprintf(stderr, "Invalid channel configuration for input audio!\n");
1333 + return 1;
1335 + break;
1338 + // ----------------------------
1340 + c = dcaenc_create(f->sample_rate, channel_config, bitrate, enc_flags);
1342 if (!c) {
1343 - printf("Wrong bitrate or sample rate\n");
1344 - return 1;
1345 + fprintf(stderr, "Insufficient bitrate or unsupported sample rate!\n");
1346 + return 1;
1349 + if((((size_t)(dcaenc_output_size(c))) > BUFFSIZE_OUT) || (((size_t)(dcaenc_input_size(c))) > BUFFSIZE_SPL))
1351 + fprintf(stderr, "Internal error, buffers are too small!\n", file_output);
1352 + return 1;
1354 - outfile = fopen(argv[2], "wb");
1355 - if (!outfile) {
1356 - printf("Could not open %s\n", argv[2]);
1357 - return 1;
1359 + outfile = strcmp(file_output, "-") ? fopen_utf8(file_output, "wb") : stdout;
1360 + if(!outfile) {
1361 + fprintf(stderr, "Could not open \"%s\" for writing!\n", file_output);
1362 + return 1;
1364 - while (wavfile_read_s32(f, data)) {
1366 + fflush(stdout);
1367 + fflush(stderr);
1369 + // ----------------------------
1371 + counter = 0;
1372 + samples_read_total = 0;
1373 + status_idx = 0;
1375 + while(samples_read = wavfile_read_s32(f, data, BUFFSIZE_SPL))
1377 + samples_read_total += samples_read;
1378 wrote = dcaenc_convert_s32(c, data, output);
1379 fwrite(output, 1, wrote, outfile);
1381 + if(counter == 0)
1383 + current_pos = samples_read_total / f->sample_rate;
1385 + if((samples_total > 0) && (samples_total < UNKNOWN_SIZE))
1387 + percent_done = ((double)(samples_total - f->samples_left)) / ((double)(samples_total));
1388 + fprintf(stderr, "Encoding... %d:%02d [%3.1f%%]\r", current_pos / 60, current_pos % 60, percent_done * 100.0);
1389 + fflush(stderr);
1391 + else
1393 + fprintf(stderr, "Encoding... %d:%02d [%c]\r", current_pos / 60, current_pos % 60, status[(status_idx = (status_idx+1) % 4)]);
1394 + fflush(stderr);
1398 + counter = (counter+1) % 125;
1401 + fprintf(stderr, "Encoding... %d:%02d [%3.1f%%]\n", (samples_read_total / f->sample_rate) / 60, (samples_read_total / f->sample_rate) % 60, 100.0);
1402 + fflush(stderr);
1404 wrote = dcaenc_destroy(c, output);
1405 fwrite(output, 1, wrote, outfile);
1406 - fclose(outfile);
1407 + if(outfile != stdout)
1409 + fclose(outfile);
1411 wavfile_close(f);
1413 + fprintf(stderr, "Done.\n");
1414 return 0;
1417 +#ifdef _WIN32
1419 +#include <Windows.h>
1420 +#include <io.h>
1421 +#include <fcntl.h>
1423 +int main( int argc, char **argv )
1425 + int dcaenc_argc;
1426 + char **dcaenc_argv;
1427 + UINT old_cp;
1428 + int exit_code;
1430 + _setmode(_fileno(stdin), _O_BINARY);
1431 + _setmode(_fileno(stdout), _O_BINARY);
1433 + old_cp = GetConsoleOutputCP();
1434 + SetConsoleOutputCP(CP_UTF8);
1436 + init_commandline_arguments_utf8(&dcaenc_argc, &dcaenc_argv);
1437 + exit_code = dcaenc_main(dcaenc_argc, dcaenc_argv);
1438 + free_commandline_arguments_utf8(&dcaenc_argc, &dcaenc_argv);
1440 + SetConsoleOutputCP(old_cp);
1441 + return exit_code;
1444 +#else //_WIN32
1446 +int main( int argc, char **argv )
1448 + return dcaenc_main(argc, argv);
1451 +#endif //_WIN32
1452 \ No newline at end of file
1453 diff --git a/math_tables.h b/math_tables.h
1454 index ce2e6c4..2b97618 100644
1455 --- a/math_tables.h
1456 +++ b/math_tables.h
1457 @@ -17,12 +17,18 @@ extern const int32_t cb_to_add[256];
1459 extern const int quant_levels_cb[27];
1461 -static inline int32_t cos_t(int x)
1462 +#ifdef _MSC_VER
1463 +#define INLINE __forceinline
1464 +#else
1465 +#define INLINE inline
1466 +#endif
1468 +INLINE static int32_t cos_t(int x)
1470 return cos_table[x & 2047];
1473 -static inline int32_t sin_t(int x)
1474 +INLINE static int32_t sin_t(int x)
1476 return cos_t(x - 512);
1478 diff --git a/unicode_support.c b/unicode_support.c
1479 new file mode 100644
1480 index 0000000..283325c
1481 --- /dev/null
1482 +++ b/unicode_support.c
1483 @@ -0,0 +1,225 @@
1484 +/*
1485 + * This file is part of dcaenc.
1487 + * Copyright (c) 2008-2011 Alexander E. Patrakov <patrakov@gmail.com>
1489 + * dcaenc is free software; you can redistribute it and/or
1490 + * modify it under the terms of the GNU Lesser General Public
1491 + * License as published by the Free Software Foundation; either
1492 + * version 2.1 of the License, or (at your option) any later version.
1494 + * dcaenc is distributed in the hope that it will be useful,
1495 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1496 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1497 + * Lesser General Public License for more details.
1499 + * You should have received a copy of the GNU Lesser General Public
1500 + * License along with dcaenc; if not, write to the Free Software
1501 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1502 + */
1503 +#include "unicode_support.h"
1505 +#ifdef _WIN32
1507 +#include <windows.h>
1508 +#include <sys/stat.h>
1509 +#include <stdio.h>
1510 +#include <wchar.h>
1512 +char *utf16_to_utf8(const wchar_t *input)
1514 + char *Buffer;
1515 + int BuffSize = 0, Result = 0;
1517 + BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
1518 + Buffer = (char*) malloc(sizeof(char) * BuffSize);
1519 + if(Buffer)
1521 + Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
1524 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1527 +char *utf16_to_ansi(const wchar_t *input)
1529 + char *Buffer;
1530 + int BuffSize = 0, Result = 0;
1532 + BuffSize = WideCharToMultiByte(CP_ACP, 0, input, -1, NULL, 0, NULL, NULL);
1533 + Buffer = (char*) malloc(sizeof(char) * BuffSize);
1534 + if(Buffer)
1536 + Result = WideCharToMultiByte(CP_ACP, 0, input, -1, Buffer, BuffSize, NULL, NULL);
1539 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1542 +wchar_t *utf8_to_utf16(const char *input)
1544 + wchar_t *Buffer;
1545 + int BuffSize = 0, Result = 0;
1547 + BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
1548 + Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
1549 + if(Buffer)
1551 + Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
1554 + return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
1557 +void init_commandline_arguments_utf8(int *argc, char ***argv)
1559 + int i, nArgs;
1560 + LPWSTR *szArglist;
1562 + szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
1564 + if(NULL == szArglist)
1566 + fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
1567 + exit(-1);
1570 + *argv = (char**) malloc(sizeof(char*) * nArgs);
1571 + *argc = nArgs;
1573 + if(NULL == *argv)
1575 + fprintf(stderr, "\nFATAL: Malloc failed\n\n");
1576 + exit(-1);
1579 + for(i = 0; i < nArgs; i++)
1581 + (*argv)[i] = utf16_to_utf8(szArglist[i]);
1582 + if(NULL == (*argv)[i])
1584 + fprintf(stderr, "\nFATAL: utf16_to_utf8 failed\n\n");
1585 + exit(-1);
1589 + LocalFree(szArglist);
1592 +void free_commandline_arguments_utf8(int *argc, char ***argv)
1594 + int i = 0;
1596 + if(*argv != NULL)
1598 + for(i = 0; i < *argc; i++)
1600 + if((*argv)[i] != NULL)
1602 + free((*argv)[i]);
1603 + (*argv)[i] = NULL;
1606 + free(*argv);
1607 + *argv = NULL;
1611 +FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8)
1613 + FILE *ret = NULL;
1614 + wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
1615 + wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
1617 + if(filename_utf16 && mode_utf16)
1619 + ret = _wfopen(filename_utf16, mode_utf16);
1622 + if(filename_utf16) free(filename_utf16);
1623 + if(mode_utf16) free(mode_utf16);
1625 + return ret;
1628 +/* int stat_utf8(const char *path_utf8, struct stat *buf)
1630 + int ret = -1;
1632 + wchar_t *path_utf16 = utf8_to_utf16(path_utf8);
1633 + if(path_utf16)
1635 + ret = wstat(path_utf16, buf);
1636 + free(path_utf16);
1639 + return ret;
1640 +} */
1642 +int rename_utf8(const char *oldname_utf8, const char *newname_utf8)
1644 + int ret = -1;
1646 + wchar_t *oldname_utf16 = utf8_to_utf16(oldname_utf8);
1647 + wchar_t *newname_utf16 = utf8_to_utf16(newname_utf8);
1649 + if(oldname_utf16 && newname_utf16)
1651 + _wunlink(newname_utf16);
1652 + ret = _wrename(oldname_utf16, newname_utf16);
1655 + if(newname_utf16) free(newname_utf16);
1656 + if(oldname_utf16) free(oldname_utf16);
1658 + return ret;
1661 +char *path_utf8_to_ansi(const char *psz_filename_utf8, int b_create)
1663 + char *short_path = NULL;
1664 + wchar_t *psz_filename_utf16 = NULL;
1666 + if(!psz_filename_utf8)
1668 + return NULL;
1671 + psz_filename_utf16 = utf8_to_utf16(psz_filename_utf8);
1672 + if(psz_filename_utf16)
1674 + char *psz_filename_ansi = NULL;
1675 + if(b_create)
1677 + FILE *fh = _wfopen(psz_filename_utf16, L"a+");
1678 + if(fh) fclose(fh);
1680 + psz_filename_ansi = utf16_to_ansi(psz_filename_utf16);
1681 + if(psz_filename_ansi)
1683 + if(strcmp(psz_filename_ansi, psz_filename_utf8))
1685 + wchar_t short_name_utf16[MAX_PATH];
1686 + DWORD result = GetShortPathNameW(psz_filename_utf16, short_name_utf16, MAX_PATH);
1687 + if((result > 0) && (result < MAX_PATH))
1689 + short_path = utf16_to_ansi(short_name_utf16);
1690 + free(psz_filename_ansi);
1692 + else
1694 + short_path = psz_filename_ansi; /*if GetShortPathName() failed, use the ANSI version*/
1697 + else
1699 + short_path = psz_filename_ansi; /*don't convert plain ASCII filenames to "short" path*/
1702 + free(psz_filename_utf16);
1705 + return short_path;
1708 +#endif //_WIN32
1709 diff --git a/unicode_support.h b/unicode_support.h
1710 new file mode 100644
1711 index 0000000..96d9ec1
1712 --- /dev/null
1713 +++ b/unicode_support.h
1714 @@ -0,0 +1,51 @@
1715 +/*
1716 + * This file is part of dcaenc.
1718 + * Copyright (c) 2008-2011 Alexander E. Patrakov <patrakov@gmail.com>
1720 + * dcaenc is free software; you can redistribute it and/or
1721 + * modify it under the terms of the GNU Lesser General Public
1722 + * License as published by the Free Software Foundation; either
1723 + * version 2.1 of the License, or (at your option) any later version.
1725 + * dcaenc is distributed in the hope that it will be useful,
1726 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1727 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1728 + * Lesser General Public License for more details.
1730 + * You should have received a copy of the GNU Lesser General Public
1731 + * License along with dcaenc; if not, write to the Free Software
1732 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1733 + */
1734 +#ifndef UNICODE_SUPPORT_H_INCLUDED
1735 +#define UNICODE_SUPPORT_H_INCLUDED
1737 +#include <ctype.h>
1738 +#include <stdio.h>
1739 +#include <stdlib.h>
1741 +#ifdef __cplusplus
1742 +extern "C" {
1743 +#endif
1745 +#ifdef _WIN32
1746 +#ifndef _INC_STAT
1747 +struct stat;
1748 +#endif
1749 +char *utf16_to_utf8(const wchar_t *input);
1750 +char *utf16_to_ansi(const wchar_t *input);
1751 +wchar_t *utf8_to_utf16(const char *input);
1752 +void init_commandline_arguments_utf8(int *argc, char ***argv);
1753 +void free_commandline_arguments_utf8(int *argc, char ***argv);
1754 +FILE *fopen_utf8(const char *filename_utf8, const char *mode_utf8);
1755 +int rename_utf8(const char *oldname_utf8, const char *newname_utf8);
1756 +char *path_utf8_to_ansi(const char *psz_filename_utf8, int b_create);
1757 +#else
1758 +#define fopen_utf8(NAME, MODE) fopen(NAME, MODE)
1759 +#define rename_utf8(OLD, NEW) rename(OLD, NEW)
1760 +#endif
1762 +#ifdef __cplusplus
1764 +#endif
1765 +#endif
1766 \ No newline at end of file
1767 diff --git a/vc_solution/dcadll_vc2010.vcxproj b/vc_solution/dcadll_vc2010.vcxproj
1768 new file mode 100644
1769 index 0000000..807df23
1770 --- /dev/null
1771 +++ b/vc_solution/dcadll_vc2010.vcxproj
1772 @@ -0,0 +1,126 @@
1773 +<?xml version="1.0" encoding="utf-8"?>
1774 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1775 + <ItemGroup Label="ProjectConfigurations">
1776 + <ProjectConfiguration Include="Debug|Win32">
1777 + <Configuration>Debug</Configuration>
1778 + <Platform>Win32</Platform>
1779 + </ProjectConfiguration>
1780 + <ProjectConfiguration Include="Release|Win32">
1781 + <Configuration>Release</Configuration>
1782 + <Platform>Win32</Platform>
1783 + </ProjectConfiguration>
1784 + </ItemGroup>
1785 + <ItemGroup>
1786 + <ClCompile Include="..\dcaenc.c" />
1787 + <ClCompile Include="..\dllmain.cpp" />
1788 + <ClCompile Include="..\math_tables.c" />
1789 + </ItemGroup>
1790 + <ItemGroup>
1791 + <ClInclude Include="..\dcaenc.h" />
1792 + <ClInclude Include="..\dcaenc_private.h" />
1793 + <ClInclude Include="..\float_data.h" />
1794 + <ClInclude Include="..\int_data.h" />
1795 + <ClInclude Include="..\math_tables.h" />
1796 + <ClInclude Include="..\softfloat.h" />
1797 + </ItemGroup>
1798 + <PropertyGroup Label="Globals">
1799 + <ProjectGuid>{8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}</ProjectGuid>
1800 + <Keyword>Win32Proj</Keyword>
1801 + <RootNamespace>dcadll_vc2010</RootNamespace>
1802 + </PropertyGroup>
1803 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
1804 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
1805 + <ConfigurationType>DynamicLibrary</ConfigurationType>
1806 + <UseDebugLibraries>true</UseDebugLibraries>
1807 + <CharacterSet>Unicode</CharacterSet>
1808 + </PropertyGroup>
1809 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
1810 + <ConfigurationType>DynamicLibrary</ConfigurationType>
1811 + <UseDebugLibraries>false</UseDebugLibraries>
1812 + <WholeProgramOptimization>true</WholeProgramOptimization>
1813 + <CharacterSet>Unicode</CharacterSet>
1814 + <PlatformToolset>Windows7.1SDK</PlatformToolset>
1815 + </PropertyGroup>
1816 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
1817 + <ImportGroup Label="ExtensionSettings">
1818 + </ImportGroup>
1819 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
1820 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
1821 + </ImportGroup>
1822 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
1823 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
1824 + </ImportGroup>
1825 + <PropertyGroup Label="UserMacros" />
1826 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
1827 + <LinkIncremental>true</LinkIncremental>
1828 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\dll\</IntDir>
1829 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
1830 + <TargetName>dcaenc-0</TargetName>
1831 + </PropertyGroup>
1832 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
1833 + <LinkIncremental>false</LinkIncremental>
1834 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\dll\</IntDir>
1835 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
1836 + <TargetName>dcaenc-0</TargetName>
1837 + </PropertyGroup>
1838 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
1839 + <ClCompile>
1840 + <PrecompiledHeader>NotUsing</PrecompiledHeader>
1841 + <WarningLevel>Level3</WarningLevel>
1842 + <Optimization>Disabled</Optimization>
1843 + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DCADLL_VC2010_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1844 + </ClCompile>
1845 + <Link>
1846 + <SubSystem>Windows</SubSystem>
1847 + <GenerateDebugInformation>true</GenerateDebugInformation>
1848 + <ImportLibrary>$(TargetDir)$(TargetName)_imp.lib</ImportLibrary>
1849 + </Link>
1850 + <PreBuildEvent>
1851 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
1852 + </PreBuildEvent>
1853 + <PreBuildEvent>
1854 + <Message>Create: "$(SolutionDir)config.h"</Message>
1855 + </PreBuildEvent>
1856 + </ItemDefinitionGroup>
1857 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
1858 + <ClCompile>
1859 + <WarningLevel>Level3</WarningLevel>
1860 + <PrecompiledHeader>NotUsing</PrecompiledHeader>
1861 + <Optimization>Full</Optimization>
1862 + <FunctionLevelLinking>true</FunctionLevelLinking>
1863 + <IntrinsicFunctions>true</IntrinsicFunctions>
1864 + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DCADLL_VC2010_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1865 + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
1866 + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
1867 + <OmitFramePointers>true</OmitFramePointers>
1868 + <WholeProgramOptimization>true</WholeProgramOptimization>
1869 + <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
1870 + <FloatingPointModel>Fast</FloatingPointModel>
1871 + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
1872 + <BufferSecurityCheck>false</BufferSecurityCheck>
1873 + <CreateHotpatchableImage>false</CreateHotpatchableImage>
1874 + </ClCompile>
1875 + <Link>
1876 + <SubSystem>Windows</SubSystem>
1877 + <GenerateDebugInformation>false</GenerateDebugInformation>
1878 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
1879 + <OptimizeReferences>true</OptimizeReferences>
1880 + <ImportLibrary>$(TargetDir)$(TargetName).dll.lib</ImportLibrary>
1881 + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
1882 + <AdditionalDependencies>$(SolutionDir)lib\EncodePointer.lib;$(SolutionDir)lib\msvcrt_vc6.lib;%(AdditionalDependencies)</AdditionalDependencies>
1883 + <MinimumRequiredVersion>5.0</MinimumRequiredVersion>
1884 + <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
1885 + <NoEntryPoint>true</NoEntryPoint>
1886 + </Link>
1887 + <ProjectReference />
1888 + <PreBuildEvent>
1889 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
1890 + </PreBuildEvent>
1891 + <PreBuildEvent>
1892 + <Message>Create: "$(SolutionDir)config.h"</Message>
1893 + </PreBuildEvent>
1894 + </ItemDefinitionGroup>
1895 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
1896 + <ImportGroup Label="ExtensionTargets">
1897 + </ImportGroup>
1898 +</Project>
1899 \ No newline at end of file
1900 diff --git a/vc_solution/dcadll_vc2010.vcxproj.filters b/vc_solution/dcadll_vc2010.vcxproj.filters
1901 new file mode 100644
1902 index 0000000..d98bb04
1903 --- /dev/null
1904 +++ b/vc_solution/dcadll_vc2010.vcxproj.filters
1905 @@ -0,0 +1,48 @@
1906 +<?xml version="1.0" encoding="utf-8"?>
1907 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1908 + <ItemGroup>
1909 + <Filter Include="Source Files">
1910 + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
1911 + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
1912 + </Filter>
1913 + <Filter Include="Header Files">
1914 + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
1915 + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
1916 + </Filter>
1917 + <Filter Include="Resource Files">
1918 + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
1919 + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
1920 + </Filter>
1921 + </ItemGroup>
1922 + <ItemGroup>
1923 + <ClCompile Include="..\dllmain.cpp">
1924 + <Filter>Source Files</Filter>
1925 + </ClCompile>
1926 + <ClCompile Include="..\dcaenc.c">
1927 + <Filter>Source Files</Filter>
1928 + </ClCompile>
1929 + <ClCompile Include="..\math_tables.c">
1930 + <Filter>Source Files</Filter>
1931 + </ClCompile>
1932 + </ItemGroup>
1933 + <ItemGroup>
1934 + <ClInclude Include="..\softfloat.h">
1935 + <Filter>Header Files</Filter>
1936 + </ClInclude>
1937 + <ClInclude Include="..\dcaenc.h">
1938 + <Filter>Header Files</Filter>
1939 + </ClInclude>
1940 + <ClInclude Include="..\dcaenc_private.h">
1941 + <Filter>Header Files</Filter>
1942 + </ClInclude>
1943 + <ClInclude Include="..\float_data.h">
1944 + <Filter>Header Files</Filter>
1945 + </ClInclude>
1946 + <ClInclude Include="..\int_data.h">
1947 + <Filter>Header Files</Filter>
1948 + </ClInclude>
1949 + <ClInclude Include="..\math_tables.h">
1950 + <Filter>Header Files</Filter>
1951 + </ClInclude>
1952 + </ItemGroup>
1953 +</Project>
1954 \ No newline at end of file
1955 diff --git a/vc_solution/dcadll_vc2010.vcxproj.user b/vc_solution/dcadll_vc2010.vcxproj.user
1956 new file mode 100644
1957 index 0000000..ace9a86
1958 --- /dev/null
1959 +++ b/vc_solution/dcadll_vc2010.vcxproj.user
1960 @@ -0,0 +1,3 @@
1961 +<?xml version="1.0" encoding="utf-8"?>
1962 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1963 +</Project>
1964 \ No newline at end of file
1965 diff --git a/vc_solution/dcaenc_vc2010.sln b/vc_solution/dcaenc_vc2010.sln
1966 new file mode 100644
1967 index 0000000..2b49e18
1968 --- /dev/null
1969 +++ b/vc_solution/dcaenc_vc2010.sln
1970 @@ -0,0 +1,59 @@
1971 +
1972 +Microsoft Visual Studio Solution File, Format Version 11.00
1973 +# Visual Studio 2010
1974 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dcaenc_vc2010", "dcaenc_vc2010.vcxproj", "{F90211C8-0718-46F1-AD58-683FA005BFA5}"
1975 + ProjectSection(ProjectDependencies) = postProject
1976 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866} = {282DDEDF-52A5-442E-90DE-94ABEC4B4866}
1977 + EndProjectSection
1978 +EndProject
1979 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dcalib_vc2010", "dcalib_vc2010.vcxproj", "{B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}"
1980 + ProjectSection(ProjectDependencies) = postProject
1981 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866} = {282DDEDF-52A5-442E-90DE-94ABEC4B4866}
1982 + EndProjectSection
1983 +EndProject
1984 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dcadll_vc2010", "dcadll_vc2010.vcxproj", "{8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}"
1985 + ProjectSection(ProjectDependencies) = postProject
1986 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866} = {282DDEDF-52A5-442E-90DE-94ABEC4B4866}
1987 + EndProjectSection
1988 +EndProject
1989 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gentables", "gentables.vcxproj", "{282DDEDF-52A5-442E-90DE-94ABEC4B4866}"
1990 +EndProject
1991 +Global
1992 + GlobalSection(SolutionConfigurationPlatforms) = preSolution
1993 + Debug|Win32 = Debug|Win32
1994 + Debug|x64 = Debug|x64
1995 + Release|Win32 = Release|Win32
1996 + Release|x64 = Release|x64
1997 + EndGlobalSection
1998 + GlobalSection(ProjectConfigurationPlatforms) = postSolution
1999 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Debug|Win32.ActiveCfg = Debug|Win32
2000 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Debug|Win32.Build.0 = Debug|Win32
2001 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Debug|x64.ActiveCfg = Debug|x64
2002 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Debug|x64.Build.0 = Debug|x64
2003 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Release|Win32.ActiveCfg = Release|Win32
2004 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Release|Win32.Build.0 = Release|Win32
2005 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Release|x64.ActiveCfg = Release|x64
2006 + {F90211C8-0718-46F1-AD58-683FA005BFA5}.Release|x64.Build.0 = Release|x64
2007 + {B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}.Debug|Win32.ActiveCfg = Debug|Win32
2008 + {B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}.Debug|Win32.Build.0 = Debug|Win32
2009 + {B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}.Debug|x64.ActiveCfg = Debug|Win32
2010 + {B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}.Release|Win32.ActiveCfg = Release|Win32
2011 + {B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}.Release|Win32.Build.0 = Release|Win32
2012 + {B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}.Release|x64.ActiveCfg = Release|Win32
2013 + {8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}.Debug|Win32.ActiveCfg = Debug|Win32
2014 + {8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}.Debug|Win32.Build.0 = Debug|Win32
2015 + {8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}.Debug|x64.ActiveCfg = Debug|Win32
2016 + {8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}.Release|Win32.ActiveCfg = Release|Win32
2017 + {8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}.Release|Win32.Build.0 = Release|Win32
2018 + {8AFCA1B5-C8F1-4F56-91F7-80415FFEB663}.Release|x64.ActiveCfg = Release|Win32
2019 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866}.Debug|Win32.ActiveCfg = Debug|Win32
2020 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866}.Debug|Win32.Build.0 = Debug|Win32
2021 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866}.Debug|x64.ActiveCfg = Debug|Win32
2022 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866}.Release|Win32.ActiveCfg = Release|Win32
2023 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866}.Release|Win32.Build.0 = Release|Win32
2024 + {282DDEDF-52A5-442E-90DE-94ABEC4B4866}.Release|x64.ActiveCfg = Release|Win32
2025 + EndGlobalSection
2026 + GlobalSection(SolutionProperties) = preSolution
2027 + HideSolutionNode = FALSE
2028 + EndGlobalSection
2029 +EndGlobal
2030 diff --git a/vc_solution/dcaenc_vc2010.vcxproj b/vc_solution/dcaenc_vc2010.vcxproj
2031 new file mode 100644
2032 index 0000000..39cb22b
2033 --- /dev/null
2034 +++ b/vc_solution/dcaenc_vc2010.vcxproj
2035 @@ -0,0 +1,206 @@
2036 +<?xml version="1.0" encoding="utf-8"?>
2037 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2038 + <ItemGroup Label="ProjectConfigurations">
2039 + <ProjectConfiguration Include="Debug|Win32">
2040 + <Configuration>Debug</Configuration>
2041 + <Platform>Win32</Platform>
2042 + </ProjectConfiguration>
2043 + <ProjectConfiguration Include="Debug|x64">
2044 + <Configuration>Debug</Configuration>
2045 + <Platform>x64</Platform>
2046 + </ProjectConfiguration>
2047 + <ProjectConfiguration Include="Release|Win32">
2048 + <Configuration>Release</Configuration>
2049 + <Platform>Win32</Platform>
2050 + </ProjectConfiguration>
2051 + <ProjectConfiguration Include="Release|x64">
2052 + <Configuration>Release</Configuration>
2053 + <Platform>x64</Platform>
2054 + </ProjectConfiguration>
2055 + </ItemGroup>
2056 + <ItemGroup>
2057 + <ClInclude Include="..\compiler_info.h" />
2058 + <ClInclude Include="..\unicode_support.h" />
2059 + <ClInclude Include="..\wavfile.h" />
2060 + <ClInclude Include="..\xgetopt.h" />
2061 + </ItemGroup>
2062 + <ItemGroup>
2063 + <ClCompile Include="..\alsaplugin.c">
2064 + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
2065 + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
2066 + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
2067 + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
2068 + </ClCompile>
2069 + <ClCompile Include="..\main.c" />
2070 + <ClCompile Include="..\unicode_support.c" />
2071 + <ClCompile Include="..\wavfile.c" />
2072 + <ClCompile Include="..\xgetopt.c" />
2073 + </ItemGroup>
2074 + <ItemGroup>
2075 + <ProjectReference Include="dcalib_vc2010.vcxproj">
2076 + <Project>{b4ad2963-8469-4dbd-bd26-fad4fe303f8f}</Project>
2077 + </ProjectReference>
2078 + </ItemGroup>
2079 + <PropertyGroup Label="Globals">
2080 + <ProjectGuid>{F90211C8-0718-46F1-AD58-683FA005BFA5}</ProjectGuid>
2081 + <Keyword>Win32Proj</Keyword>
2082 + <RootNamespace>dcaenc_vc2010</RootNamespace>
2083 + </PropertyGroup>
2084 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2085 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2086 + <ConfigurationType>Application</ConfigurationType>
2087 + <UseDebugLibraries>true</UseDebugLibraries>
2088 + <CharacterSet>Unicode</CharacterSet>
2089 + </PropertyGroup>
2090 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
2091 + <ConfigurationType>Application</ConfigurationType>
2092 + <UseDebugLibraries>true</UseDebugLibraries>
2093 + <CharacterSet>Unicode</CharacterSet>
2094 + </PropertyGroup>
2095 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
2096 + <ConfigurationType>Application</ConfigurationType>
2097 + <UseDebugLibraries>false</UseDebugLibraries>
2098 + <WholeProgramOptimization>true</WholeProgramOptimization>
2099 + <CharacterSet>Unicode</CharacterSet>
2100 + <PlatformToolset>Windows7.1SDK</PlatformToolset>
2101 + </PropertyGroup>
2102 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
2103 + <ConfigurationType>Application</ConfigurationType>
2104 + <UseDebugLibraries>false</UseDebugLibraries>
2105 + <WholeProgramOptimization>true</WholeProgramOptimization>
2106 + <CharacterSet>Unicode</CharacterSet>
2107 + <PlatformToolset>Windows7.1SDK</PlatformToolset>
2108 + </PropertyGroup>
2109 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
2110 + <ImportGroup Label="ExtensionSettings">
2111 + </ImportGroup>
2112 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2113 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2114 + </ImportGroup>
2115 + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
2116 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2117 + </ImportGroup>
2118 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2119 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2120 + </ImportGroup>
2121 + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
2122 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2123 + </ImportGroup>
2124 + <PropertyGroup Label="UserMacros" />
2125 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2126 + <LinkIncremental>true</LinkIncremental>
2127 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2128 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\</IntDir>
2129 + </PropertyGroup>
2130 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
2131 + <LinkIncremental>true</LinkIncremental>
2132 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2133 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\</IntDir>
2134 + </PropertyGroup>
2135 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2136 + <LinkIncremental>false</LinkIncremental>
2137 + <TargetName>dcaenc</TargetName>
2138 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2139 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\</IntDir>
2140 + </PropertyGroup>
2141 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
2142 + <LinkIncremental>false</LinkIncremental>
2143 + <TargetName>dcaenc</TargetName>
2144 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2145 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\</IntDir>
2146 + </PropertyGroup>
2147 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2148 + <ClCompile>
2149 + <PrecompiledHeader>NotUsing</PrecompiledHeader>
2150 + <WarningLevel>Level3</WarningLevel>
2151 + <Optimization>Disabled</Optimization>
2152 + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2153 + </ClCompile>
2154 + <Link>
2155 + <SubSystem>Console</SubSystem>
2156 + <GenerateDebugInformation>true</GenerateDebugInformation>
2157 + </Link>
2158 + <PreBuildEvent>
2159 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
2160 + <Message>Create: "$(SolutionDir)config.h"</Message>
2161 + </PreBuildEvent>
2162 + </ItemDefinitionGroup>
2163 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
2164 + <ClCompile>
2165 + <PrecompiledHeader>
2166 + </PrecompiledHeader>
2167 + <WarningLevel>Level3</WarningLevel>
2168 + <Optimization>Disabled</Optimization>
2169 + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2170 + </ClCompile>
2171 + <Link>
2172 + <SubSystem>Console</SubSystem>
2173 + <GenerateDebugInformation>true</GenerateDebugInformation>
2174 + </Link>
2175 + </ItemDefinitionGroup>
2176 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2177 + <ClCompile>
2178 + <WarningLevel>Level3</WarningLevel>
2179 + <PrecompiledHeader>NotUsing</PrecompiledHeader>
2180 + <Optimization>Full</Optimization>
2181 + <FunctionLevelLinking>true</FunctionLevelLinking>
2182 + <IntrinsicFunctions>true</IntrinsicFunctions>
2183 + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2184 + <MultiProcessorCompilation>true</MultiProcessorCompilation>
2185 + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
2186 + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
2187 + <OmitFramePointers>true</OmitFramePointers>
2188 + <WholeProgramOptimization>true</WholeProgramOptimization>
2189 + <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
2190 + <BufferSecurityCheck>false</BufferSecurityCheck>
2191 + <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
2192 + <FloatingPointModel>Fast</FloatingPointModel>
2193 + <CreateHotpatchableImage>false</CreateHotpatchableImage>
2194 + </ClCompile>
2195 + <Link>
2196 + <SubSystem>Console</SubSystem>
2197 + <GenerateDebugInformation>false</GenerateDebugInformation>
2198 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
2199 + <OptimizeReferences>true</OptimizeReferences>
2200 + <MinimumRequiredVersion>5.0</MinimumRequiredVersion>
2201 + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
2202 + <AdditionalDependencies>$(SolutionDir)lib\EncodePointer.lib;%(AdditionalDependencies)</AdditionalDependencies>
2203 + </Link>
2204 + <PreBuildEvent>
2205 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
2206 + <Message>Create: "$(SolutionDir)config.h"</Message>
2207 + </PreBuildEvent>
2208 + </ItemDefinitionGroup>
2209 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
2210 + <ClCompile>
2211 + <WarningLevel>Level3</WarningLevel>
2212 + <PrecompiledHeader>NotUsing</PrecompiledHeader>
2213 + <Optimization>Full</Optimization>
2214 + <FunctionLevelLinking>true</FunctionLevelLinking>
2215 + <IntrinsicFunctions>true</IntrinsicFunctions>
2216 + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2217 + <MultiProcessorCompilation>true</MultiProcessorCompilation>
2218 + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
2219 + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
2220 + <OmitFramePointers>true</OmitFramePointers>
2221 + <WholeProgramOptimization>true</WholeProgramOptimization>
2222 + <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
2223 + <BufferSecurityCheck>false</BufferSecurityCheck>
2224 + <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
2225 + <FloatingPointModel>Fast</FloatingPointModel>
2226 + <CreateHotpatchableImage>false</CreateHotpatchableImage>
2227 + </ClCompile>
2228 + <Link>
2229 + <SubSystem>Console</SubSystem>
2230 + <GenerateDebugInformation>false</GenerateDebugInformation>
2231 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
2232 + <OptimizeReferences>true</OptimizeReferences>
2233 + <MinimumRequiredVersion>
2234 + </MinimumRequiredVersion>
2235 + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
2236 + </Link>
2237 + </ItemDefinitionGroup>
2238 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
2239 + <ImportGroup Label="ExtensionTargets">
2240 + </ImportGroup>
2241 +</Project>
2242 \ No newline at end of file
2243 diff --git a/vc_solution/dcaenc_vc2010.vcxproj.filters b/vc_solution/dcaenc_vc2010.vcxproj.filters
2244 new file mode 100644
2245 index 0000000..9af5b8d
2246 --- /dev/null
2247 +++ b/vc_solution/dcaenc_vc2010.vcxproj.filters
2248 @@ -0,0 +1,48 @@
2249 +<?xml version="1.0" encoding="utf-8"?>
2250 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2251 + <ItemGroup>
2252 + <Filter Include="Source Files">
2253 + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
2254 + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
2255 + </Filter>
2256 + <Filter Include="Header Files">
2257 + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
2258 + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
2259 + </Filter>
2260 + <Filter Include="Resource Files">
2261 + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
2262 + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
2263 + </Filter>
2264 + </ItemGroup>
2265 + <ItemGroup>
2266 + <ClInclude Include="..\unicode_support.h">
2267 + <Filter>Header Files</Filter>
2268 + </ClInclude>
2269 + <ClInclude Include="..\wavfile.h">
2270 + <Filter>Header Files</Filter>
2271 + </ClInclude>
2272 + <ClInclude Include="..\xgetopt.h">
2273 + <Filter>Header Files</Filter>
2274 + </ClInclude>
2275 + <ClInclude Include="..\compiler_info.h">
2276 + <Filter>Header Files</Filter>
2277 + </ClInclude>
2278 + </ItemGroup>
2279 + <ItemGroup>
2280 + <ClCompile Include="..\alsaplugin.c">
2281 + <Filter>Source Files</Filter>
2282 + </ClCompile>
2283 + <ClCompile Include="..\main.c">
2284 + <Filter>Source Files</Filter>
2285 + </ClCompile>
2286 + <ClCompile Include="..\unicode_support.c">
2287 + <Filter>Source Files</Filter>
2288 + </ClCompile>
2289 + <ClCompile Include="..\wavfile.c">
2290 + <Filter>Source Files</Filter>
2291 + </ClCompile>
2292 + <ClCompile Include="..\xgetopt.c">
2293 + <Filter>Source Files</Filter>
2294 + </ClCompile>
2295 + </ItemGroup>
2296 +</Project>
2297 \ No newline at end of file
2298 diff --git a/vc_solution/dcaenc_vc2010.vcxproj.user b/vc_solution/dcaenc_vc2010.vcxproj.user
2299 new file mode 100644
2300 index 0000000..ace9a86
2301 --- /dev/null
2302 +++ b/vc_solution/dcaenc_vc2010.vcxproj.user
2303 @@ -0,0 +1,3 @@
2304 +<?xml version="1.0" encoding="utf-8"?>
2305 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2306 +</Project>
2307 \ No newline at end of file
2308 diff --git a/vc_solution/dcalib_vc2010.vcxproj b/vc_solution/dcalib_vc2010.vcxproj
2309 new file mode 100644
2310 index 0000000..5216233
2311 --- /dev/null
2312 +++ b/vc_solution/dcalib_vc2010.vcxproj
2313 @@ -0,0 +1,114 @@
2314 +<?xml version="1.0" encoding="utf-8"?>
2315 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2316 + <ItemGroup Label="ProjectConfigurations">
2317 + <ProjectConfiguration Include="Debug|Win32">
2318 + <Configuration>Debug</Configuration>
2319 + <Platform>Win32</Platform>
2320 + </ProjectConfiguration>
2321 + <ProjectConfiguration Include="Release|Win32">
2322 + <Configuration>Release</Configuration>
2323 + <Platform>Win32</Platform>
2324 + </ProjectConfiguration>
2325 + </ItemGroup>
2326 + <PropertyGroup Label="Globals">
2327 + <ProjectGuid>{B4AD2963-8469-4DBD-BD26-FAD4FE303F8F}</ProjectGuid>
2328 + <Keyword>Win32Proj</Keyword>
2329 + <RootNamespace>dcalib_vc2010</RootNamespace>
2330 + </PropertyGroup>
2331 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2332 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2333 + <ConfigurationType>StaticLibrary</ConfigurationType>
2334 + <UseDebugLibraries>true</UseDebugLibraries>
2335 + <CharacterSet>Unicode</CharacterSet>
2336 + </PropertyGroup>
2337 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
2338 + <ConfigurationType>StaticLibrary</ConfigurationType>
2339 + <UseDebugLibraries>false</UseDebugLibraries>
2340 + <WholeProgramOptimization>true</WholeProgramOptimization>
2341 + <CharacterSet>Unicode</CharacterSet>
2342 + <PlatformToolset>Windows7.1SDK</PlatformToolset>
2343 + </PropertyGroup>
2344 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
2345 + <ImportGroup Label="ExtensionSettings">
2346 + </ImportGroup>
2347 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2348 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2349 + </ImportGroup>
2350 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2351 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2352 + </ImportGroup>
2353 + <PropertyGroup Label="UserMacros" />
2354 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2355 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2356 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\lib\</IntDir>
2357 + <TargetName>dcaenc-static-0</TargetName>
2358 + </PropertyGroup>
2359 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2360 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2361 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\lib\</IntDir>
2362 + <TargetName>dcaenc-static-0</TargetName>
2363 + </PropertyGroup>
2364 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2365 + <ClCompile>
2366 + <PrecompiledHeader>NotUsing</PrecompiledHeader>
2367 + <WarningLevel>Level3</WarningLevel>
2368 + <Optimization>Disabled</Optimization>
2369 + <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2370 + </ClCompile>
2371 + <Link>
2372 + <SubSystem>Windows</SubSystem>
2373 + <GenerateDebugInformation>true</GenerateDebugInformation>
2374 + </Link>
2375 + <PreBuildEvent>
2376 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
2377 + <Message>Create: "$(SolutionDir)config.h"</Message>
2378 + </PreBuildEvent>
2379 + </ItemDefinitionGroup>
2380 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2381 + <ClCompile>
2382 + <WarningLevel>Level3</WarningLevel>
2383 + <PrecompiledHeader>NotUsing</PrecompiledHeader>
2384 + <Optimization>Full</Optimization>
2385 + <FunctionLevelLinking>true</FunctionLevelLinking>
2386 + <IntrinsicFunctions>true</IntrinsicFunctions>
2387 + <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2388 + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
2389 + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
2390 + <OmitFramePointers>true</OmitFramePointers>
2391 + <WholeProgramOptimization>true</WholeProgramOptimization>
2392 + <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
2393 + <FloatingPointModel>Fast</FloatingPointModel>
2394 + <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
2395 + <CreateHotpatchableImage>false</CreateHotpatchableImage>
2396 + <BufferSecurityCheck>false</BufferSecurityCheck>
2397 + </ClCompile>
2398 + <Link>
2399 + <SubSystem>Windows</SubSystem>
2400 + <GenerateDebugInformation>true</GenerateDebugInformation>
2401 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
2402 + <OptimizeReferences>true</OptimizeReferences>
2403 + </Link>
2404 + <Lib>
2405 + <LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
2406 + </Lib>
2407 + <PreBuildEvent>
2408 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
2409 + <Message>Create: "$(SolutionDir)config.h"</Message>
2410 + </PreBuildEvent>
2411 + </ItemDefinitionGroup>
2412 + <ItemGroup>
2413 + <ClCompile Include="..\dcaenc.c" />
2414 + <ClCompile Include="..\math_tables.c" />
2415 + </ItemGroup>
2416 + <ItemGroup>
2417 + <ClInclude Include="..\dcaenc.h" />
2418 + <ClInclude Include="..\dcaenc_private.h" />
2419 + <ClInclude Include="..\float_data.h" />
2420 + <ClInclude Include="..\int_data.h" />
2421 + <ClInclude Include="..\math_tables.h" />
2422 + <ClInclude Include="..\softfloat.h" />
2423 + </ItemGroup>
2424 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
2425 + <ImportGroup Label="ExtensionTargets">
2426 + </ImportGroup>
2427 +</Project>
2428 \ No newline at end of file
2429 diff --git a/vc_solution/dcalib_vc2010.vcxproj.filters b/vc_solution/dcalib_vc2010.vcxproj.filters
2430 new file mode 100644
2431 index 0000000..b2d7092
2432 --- /dev/null
2433 +++ b/vc_solution/dcalib_vc2010.vcxproj.filters
2434 @@ -0,0 +1,45 @@
2435 +<?xml version="1.0" encoding="utf-8"?>
2436 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2437 + <ItemGroup>
2438 + <Filter Include="Source Files">
2439 + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
2440 + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
2441 + </Filter>
2442 + <Filter Include="Header Files">
2443 + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
2444 + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
2445 + </Filter>
2446 + <Filter Include="Resource Files">
2447 + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
2448 + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
2449 + </Filter>
2450 + </ItemGroup>
2451 + <ItemGroup>
2452 + <ClCompile Include="..\dcaenc.c">
2453 + <Filter>Source Files</Filter>
2454 + </ClCompile>
2455 + <ClCompile Include="..\math_tables.c">
2456 + <Filter>Source Files</Filter>
2457 + </ClCompile>
2458 + </ItemGroup>
2459 + <ItemGroup>
2460 + <ClInclude Include="..\dcaenc.h">
2461 + <Filter>Header Files</Filter>
2462 + </ClInclude>
2463 + <ClInclude Include="..\dcaenc_private.h">
2464 + <Filter>Header Files</Filter>
2465 + </ClInclude>
2466 + <ClInclude Include="..\math_tables.h">
2467 + <Filter>Header Files</Filter>
2468 + </ClInclude>
2469 + <ClInclude Include="..\int_data.h">
2470 + <Filter>Header Files</Filter>
2471 + </ClInclude>
2472 + <ClInclude Include="..\softfloat.h">
2473 + <Filter>Header Files</Filter>
2474 + </ClInclude>
2475 + <ClInclude Include="..\float_data.h">
2476 + <Filter>Header Files</Filter>
2477 + </ClInclude>
2478 + </ItemGroup>
2479 +</Project>
2480 \ No newline at end of file
2481 diff --git a/vc_solution/dcalib_vc2010.vcxproj.user b/vc_solution/dcalib_vc2010.vcxproj.user
2482 new file mode 100644
2483 index 0000000..ace9a86
2484 --- /dev/null
2485 +++ b/vc_solution/dcalib_vc2010.vcxproj.user
2486 @@ -0,0 +1,3 @@
2487 +<?xml version="1.0" encoding="utf-8"?>
2488 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2489 +</Project>
2490 \ No newline at end of file
2491 diff --git a/vc_solution/gentables.vcxproj b/vc_solution/gentables.vcxproj
2492 new file mode 100644
2493 index 0000000..85b4751
2494 --- /dev/null
2495 +++ b/vc_solution/gentables.vcxproj
2496 @@ -0,0 +1,125 @@
2497 +<?xml version="1.0" encoding="utf-8"?>
2498 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2499 + <ItemGroup Label="ProjectConfigurations">
2500 + <ProjectConfiguration Include="Debug|Win32">
2501 + <Configuration>Debug</Configuration>
2502 + <Platform>Win32</Platform>
2503 + </ProjectConfiguration>
2504 + <ProjectConfiguration Include="Release|Win32">
2505 + <Configuration>Release</Configuration>
2506 + <Platform>Win32</Platform>
2507 + </ProjectConfiguration>
2508 + </ItemGroup>
2509 + <PropertyGroup Label="Globals">
2510 + <ProjectGuid>{282DDEDF-52A5-442E-90DE-94ABEC4B4866}</ProjectGuid>
2511 + <Keyword>Win32Proj</Keyword>
2512 + <RootNamespace>gentables</RootNamespace>
2513 + </PropertyGroup>
2514 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2515 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2516 + <ConfigurationType>Application</ConfigurationType>
2517 + <UseDebugLibraries>true</UseDebugLibraries>
2518 + <CharacterSet>Unicode</CharacterSet>
2519 + </PropertyGroup>
2520 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
2521 + <ConfigurationType>Application</ConfigurationType>
2522 + <UseDebugLibraries>false</UseDebugLibraries>
2523 + <WholeProgramOptimization>true</WholeProgramOptimization>
2524 + <CharacterSet>Unicode</CharacterSet>
2525 + </PropertyGroup>
2526 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
2527 + <ImportGroup Label="ExtensionSettings">
2528 + </ImportGroup>
2529 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2530 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2531 + </ImportGroup>
2532 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2533 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
2534 + </ImportGroup>
2535 + <PropertyGroup Label="UserMacros" />
2536 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2537 + <LinkIncremental>true</LinkIncremental>
2538 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2539 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\gen\</IntDir>
2540 + </PropertyGroup>
2541 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2542 + <LinkIncremental>false</LinkIncremental>
2543 + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
2544 + <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\tmp\gen\</IntDir>
2545 + </PropertyGroup>
2546 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2547 + <ClCompile>
2548 + <PrecompiledHeader>
2549 + </PrecompiledHeader>
2550 + <WarningLevel>Level3</WarningLevel>
2551 + <Optimization>Disabled</Optimization>
2552 + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2553 + </ClCompile>
2554 + <Link>
2555 + <SubSystem>Console</SubSystem>
2556 + <GenerateDebugInformation>true</GenerateDebugInformation>
2557 + </Link>
2558 + <CustomBuildStep>
2559 + <Command>
2560 + </Command>
2561 + </CustomBuildStep>
2562 + <CustomBuildStep>
2563 + <Message>
2564 + </Message>
2565 + </CustomBuildStep>
2566 + <PostBuildEvent>
2567 + <Command>"$(OutDir)\gentables.exe" &gt; "$(SolutionDir)..\math_tables.c"</Command>
2568 + <Message>Generating Tables</Message>
2569 + </PostBuildEvent>
2570 + <PreBuildEvent>
2571 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
2572 + <Message>Create: "$(SolutionDir)config.h"</Message>
2573 + </PreBuildEvent>
2574 + </ItemDefinitionGroup>
2575 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
2576 + <ClCompile>
2577 + <WarningLevel>Level3</WarningLevel>
2578 + <PrecompiledHeader>
2579 + </PrecompiledHeader>
2580 + <Optimization>MaxSpeed</Optimization>
2581 + <FunctionLevelLinking>true</FunctionLevelLinking>
2582 + <IntrinsicFunctions>true</IntrinsicFunctions>
2583 + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2584 + </ClCompile>
2585 + <Link>
2586 + <SubSystem>Console</SubSystem>
2587 + <GenerateDebugInformation>true</GenerateDebugInformation>
2588 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
2589 + <OptimizeReferences>true</OptimizeReferences>
2590 + </Link>
2591 + <CustomBuildStep>
2592 + <Command>
2593 + </Command>
2594 + </CustomBuildStep>
2595 + <CustomBuildStep>
2596 + <Message>
2597 + </Message>
2598 + </CustomBuildStep>
2599 + <PostBuildEvent>
2600 + <Command>"$(OutDir)\gentables.exe" &gt; "$(SolutionDir)..\math_tables.c"</Command>
2601 + <Message>Generating Tables</Message>
2602 + </PostBuildEvent>
2603 + <PreBuildEvent>
2604 + <Command>copy /Y "$(SolutionDir)..\config_msvc.h" "$(SolutionDir)..\config.h"</Command>
2605 + <Message>Create: "$(SolutionDir)config.h"</Message>
2606 + </PreBuildEvent>
2607 + </ItemDefinitionGroup>
2608 + <ItemGroup>
2609 + <None Include="ReadMe.txt" />
2610 + </ItemGroup>
2611 + <ItemGroup>
2612 + <ClInclude Include="..\float_data.h" />
2613 + <ClInclude Include="..\int_data.h" />
2614 + </ItemGroup>
2615 + <ItemGroup>
2616 + <ClCompile Include="..\gentables.c" />
2617 + </ItemGroup>
2618 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
2619 + <ImportGroup Label="ExtensionTargets">
2620 + </ImportGroup>
2621 +</Project>
2622 \ No newline at end of file
2623 diff --git a/vc_solution/gentables.vcxproj.filters b/vc_solution/gentables.vcxproj.filters
2624 new file mode 100644
2625 index 0000000..754afe3
2626 --- /dev/null
2627 +++ b/vc_solution/gentables.vcxproj.filters
2628 @@ -0,0 +1,33 @@
2629 +<?xml version="1.0" encoding="utf-8"?>
2630 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2631 + <ItemGroup>
2632 + <Filter Include="Source Files">
2633 + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
2634 + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
2635 + </Filter>
2636 + <Filter Include="Header Files">
2637 + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
2638 + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
2639 + </Filter>
2640 + <Filter Include="Resource Files">
2641 + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
2642 + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
2643 + </Filter>
2644 + </ItemGroup>
2645 + <ItemGroup>
2646 + <None Include="ReadMe.txt" />
2647 + </ItemGroup>
2648 + <ItemGroup>
2649 + <ClInclude Include="..\int_data.h">
2650 + <Filter>Header Files</Filter>
2651 + </ClInclude>
2652 + <ClInclude Include="..\float_data.h">
2653 + <Filter>Header Files</Filter>
2654 + </ClInclude>
2655 + </ItemGroup>
2656 + <ItemGroup>
2657 + <ClCompile Include="..\gentables.c">
2658 + <Filter>Source Files</Filter>
2659 + </ClCompile>
2660 + </ItemGroup>
2661 +</Project>
2662 \ No newline at end of file
2663 diff --git a/vc_solution/lib/EncodePointer.lib b/vc_solution/lib/EncodePointer.lib
2664 new file mode 100644
2665 index 0000000..c035792
2666 Binary files /dev/null and b/vc_solution/lib/EncodePointer.lib differ
2667 diff --git a/vc_solution/lib/msvcrt_vc6.lib b/vc_solution/lib/msvcrt_vc6.lib
2668 new file mode 100644
2669 index 0000000..26f03fe
2670 Binary files /dev/null and b/vc_solution/lib/msvcrt_vc6.lib differ
2671 diff --git a/wavfile.c b/wavfile.c
2672 index 950a08d..7f35e2f 100644
2673 --- a/wavfile.c
2674 +++ b/wavfile.c
2675 @@ -23,189 +23,332 @@
2676 #include <string.h>
2677 #include <stdio.h>
2678 #include "wavfile.h"
2679 +#include "unicode_support.h"
2681 -static uint32_t find_chunk(FILE * file, const uint8_t chunk_id[4])
2682 +#ifdef _M_X64
2683 +#define SIZE2UINT32(X) (uint32_t)(((X) > UINT32_MAX) ? UINT32_MAX : (X))
2684 +#define SIZE2INT(X) (uint32_t)(((X) > INT_MAX) ? INT_MAX : (X))
2685 +#else
2686 +#define SIZE2UINT32(X) (X)
2687 +#define SIZE2INT(X) (X)
2688 +#endif
2690 +#define BUFFSIZE_SAMPLES 512
2691 +#define BUFFSIZE_BYTES (BUFFSIZE_SAMPLES * 6 * 4)
2693 +static const char *g_error_msg[13] =
2695 - uint8_t buffer[8];
2696 - while (1) {
2697 - size_t chunksize;
2698 - size_t s = fread(buffer, 1, 8, file);
2699 - if (s < 8)
2700 - return 0;
2701 - chunksize = (uint32_t)buffer[4] | ((uint32_t)buffer[5] << 8) |
2702 - ((uint32_t)buffer[6] << 16) | ((uint32_t)buffer[7] << 24);
2703 - if (!memcmp(buffer, chunk_id, 4))
2704 - return chunksize;
2705 - fseek(file, chunksize, SEEK_CUR);
2707 + /* 0*/ "Success",
2708 + /* 1*/ "Failed to open file",
2709 + /* 2*/ "RIFF header not found",
2710 + /* 3*/ "WAVE chunk not found",
2711 + /* 4*/ "Format chunk not found",
2712 + /* 5*/ "Failed to read Format chunk",
2713 + /* 6*/ "Invalid or unsupported format tag",
2714 + /* 7*/ "Unsupported number of channels (only 1, 2, 3, 4, 5 and 6)",
2715 + /* 8*/ "Unsupported bits per sample (only 16 and 32 for now)",
2716 + /* 9*/ "Inconsistent block alignment",
2717 + /*10*/ "Inconsistent average bitrate",
2718 + /*11*/ "Data chunk not found",
2719 + /*12*/ "Data chunk size is invalid"
2722 +static int find_chunk(FILE * file, const uint8_t chunk_id[4], size_t *chunk_size)
2724 + uint8_t buffer[8];
2725 + *chunk_size = 0;
2727 + while (1) {
2728 + size_t chunksize;
2729 + size_t s = fread(buffer, 1, 8, file);
2730 + if (s < 8)
2731 + return 0;
2732 + chunksize = (uint32_t)buffer[4] | ((uint32_t)buffer[5] << 8) |
2733 + ((uint32_t)buffer[6] << 16) | ((uint32_t)buffer[7] << 24);
2735 + if(!memcmp(buffer, chunk_id, 4))
2737 + *chunk_size = chunksize;
2738 + return 1;
2741 + if((chunksize % 2) == 1) chunksize++; //Skip extra "unused" byte at the end of odd-size chunks
2743 + if(fseek(file, SIZE2UINT32(chunksize), SEEK_CUR))
2745 + while(chunksize > 8)
2747 + s = fread(buffer, 1, 8, file);
2748 + if (s < 8)
2749 + return 0;
2750 + chunksize -= 8;
2752 + s = fread(buffer, 1, chunksize, file);
2753 + if (s < chunksize)
2754 + return 0;
2759 -wavfile * wavfile_open(const char * filename)
2760 +wavfile * wavfile_open(const char * filename, const char ** error_msg, const int ignore_len)
2762 - wavfile *result;
2763 - size_t s;
2764 - uint8_t buffer[8];
2765 - uint8_t *fmt;
2766 - uint32_t v;
2767 - uint32_t avg_bps;
2768 - uint32_t block_align;
2769 - static const uint8_t riff[4] = {'R', 'I', 'F', 'F'};
2770 - static const uint8_t wave[4] = { 'W', 'A', 'V', 'E'};
2771 - static const uint8_t fmt_[4] = {'f', 'm', 't', ' '};
2772 - static const uint8_t data[4] = {'d', 'a', 't', 'a'};
2774 - result = (wavfile *)calloc(1, sizeof(wavfile));
2775 - if (!result)
2776 - goto err0;
2778 - result->file = fopen(filename, "rb");
2779 - if (!result->file)
2780 - goto err1;
2782 - s = fread(buffer, 1, 8, result->file);
2783 - if (s < 8)
2784 - goto err2;
2786 - if (memcmp(buffer, riff, 4))
2787 - goto err2;
2789 - /* TODO: check size (in buffer[4..8]) */
2790 - s = fread(buffer, 1, 4, result->file);
2791 - if (s < 4)
2792 - goto err2;
2794 - if (memcmp(buffer, wave, 4))
2795 - goto err2;
2797 - s = find_chunk(result->file, fmt_);
2798 - if (s != 16 && s != 40)
2799 - goto err2;
2801 - fmt = (uint8_t*)malloc(s);
2802 - if (!fmt)
2803 - goto err2;
2805 - if (fread(fmt, 1, s, result->file) != s)
2806 - goto err3;
2808 - /* wFormatTag */
2809 - v = (uint32_t)fmt[0] | ((uint32_t)fmt[1] << 8);
2810 - if (v != 1 && v != 0xfffe)
2811 - goto err3;
2813 - /* wChannels */
2814 - v = (uint32_t)fmt[2] | ((uint32_t)fmt[3] << 8);
2815 - if (v != 1 && v != 2 && v != 4 && v != 5 && v !=6)
2816 - goto err3;
2817 - result->channels = v;
2818 - /* dwSamplesPerSec */
2819 - result->sample_rate = (uint32_t)fmt[4] | ((uint32_t)fmt[5] << 8) |
2820 - ((uint32_t)fmt[6] << 16) | ((uint32_t)fmt[7] << 24);
2822 - /* dwAvgBytesPerSec */
2823 - avg_bps = (uint32_t)fmt[8] | ((uint32_t)fmt[9] << 8) |
2824 - ((uint32_t)fmt[10] << 16) | ((uint32_t)fmt[11] << 24);
2826 - /* wBlockAlign */
2827 - block_align = (uint32_t)fmt[12] | ((uint32_t)fmt[13] << 8);
2829 - /* wBitsPerSample */
2830 - result->bits_per_sample = (uint32_t)fmt[14] | ((uint32_t)fmt[15] << 8);
2831 - if (result->bits_per_sample != 16 && result->bits_per_sample != 32)
2832 - goto err3;
2834 - if (block_align != result->channels * (result->bits_per_sample / 8))
2835 - goto err3;
2837 - if (avg_bps != block_align * result->sample_rate)
2838 - goto err3;
2840 - v = find_chunk(result->file, data);
2841 - if (v == 0 || v % block_align != 0)
2842 - goto err3;
2844 - result->samples_left = v / block_align;
2845 - free(fmt);
2846 - return result;
2848 - err3:
2849 + wavfile *result;
2850 + size_t s;
2851 + uint8_t buffer[8];
2852 + uint8_t *fmt;
2853 + size_t v;
2854 + uint32_t avg_bps;
2855 + uint32_t block_align;
2856 + static const uint8_t riff[4] = {'R', 'I', 'F', 'F'};
2857 + static const uint8_t wave[4] = { 'W', 'A', 'V', 'E'};
2858 + static const uint8_t fmt_[4] = {'f', 'm', 't', ' '};
2859 + static const uint8_t data[4] = {'d', 'a', 't', 'a'};
2861 + result = (wavfile *)calloc(1, sizeof(wavfile));
2862 + if (!result)
2863 + goto err0;
2865 + result->file = strcmp(filename, "-") ? fopen_utf8(filename, "rb") : stdin;
2866 + if (!result->file)
2868 + *error_msg = g_error_msg[1];
2869 + goto err1;
2872 + s = fread(buffer, 1, 8, result->file);
2873 + if (s < 8)
2875 + *error_msg = g_error_msg[2];
2876 + goto err2;
2879 + if (memcmp(buffer, riff, 4))
2881 + *error_msg = g_error_msg[2];
2882 + goto err2;
2885 + /* TODO: check size (in buffer[4..8]) */
2886 + s = fread(buffer, 1, 4, result->file);
2887 + if (s < 4)
2889 + *error_msg = g_error_msg[3];
2890 + goto err2;
2893 + if (memcmp(buffer, wave, 4))
2895 + *error_msg = g_error_msg[3];
2896 + goto err2;
2899 + if(!find_chunk(result->file, fmt_, &s))
2901 + *error_msg = g_error_msg[4];
2902 + goto err2;
2904 + if((s < 16) || (s > 40))
2906 + *error_msg = g_error_msg[4];
2907 + goto err2;
2910 + fmt = (uint8_t*)malloc(s);
2911 + if(!fmt)
2913 + *error_msg = g_error_msg[5];
2914 + goto err2;
2917 + if(fread(fmt, 1, s, result->file) != s)
2919 + *error_msg = g_error_msg[5];
2920 + goto err3;
2923 + /* skip unused byte (for odd-size chunks) */
2924 + if((s % 2) == 1)
2926 + char dummy[1];
2927 + if(fread(&dummy, 1, 1, result->file) != 1)
2929 + *error_msg = g_error_msg[5];
2930 + goto err3;
2934 + /* wFormatTag */
2935 + v = (uint32_t)fmt[0] | ((uint32_t)fmt[1] << 8);
2936 + if(v != 1 && v != 0xfffe)
2938 + *error_msg = g_error_msg[6];
2939 + goto err3;
2942 + /* wChannels */
2943 + v = (uint32_t)fmt[2] | ((uint32_t)fmt[3] << 8);
2944 + if((v < 1) || (v > 6))
2946 + *error_msg = g_error_msg[7];
2947 + goto err3;
2949 + result->channels = SIZE2UINT32(v);
2951 + /* dwSamplesPerSec */
2952 + result->sample_rate = (uint32_t)fmt[4] | ((uint32_t)fmt[5] << 8) |
2953 + ((uint32_t)fmt[6] << 16) | ((uint32_t)fmt[7] << 24);
2955 + /* dwAvgBytesPerSec */
2956 + avg_bps = (uint32_t)fmt[8] | ((uint32_t)fmt[9] << 8) |
2957 + ((uint32_t)fmt[10] << 16) | ((uint32_t)fmt[11] << 24);
2959 + /* wBlockAlign */
2960 + block_align = (uint32_t)fmt[12] | ((uint32_t)fmt[13] << 8);
2962 + /* wBitsPerSample */
2963 + result->bits_per_sample = (uint32_t)fmt[14] | ((uint32_t)fmt[15] << 8);
2964 + if(result->bits_per_sample != 16 && result->bits_per_sample != 32)
2966 + *error_msg = g_error_msg[8];
2967 + goto err3;
2970 + if(block_align != result->channels * (result->bits_per_sample / 8))
2972 + *error_msg = g_error_msg[9];
2973 + goto err3;
2976 + if(avg_bps != block_align * result->sample_rate)
2978 + *error_msg = g_error_msg[10];
2979 + goto err3;
2982 + if(!find_chunk(result->file, data, &v))
2984 + *error_msg = g_error_msg[11];
2985 + goto err3;
2987 + if(((v == 0) || (v % block_align != 0)) && (!ignore_len))
2989 + *error_msg = g_error_msg[12];
2990 + goto err3;
2993 + result->samples_left = SIZE2UINT32(ignore_len ? UNKNOWN_SIZE : (v / block_align));
2994 free(fmt);
2995 - err2:
2996 - fclose(result->file);
2997 - err1:
2998 + *error_msg = g_error_msg[0];
2999 + return result;
3001 + err3:
3002 + free(fmt);
3003 + err2:
3004 + if(result->file != stdin) fclose(result->file);
3005 + err1:
3006 free(result);
3007 - err0:
3008 + err0:
3009 return NULL;
3012 void wavfile_close(wavfile * f)
3014 - fclose(f->file);
3015 - free(f);
3016 + if(f->file != stdin)
3018 + fclose(f->file);
3020 + free(f);
3023 static int32_t get_s32_sample(const wavfile * f, const uint8_t *buffer, int sample, int channel)
3025 - int offset = (f->bits_per_sample / 8) * (f->channels * sample + channel);
3026 - uint32_t v;
3027 - switch (f->bits_per_sample) {
3028 + int offset = (f->bits_per_sample / 8) * (f->channels * sample + channel);
3029 + uint32_t v;
3030 + switch (f->bits_per_sample)
3032 case 16:
3033 - v = (uint32_t)buffer[offset + 0] | ((uint32_t)buffer[offset + 1] << 8);
3034 - return v << 16;
3035 - break;
3036 + v = (uint32_t)buffer[offset + 0] | ((uint32_t)buffer[offset + 1] << 8);
3037 + return v << 16;
3038 + break;
3039 case 32:
3040 - v = (uint32_t)buffer[offset + 0] | ((uint32_t)buffer[offset + 1] << 8) |
3041 + v = (uint32_t)buffer[offset + 0] | ((uint32_t)buffer[offset + 1] << 8) |
3042 ((uint32_t)buffer[offset + 2] << 16) | ((uint32_t)buffer[offset + 3] << 24);
3043 - return v;
3044 - break;
3045 + return v;
3046 + break;
3047 default:
3048 - return 0;
3050 + return 0;
3054 -int wavfile_read_s32(wavfile * f, int32_t *samples)
3055 +int wavfile_read_s32(wavfile * f, int32_t *samples, size_t sample_count)
3057 - uint8_t buffer[512 * 6 * 4];
3058 - int32_t smpte_sample[6];
3059 - int samples_to_read;
3060 - int bytes_to_read;
3061 - unsigned int i, ch;
3063 - memset(buffer, 0, 512 * 6 * 4);
3064 - samples_to_read = f->samples_left < 512 ? f->samples_left : 512;
3065 - bytes_to_read = samples_to_read * f->channels * (f->bits_per_sample / 8);
3066 - f->samples_left -= samples_to_read;
3067 - if (fread(buffer, 1, bytes_to_read, f->file) != bytes_to_read) {
3068 - f->samples_left = 0;
3071 - for (i = 0; i < 512; i++) {
3072 - for (ch = 0; ch < f->channels; ch++)
3073 - smpte_sample[ch] = get_s32_sample(f, buffer, i, ch);
3074 - switch(f->channels) {
3075 - case 1:
3076 - case 2:
3077 - case 4:
3078 - for (ch = 0; ch < f->channels; ch++)
3079 - *(samples++) = smpte_sample[ch];
3080 - break;
3081 - case 5:
3082 - *(samples++) = smpte_sample[2];
3083 - *(samples++) = smpte_sample[0];
3084 - *(samples++) = smpte_sample[1];
3085 - *(samples++) = smpte_sample[3];
3086 - *(samples++) = smpte_sample[4];
3087 - break;
3088 - case 6:
3089 - *(samples++) = smpte_sample[2];
3090 - *(samples++) = smpte_sample[0];
3091 - *(samples++) = smpte_sample[1];
3092 - *(samples++) = smpte_sample[4];
3093 - *(samples++) = smpte_sample[5];
3094 - *(samples++) = smpte_sample[3];
3095 - break;
3099 - return f->samples_left;
3100 + uint8_t buffer[BUFFSIZE_BYTES];
3101 + int32_t smpte_sample[6];
3102 + int samples_to_read;
3103 + int bytes_to_read;
3104 + int bytes_read;
3105 + unsigned int i, ch;
3107 + if(sample_count != BUFFSIZE_SAMPLES)
3109 + fprintf(stderr, "Only 512 samples currently supported!\n");
3110 + return 0;
3113 + if(f->samples_left < 1)
3115 + return 0;
3118 + memset(buffer, 0, BUFFSIZE_BYTES);
3119 + samples_to_read = (f->samples_left < BUFFSIZE_SAMPLES) ? f->samples_left : BUFFSIZE_SAMPLES;
3120 + bytes_to_read = samples_to_read * f->channels * (f->bits_per_sample / 8);
3121 + if(f->samples_left != UNKNOWN_SIZE) {
3122 + f->samples_left -= samples_to_read;
3125 + bytes_read = SIZE2INT(fread(buffer, 1, bytes_to_read, f->file));
3126 + if(bytes_read != bytes_to_read) {
3127 + f->samples_left = 0;
3130 + for (i = 0; i < BUFFSIZE_SAMPLES; i++)
3132 + for (ch = 0; ch < f->channels; ch++)
3133 + smpte_sample[ch] = get_s32_sample(f, buffer, i, ch);
3134 + switch(f->channels)
3136 + case 1:
3137 + case 2:
3138 + case 4:
3139 + for (ch = 0; ch < f->channels; ch++)
3140 + *(samples++) = smpte_sample[ch];
3141 + break;
3142 + case 3:
3143 + *(samples++) = smpte_sample[2];
3144 + *(samples++) = smpte_sample[0];
3145 + *(samples++) = smpte_sample[1];
3146 + break;
3147 + case 5:
3148 + *(samples++) = smpte_sample[2];
3149 + *(samples++) = smpte_sample[0];
3150 + *(samples++) = smpte_sample[1];
3151 + *(samples++) = smpte_sample[3];
3152 + *(samples++) = smpte_sample[4];
3153 + break;
3154 + case 6:
3155 + *(samples++) = smpte_sample[2];
3156 + *(samples++) = smpte_sample[0];
3157 + *(samples++) = smpte_sample[1];
3158 + *(samples++) = smpte_sample[4];
3159 + *(samples++) = smpte_sample[5];
3160 + *(samples++) = smpte_sample[3];
3161 + break;
3162 + default:
3163 + fprintf(stderr, "FIXME: Unexpected channel number!\n");
3164 + exit(1);
3168 + return bytes_read / (f->channels * (f->bits_per_sample / 8));
3170 diff --git a/wavfile.h b/wavfile.h
3171 index b8945e2..418e55f 100644
3172 --- a/wavfile.h
3173 +++ b/wavfile.h
3174 @@ -23,6 +23,8 @@
3176 #include <stdio.h>
3178 +#define UNKNOWN_SIZE 0xFFFFFFFF
3180 typedef struct {
3181 FILE * file;
3182 unsigned int channels;
3183 @@ -31,8 +33,8 @@ typedef struct {
3184 unsigned int samples_left;
3185 } wavfile;
3187 -wavfile * wavfile_open(const char * filename);
3188 -int wavfile_read_s32(wavfile * f, int32_t * samples);
3189 +wavfile * wavfile_open(const char * filename, const char ** error_msg, const int ignore_len);
3190 +int wavfile_read_s32(wavfile * f, int32_t *samples, size_t sample_count);
3191 void wavfile_close(wavfile * f);
3193 #endif
3194 diff --git a/xgetopt.c b/xgetopt.c
3195 new file mode 100644
3196 index 0000000..507b44d
3197 --- /dev/null
3198 +++ b/xgetopt.c
3199 @@ -0,0 +1,206 @@
3200 +// XGetopt.cpp Version 1.2
3202 +// Author: Hans Dietrich
3203 +// hdietrich2@hotmail.com
3205 +// Description:
3206 +// XGetopt.cpp implements getopt(), a function to parse command lines.
3208 +// History
3209 +// Version 1.2 - 2003 May 17
3210 +// - Added Unicode support
3212 +// Version 1.1 - 2002 March 10
3213 +// - Added example to XGetopt.cpp module header
3215 +// This software is released into the public domain.
3216 +// You are free to use it in any way you like.
3218 +// This software is provided "as is" with no expressed
3219 +// or implied warranty. I accept no liability for any
3220 +// damage or loss of business that this software may cause.
3222 +///////////////////////////////////////////////////////////////////////////////
3224 +///////////////////////////////////////////////////////////////////////////////
3225 +#include <stdio.h>
3226 +#include <string.h>
3227 +///////////////////////////////////////////////////////////////////////////////
3229 +#include "xgetopt.h"
3231 +///////////////////////////////////////////////////////////////////////////////
3233 +// X G e t o p t . c p p
3236 +// NAME
3237 +// getopt -- parse command line options
3239 +// SYNOPSIS
3240 +// int getopt(int argc, char *argv[], char *optstring)
3242 +// extern char *optarg;
3243 +// extern int optind;
3245 +// DESCRIPTION
3246 +// The getopt() function parses the command line arguments. Its
3247 +// arguments argc and argv are the argument count and array as
3248 +// passed into the application on program invocation. In the case
3249 +// of Visual C++ programs, argc and argv are available via the
3250 +// variables __argc and __argv (double underscores), respectively.
3251 +// getopt returns the next option letter in argv that matches a
3252 +// letter in optstring. (Note: Unicode programs should use
3253 +// __targv instead of __argv. Also, all character and string
3254 +// literals should be enclosed in _T( ) ).
3256 +// optstring is a string of recognized option letters; if a letter
3257 +// is followed by a colon, the option is expected to have an argument
3258 +// that may or may not be separated from it by white space. optarg
3259 +// is set to point to the start of the option argument on return from
3260 +// getopt.
3262 +// Option letters may be combined, e.g., "-ab" is equivalent to
3263 +// "-a -b". Option letters are case sensitive.
3265 +// getopt places in the external variable optind the argv index
3266 +// of the next argument to be processed. optind is initialized
3267 +// to 0 before the first call to getopt.
3269 +// When all options have been processed (i.e., up to the first
3270 +// non-option argument), getopt returns EOF, optarg will point
3271 +// to the argument, and optind will be set to the argv index of
3272 +// the argument. If there are no non-option arguments, optarg
3273 +// will be set to NULL.
3275 +// The special option "--" may be used to delimit the end of the
3276 +// options; EOF will be returned, and "--" (and everything after it)
3277 +// will be skipped.
3279 +// RETURN VALUE
3280 +// For option letters contained in the string optstring, getopt
3281 +// will return the option letter. getopt returns a question mark (?)
3282 +// when it encounters an option letter not included in optstring.
3283 +// EOF is returned when processing is finished.
3285 +// BUGS
3286 +// 1) Long options are not supported.
3287 +// 2) The GNU double-colon extension is not supported.
3288 +// 3) The environment variable POSIXLY_CORRECT is not supported.
3289 +// 4) The + syntax is not supported.
3290 +// 5) The automatic permutation of arguments is not supported.
3291 +// 6) This implementation of getopt() returns EOF if an error is
3292 +// encountered, instead of -1 as the latest standard requires.
3294 +// EXAMPLE
3295 +// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[])
3296 +// {
3297 +// int c;
3299 +// while ((c = getopt(argc, argv, _T("aBn:"))) != EOF)
3300 +// {
3301 +// switch (c)
3302 +// {
3303 +// case _T('a'):
3304 +// TRACE(_T("option a\n"));
3305 +// //
3306 +// // set some flag here
3307 +// //
3308 +// break;
3310 +// case _T('B'):
3311 +// TRACE( _T("option B\n"));
3312 +// //
3313 +// // set some other flag here
3314 +// //
3315 +// break;
3317 +// case _T('n'):
3318 +// TRACE(_T("option n: value=%d\n"), atoi(optarg));
3319 +// //
3320 +// // do something with value here
3321 +// //
3322 +// break;
3324 +// case _T('?'):
3325 +// TRACE(_T("ERROR: illegal option %s\n"), argv[optind-1]);
3326 +// return FALSE;
3327 +// break;
3329 +// default:
3330 +// TRACE(_T("WARNING: no handler for option %c\n"), c);
3331 +// return FALSE;
3332 +// break;
3333 +// }
3334 +// }
3335 +// //
3336 +// // check for non-option args here
3337 +// //
3338 +// return TRUE;
3339 +// }
3341 +///////////////////////////////////////////////////////////////////////////////
3343 +int xgetopt(int argc, char *argv[], char *optstring, xgetopt_t *ctx)
3345 + char c, *cp;
3347 + if (ctx->optind == 0)
3348 + ctx->next = NULL;
3350 + ctx->optarg = NULL;
3352 + if (ctx->next == NULL || *ctx->next == '\0')
3354 + if (ctx->optind == 0)
3355 + ctx->optind++;
3357 + if (ctx->optind >= argc || argv[ctx->optind][0] != '-' || argv[ctx->optind][1] == '\0')
3359 + ctx->optarg = NULL;
3360 + if (ctx->optind < argc)
3361 + ctx->optarg = argv[ctx->optind];
3362 + return EOF;
3365 + if (strcmp(argv[ctx->optind], "--") == 0)
3367 + ctx->optind++;
3368 + ctx->optarg = NULL;
3369 + if (ctx->optind < argc)
3370 + ctx->optarg = argv[ctx->optind];
3371 + return EOF;
3374 + ctx->next = argv[ctx->optind];
3375 + ctx->next++; // skip past -
3376 + ctx->optind++;
3379 + c = *ctx->next++;
3380 + cp = strchr(optstring, c);
3382 + if (cp == NULL || c == ':')
3383 + return '?';
3385 + cp++;
3386 + if (*cp == ':')
3388 + if (*ctx->next != '\0')
3390 + ctx->optarg = ctx->next;
3391 + ctx->next = NULL;
3393 + else if (ctx->optind < argc)
3395 + ctx->optarg = argv[ctx->optind];
3396 + ctx->optind++;
3398 + else
3400 + return '?';
3404 + return c;
3406 diff --git a/xgetopt.h b/xgetopt.h
3407 new file mode 100644
3408 index 0000000..f9371b9
3409 --- /dev/null
3410 +++ b/xgetopt.h
3411 @@ -0,0 +1,29 @@
3412 +// XGetopt.h Version 1.2
3414 +// Author: Hans Dietrich
3415 +// hdietrich2@hotmail.com
3417 +// This software is released into the public domain.
3418 +// You are free to use it in any way you like.
3420 +// This software is provided "as is" with no expressed
3421 +// or implied warranty. I accept no liability for any
3422 +// damage or loss of business that this software may cause.
3424 +///////////////////////////////////////////////////////////////////////////////
3426 +#ifndef XGETOPT_H
3427 +#define XGETOPT_H
3429 +typedef struct
3431 + int optind;
3432 + int opterr;
3433 + char *optarg;
3434 + char *next;
3436 +xgetopt_t;
3438 +int xgetopt(int argc, char *argv[], char *optstring, xgetopt_t *ctx);
3440 +#endif //XGETOPT_H