Index: third_party/libwebp/utils/bit_reader.h |
diff --git a/third_party/libwebp/utils/bit_reader.h b/third_party/libwebp/utils/bit_reader.h |
index 588222b3be7925186bf651f8478f3916ae631e07..98df98a7678648c1347ba8fad564bb8fa33b2924 100644 |
--- a/third_party/libwebp/utils/bit_reader.h |
+++ b/third_party/libwebp/utils/bit_reader.h |
@@ -19,10 +19,9 @@ |
#ifdef _MSC_VER |
#include <stdlib.h> // _byteswap_ulong |
#endif |
-#include <string.h> // For memcpy |
#include "../webp/types.h" |
-#if defined(__cplusplus) || defined(c_plusplus) |
+#ifdef __cplusplus |
extern "C" { |
#endif |
@@ -55,7 +54,7 @@ extern "C" { |
// And just after calling VP8LoadNewBytes(): |
// [........vvvvvvvvBBBBBBBBBBBBBBBB]LSB || [........vvvvvvvvBBBBBBBBBBBBBBBB] |
// |
-// -> we're back to height active 'value_' bits (marked 'v') and BITS cached |
+// -> we're back to eight active 'value_' bits (marked 'v') and BITS cached |
// bits (marked 'B') |
// |
// The right-justify strategy tends to use less shifts and is often faster. |
@@ -155,7 +154,7 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) { |
if (br->buf_ + sizeof(lbit_t) <= br->buf_end_) { |
// convert memory type to register type (with some zero'ing!) |
bit_t bits; |
- lbit_t in_bits = *(lbit_t*)br->buf_; |
+ const lbit_t in_bits = *(const lbit_t*)br->buf_; |
br->buf_ += (BITS) >> 3; |
#if !defined(__BIG_ENDIAN__) |
#if (BITS > 32) |
@@ -179,8 +178,11 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) { |
bits >>= 64 - BITS; |
#elif (BITS >= 24) |
#if defined(__i386__) || defined(__x86_64__) |
- __asm__ volatile("bswap %k0" : "=r"(in_bits) : "0"(in_bits)); |
- bits = (bit_t)in_bits; // 24b/32b -> 32b/64b zero-extension |
+ { |
+ lbit_t swapped_in_bits; |
+ __asm__ volatile("bswap %k0" : "=r"(swapped_in_bits) : "0"(in_bits)); |
+ bits = (bit_t)swapped_in_bits; // 24b/32b -> 32b/64b zero-extension |
+ } |
#elif defined(_MSC_VER) |
bits = (bit_t)_byteswap_ulong(in_bits); |
#else |
@@ -254,6 +256,7 @@ static WEBP_INLINE void VP8Shift(VP8BitReader* const br) { |
br->bits_ -= shift; |
#endif |
} |
+ |
static WEBP_INLINE int VP8GetBit(VP8BitReader* const br, int prob) { |
#ifndef USE_RIGHT_JUSTIFY |
// It's important to avoid generating a 64bit x 64bit multiply here. |
@@ -282,7 +285,6 @@ static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) { |
return bit ? -v : v; |
} |
- |
// ----------------------------------------------------------------------------- |
// Bitreader for lossless format |
@@ -316,15 +318,16 @@ static WEBP_INLINE uint32_t VP8LPrefetchBits(VP8LBitReader* const br) { |
return (uint32_t)(br->val_ >> br->bit_pos_); |
} |
-// Discard 'num_bits' bits from the cache. |
-static WEBP_INLINE void VP8LDiscardBits(VP8LBitReader* const br, int num_bits) { |
- br->bit_pos_ += num_bits; |
+// For jumping over a number of bits in the bit stream when accessed with |
+// VP8LPrefetchBits and VP8LFillBitWindow. |
+static WEBP_INLINE void VP8LSetBitPos(VP8LBitReader* const br, int val) { |
+ br->bit_pos_ = val; |
} |
-// Advances the Read buffer by 4 bytes to make room for reading next 32 bits. |
+// Advances the read buffer by 4 bytes to make room for reading next 32 bits. |
void VP8LFillBitWindow(VP8LBitReader* const br); |
-#if defined(__cplusplus) || defined(c_plusplus) |
+#ifdef __cplusplus |
} // extern "C" |
#endif |