mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
use inline byte-swapping function for MSVC
This commit is contained in:
@@ -66,8 +66,12 @@ typedef FLAC__uint32 brword;
|
|||||||
#if WORDS_BIGENDIAN
|
#if WORDS_BIGENDIAN
|
||||||
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
||||||
#else
|
#else
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define SWAP_BE_WORD_TO_HOST(x) local_swap32_(x)
|
||||||
|
#else
|
||||||
#define SWAP_BE_WORD_TO_HOST(x) ntohl(x)
|
#define SWAP_BE_WORD_TO_HOST(x) ntohl(x)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
/* counts the # of zero MSBs in a word */
|
/* counts the # of zero MSBs in a word */
|
||||||
#define ALIGNED_UNARY_BITS(word) ( \
|
#define ALIGNED_UNARY_BITS(word) ( \
|
||||||
(word) <= 0xffff ? \
|
(word) <= 0xffff ? \
|
||||||
@@ -147,6 +151,15 @@ struct FLAC__BitReader {
|
|||||||
void *client_data;
|
void *client_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, brword word)
|
static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, brword word)
|
||||||
{
|
{
|
||||||
register unsigned crc = br->read_crc16;
|
register unsigned crc = br->read_crc16;
|
||||||
|
|||||||
@@ -58,8 +58,12 @@ typedef FLAC__uint32 bwword;
|
|||||||
#if WORDS_BIGENDIAN
|
#if WORDS_BIGENDIAN
|
||||||
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
||||||
#else
|
#else
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define SWAP_BE_WORD_TO_HOST(x) local_swap32_(x)
|
||||||
|
#else
|
||||||
#define SWAP_BE_WORD_TO_HOST(x) ntohl(x)
|
#define SWAP_BE_WORD_TO_HOST(x) ntohl(x)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The default capacity here doesn't matter too much. The buffer always grows
|
* 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 */
|
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. */
|
/* * WATCHOUT: The current implementation only grows the buffer. */
|
||||||
static FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, unsigned bits_to_add)
|
static FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, unsigned bits_to_add)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user