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