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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
|
/* Copyright (C) 2001-2023 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution.
Refer to licensing information at http://www.artifex.com or contact
Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
CA 94129, USA, for further information.
*/
/*
jbig2dec
*/
/* predefined Huffman table definitions
-- See Annex B of the JBIG2 specification */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "os_types.h"
#include <stdlib.h>
#include "jbig2.h"
#include "jbig2_priv.h"
#include "jbig2_huffman.h"
#include "jbig2_hufftab.h"
#define JBIG2_COUNTOF(x) (sizeof((x)) / sizeof((x)[0]))
/* Table B.1 */
static const Jbig2HuffmanLine jbig2_huffman_lines_A[] = {
{1, 4, 0},
{2, 8, 16},
{3, 16, 272},
{0, 32, -1}, /* low */
{3, 32, 65808} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_A = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_A), jbig2_huffman_lines_A };
/* Table B.2 */
static const Jbig2HuffmanLine jbig2_huffman_lines_B[] = {
{1, 0, 0},
{2, 0, 1},
{3, 0, 2},
{4, 3, 3},
{5, 6, 11},
{0, 32, -1}, /* low */
{6, 32, 75}, /* high */
{6, 0, 0} /* OOB */
};
const Jbig2HuffmanParams jbig2_huffman_params_B = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_B), jbig2_huffman_lines_B };
/* Table B.3 */
static const Jbig2HuffmanLine jbig2_huffman_lines_C[] = {
{8, 8, -256},
{1, 0, 0},
{2, 0, 1},
{3, 0, 2},
{4, 3, 3},
{5, 6, 11},
{8, 32, -257}, /* low */
{7, 32, 75}, /* high */
{6, 0, 0} /* OOB */
};
const Jbig2HuffmanParams jbig2_huffman_params_C = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_C), jbig2_huffman_lines_C };
/* Table B.4 */
static const Jbig2HuffmanLine jbig2_huffman_lines_D[] = {
{1, 0, 1},
{2, 0, 2},
{3, 0, 3},
{4, 3, 4},
{5, 6, 12},
{0, 32, -1}, /* low */
{5, 32, 76}, /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_D = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_D), jbig2_huffman_lines_D };
/* Table B.5 */
static const Jbig2HuffmanLine jbig2_huffman_lines_E[] = {
{7, 8, -255},
{1, 0, 1},
{2, 0, 2},
{3, 0, 3},
{4, 3, 4},
{5, 6, 12},
{7, 32, -256}, /* low */
{6, 32, 76} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_E = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_E), jbig2_huffman_lines_E };
/* Table B.6 */
static const Jbig2HuffmanLine jbig2_huffman_lines_F[] = {
{5, 10, -2048},
{4, 9, -1024},
{4, 8, -512},
{4, 7, -256},
{5, 6, -128},
{5, 5, -64},
{4, 5, -32},
{2, 7, 0},
{3, 7, 128},
{3, 8, 256},
{4, 9, 512},
{4, 10, 1024},
{6, 32, -2049}, /* low */
{6, 32, 2048} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_F = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_F), jbig2_huffman_lines_F };
/* Table B.7 */
static const Jbig2HuffmanLine jbig2_huffman_lines_G[] = {
{4, 9, -1024},
{3, 8, -512},
{4, 7, -256},
{5, 6, -128},
{5, 5, -64},
{4, 5, -32},
{4, 5, 0},
{5, 5, 32},
{5, 6, 64},
{4, 7, 128},
{3, 8, 256},
{3, 9, 512},
{3, 10, 1024},
{5, 32, -1025}, /* low */
{5, 32, 2048} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_G = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_G), jbig2_huffman_lines_G };
/* Table B.8 */
static const Jbig2HuffmanLine jbig2_huffman_lines_H[] = {
{8, 3, -15},
{9, 1, -7},
{8, 1, -5},
{9, 0, -3},
{7, 0, -2},
{4, 0, -1},
{2, 1, 0},
{5, 0, 2},
{6, 0, 3},
{3, 4, 4},
{6, 1, 20},
{4, 4, 22},
{4, 5, 38},
{5, 6, 70},
{5, 7, 134},
{6, 7, 262},
{7, 8, 390},
{6, 10, 646},
{9, 32, -16}, /* low */
{9, 32, 1670}, /* high */
{2, 0, 0} /* OOB */
};
const Jbig2HuffmanParams jbig2_huffman_params_H = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_H), jbig2_huffman_lines_H };
/* Table B.9 */
static const Jbig2HuffmanLine jbig2_huffman_lines_I[] = {
{8, 4, -31},
{9, 2, -15},
{8, 2, -11},
{9, 1, -7},
{7, 1, -5},
{4, 1, -3},
{3, 1, -1},
{3, 1, 1},
{5, 1, 3},
{6, 1, 5},
{3, 5, 7},
{6, 2, 39},
{4, 5, 43},
{4, 6, 75},
{5, 7, 139},
{5, 8, 267},
{6, 8, 523},
{7, 9, 779},
{6, 11, 1291},
{9, 32, -32}, /* low */
{9, 32, 3339}, /* high */
{2, 0, 0} /* OOB */
};
const Jbig2HuffmanParams jbig2_huffman_params_I = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_I), jbig2_huffman_lines_I };
/* Table B.10 */
static const Jbig2HuffmanLine jbig2_huffman_lines_J[] = {
{7, 4, -21},
{8, 0, -5},
{7, 0, -4},
{5, 0, -3},
{2, 2, -2},
{5, 0, 2},
{6, 0, 3},
{7, 0, 4},
{8, 0, 5},
{2, 6, 6},
{5, 5, 70},
{6, 5, 102},
{6, 6, 134},
{6, 7, 198},
{6, 8, 326},
{6, 9, 582},
{6, 10, 1094},
{7, 11, 2118},
{8, 32, -22}, /* low */
{8, 32, 4166}, /* high */
{2, 0, 0} /* OOB */
};
const Jbig2HuffmanParams jbig2_huffman_params_J = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_J), jbig2_huffman_lines_J };
/* Table B.11 */
static const Jbig2HuffmanLine jbig2_huffman_lines_K[] = {
{1, 0, 1},
{2, 1, 2},
{4, 0, 4},
{4, 1, 5},
{5, 1, 7},
{5, 2, 9},
{6, 2, 13},
{7, 2, 17},
{7, 3, 21},
{7, 4, 29},
{7, 5, 45},
{7, 6, 77},
{0, 32, -1}, /* low */
{7, 32, 141} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_K = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_K), jbig2_huffman_lines_K };
/* Table B.12 */
static const Jbig2HuffmanLine jbig2_huffman_lines_L[] = {
{1, 0, 1},
{2, 0, 2},
{3, 1, 3},
{5, 0, 5},
{5, 1, 6},
{6, 1, 8},
{7, 0, 10},
{7, 1, 11},
{7, 2, 13},
{7, 3, 17},
{7, 4, 25},
{8, 5, 41},
{8, 32, 73},
{0, 32, -1}, /* low */
{0, 32, 0} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_L = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_L), jbig2_huffman_lines_L };
/* Table B.13 */
static const Jbig2HuffmanLine jbig2_huffman_lines_M[] = {
{1, 0, 1},
{3, 0, 2},
{4, 0, 3},
{5, 0, 4},
{4, 1, 5},
{3, 3, 7},
{6, 1, 15},
{6, 2, 17},
{6, 3, 21},
{6, 4, 29},
{6, 5, 45},
{7, 6, 77},
{0, 32, -1}, /* low */
{7, 32, 141} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_M = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_M), jbig2_huffman_lines_M };
/* Table B.14 */
static const Jbig2HuffmanLine jbig2_huffman_lines_N[] = {
{3, 0, -2},
{3, 0, -1},
{1, 0, 0},
{3, 0, 1},
{3, 0, 2},
{0, 32, -1}, /* low */
{0, 32, 3}, /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_N = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_N), jbig2_huffman_lines_N };
/* Table B.15 */
static const Jbig2HuffmanLine jbig2_huffman_lines_O[] = {
{7, 4, -24},
{6, 2, -8},
{5, 1, -4},
{4, 0, -2},
{3, 0, -1},
{1, 0, 0},
{3, 0, 1},
{4, 0, 2},
{5, 1, 3},
{6, 2, 5},
{7, 4, 9},
{7, 32, -25}, /* low */
{7, 32, 25} /* high */
};
const Jbig2HuffmanParams jbig2_huffman_params_O = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_O), jbig2_huffman_lines_O };
|