Add ICU message format support
[chromium-blink-merge.git] / third_party / brotli / dec / huffman.h
blobedadac3b4439ef3f00234d83a570f1ba545b8fa7
1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
16 /* Utilities for building Huffman decoding tables. */
18 #ifndef BROTLI_DEC_HUFFMAN_H_
19 #define BROTLI_DEC_HUFFMAN_H_
21 #include <assert.h>
22 #include "./types.h"
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
28 /* Maximum possible Huffman table size for an alphabet size of 704, max code
29 * length 15 and root table bits 8. */
30 #define BROTLI_HUFFMAN_MAX_TABLE_SIZE 1080
32 typedef struct {
33 uint8_t bits; /* number of bits used for this symbol */
34 uint16_t value; /* symbol value or table offset */
35 } HuffmanCode;
37 /* Builds Huffman lookup table assuming code lengths are in symbol order. */
38 /* Returns false in case of error (invalid tree or memory error). */
39 int BrotliBuildHuffmanTable(HuffmanCode* root_table,
40 int root_bits,
41 const uint8_t* const code_lengths,
42 int code_lengths_size);
44 /* Contains a collection of huffman trees with the same alphabet size. */
45 typedef struct {
46 int alphabet_size;
47 int num_htrees;
48 HuffmanCode* codes;
49 HuffmanCode** htrees;
50 } HuffmanTreeGroup;
52 void BrotliHuffmanTreeGroupInit(HuffmanTreeGroup* group,
53 int alphabet_size, int ntrees);
54 void BrotliHuffmanTreeGroupRelease(HuffmanTreeGroup* group);
56 #if defined(__cplusplus) || defined(c_plusplus)
57 } /* extern "C" */
58 #endif
60 #endif /* BROTLI_DEC_HUFFMAN_H_ */