OLD | NEW |
1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
9 // | 9 // |
10 // Author: Jyrki Alakuijala (jyrki@google.com) | 10 // Author: Jyrki Alakuijala (jyrki@google.com) |
11 // | 11 // |
12 // Entropy encoding (Huffman) for webp lossless | 12 // Entropy encoding (Huffman) for webp lossless |
13 | 13 |
14 #ifndef WEBP_UTILS_HUFFMAN_ENCODE_H_ | 14 #ifndef WEBP_UTILS_HUFFMAN_ENCODE_H_ |
15 #define WEBP_UTILS_HUFFMAN_ENCODE_H_ | 15 #define WEBP_UTILS_HUFFMAN_ENCODE_H_ |
16 | 16 |
17 #include "../webp/types.h" | 17 #include "../webp/types.h" |
18 | 18 |
19 #if defined(__cplusplus) || defined(c_plusplus) | 19 #ifdef __cplusplus |
20 extern "C" { | 20 extern "C" { |
21 #endif | 21 #endif |
22 | 22 |
23 // Struct for holding the tree header in coded form. | 23 // Struct for holding the tree header in coded form. |
24 typedef struct { | 24 typedef struct { |
25 uint8_t code; // value (0..15) or escape code (16,17,18) | 25 uint8_t code; // value (0..15) or escape code (16,17,18) |
26 uint8_t extra_bits; // extra bits for escape codes | 26 uint8_t extra_bits; // extra bits for escape codes |
27 } HuffmanTreeToken; | 27 } HuffmanTreeToken; |
28 | 28 |
29 // Struct to represent the tree codes (depth and bits array). | 29 // Struct to represent the tree codes (depth and bits array). |
30 typedef struct { | 30 typedef struct { |
31 int num_symbols; // Number of symbols. | 31 int num_symbols; // Number of symbols. |
32 uint8_t* code_lengths; // Code lengths of the symbols. | 32 uint8_t* code_lengths; // Code lengths of the symbols. |
33 uint16_t* codes; // Symbol Codes. | 33 uint16_t* codes; // Symbol Codes. |
34 } HuffmanTreeCode; | 34 } HuffmanTreeCode; |
35 | 35 |
36 // Turn the Huffman tree into a token sequence. | 36 // Turn the Huffman tree into a token sequence. |
37 // Returns the number of tokens used. | 37 // Returns the number of tokens used. |
38 int VP8LCreateCompressedHuffmanTree(const HuffmanTreeCode* const tree, | 38 int VP8LCreateCompressedHuffmanTree(const HuffmanTreeCode* const tree, |
39 HuffmanTreeToken* tokens, int max_tokens); | 39 HuffmanTreeToken* tokens, int max_tokens); |
40 | 40 |
41 // Create an optimized tree, and tokenize it. | 41 // Create an optimized tree, and tokenize it. |
42 int VP8LCreateHuffmanTree(int* const histogram, int tree_depth_limit, | 42 int VP8LCreateHuffmanTree(int* const histogram, int tree_depth_limit, |
43 HuffmanTreeCode* const tree); | 43 HuffmanTreeCode* const tree); |
44 | 44 |
45 #if defined(__cplusplus) || defined(c_plusplus) | 45 #ifdef __cplusplus |
46 } | 46 } |
47 #endif | 47 #endif |
48 | 48 |
49 #endif // WEBP_UTILS_HUFFMAN_ENCODE_H_ | 49 #endif // WEBP_UTILS_HUFFMAN_ENCODE_H_ |
OLD | NEW |