Index: third_party/libwebp/utils/huffman.h |
diff --git a/third_party/libwebp/utils/huffman.h b/third_party/libwebp/utils/huffman.h |
index 83a517ee60dd1421cbeebf488e6684dcad7e8242..e8afd27f24468a931d8d94058d8c71e5f42f7108 100644 |
--- a/third_party/libwebp/utils/huffman.h |
+++ b/third_party/libwebp/utils/huffman.h |
@@ -17,7 +17,7 @@ |
#include <assert.h> |
#include "../webp/types.h" |
-#if defined(__cplusplus) || defined(c_plusplus) |
+#ifdef __cplusplus |
extern "C" { |
#endif |
@@ -28,17 +28,24 @@ typedef struct { |
} HuffmanTreeNode; |
// Huffman Tree. |
+#define HUFF_LUT_BITS 7 |
+#define HUFF_LUT (1U << HUFF_LUT_BITS) |
typedef struct HuffmanTree HuffmanTree; |
struct HuffmanTree { |
+ // Fast lookup for short bit lengths. |
+ uint8_t lut_bits_[HUFF_LUT]; |
+ int16_t lut_symbol_[HUFF_LUT]; |
+ int16_t lut_jump_[HUFF_LUT]; |
+ // Complete tree for lookups. |
HuffmanTreeNode* root_; // all the nodes, starting at root. |
int max_nodes_; // max number of nodes |
int num_nodes_; // number of currently occupied nodes |
}; |
-// Returns true if the given node is a leaf of the Huffman tree. |
-static WEBP_INLINE int HuffmanTreeNodeIsLeaf( |
+// Returns true if the given node is not a leaf of the Huffman tree. |
+static WEBP_INLINE int HuffmanTreeNodeIsNotLeaf( |
const HuffmanTreeNode* const node) { |
- return (node->children_ == 0); |
+ return node->children_; |
} |
// Go down one level. Most critical function. 'right_child' must be 0 or 1. |
@@ -73,7 +80,7 @@ int HuffmanCodeLengthsToCodes(const int* const code_lengths, |
int code_lengths_size, int* const huff_codes); |
-#if defined(__cplusplus) || defined(c_plusplus) |
+#ifdef __cplusplus |
} // extern "C" |
#endif |