-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhuff_tbl.c
183 lines (166 loc) · 6.16 KB
/
huff_tbl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include "entropy.h"
#ifndef ALL_ARITH
HUFF_TABLE b2 = {6, /* size */
{{0x00, 1, 0}, {0x02, 2, 0}, {0x06, 3, 0}, {0x0e, 4, 3},
{0x1e, 5, 6}, {0x3e, 6,32}}, /* code table */
{{0, 0}, {1, 1}, {2, 2}, {3, 10}, {11, 74},
{75, INF}}, /* range table*/
0x3f, /* OOB code */
6 /* OOB length */
};
HUFF_TABLE b3 = {8,
{{0xff, 8,32}, {0xfe, 8, 8}, {0x00, 1, 0}, {0x02, 2, 0},
{0x06, 3, 0}, {0x0e, 4, 3}, {0x1e, 5, 6}, {0x7e, 6,32}},
{{-INF, -257}, {-256, -1}, {0, 0}, {1, 1},
{2, 2}, {3, 10}, {11, 74}, {75, INF}},
0x3e,
6
};
HUFF_TABLE b4 = {6,
{{0x00, 1, 0}, {0x02, 2, 0}, {0x06, 3, 0}, {0x0e, 4, 3},
{0x1e, 5, 6}, {0x1f, 5,32}},
{{1, 1}, {2, 2}, {3, 3}, {4, 11}, {12, 75}, {76, INF}},
0x00,
0
};
HUFF_TABLE b5 = {8,
{{0x7f, 7,32}, {0x7e, 7, 8}, {0x00, 1, 0}, {0x02, 2, 0},
{0x06, 3, 0}, {0x0e, 4, 3}, {0x1e, 5, 6}, {0x3e, 6,32}},
{{-INF, -256}, {-255, 0}, {1, 1}, {2, 2}, {3, 3},
{4, 11}, {12, 75}, {76, INF}},
0x00,
0
};
HUFF_TABLE b6 = {14,
{{0x3e, 6,32}, {0x1c, 5,10}, {0x08, 4, 9}, {0x09, 4, 8},
{0x0a, 4, 7}, {0x1d, 5, 6}, {0x1e, 5, 5}, {0x0b, 4, 5},
{0x00, 2, 7}, {0x02, 3, 7}, {0x03, 3, 8}, {0x0c, 4, 9},
{0x0d, 4,10}, {0x3f, 6,32}},
{{-INF, -2049}, {-2048, -1025}, {-1024, -513},
{-512, -257}, {-256, -129}, {-128, -65}, {-64, -33},
{-32, -1}, {0, 127}, {128, 255}, {256, 511},
{512, 1023}, {1024, 2047}, {2048, INF}},
0x00,
0
};
HUFF_TABLE b7 = {15,
{{0x1e, 5,32}, {0x08, 4, 9}, {0x00, 3, 8}, {0x09, 4, 7},
{0x1a, 5, 6}, {0x1b, 5, 5}, {0x0a, 4, 5}, {0x0b, 4, 5},
{0x1c, 5, 5}, {0x1d, 5, 6}, {0x0c, 4, 7}, {0x01, 3, 8},
{0x02, 3, 9}, {0x03, 3,10}, {0x1f, 5,32}},
{{-INF, -1025}, {-1024, -513}, {-512, -257}, {-256, -129},
{-128, -65}, {-64, -33}, {-32, -1}, {0, 31}, {32, 63},
{64, 127}, {128, 255}, {256, 511}, {512, 1023},
{1024, 2047}, {2048, INF}},
0x00,
0
};
HUFF_TABLE b8 = {20,
{{0x1fe, 9,32}, {0x0fc, 8, 3}, {0x1fc, 9, 1}, {0x0fd, 8, 1},
{0x1fd, 9, 0}, {0x07c, 7, 0}, {0x00a, 4, 0}, {0x000, 2, 1},
{0x01a, 5, 0}, {0x03a, 6, 0}, {0x004, 3, 4}, {0x03b, 6, 1},
{0x00b, 4, 4}, {0x00c, 4, 5}, {0x01b, 5, 6}, {0x01c, 5, 7},
{0x03c, 6, 7}, {0x07d, 7, 8}, {0x03d, 6,10}, {0x1ff, 9,32}},
{{-INF, -16}, {-15, -8}, {-7, -6}, {-5, -4}, {-3, -3},
{-2, -2}, {-1, -1}, {0, 1}, {2, 2}, {3, 3}, {4, 19},
{20, 21}, {22, 37}, {38, 69}, {70, 133}, {134, 261},
{262, 389}, {390, 645}, {646, 1669}, {1670, INF}},
0x001,
2
};
HUFF_TABLE b9 = {21,
{{0x1fe, 9,32}, {0x0fc, 8, 4}, {0x1fc, 9, 2}, {0x0fd, 8, 2},
{0x1fd, 9, 1}, {0x07c, 7, 1}, {0x00a, 4, 1}, {0x002, 3, 1},
{0x003, 3, 1}, {0x01a, 5, 1}, {0x03a, 6, 1}, {0x004, 3, 5},
{0x03b, 6, 2}, {0x00b, 4, 5}, {0x00c, 4, 6}, {0x01b, 5, 7},
{0x01c, 5, 8}, {0x03c, 6, 8}, {0x07b, 7, 9}, {0x03b, 6,11},
{0x1ff, 9,32}},
{{-INF, -32}, {-31, -16}, {-15, -12}, {-11, -8}, {-7, -6},
{-5, -4}, {-3, -2}, {-1, 0}, {1, 2}, {3, 4}, {5, 6},
{7, 38}, {39, 42}, {43, 74}, {75, 138}, {139, 266},
{267, 522}, {523, 778}, {779, 1290}, {1291, 3338},
{3339, INF}},
0x000,
2
};
HUFF_TABLE b10 = {20,
{{0xfe, 8,32}, {0x7a, 7, 4}, {0xfc, 8, 0}, {0x7b, 7, 0},
{0x18, 5, 0}, {0x00, 2, 2}, {0x19, 5, 0}, {0x36, 6, 0},
{0x7c, 7, 0}, {0xfd, 8, 0}, {0x01, 2, 6}, {0x1a, 5, 5},
{0x37, 6, 5}, {0x38, 6, 6}, {0x39, 6, 7}, {0x3a, 6, 8},
{0x3b, 6, 9}, {0x3c, 6,10}, {0x7d, 7,11}, {0xff, 8,32}},
{{-INF, -22}, {-21, -6}, {-5, -5}, {-4, -4}, {-3, -3},
{-2, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 69},
{70, 101}, {102, 133}, {134, 197}, {198, 325},
{326, 581}, {582, 1093}, {1094, 2117}, {2118, 4165},
{4166, INF}},
0x02,
2
};
HUFF_TABLE b11 = {13,
{{0x00, 1, 0}, {0x02, 2, 1}, {0x0c, 4, 0}, {0x0d, 4, 1},
{0x1c, 5, 1}, {0x1d, 5, 2}, {0x3c, 6, 2}, {0x7a, 7, 2},
{0x7b, 7, 3}, {0x7c, 7, 4}, {0x7d, 7, 5}, {0x7e, 7, 6},
{0x7f, 7,32}},
{{1, 1}, {2, 3}, {4, 4}, {5, 6}, {7, 8}, {9, 12},
{13, 16}, {17, 20}, {21, 28}, {29, 44}, {45, 76},
{77, 140}, {141, INF}},
0x00,
0
};
HUFF_TABLE b12 = {13,
{{0x00, 1, 0}, {0x02, 2, 0}, {0x06, 3, 1}, {0x1c, 5, 0},
{0x1d, 5, 1}, {0x3c, 6, 1}, {0x7a, 7, 0}, {0x7b, 7, 1},
{0x7c, 7, 2}, {0x7d, 7, 3}, {0x7e, 7, 4}, {0xfe, 8, 5},
{0xff, 8,32}},
{{1, 1}, {2, 2}, {3, 4}, {5, 5}, {6, 7}, {8, 9},
{10, 10}, {11, 12}, {13, 16}, {17, 24}, {25, 40},
{41, 72}, {73, INF}},
0x00,
0
};
HUFF_TABLE b13 = {13,
{{0x00, 1, 0}, {0x04, 3, 0}, {0x0c, 4, 0}, {0x1c, 5, 0},
{0x0d, 4, 1}, {0x05, 3, 3}, {0x3a, 6, 1}, {0x3b, 6, 2},
{0x3c, 6, 3}, {0x3d, 6, 4}, {0x3e, 6, 5}, {0x7e, 7, 6},
{0x7f, 7,32}},
{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 6}, {7, 14},
{15, 16}, {17, 20}, {21, 28}, {29, 44}, {45, 76},
{77, 140}, {141, INF}},
0x00,
0
};
HUFF_TABLE b14 = {5,
{{0x04, 3, 0}, {0x05, 3, 0}, {0x00, 1, 0}, {0x06, 3, 0},
{0x07, 3, 0}},
{{-2, -2}, {-1, -1}, {0, 0}, {1, 1}, {2, 2}},
0x00,
0
};
HUFF_TABLE b15 = {13,
{{0x7e, 7,32}, {0x7c, 7, 4}, {0x3c, 6, 2}, {0x1c, 5, 1},
{0x0c, 4, 0}, {0x04, 3, 0}, {0x00, 1, 0}, {0x05, 3, 0},
{0x0d, 4, 0}, {0x1d, 5, 1}, {0x3d, 6, 2}, {0x7d, 7, 4},
{0x7f, 7, 32}},
{{-INF, -25}, {-24, -9}, {-8, -5}, {-4, -3},
{-2, -2}, {-1, -1}, {0, 0}, {1, 1}, {2, 2},
{3, 4}, {5, 8}, {9, 24}, {25, INF}},
0x00,
0
};
#endif
/* not really for Huffman coding, this table is actually used to */
/* arithmetic encode numerical data other than symbol IDs, it's */
/* put here just for the similarity of format */
HUFF_TABLE int_arith =
{13,
{{0x3f, 6,32}, {0x3e, 6,12}, {0x1e, 5, 8}, {0x0e, 4, 6},
{0x06, 3, 4}, {0x05, 3, 1}, {0x09, 4, 0}, {0x00, 2, 2},
{0x02, 3, 4}, {0x06, 4, 6}, {0x0e, 5, 8}, {0x1e, 6,12},
{0x1f, 6,32}},
{{-INF, -4436}, {-4435, -340}, {-339, -84}, {-83, -20},
{-19, -4}, {-3, -2}, {-1, -1}, {0, 3}, {4, 19},
{20, 83}, {84, 339}, {340, 4435}, {4436, INF}},
0x08,
4
};