summaryrefslogtreecommitdiff
path: root/src/libFLAC/bitwriter.c
diff options
context:
space:
mode:
authorJosh Coalson <jcoalson@users.sourceforce.net>2007-02-04 02:57:48 +0000
committerJosh Coalson <jcoalson@users.sourceforce.net>2007-02-04 02:57:48 +0000
commitc85056b3d5bcde151fbb92f22dcfb8d0638389aa (patch)
treeec8b7717fe908fd053a16141e00c4e59bb96cc28 /src/libFLAC/bitwriter.c
parent8640da31f7bbead90522ef256692d3c304402c9b (diff)
downloadflac-c85056b3d5bcde151fbb92f22dcfb8d0638389aa.tar.gz
use inline byte-swapping function for MSVC
Diffstat (limited to 'src/libFLAC/bitwriter.c')
-rw-r--r--src/libFLAC/bitwriter.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libFLAC/bitwriter.c b/src/libFLAC/bitwriter.c
index e9962e97..ba2a9d79 100644
--- a/src/libFLAC/bitwriter.c
+++ b/src/libFLAC/bitwriter.c
@@ -58,8 +58,12 @@ typedef FLAC__uint32 bwword;
#if WORDS_BIGENDIAN
#define SWAP_BE_WORD_TO_HOST(x) (x)
#else
+#ifdef _MSC_VER
+#define SWAP_BE_WORD_TO_HOST(x) local_swap32_(x)
+#else
#define SWAP_BE_WORD_TO_HOST(x) ntohl(x)
#endif
+#endif
/*
* The default capacity here doesn't matter too much. The buffer always grows
@@ -98,6 +102,15 @@ struct FLAC__BitWriter {
unsigned bits; /* # of used bits in accum */
};
+#ifdef _MSC_VER
+/* OPT: an MSVC built-in would be better */
+static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x)
+{
+ x = ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
+ return (x>>16) | (x<<16);
+}
+#endif
+
/* * WATCHOUT: The current implementation only grows the buffer. */
static FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, unsigned bits_to_add)
{