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 // 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) {