Hi!
There's a piece of MSVC inline asm in libFLAC as of flac-1.2.1 that
doesn't respect the FLAC__NO_ASM constant. It's causing trouble only
when compiling with MSVC _and_ targeting x64 (since inline asm doesn't
work in x64).
I've attached a patch that fixes the issue to this mail.
When applied, flac-1.2.1 compiles on Windows x86 and Windows x64
flawlessly. Playback seems fine from what I can tell!
-Markus-
diff -u -r flac-1.2.1-original\src\libFLAC\bitreader.c
flac-1.2.1\src\libFLAC\bitreader.c
--- flac-1.2.1-original\src\libFLAC\bitreader.c Tue Sep 11 06:48:56 2007
+++ flac-1.2.1\src\libFLAC\bitreader.c Tue May 20 12:30:08 2008
@@ -149,15 +149,37 @@
FLAC__CPUInfo cpu_info;
};
-#ifdef _MSC_VER
-/* OPT: an MSVC built-in would be better */
+
+/* local_swap32_() */
+/* Swaps the byte order of a 32 bits integer, converting between big-endian
and little-endian */
+#if defined(_MSC_VER)
+
+#include <stdlib.h> // Contains _byteswap_ulong() for MSVC according to MSDN
static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x)
{
+ /* This is an intrinsic and will expanded to minimal asm by the
compiler */
+ return _byteswap_ulong(x);
+}
+
+#else /* defined(_MSC_VER) */
+
+static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x)
+{
+ /* Manual version, a bit slower but works everywhere */
x = ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
return (x>>16) | (x<<16);
}
+
+#endif /* defined(_MSC_VER) */
+
+
+/* local_swap32_block_() */
+/* Swaps the byte order of an array of 32 bits integers */
+#if defined(_MSC_VER) && !defined(FLAC__NO_ASM) || !defined(_M_X64)
+
static void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len)
{
+ /* MSVC specific 32 bit asm version */
__asm {
mov edx, start
mov ecx, len
@@ -173,7 +195,22 @@
done1:
}
}
-#endif
+
+#else /* defined(_MSC_VER) && !defined(FLAC__NO_ASM) || !defined(_M_X64) */
+
+static void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len)
+{
+ /* MSVC specific intrinsic version */
+ while(len > 0)
+ {
+ *start = local_swap32_(*start);
+ ++start;
+ --len;
+ }
+}
+
+#endif /* defined(_MSC_VER) && !defined(FLAC__NO_ASM) || !defined(_M_X64) */
+
static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, brword word)
{
_______________________________________________
Flac-dev mailing list
Flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev