Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | /*-------------------------------------------------------------*/ |
michael@0 | 3 | /*--- Private header file for the library. ---*/ |
michael@0 | 4 | /*--- bzlib_private.h ---*/ |
michael@0 | 5 | /*-------------------------------------------------------------*/ |
michael@0 | 6 | |
michael@0 | 7 | /* ------------------------------------------------------------------ |
michael@0 | 8 | This file is part of bzip2/libbzip2, a program and library for |
michael@0 | 9 | lossless, block-sorting data compression. |
michael@0 | 10 | |
michael@0 | 11 | bzip2/libbzip2 version 1.0.4 of 20 December 2006 |
michael@0 | 12 | Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org> |
michael@0 | 13 | |
michael@0 | 14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the |
michael@0 | 15 | README file. |
michael@0 | 16 | |
michael@0 | 17 | This program is released under the terms of the license contained |
michael@0 | 18 | in the file LICENSE. |
michael@0 | 19 | ------------------------------------------------------------------ */ |
michael@0 | 20 | |
michael@0 | 21 | |
michael@0 | 22 | #ifndef _BZLIB_PRIVATE_H |
michael@0 | 23 | #define _BZLIB_PRIVATE_H |
michael@0 | 24 | |
michael@0 | 25 | #include <stdlib.h> |
michael@0 | 26 | |
michael@0 | 27 | #ifndef BZ_NO_STDIO |
michael@0 | 28 | #include <stdio.h> |
michael@0 | 29 | #include <ctype.h> |
michael@0 | 30 | #include <string.h> |
michael@0 | 31 | #endif |
michael@0 | 32 | |
michael@0 | 33 | #include "bzlib.h" |
michael@0 | 34 | |
michael@0 | 35 | |
michael@0 | 36 | |
michael@0 | 37 | /*-- General stuff. --*/ |
michael@0 | 38 | |
michael@0 | 39 | #define BZ_VERSION "1.0.4, 20-Dec-2006" |
michael@0 | 40 | |
michael@0 | 41 | typedef char Char; |
michael@0 | 42 | typedef unsigned char Bool; |
michael@0 | 43 | typedef unsigned char UChar; |
michael@0 | 44 | typedef int Int32; |
michael@0 | 45 | typedef unsigned int UInt32; |
michael@0 | 46 | typedef short Int16; |
michael@0 | 47 | typedef unsigned short UInt16; |
michael@0 | 48 | |
michael@0 | 49 | #define True ((Bool)1) |
michael@0 | 50 | #define False ((Bool)0) |
michael@0 | 51 | |
michael@0 | 52 | #ifndef __GNUC__ |
michael@0 | 53 | #define __inline__ /* */ |
michael@0 | 54 | #endif |
michael@0 | 55 | |
michael@0 | 56 | #ifndef BZ_NO_STDIO |
michael@0 | 57 | |
michael@0 | 58 | extern void BZ2_bz__AssertH__fail ( int errcode ); |
michael@0 | 59 | #define AssertH(cond,errcode) \ |
michael@0 | 60 | { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } |
michael@0 | 61 | |
michael@0 | 62 | #if BZ_DEBUG |
michael@0 | 63 | #define AssertD(cond,msg) \ |
michael@0 | 64 | { if (!(cond)) { \ |
michael@0 | 65 | fprintf ( stderr, \ |
michael@0 | 66 | "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ |
michael@0 | 67 | exit(1); \ |
michael@0 | 68 | }} |
michael@0 | 69 | #else |
michael@0 | 70 | #define AssertD(cond,msg) /* */ |
michael@0 | 71 | #endif |
michael@0 | 72 | |
michael@0 | 73 | #define VPrintf0(zf) \ |
michael@0 | 74 | fprintf(stderr,zf) |
michael@0 | 75 | #define VPrintf1(zf,za1) \ |
michael@0 | 76 | fprintf(stderr,zf,za1) |
michael@0 | 77 | #define VPrintf2(zf,za1,za2) \ |
michael@0 | 78 | fprintf(stderr,zf,za1,za2) |
michael@0 | 79 | #define VPrintf3(zf,za1,za2,za3) \ |
michael@0 | 80 | fprintf(stderr,zf,za1,za2,za3) |
michael@0 | 81 | #define VPrintf4(zf,za1,za2,za3,za4) \ |
michael@0 | 82 | fprintf(stderr,zf,za1,za2,za3,za4) |
michael@0 | 83 | #define VPrintf5(zf,za1,za2,za3,za4,za5) \ |
michael@0 | 84 | fprintf(stderr,zf,za1,za2,za3,za4,za5) |
michael@0 | 85 | |
michael@0 | 86 | #else |
michael@0 | 87 | |
michael@0 | 88 | extern void bz_internal_error ( int errcode ); |
michael@0 | 89 | #define AssertH(cond,errcode) \ |
michael@0 | 90 | { if (!(cond)) bz_internal_error ( errcode ); } |
michael@0 | 91 | #define AssertD(cond,msg) do { } while (0) |
michael@0 | 92 | #define VPrintf0(zf) do { } while (0) |
michael@0 | 93 | #define VPrintf1(zf,za1) do { } while (0) |
michael@0 | 94 | #define VPrintf2(zf,za1,za2) do { } while (0) |
michael@0 | 95 | #define VPrintf3(zf,za1,za2,za3) do { } while (0) |
michael@0 | 96 | #define VPrintf4(zf,za1,za2,za3,za4) do { } while (0) |
michael@0 | 97 | #define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0) |
michael@0 | 98 | |
michael@0 | 99 | #endif |
michael@0 | 100 | |
michael@0 | 101 | |
michael@0 | 102 | #define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) |
michael@0 | 103 | #define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) |
michael@0 | 104 | |
michael@0 | 105 | |
michael@0 | 106 | /*-- Header bytes. --*/ |
michael@0 | 107 | |
michael@0 | 108 | #define BZ_HDR_B 0x42 /* 'B' */ |
michael@0 | 109 | #define BZ_HDR_Z 0x5a /* 'Z' */ |
michael@0 | 110 | #define BZ_HDR_h 0x68 /* 'h' */ |
michael@0 | 111 | #define BZ_HDR_0 0x30 /* '0' */ |
michael@0 | 112 | |
michael@0 | 113 | /*-- Constants for the back end. --*/ |
michael@0 | 114 | |
michael@0 | 115 | #define BZ_MAX_ALPHA_SIZE 258 |
michael@0 | 116 | #define BZ_MAX_CODE_LEN 23 |
michael@0 | 117 | |
michael@0 | 118 | #define BZ_RUNA 0 |
michael@0 | 119 | #define BZ_RUNB 1 |
michael@0 | 120 | |
michael@0 | 121 | #define BZ_N_GROUPS 6 |
michael@0 | 122 | #define BZ_G_SIZE 50 |
michael@0 | 123 | #define BZ_N_ITERS 4 |
michael@0 | 124 | |
michael@0 | 125 | #define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE)) |
michael@0 | 126 | |
michael@0 | 127 | |
michael@0 | 128 | |
michael@0 | 129 | /*-- Stuff for randomising repetitive blocks. --*/ |
michael@0 | 130 | |
michael@0 | 131 | extern Int32 BZ2_rNums[512]; |
michael@0 | 132 | |
michael@0 | 133 | #define BZ_RAND_DECLS \ |
michael@0 | 134 | Int32 rNToGo; \ |
michael@0 | 135 | Int32 rTPos \ |
michael@0 | 136 | |
michael@0 | 137 | #define BZ_RAND_INIT_MASK \ |
michael@0 | 138 | s->rNToGo = 0; \ |
michael@0 | 139 | s->rTPos = 0 \ |
michael@0 | 140 | |
michael@0 | 141 | #define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0) |
michael@0 | 142 | |
michael@0 | 143 | #define BZ_RAND_UPD_MASK \ |
michael@0 | 144 | if (s->rNToGo == 0) { \ |
michael@0 | 145 | s->rNToGo = BZ2_rNums[s->rTPos]; \ |
michael@0 | 146 | s->rTPos++; \ |
michael@0 | 147 | if (s->rTPos == 512) s->rTPos = 0; \ |
michael@0 | 148 | } \ |
michael@0 | 149 | s->rNToGo--; |
michael@0 | 150 | |
michael@0 | 151 | |
michael@0 | 152 | |
michael@0 | 153 | /*-- Stuff for doing CRCs. --*/ |
michael@0 | 154 | |
michael@0 | 155 | extern UInt32 BZ2_crc32Table[256]; |
michael@0 | 156 | |
michael@0 | 157 | #define BZ_INITIALISE_CRC(crcVar) \ |
michael@0 | 158 | { \ |
michael@0 | 159 | crcVar = 0xffffffffL; \ |
michael@0 | 160 | } |
michael@0 | 161 | |
michael@0 | 162 | #define BZ_FINALISE_CRC(crcVar) \ |
michael@0 | 163 | { \ |
michael@0 | 164 | crcVar = ~(crcVar); \ |
michael@0 | 165 | } |
michael@0 | 166 | |
michael@0 | 167 | #define BZ_UPDATE_CRC(crcVar,cha) \ |
michael@0 | 168 | { \ |
michael@0 | 169 | crcVar = (crcVar << 8) ^ \ |
michael@0 | 170 | BZ2_crc32Table[(crcVar >> 24) ^ \ |
michael@0 | 171 | ((UChar)cha)]; \ |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | |
michael@0 | 175 | |
michael@0 | 176 | /*-- States and modes for compression. --*/ |
michael@0 | 177 | |
michael@0 | 178 | #define BZ_M_IDLE 1 |
michael@0 | 179 | #define BZ_M_RUNNING 2 |
michael@0 | 180 | #define BZ_M_FLUSHING 3 |
michael@0 | 181 | #define BZ_M_FINISHING 4 |
michael@0 | 182 | |
michael@0 | 183 | #define BZ_S_OUTPUT 1 |
michael@0 | 184 | #define BZ_S_INPUT 2 |
michael@0 | 185 | |
michael@0 | 186 | #define BZ_N_RADIX 2 |
michael@0 | 187 | #define BZ_N_QSORT 12 |
michael@0 | 188 | #define BZ_N_SHELL 18 |
michael@0 | 189 | #define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) |
michael@0 | 190 | |
michael@0 | 191 | |
michael@0 | 192 | |
michael@0 | 193 | |
michael@0 | 194 | /*-- Structure holding all the compression-side stuff. --*/ |
michael@0 | 195 | |
michael@0 | 196 | typedef |
michael@0 | 197 | struct { |
michael@0 | 198 | /* pointer back to the struct bz_stream */ |
michael@0 | 199 | bz_stream* strm; |
michael@0 | 200 | |
michael@0 | 201 | /* mode this stream is in, and whether inputting */ |
michael@0 | 202 | /* or outputting data */ |
michael@0 | 203 | Int32 mode; |
michael@0 | 204 | Int32 state; |
michael@0 | 205 | |
michael@0 | 206 | /* remembers avail_in when flush/finish requested */ |
michael@0 | 207 | UInt32 avail_in_expect; |
michael@0 | 208 | |
michael@0 | 209 | /* for doing the block sorting */ |
michael@0 | 210 | UInt32* arr1; |
michael@0 | 211 | UInt32* arr2; |
michael@0 | 212 | UInt32* ftab; |
michael@0 | 213 | Int32 origPtr; |
michael@0 | 214 | |
michael@0 | 215 | /* aliases for arr1 and arr2 */ |
michael@0 | 216 | UInt32* ptr; |
michael@0 | 217 | UChar* block; |
michael@0 | 218 | UInt16* mtfv; |
michael@0 | 219 | UChar* zbits; |
michael@0 | 220 | |
michael@0 | 221 | /* for deciding when to use the fallback sorting algorithm */ |
michael@0 | 222 | Int32 workFactor; |
michael@0 | 223 | |
michael@0 | 224 | /* run-length-encoding of the input */ |
michael@0 | 225 | UInt32 state_in_ch; |
michael@0 | 226 | Int32 state_in_len; |
michael@0 | 227 | BZ_RAND_DECLS; |
michael@0 | 228 | |
michael@0 | 229 | /* input and output limits and current posns */ |
michael@0 | 230 | Int32 nblock; |
michael@0 | 231 | Int32 nblockMAX; |
michael@0 | 232 | Int32 numZ; |
michael@0 | 233 | Int32 state_out_pos; |
michael@0 | 234 | |
michael@0 | 235 | /* map of bytes used in block */ |
michael@0 | 236 | Int32 nInUse; |
michael@0 | 237 | Bool inUse[256]; |
michael@0 | 238 | UChar unseqToSeq[256]; |
michael@0 | 239 | |
michael@0 | 240 | /* the buffer for bit stream creation */ |
michael@0 | 241 | UInt32 bsBuff; |
michael@0 | 242 | Int32 bsLive; |
michael@0 | 243 | |
michael@0 | 244 | /* block and combined CRCs */ |
michael@0 | 245 | UInt32 blockCRC; |
michael@0 | 246 | UInt32 combinedCRC; |
michael@0 | 247 | |
michael@0 | 248 | /* misc administratium */ |
michael@0 | 249 | Int32 verbosity; |
michael@0 | 250 | Int32 blockNo; |
michael@0 | 251 | Int32 blockSize100k; |
michael@0 | 252 | |
michael@0 | 253 | /* stuff for coding the MTF values */ |
michael@0 | 254 | Int32 nMTF; |
michael@0 | 255 | Int32 mtfFreq [BZ_MAX_ALPHA_SIZE]; |
michael@0 | 256 | UChar selector [BZ_MAX_SELECTORS]; |
michael@0 | 257 | UChar selectorMtf[BZ_MAX_SELECTORS]; |
michael@0 | 258 | |
michael@0 | 259 | UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
michael@0 | 260 | Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
michael@0 | 261 | Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
michael@0 | 262 | /* second dimension: only 3 needed; 4 makes index calculations faster */ |
michael@0 | 263 | UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4]; |
michael@0 | 264 | |
michael@0 | 265 | } |
michael@0 | 266 | EState; |
michael@0 | 267 | |
michael@0 | 268 | |
michael@0 | 269 | |
michael@0 | 270 | /*-- externs for compression. --*/ |
michael@0 | 271 | |
michael@0 | 272 | extern void |
michael@0 | 273 | BZ2_blockSort ( EState* ); |
michael@0 | 274 | |
michael@0 | 275 | extern void |
michael@0 | 276 | BZ2_compressBlock ( EState*, Bool ); |
michael@0 | 277 | |
michael@0 | 278 | extern void |
michael@0 | 279 | BZ2_bsInitWrite ( EState* ); |
michael@0 | 280 | |
michael@0 | 281 | extern void |
michael@0 | 282 | BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); |
michael@0 | 283 | |
michael@0 | 284 | extern void |
michael@0 | 285 | BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); |
michael@0 | 286 | |
michael@0 | 287 | |
michael@0 | 288 | |
michael@0 | 289 | /*-- states for decompression. --*/ |
michael@0 | 290 | |
michael@0 | 291 | #define BZ_X_IDLE 1 |
michael@0 | 292 | #define BZ_X_OUTPUT 2 |
michael@0 | 293 | |
michael@0 | 294 | #define BZ_X_MAGIC_1 10 |
michael@0 | 295 | #define BZ_X_MAGIC_2 11 |
michael@0 | 296 | #define BZ_X_MAGIC_3 12 |
michael@0 | 297 | #define BZ_X_MAGIC_4 13 |
michael@0 | 298 | #define BZ_X_BLKHDR_1 14 |
michael@0 | 299 | #define BZ_X_BLKHDR_2 15 |
michael@0 | 300 | #define BZ_X_BLKHDR_3 16 |
michael@0 | 301 | #define BZ_X_BLKHDR_4 17 |
michael@0 | 302 | #define BZ_X_BLKHDR_5 18 |
michael@0 | 303 | #define BZ_X_BLKHDR_6 19 |
michael@0 | 304 | #define BZ_X_BCRC_1 20 |
michael@0 | 305 | #define BZ_X_BCRC_2 21 |
michael@0 | 306 | #define BZ_X_BCRC_3 22 |
michael@0 | 307 | #define BZ_X_BCRC_4 23 |
michael@0 | 308 | #define BZ_X_RANDBIT 24 |
michael@0 | 309 | #define BZ_X_ORIGPTR_1 25 |
michael@0 | 310 | #define BZ_X_ORIGPTR_2 26 |
michael@0 | 311 | #define BZ_X_ORIGPTR_3 27 |
michael@0 | 312 | #define BZ_X_MAPPING_1 28 |
michael@0 | 313 | #define BZ_X_MAPPING_2 29 |
michael@0 | 314 | #define BZ_X_SELECTOR_1 30 |
michael@0 | 315 | #define BZ_X_SELECTOR_2 31 |
michael@0 | 316 | #define BZ_X_SELECTOR_3 32 |
michael@0 | 317 | #define BZ_X_CODING_1 33 |
michael@0 | 318 | #define BZ_X_CODING_2 34 |
michael@0 | 319 | #define BZ_X_CODING_3 35 |
michael@0 | 320 | #define BZ_X_MTF_1 36 |
michael@0 | 321 | #define BZ_X_MTF_2 37 |
michael@0 | 322 | #define BZ_X_MTF_3 38 |
michael@0 | 323 | #define BZ_X_MTF_4 39 |
michael@0 | 324 | #define BZ_X_MTF_5 40 |
michael@0 | 325 | #define BZ_X_MTF_6 41 |
michael@0 | 326 | #define BZ_X_ENDHDR_2 42 |
michael@0 | 327 | #define BZ_X_ENDHDR_3 43 |
michael@0 | 328 | #define BZ_X_ENDHDR_4 44 |
michael@0 | 329 | #define BZ_X_ENDHDR_5 45 |
michael@0 | 330 | #define BZ_X_ENDHDR_6 46 |
michael@0 | 331 | #define BZ_X_CCRC_1 47 |
michael@0 | 332 | #define BZ_X_CCRC_2 48 |
michael@0 | 333 | #define BZ_X_CCRC_3 49 |
michael@0 | 334 | #define BZ_X_CCRC_4 50 |
michael@0 | 335 | |
michael@0 | 336 | |
michael@0 | 337 | |
michael@0 | 338 | /*-- Constants for the fast MTF decoder. --*/ |
michael@0 | 339 | |
michael@0 | 340 | #define MTFA_SIZE 4096 |
michael@0 | 341 | #define MTFL_SIZE 16 |
michael@0 | 342 | |
michael@0 | 343 | |
michael@0 | 344 | |
michael@0 | 345 | /*-- Structure holding all the decompression-side stuff. --*/ |
michael@0 | 346 | |
michael@0 | 347 | typedef |
michael@0 | 348 | struct { |
michael@0 | 349 | /* pointer back to the struct bz_stream */ |
michael@0 | 350 | bz_stream* strm; |
michael@0 | 351 | |
michael@0 | 352 | /* state indicator for this stream */ |
michael@0 | 353 | Int32 state; |
michael@0 | 354 | |
michael@0 | 355 | /* for doing the final run-length decoding */ |
michael@0 | 356 | UChar state_out_ch; |
michael@0 | 357 | Int32 state_out_len; |
michael@0 | 358 | Bool blockRandomised; |
michael@0 | 359 | BZ_RAND_DECLS; |
michael@0 | 360 | |
michael@0 | 361 | /* the buffer for bit stream reading */ |
michael@0 | 362 | UInt32 bsBuff; |
michael@0 | 363 | Int32 bsLive; |
michael@0 | 364 | |
michael@0 | 365 | /* misc administratium */ |
michael@0 | 366 | Int32 blockSize100k; |
michael@0 | 367 | Bool smallDecompress; |
michael@0 | 368 | Int32 currBlockNo; |
michael@0 | 369 | Int32 verbosity; |
michael@0 | 370 | |
michael@0 | 371 | /* for undoing the Burrows-Wheeler transform */ |
michael@0 | 372 | Int32 origPtr; |
michael@0 | 373 | UInt32 tPos; |
michael@0 | 374 | Int32 k0; |
michael@0 | 375 | Int32 unzftab[256]; |
michael@0 | 376 | Int32 nblock_used; |
michael@0 | 377 | Int32 cftab[257]; |
michael@0 | 378 | Int32 cftabCopy[257]; |
michael@0 | 379 | |
michael@0 | 380 | /* for undoing the Burrows-Wheeler transform (FAST) */ |
michael@0 | 381 | UInt32 *tt; |
michael@0 | 382 | |
michael@0 | 383 | /* for undoing the Burrows-Wheeler transform (SMALL) */ |
michael@0 | 384 | UInt16 *ll16; |
michael@0 | 385 | UChar *ll4; |
michael@0 | 386 | |
michael@0 | 387 | /* stored and calculated CRCs */ |
michael@0 | 388 | UInt32 storedBlockCRC; |
michael@0 | 389 | UInt32 storedCombinedCRC; |
michael@0 | 390 | UInt32 calculatedBlockCRC; |
michael@0 | 391 | UInt32 calculatedCombinedCRC; |
michael@0 | 392 | |
michael@0 | 393 | /* map of bytes used in block */ |
michael@0 | 394 | Int32 nInUse; |
michael@0 | 395 | Bool inUse[256]; |
michael@0 | 396 | Bool inUse16[16]; |
michael@0 | 397 | UChar seqToUnseq[256]; |
michael@0 | 398 | |
michael@0 | 399 | /* for decoding the MTF values */ |
michael@0 | 400 | UChar mtfa [MTFA_SIZE]; |
michael@0 | 401 | Int32 mtfbase[256 / MTFL_SIZE]; |
michael@0 | 402 | UChar selector [BZ_MAX_SELECTORS]; |
michael@0 | 403 | UChar selectorMtf[BZ_MAX_SELECTORS]; |
michael@0 | 404 | UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
michael@0 | 405 | |
michael@0 | 406 | Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
michael@0 | 407 | Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
michael@0 | 408 | Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
michael@0 | 409 | Int32 minLens[BZ_N_GROUPS]; |
michael@0 | 410 | |
michael@0 | 411 | /* save area for scalars in the main decompress code */ |
michael@0 | 412 | Int32 save_i; |
michael@0 | 413 | Int32 save_j; |
michael@0 | 414 | Int32 save_t; |
michael@0 | 415 | Int32 save_alphaSize; |
michael@0 | 416 | Int32 save_nGroups; |
michael@0 | 417 | Int32 save_nSelectors; |
michael@0 | 418 | Int32 save_EOB; |
michael@0 | 419 | Int32 save_groupNo; |
michael@0 | 420 | Int32 save_groupPos; |
michael@0 | 421 | Int32 save_nextSym; |
michael@0 | 422 | Int32 save_nblockMAX; |
michael@0 | 423 | Int32 save_nblock; |
michael@0 | 424 | Int32 save_es; |
michael@0 | 425 | Int32 save_N; |
michael@0 | 426 | Int32 save_curr; |
michael@0 | 427 | Int32 save_zt; |
michael@0 | 428 | Int32 save_zn; |
michael@0 | 429 | Int32 save_zvec; |
michael@0 | 430 | Int32 save_zj; |
michael@0 | 431 | Int32 save_gSel; |
michael@0 | 432 | Int32 save_gMinlen; |
michael@0 | 433 | Int32* save_gLimit; |
michael@0 | 434 | Int32* save_gBase; |
michael@0 | 435 | Int32* save_gPerm; |
michael@0 | 436 | |
michael@0 | 437 | } |
michael@0 | 438 | DState; |
michael@0 | 439 | |
michael@0 | 440 | |
michael@0 | 441 | |
michael@0 | 442 | /*-- Macros for decompression. --*/ |
michael@0 | 443 | |
michael@0 | 444 | #define BZ_GET_FAST(cccc) \ |
michael@0 | 445 | s->tPos = s->tt[s->tPos]; \ |
michael@0 | 446 | cccc = (UChar)(s->tPos & 0xff); \ |
michael@0 | 447 | s->tPos >>= 8; |
michael@0 | 448 | |
michael@0 | 449 | #define BZ_GET_FAST_C(cccc) \ |
michael@0 | 450 | c_tPos = c_tt[c_tPos]; \ |
michael@0 | 451 | cccc = (UChar)(c_tPos & 0xff); \ |
michael@0 | 452 | c_tPos >>= 8; |
michael@0 | 453 | |
michael@0 | 454 | #define SET_LL4(i,n) \ |
michael@0 | 455 | { if (((i) & 0x1) == 0) \ |
michael@0 | 456 | s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \ |
michael@0 | 457 | s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \ |
michael@0 | 458 | } |
michael@0 | 459 | |
michael@0 | 460 | #define GET_LL4(i) \ |
michael@0 | 461 | ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF) |
michael@0 | 462 | |
michael@0 | 463 | #define SET_LL(i,n) \ |
michael@0 | 464 | { s->ll16[i] = (UInt16)(n & 0x0000ffff); \ |
michael@0 | 465 | SET_LL4(i, n >> 16); \ |
michael@0 | 466 | } |
michael@0 | 467 | |
michael@0 | 468 | #define GET_LL(i) \ |
michael@0 | 469 | (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16)) |
michael@0 | 470 | |
michael@0 | 471 | #define BZ_GET_SMALL(cccc) \ |
michael@0 | 472 | cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \ |
michael@0 | 473 | s->tPos = GET_LL(s->tPos); |
michael@0 | 474 | |
michael@0 | 475 | |
michael@0 | 476 | /*-- externs for decompression. --*/ |
michael@0 | 477 | |
michael@0 | 478 | extern Int32 |
michael@0 | 479 | BZ2_indexIntoF ( Int32, Int32* ); |
michael@0 | 480 | |
michael@0 | 481 | extern Int32 |
michael@0 | 482 | BZ2_decompress ( DState* ); |
michael@0 | 483 | |
michael@0 | 484 | extern void |
michael@0 | 485 | BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, |
michael@0 | 486 | Int32, Int32, Int32 ); |
michael@0 | 487 | |
michael@0 | 488 | |
michael@0 | 489 | #endif |
michael@0 | 490 | |
michael@0 | 491 | |
michael@0 | 492 | /*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ |
michael@0 | 493 | |
michael@0 | 494 | #ifdef BZ_NO_STDIO |
michael@0 | 495 | #ifndef NULL |
michael@0 | 496 | #define NULL 0 |
michael@0 | 497 | #endif |
michael@0 | 498 | #endif |
michael@0 | 499 | |
michael@0 | 500 | |
michael@0 | 501 | /*-------------------------------------------------------------*/ |
michael@0 | 502 | /*--- end bzlib_private.h ---*/ |
michael@0 | 503 | /*-------------------------------------------------------------*/ |