2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2013 Tatsuhiro Tsujikawa
6 * SPDX-License-Identifier: MIT
8 #ifndef NGHTTP2_HD_HUFFMAN_H
9 #define NGHTTP2_HD_HUFFMAN_H
17 /* FSA accepts this state as the end of huffman encoding
19 NGHTTP2_HUFF_ACCEPTED
= 1 << 14,
20 /* This state emits symbol */
21 NGHTTP2_HUFF_SYM
= 1 << 15,
22 } nghttp2_huff_decode_flag
;
25 /* fstate is the current huffman decoding state, which is actually
26 the node ID of internal huffman tree with
27 nghttp2_huff_decode_flag OR-ed. We have 257 leaf nodes, but they
28 are identical to root node other than emitting a symbol, so we
29 have 256 internal nodes [1..255], inclusive. The node ID 256 is
30 a special node and it is a terminal state that means decoding
33 /* symbol if NGHTTP2_HUFF_SYM flag set */
35 } nghttp2_huff_decode
;
37 typedef nghttp2_huff_decode huff_decode_table_type
[16];
40 /* fstate is the current huffman decoding state. */
42 } nghttp2_hd_huff_decode_context
;
45 /* The number of bits in this code */
47 /* Huffman code aligned to LSB */
51 extern const nghttp2_huff_sym huff_sym_table
[];
52 extern const nghttp2_huff_decode huff_decode_table
[][16];
54 #endif /* NGHTTP2_HD_HUFFMAN_H */