more decompress
[wireshark-sm.git] / epan / nghttp2_hd_huffman.h
blob01a1fbc8b70db7046ebafb619ded3576ad423a4c
1 /* @file
2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2013 Tatsuhiro Tsujikawa
6 * SPDX-License-Identifier: MIT
7 */
8 #ifndef NGHTTP2_HD_HUFFMAN_H
9 #define NGHTTP2_HD_HUFFMAN_H
11 #include <config.h>
13 #include <stdlib.h>
14 #include <stdint.h>
16 typedef enum {
17 /* FSA accepts this state as the end of huffman encoding
18 sequence. */
19 NGHTTP2_HUFF_ACCEPTED = 1 << 14,
20 /* This state emits symbol */
21 NGHTTP2_HUFF_SYM = 1 << 15,
22 } nghttp2_huff_decode_flag;
24 typedef struct {
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
31 failed. */
32 uint16_t fstate;
33 /* symbol if NGHTTP2_HUFF_SYM flag set */
34 uint8_t sym;
35 } nghttp2_huff_decode;
37 typedef nghttp2_huff_decode huff_decode_table_type[16];
39 typedef struct {
40 /* fstate is the current huffman decoding state. */
41 uint16_t fstate;
42 } nghttp2_hd_huff_decode_context;
44 typedef struct {
45 /* The number of bits in this code */
46 uint32_t nbits;
47 /* Huffman code aligned to LSB */
48 uint32_t code;
49 } nghttp2_huff_sym;
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 */