summaryrefslogtreecommitdiff
path: root/drivers/webp/utils/huffman.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/webp/utils/huffman.h')
-rw-r--r--drivers/webp/utils/huffman.h25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/webp/utils/huffman.h b/drivers/webp/utils/huffman.h
index e8afd27f24..70220a67fb 100644
--- a/drivers/webp/utils/huffman.h
+++ b/drivers/webp/utils/huffman.h
@@ -1,10 +1,8 @@
// Copyright 2012 Google Inc. All Rights Reserved.
//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
+// This code is licensed under the same terms as WebM:
+// Software License Agreement: http://www.webmproject.org/license/software/
+// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
// -----------------------------------------------------------------------------
//
// Utilities for building and looking up Huffman trees.
@@ -17,7 +15,7 @@
#include <assert.h>
#include "../webp/types.h"
-#ifdef __cplusplus
+#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
@@ -28,24 +26,17 @@ 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 not a leaf of the Huffman tree.
-static WEBP_INLINE int HuffmanTreeNodeIsNotLeaf(
+// Returns true if the given node is a leaf of the Huffman tree.
+static WEBP_INLINE int HuffmanTreeNodeIsLeaf(
const HuffmanTreeNode* const node) {
- return node->children_;
+ return (node->children_ == 0);
}
// Go down one level. Most critical function. 'right_child' must be 0 or 1.
@@ -80,7 +71,7 @@ int HuffmanCodeLengthsToCodes(const int* const code_lengths,
int code_lengths_size, int* const huff_codes);
-#ifdef __cplusplus
+#if defined(__cplusplus) || defined(c_plusplus)
} // extern "C"
#endif