mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-28 14:38:21 +01:00
endian_inl.h: add BSwap16
+ use it in VP8LoadNewBytes() Change-Id: I701d3652dc0cbd553852978702ef68c2657bca1c
This commit is contained in:
parent
6fbf5345e3
commit
f2664d1aab
@ -89,8 +89,7 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) {
|
|||||||
bits = BSwap32(in_bits);
|
bits = BSwap32(in_bits);
|
||||||
bits >>= (32 - BITS);
|
bits >>= (32 - BITS);
|
||||||
#elif (BITS == 16)
|
#elif (BITS == 16)
|
||||||
// gcc will recognize a 'rorw $8, ...' here:
|
bits = BSwap16(in_bits);
|
||||||
bits = (bit_t)(in_bits >> 8) | ((in_bits & 0xff) << 8);
|
|
||||||
#else // BITS == 8
|
#else // BITS == 8
|
||||||
bits = (bit_t)in_bits;
|
bits = (bit_t)in_bits;
|
||||||
#endif // BITS > 32
|
#endif // BITS > 32
|
||||||
|
@ -61,6 +61,15 @@
|
|||||||
#define HAVE_BUILTIN_BSWAP
|
#define HAVE_BUILTIN_BSWAP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static WEBP_INLINE uint16_t BSwap16(uint16_t x) {
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
return _byteswap_ushort(x);
|
||||||
|
#else
|
||||||
|
// gcc will recognize a 'rorw $8, ...' here:
|
||||||
|
return (x >> 8) | ((x & 0xff) << 8);
|
||||||
|
#endif // _MSC_VER
|
||||||
|
}
|
||||||
|
|
||||||
static WEBP_INLINE uint32_t BSwap32(uint32_t x) {
|
static WEBP_INLINE uint32_t BSwap32(uint32_t x) {
|
||||||
#if defined(HAVE_BUILTIN_BSWAP)
|
#if defined(HAVE_BUILTIN_BSWAP)
|
||||||
return __builtin_bswap32(x);
|
return __builtin_bswap32(x);
|
||||||
|
Loading…
Reference in New Issue
Block a user