1/* Copyright (C) 2001-2019 Artifex Software, Inc.
2 All Rights Reserved.
3
4 This software is provided AS-IS with no warranty, either express or
5 implied.
6
7 This software is distributed under license and may not be copied,
8 modified or distributed except as expressly authorized under the terms
9 of the license contained in the file LICENSE in this distribution.
10
11 Refer to licensing information at http://www.artifex.com or contact
12 Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
13 CA 94945, U.S.A., +1(415)492-9861, for further information.
14*/
15
16/*
17 jbig2dec
18*/
19
20/* predefined Huffman table definitions
21 -- See Annex B of the JBIG2 specification */
22
23#ifndef _JBIG2_HUFFTAB_H
24#define _JBIG2_HUFFTAB_H
25
26/* types are in jbig2_huffman.h, you must include that first */
27
28#define JBIG2_COUNTOF(x) (sizeof((x)) / sizeof((x)[0]))
29
30/* Table B.1 */
31const Jbig2HuffmanLine jbig2_huffman_lines_A[] = {
32 {1, 4, 0},
33 {2, 8, 16},
34 {3, 16, 272},
35 {0, 32, -1}, /* low */
36 {3, 32, 65808} /* high */
37};
38
39const Jbig2HuffmanParams jbig2_huffman_params_A = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_A), jbig2_huffman_lines_A };
40
41/* Table B.2 */
42const Jbig2HuffmanLine jbig2_huffman_lines_B[] = {
43 {1, 0, 0},
44 {2, 0, 1},
45 {3, 0, 2},
46 {4, 3, 3},
47 {5, 6, 11},
48 {0, 32, -1}, /* low */
49 {6, 32, 75}, /* high */
50 {6, 0, 0} /* OOB */
51};
52
53const Jbig2HuffmanParams jbig2_huffman_params_B = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_B), jbig2_huffman_lines_B };
54
55/* Table B.3 */
56const Jbig2HuffmanLine jbig2_huffman_lines_C[] = {
57 {8, 8, -256},
58 {1, 0, 0},
59 {2, 0, 1},
60 {3, 0, 2},
61 {4, 3, 3},
62 {5, 6, 11},
63 {8, 32, -257}, /* low */
64 {7, 32, 75}, /* high */
65 {6, 0, 0} /* OOB */
66};
67
68const Jbig2HuffmanParams jbig2_huffman_params_C = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_C), jbig2_huffman_lines_C };
69
70/* Table B.4 */
71const Jbig2HuffmanLine jbig2_huffman_lines_D[] = {
72 {1, 0, 1},
73 {2, 0, 2},
74 {3, 0, 3},
75 {4, 3, 4},
76 {5, 6, 12},
77 {0, 32, -1}, /* low */
78 {5, 32, 76}, /* high */
79};
80
81const Jbig2HuffmanParams jbig2_huffman_params_D = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_D), jbig2_huffman_lines_D };
82
83/* Table B.5 */
84const Jbig2HuffmanLine jbig2_huffman_lines_E[] = {
85 {7, 8, -255},
86 {1, 0, 1},
87 {2, 0, 2},
88 {3, 0, 3},
89 {4, 3, 4},
90 {5, 6, 12},
91 {7, 32, -256}, /* low */
92 {6, 32, 76} /* high */
93};
94
95const Jbig2HuffmanParams jbig2_huffman_params_E = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_E), jbig2_huffman_lines_E };
96
97/* Table B.6 */
98const Jbig2HuffmanLine jbig2_huffman_lines_F[] = {
99 {5, 10, -2048},
100 {4, 9, -1024},
101 {4, 8, -512},
102 {4, 7, -256},
103 {5, 6, -128},
104 {5, 5, -64},
105 {4, 5, -32},
106 {2, 7, 0},
107 {3, 7, 128},
108 {3, 8, 256},
109 {4, 9, 512},
110 {4, 10, 1024},
111 {6, 32, -2049}, /* low */
112 {6, 32, 2048} /* high */
113};
114
115const Jbig2HuffmanParams jbig2_huffman_params_F = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_F), jbig2_huffman_lines_F };
116
117/* Table B.7 */
118const Jbig2HuffmanLine jbig2_huffman_lines_G[] = {
119 {4, 9, -1024},
120 {3, 8, -512},
121 {4, 7, -256},
122 {5, 6, -128},
123 {5, 5, -64},
124 {4, 5, -32},
125 {4, 5, 0},
126 {5, 5, 32},
127 {5, 6, 64},
128 {4, 7, 128},
129 {3, 8, 256},
130 {3, 9, 512},
131 {3, 10, 1024},
132 {5, 32, -1025}, /* low */
133 {5, 32, 2048} /* high */
134};
135
136const Jbig2HuffmanParams jbig2_huffman_params_G = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_G), jbig2_huffman_lines_G };
137
138/* Table B.8 */
139const Jbig2HuffmanLine jbig2_huffman_lines_H[] = {
140 {8, 3, -15},
141 {9, 1, -7},
142 {8, 1, -5},
143 {9, 0, -3},
144 {7, 0, -2},
145 {4, 0, -1},
146 {2, 1, 0},
147 {5, 0, 2},
148 {6, 0, 3},
149 {3, 4, 4},
150 {6, 1, 20},
151 {4, 4, 22},
152 {4, 5, 38},
153 {5, 6, 70},
154 {5, 7, 134},
155 {6, 7, 262},
156 {7, 8, 390},
157 {6, 10, 646},
158 {9, 32, -16}, /* low */
159 {9, 32, 1670}, /* high */
160 {2, 0, 0} /* OOB */
161};
162
163const Jbig2HuffmanParams jbig2_huffman_params_H = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_H), jbig2_huffman_lines_H };
164
165/* Table B.9 */
166const Jbig2HuffmanLine jbig2_huffman_lines_I[] = {
167 {8, 4, -31},
168 {9, 2, -15},
169 {8, 2, -11},
170 {9, 1, -7},
171 {7, 1, -5},
172 {4, 1, -3},
173 {3, 1, -1},
174 {3, 1, 1},
175 {5, 1, 3},
176 {6, 1, 5},
177 {3, 5, 7},
178 {6, 2, 39},
179 {4, 5, 43},
180 {4, 6, 75},
181 {5, 7, 139},
182 {5, 8, 267},
183 {6, 8, 523},
184 {7, 9, 779},
185 {6, 11, 1291},
186 {9, 32, -32}, /* low */
187 {9, 32, 3339}, /* high */
188 {2, 0, 0} /* OOB */
189};
190
191const Jbig2HuffmanParams jbig2_huffman_params_I = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_I), jbig2_huffman_lines_I };
192
193/* Table B.10 */
194const Jbig2HuffmanLine jbig2_huffman_lines_J[] = {
195 {7, 4, -21},
196 {8, 0, -5},
197 {7, 0, -4},
198 {5, 0, -3},
199 {2, 2, -2},
200 {5, 0, 2},
201 {6, 0, 3},
202 {7, 0, 4},
203 {8, 0, 5},
204 {2, 6, 6},
205 {5, 5, 70},
206 {6, 5, 102},
207 {6, 6, 134},
208 {6, 7, 198},
209 {6, 8, 326},
210 {6, 9, 582},
211 {6, 10, 1094},
212 {7, 11, 2118},
213 {8, 32, -22}, /* low */
214 {8, 32, 4166}, /* high */
215 {2, 0, 0} /* OOB */
216};
217
218const Jbig2HuffmanParams jbig2_huffman_params_J = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_J), jbig2_huffman_lines_J };
219
220/* Table B.11 */
221const Jbig2HuffmanLine jbig2_huffman_lines_K[] = {
222 {1, 0, 1},
223 {2, 1, 2},
224 {4, 0, 4},
225 {4, 1, 5},
226 {5, 1, 7},
227 {5, 2, 9},
228 {6, 2, 13},
229 {7, 2, 17},
230 {7, 3, 21},
231 {7, 4, 29},
232 {7, 5, 45},
233 {7, 6, 77},
234 {0, 32, -1}, /* low */
235 {7, 32, 141} /* high */
236};
237
238const Jbig2HuffmanParams jbig2_huffman_params_K = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_K), jbig2_huffman_lines_K };
239
240/* Table B.12 */
241const Jbig2HuffmanLine jbig2_huffman_lines_L[] = {
242 {1, 0, 1},
243 {2, 0, 2},
244 {3, 1, 3},
245 {5, 0, 5},
246 {5, 1, 6},
247 {6, 1, 8},
248 {7, 0, 10},
249 {7, 1, 11},
250 {7, 2, 13},
251 {7, 3, 17},
252 {7, 4, 25},
253 {8, 5, 41},
254 {8, 32, 73},
255 {0, 32, -1}, /* low */
256 {0, 32, 0} /* high */
257};
258
259const Jbig2HuffmanParams jbig2_huffman_params_L = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_L), jbig2_huffman_lines_L };
260
261/* Table B.13 */
262const Jbig2HuffmanLine jbig2_huffman_lines_M[] = {
263 {1, 0, 1},
264 {3, 0, 2},
265 {4, 0, 3},
266 {5, 0, 4},
267 {4, 1, 5},
268 {3, 3, 7},
269 {6, 1, 15},
270 {6, 2, 17},
271 {6, 3, 21},
272 {6, 4, 29},
273 {6, 5, 45},
274 {7, 6, 77},
275 {0, 32, -1}, /* low */
276 {7, 32, 141} /* high */
277};
278
279const Jbig2HuffmanParams jbig2_huffman_params_M = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_M), jbig2_huffman_lines_M };
280
281/* Table B.14 */
282const Jbig2HuffmanLine jbig2_huffman_lines_N[] = {
283 {3, 0, -2},
284 {3, 0, -1},
285 {1, 0, 0},
286 {3, 0, 1},
287 {3, 0, 2},
288 {0, 32, -1}, /* low */
289 {0, 32, 3}, /* high */
290};
291
292const Jbig2HuffmanParams jbig2_huffman_params_N = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_N), jbig2_huffman_lines_N };
293
294/* Table B.15 */
295const Jbig2HuffmanLine jbig2_huffman_lines_O[] = {
296 {7, 4, -24},
297 {6, 2, -8},
298 {5, 1, -4},
299 {4, 0, -2},
300 {3, 0, -1},
301 {1, 0, 0},
302 {3, 0, 1},
303 {4, 0, 2},
304 {5, 1, 3},
305 {6, 2, 5},
306 {7, 4, 9},
307 {7, 32, -25}, /* low */
308 {7, 32, 25} /* high */
309};
310
311const Jbig2HuffmanParams jbig2_huffman_params_O = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_O), jbig2_huffman_lines_O };
312
313#undef JBIG2_COUNTOF
314
315#endif /* _JBIG2_HUFFTAB_H */
316