ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bzlib_private.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "bzlib.h"
Include dependency graph for bzlib_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EState
 
struct  DState
 

Macros

#define BZ_VERSION   "1.0.5, 10-Dec-2007"
 
#define True   ((Bool)1)
 
#define False   ((Bool)0)
 
#define __inline__   /* */
 
#define AssertH(cond, errcode)
 
#define AssertD(cond, msg)
 
#define VPrintf0(zf)
 
#define VPrintf1(zf, za1)
 
#define VPrintf2(zf, za1, za2)
 
#define VPrintf3(zf, za1, za2, za3)
 
#define VPrintf4(zf, za1, za2, za3, za4)
 
#define VPrintf5(zf, za1, za2, za3, za4, za5)
 
#define BZALLOC(nnn)
 
#define BZFREE(ppp)
 
#define BZ_HDR_B   0x42 /* 'B' */
 
#define BZ_HDR_Z   0x5a /* 'Z' */
 
#define BZ_HDR_h   0x68 /* 'h' */
 
#define BZ_HDR_0   0x30 /* '0' */
 
#define BZ_MAX_ALPHA_SIZE   258
 
#define BZ_MAX_CODE_LEN   23
 
#define BZ_RUNA   0
 
#define BZ_RUNB   1
 
#define BZ_N_GROUPS   6
 
#define BZ_G_SIZE   50
 
#define BZ_N_ITERS   4
 
#define BZ_MAX_SELECTORS   (2 + (900000 / BZ_G_SIZE))
 
#define BZ_RAND_DECLS
 
#define BZ_RAND_INIT_MASK
 
#define BZ_RAND_MASK   ((s->rNToGo == 1) ? 1 : 0)
 
#define BZ_RAND_UPD_MASK
 
#define BZ_INITIALISE_CRC(crcVar)
 
#define BZ_FINALISE_CRC(crcVar)
 
#define BZ_UPDATE_CRC(crcVar, cha)
 
#define BZ_M_IDLE   1
 
#define BZ_M_RUNNING   2
 
#define BZ_M_FLUSHING   3
 
#define BZ_M_FINISHING   4
 
#define BZ_S_OUTPUT   1
 
#define BZ_S_INPUT   2
 
#define BZ_N_RADIX   2
 
#define BZ_N_QSORT   12
 
#define BZ_N_SHELL   18
 
#define BZ_N_OVERSHOOT   (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
 
#define BZ_X_IDLE   1
 
#define BZ_X_OUTPUT   2
 
#define BZ_X_MAGIC_1   10
 
#define BZ_X_MAGIC_2   11
 
#define BZ_X_MAGIC_3   12
 
#define BZ_X_MAGIC_4   13
 
#define BZ_X_BLKHDR_1   14
 
#define BZ_X_BLKHDR_2   15
 
#define BZ_X_BLKHDR_3   16
 
#define BZ_X_BLKHDR_4   17
 
#define BZ_X_BLKHDR_5   18
 
#define BZ_X_BLKHDR_6   19
 
#define BZ_X_BCRC_1   20
 
#define BZ_X_BCRC_2   21
 
#define BZ_X_BCRC_3   22
 
#define BZ_X_BCRC_4   23
 
#define BZ_X_RANDBIT   24
 
#define BZ_X_ORIGPTR_1   25
 
#define BZ_X_ORIGPTR_2   26
 
#define BZ_X_ORIGPTR_3   27
 
#define BZ_X_MAPPING_1   28
 
#define BZ_X_MAPPING_2   29
 
#define BZ_X_SELECTOR_1   30
 
#define BZ_X_SELECTOR_2   31
 
#define BZ_X_SELECTOR_3   32
 
#define BZ_X_CODING_1   33
 
#define BZ_X_CODING_2   34
 
#define BZ_X_CODING_3   35
 
#define BZ_X_MTF_1   36
 
#define BZ_X_MTF_2   37
 
#define BZ_X_MTF_3   38
 
#define BZ_X_MTF_4   39
 
#define BZ_X_MTF_5   40
 
#define BZ_X_MTF_6   41
 
#define BZ_X_ENDHDR_2   42
 
#define BZ_X_ENDHDR_3   43
 
#define BZ_X_ENDHDR_4   44
 
#define BZ_X_ENDHDR_5   45
 
#define BZ_X_ENDHDR_6   46
 
#define BZ_X_CCRC_1   47
 
#define BZ_X_CCRC_2   48
 
#define BZ_X_CCRC_3   49
 
#define BZ_X_CCRC_4   50
 
#define MTFA_SIZE   4096
 
#define MTFL_SIZE   16
 
#define BZ_GET_FAST(cccc)
 
#define BZ_GET_FAST_C(cccc)
 
#define SET_LL4(i, n)
 
#define GET_LL4(i)
 
#define SET_LL(i, n)
 
#define GET_LL(i)
 
#define BZ_GET_SMALL(cccc)
 

Typedefs

typedef char Char
 
typedef unsigned char Bool
 
typedef unsigned char UChar
 
typedef int Int32
 
typedef unsigned int UInt32
 
typedef short Int16
 
typedef unsigned short UInt16
 

Functions

void BZ2_bz__AssertH__fail (int errcode)
 
void BZ2_blockSort (EState *)
 
void BZ2_compressBlock (EState *, Bool)
 
void BZ2_bsInitWrite (EState *)
 
void BZ2_hbAssignCodes (Int32 *, UChar *, Int32, Int32, Int32)
 
void BZ2_hbMakeCodeLengths (UChar *, Int32 *, Int32, Int32)
 
Int32 BZ2_indexIntoF (Int32, Int32 *)
 
Int32 BZ2_decompress (DState *)
 
void BZ2_hbCreateDecodeTables (Int32 *, Int32 *, Int32 *, UChar *, Int32, Int32, Int32)
 

Variables

Int32 BZ2_rNums [512]
 
UInt32 BZ2_crc32Table [256]
 

Macro Definition Documentation

◆ __inline__

#define __inline__   /* */

Definition at line 55 of file bzlib_private.h.

◆ AssertD

#define AssertD ( cond,
msg )
Value:
/* */

Definition at line 72 of file bzlib_private.h.

◆ AssertH

#define AssertH ( cond,
errcode )
Value:
{ if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
ABC_NAMESPACE_IMPL_START void BZ2_bz__AssertH__fail(int errcode)
Definition bzlib.c:52

Definition at line 61 of file bzlib_private.h.

61#define AssertH(cond,errcode) \
62 { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }

◆ BZ_FINALISE_CRC

#define BZ_FINALISE_CRC ( crcVar)
Value:
{ \
crcVar = ~(crcVar); \
}

Definition at line 164 of file bzlib_private.h.

164#define BZ_FINALISE_CRC(crcVar) \
165{ \
166 crcVar = ~(crcVar); \
167}

◆ BZ_G_SIZE

#define BZ_G_SIZE   50

Definition at line 124 of file bzlib_private.h.

◆ BZ_GET_FAST

#define BZ_GET_FAST ( cccc)
Value:
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
s->tPos = s->tt[s->tPos]; \
cccc = (UChar)(s->tPos & 0xff); \
s->tPos >>= 8;
unsigned int UInt32
unsigned char UChar
#define True

Definition at line 446 of file bzlib_private.h.

446#define BZ_GET_FAST(cccc) \
447 /* c_tPos is unsigned, hence test < 0 is pointless. */ \
448 if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
449 s->tPos = s->tt[s->tPos]; \
450 cccc = (UChar)(s->tPos & 0xff); \
451 s->tPos >>= 8;

◆ BZ_GET_FAST_C

#define BZ_GET_FAST_C ( cccc)
Value:
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \
c_tPos = c_tt[c_tPos]; \
cccc = (UChar)(c_tPos & 0xff); \
c_tPos >>= 8;

Definition at line 453 of file bzlib_private.h.

453#define BZ_GET_FAST_C(cccc) \
454 /* c_tPos is unsigned, hence test < 0 is pointless. */ \
455 if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \
456 c_tPos = c_tt[c_tPos]; \
457 cccc = (UChar)(c_tPos & 0xff); \
458 c_tPos >>= 8;

◆ BZ_GET_SMALL

#define BZ_GET_SMALL ( cccc)
Value:
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
s->tPos = GET_LL(s->tPos);
Int32 BZ2_indexIntoF(Int32 indx, Int32 *cftab)
Definition bzlib.c:698
#define GET_LL(i)

Definition at line 477 of file bzlib_private.h.

477#define BZ_GET_SMALL(cccc) \
478 /* c_tPos is unsigned, hence test < 0 is pointless. */ \
479 if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
480 cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
481 s->tPos = GET_LL(s->tPos);

◆ BZ_HDR_0

#define BZ_HDR_0   0x30 /* '0' */

Definition at line 113 of file bzlib_private.h.

◆ BZ_HDR_B

#define BZ_HDR_B   0x42 /* 'B' */

Definition at line 110 of file bzlib_private.h.

◆ BZ_HDR_h

#define BZ_HDR_h   0x68 /* 'h' */

Definition at line 112 of file bzlib_private.h.

◆ BZ_HDR_Z

#define BZ_HDR_Z   0x5a /* 'Z' */

Definition at line 111 of file bzlib_private.h.

◆ BZ_INITIALISE_CRC

#define BZ_INITIALISE_CRC ( crcVar)
Value:
{ \
crcVar = 0xffffffffL; \
}

Definition at line 159 of file bzlib_private.h.

159#define BZ_INITIALISE_CRC(crcVar) \
160{ \
161 crcVar = 0xffffffffL; \
162}

◆ BZ_M_FINISHING

#define BZ_M_FINISHING   4

Definition at line 183 of file bzlib_private.h.

◆ BZ_M_FLUSHING

#define BZ_M_FLUSHING   3

Definition at line 182 of file bzlib_private.h.

◆ BZ_M_IDLE

#define BZ_M_IDLE   1

Definition at line 180 of file bzlib_private.h.

◆ BZ_M_RUNNING

#define BZ_M_RUNNING   2

Definition at line 181 of file bzlib_private.h.

◆ BZ_MAX_ALPHA_SIZE

#define BZ_MAX_ALPHA_SIZE   258

Definition at line 117 of file bzlib_private.h.

◆ BZ_MAX_CODE_LEN

#define BZ_MAX_CODE_LEN   23

Definition at line 118 of file bzlib_private.h.

◆ BZ_MAX_SELECTORS

#define BZ_MAX_SELECTORS   (2 + (900000 / BZ_G_SIZE))

Definition at line 127 of file bzlib_private.h.

◆ BZ_N_GROUPS

#define BZ_N_GROUPS   6

Definition at line 123 of file bzlib_private.h.

◆ BZ_N_ITERS

#define BZ_N_ITERS   4

Definition at line 125 of file bzlib_private.h.

◆ BZ_N_OVERSHOOT

#define BZ_N_OVERSHOOT   (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)

Definition at line 191 of file bzlib_private.h.

◆ BZ_N_QSORT

#define BZ_N_QSORT   12

Definition at line 189 of file bzlib_private.h.

◆ BZ_N_RADIX

#define BZ_N_RADIX   2

Definition at line 188 of file bzlib_private.h.

◆ BZ_N_SHELL

#define BZ_N_SHELL   18

Definition at line 190 of file bzlib_private.h.

◆ BZ_RAND_DECLS

#define BZ_RAND_DECLS
Value:
Int32 rNToGo; \
Int32 rTPos \
int Int32

Definition at line 135 of file bzlib_private.h.

135#define BZ_RAND_DECLS \
136 Int32 rNToGo; \
137 Int32 rTPos \
138

◆ BZ_RAND_INIT_MASK

#define BZ_RAND_INIT_MASK
Value:
s->rNToGo = 0; \
s->rTPos = 0 \

Definition at line 139 of file bzlib_private.h.

139#define BZ_RAND_INIT_MASK \
140 s->rNToGo = 0; \
141 s->rTPos = 0 \
142

◆ BZ_RAND_MASK

#define BZ_RAND_MASK   ((s->rNToGo == 1) ? 1 : 0)

Definition at line 143 of file bzlib_private.h.

◆ BZ_RAND_UPD_MASK

#define BZ_RAND_UPD_MASK
Value:
if (s->rNToGo == 0) { \
s->rNToGo = BZ2_rNums[s->rTPos]; \
s->rTPos++; \
if (s->rTPos == 512) s->rTPos = 0; \
} \
s->rNToGo--;
Int32 BZ2_rNums[512]
Definition randtable.c:29

Definition at line 145 of file bzlib_private.h.

145#define BZ_RAND_UPD_MASK \
146 if (s->rNToGo == 0) { \
147 s->rNToGo = BZ2_rNums[s->rTPos]; \
148 s->rTPos++; \
149 if (s->rTPos == 512) s->rTPos = 0; \
150 } \
151 s->rNToGo--;

◆ BZ_RUNA

#define BZ_RUNA   0

Definition at line 120 of file bzlib_private.h.

◆ BZ_RUNB

#define BZ_RUNB   1

Definition at line 121 of file bzlib_private.h.

◆ BZ_S_INPUT

#define BZ_S_INPUT   2

Definition at line 186 of file bzlib_private.h.

◆ BZ_S_OUTPUT

#define BZ_S_OUTPUT   1

Definition at line 185 of file bzlib_private.h.

◆ BZ_UPDATE_CRC

#define BZ_UPDATE_CRC ( crcVar,
cha )
Value:
{ \
crcVar = (crcVar << 8) ^ \
BZ2_crc32Table[(crcVar >> 24) ^ \
((UChar)cha)]; \
}
UInt32 BZ2_crc32Table[256]
Definition crctable.c:34

Definition at line 169 of file bzlib_private.h.

169#define BZ_UPDATE_CRC(crcVar,cha) \
170{ \
171 crcVar = (crcVar << 8) ^ \
172 BZ2_crc32Table[(crcVar >> 24) ^ \
173 ((UChar)cha)]; \
174}

◆ BZ_VERSION

#define BZ_VERSION   "1.0.5, 10-Dec-2007"

Definition at line 41 of file bzlib_private.h.

◆ BZ_X_BCRC_1

#define BZ_X_BCRC_1   20

Definition at line 306 of file bzlib_private.h.

◆ BZ_X_BCRC_2

#define BZ_X_BCRC_2   21

Definition at line 307 of file bzlib_private.h.

◆ BZ_X_BCRC_3

#define BZ_X_BCRC_3   22

Definition at line 308 of file bzlib_private.h.

◆ BZ_X_BCRC_4

#define BZ_X_BCRC_4   23

Definition at line 309 of file bzlib_private.h.

◆ BZ_X_BLKHDR_1

#define BZ_X_BLKHDR_1   14

Definition at line 300 of file bzlib_private.h.

◆ BZ_X_BLKHDR_2

#define BZ_X_BLKHDR_2   15

Definition at line 301 of file bzlib_private.h.

◆ BZ_X_BLKHDR_3

#define BZ_X_BLKHDR_3   16

Definition at line 302 of file bzlib_private.h.

◆ BZ_X_BLKHDR_4

#define BZ_X_BLKHDR_4   17

Definition at line 303 of file bzlib_private.h.

◆ BZ_X_BLKHDR_5

#define BZ_X_BLKHDR_5   18

Definition at line 304 of file bzlib_private.h.

◆ BZ_X_BLKHDR_6

#define BZ_X_BLKHDR_6   19

Definition at line 305 of file bzlib_private.h.

◆ BZ_X_CCRC_1

#define BZ_X_CCRC_1   47

Definition at line 333 of file bzlib_private.h.

◆ BZ_X_CCRC_2

#define BZ_X_CCRC_2   48

Definition at line 334 of file bzlib_private.h.

◆ BZ_X_CCRC_3

#define BZ_X_CCRC_3   49

Definition at line 335 of file bzlib_private.h.

◆ BZ_X_CCRC_4

#define BZ_X_CCRC_4   50

Definition at line 336 of file bzlib_private.h.

◆ BZ_X_CODING_1

#define BZ_X_CODING_1   33

Definition at line 319 of file bzlib_private.h.

◆ BZ_X_CODING_2

#define BZ_X_CODING_2   34

Definition at line 320 of file bzlib_private.h.

◆ BZ_X_CODING_3

#define BZ_X_CODING_3   35

Definition at line 321 of file bzlib_private.h.

◆ BZ_X_ENDHDR_2

#define BZ_X_ENDHDR_2   42

Definition at line 328 of file bzlib_private.h.

◆ BZ_X_ENDHDR_3

#define BZ_X_ENDHDR_3   43

Definition at line 329 of file bzlib_private.h.

◆ BZ_X_ENDHDR_4

#define BZ_X_ENDHDR_4   44

Definition at line 330 of file bzlib_private.h.

◆ BZ_X_ENDHDR_5

#define BZ_X_ENDHDR_5   45

Definition at line 331 of file bzlib_private.h.

◆ BZ_X_ENDHDR_6

#define BZ_X_ENDHDR_6   46

Definition at line 332 of file bzlib_private.h.

◆ BZ_X_IDLE

#define BZ_X_IDLE   1

Definition at line 293 of file bzlib_private.h.

◆ BZ_X_MAGIC_1

#define BZ_X_MAGIC_1   10

Definition at line 296 of file bzlib_private.h.

◆ BZ_X_MAGIC_2

#define BZ_X_MAGIC_2   11

Definition at line 297 of file bzlib_private.h.

◆ BZ_X_MAGIC_3

#define BZ_X_MAGIC_3   12

Definition at line 298 of file bzlib_private.h.

◆ BZ_X_MAGIC_4

#define BZ_X_MAGIC_4   13

Definition at line 299 of file bzlib_private.h.

◆ BZ_X_MAPPING_1

#define BZ_X_MAPPING_1   28

Definition at line 314 of file bzlib_private.h.

◆ BZ_X_MAPPING_2

#define BZ_X_MAPPING_2   29

Definition at line 315 of file bzlib_private.h.

◆ BZ_X_MTF_1

#define BZ_X_MTF_1   36

Definition at line 322 of file bzlib_private.h.

◆ BZ_X_MTF_2

#define BZ_X_MTF_2   37

Definition at line 323 of file bzlib_private.h.

◆ BZ_X_MTF_3

#define BZ_X_MTF_3   38

Definition at line 324 of file bzlib_private.h.

◆ BZ_X_MTF_4

#define BZ_X_MTF_4   39

Definition at line 325 of file bzlib_private.h.

◆ BZ_X_MTF_5

#define BZ_X_MTF_5   40

Definition at line 326 of file bzlib_private.h.

◆ BZ_X_MTF_6

#define BZ_X_MTF_6   41

Definition at line 327 of file bzlib_private.h.

◆ BZ_X_ORIGPTR_1

#define BZ_X_ORIGPTR_1   25

Definition at line 311 of file bzlib_private.h.

◆ BZ_X_ORIGPTR_2

#define BZ_X_ORIGPTR_2   26

Definition at line 312 of file bzlib_private.h.

◆ BZ_X_ORIGPTR_3

#define BZ_X_ORIGPTR_3   27

Definition at line 313 of file bzlib_private.h.

◆ BZ_X_OUTPUT

#define BZ_X_OUTPUT   2

Definition at line 294 of file bzlib_private.h.

◆ BZ_X_RANDBIT

#define BZ_X_RANDBIT   24

Definition at line 310 of file bzlib_private.h.

◆ BZ_X_SELECTOR_1

#define BZ_X_SELECTOR_1   30

Definition at line 316 of file bzlib_private.h.

◆ BZ_X_SELECTOR_2

#define BZ_X_SELECTOR_2   31

Definition at line 317 of file bzlib_private.h.

◆ BZ_X_SELECTOR_3

#define BZ_X_SELECTOR_3   32

Definition at line 318 of file bzlib_private.h.

◆ BZALLOC

#define BZALLOC ( nnn)
Value:
(strm->bzalloc)(strm->opaque,(nnn),1)

Definition at line 104 of file bzlib_private.h.

◆ BZFREE

#define BZFREE ( ppp)
Value:
(strm->bzfree)(strm->opaque,(ppp))

Definition at line 105 of file bzlib_private.h.

◆ False

#define False   ((Bool)0)

Definition at line 52 of file bzlib_private.h.

◆ GET_LL

#define GET_LL ( i)
Value:
(((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
#define GET_LL4(i)

Definition at line 474 of file bzlib_private.h.

474#define GET_LL(i) \
475 (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))

◆ GET_LL4

#define GET_LL4 ( i)
Value:
((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)

Definition at line 466 of file bzlib_private.h.

466#define GET_LL4(i) \
467 ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)

◆ MTFA_SIZE

#define MTFA_SIZE   4096

Definition at line 342 of file bzlib_private.h.

◆ MTFL_SIZE

#define MTFL_SIZE   16

Definition at line 343 of file bzlib_private.h.

◆ SET_LL

#define SET_LL ( i,
n )
Value:
{ s->ll16[i] = (UInt16)(n & 0x0000ffff); \
SET_LL4(i, n >> 16); \
}
unsigned short UInt16

Definition at line 469 of file bzlib_private.h.

469#define SET_LL(i,n) \
470 { s->ll16[i] = (UInt16)(n & 0x0000ffff); \
471 SET_LL4(i, n >> 16); \
472 }

◆ SET_LL4

#define SET_LL4 ( i,
n )
Value:
{ if (((i) & 0x1) == 0) \
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
}

Definition at line 460 of file bzlib_private.h.

460#define SET_LL4(i,n) \
461 { if (((i) & 0x1) == 0) \
462 s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
463 s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
464 }

◆ True

#define True   ((Bool)1)

Definition at line 51 of file bzlib_private.h.

◆ VPrintf0

#define VPrintf0 ( zf)
Value:
fprintf(stderr,zf)

Definition at line 75 of file bzlib_private.h.

75#define VPrintf0(zf) \
76 fprintf(stderr,zf)

◆ VPrintf1

#define VPrintf1 ( zf,
za1 )
Value:
fprintf(stderr,zf,za1)

Definition at line 77 of file bzlib_private.h.

77#define VPrintf1(zf,za1) \
78 fprintf(stderr,zf,za1)

◆ VPrintf2

#define VPrintf2 ( zf,
za1,
za2 )
Value:
fprintf(stderr,zf,za1,za2)

Definition at line 79 of file bzlib_private.h.

79#define VPrintf2(zf,za1,za2) \
80 fprintf(stderr,zf,za1,za2)

◆ VPrintf3

#define VPrintf3 ( zf,
za1,
za2,
za3 )
Value:
fprintf(stderr,zf,za1,za2,za3)

Definition at line 81 of file bzlib_private.h.

81#define VPrintf3(zf,za1,za2,za3) \
82 fprintf(stderr,zf,za1,za2,za3)

◆ VPrintf4

#define VPrintf4 ( zf,
za1,
za2,
za3,
za4 )
Value:
fprintf(stderr,zf,za1,za2,za3,za4)

Definition at line 83 of file bzlib_private.h.

83#define VPrintf4(zf,za1,za2,za3,za4) \
84 fprintf(stderr,zf,za1,za2,za3,za4)

◆ VPrintf5

#define VPrintf5 ( zf,
za1,
za2,
za3,
za4,
za5 )
Value:
fprintf(stderr,zf,za1,za2,za3,za4,za5)

Definition at line 85 of file bzlib_private.h.

85#define VPrintf5(zf,za1,za2,za3,za4,za5) \
86 fprintf(stderr,zf,za1,za2,za3,za4,za5)

Typedef Documentation

◆ Bool

typedef unsigned char Bool

Definition at line 44 of file bzlib_private.h.

◆ Char

typedef char Char

Definition at line 43 of file bzlib_private.h.

◆ Int16

typedef short Int16

Definition at line 48 of file bzlib_private.h.

◆ Int32

typedef int Int32

Definition at line 46 of file bzlib_private.h.

◆ UChar

typedef unsigned char UChar

Definition at line 45 of file bzlib_private.h.

◆ UInt16

typedef unsigned short UInt16

Definition at line 49 of file bzlib_private.h.

◆ UInt32

typedef unsigned int UInt32

Definition at line 47 of file bzlib_private.h.

Function Documentation

◆ BZ2_blockSort()

void BZ2_blockSort ( EState * s)
extern

Definition at line 1033 of file blocksort.c.

1034{
1035 UInt32* ptr = s->ptr;
1036 UChar* block = s->block;
1037 UInt32* ftab = s->ftab;
1038 Int32 nblock = s->nblock;
1039 Int32 verb = s->verbosity;
1040 Int32 wfact = s->workFactor;
1041 UInt16* quadrant;
1042 Int32 budget;
1043 Int32 budgetInit;
1044 Int32 i;
1045
1046 if (nblock < 10000) {
1047 fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
1048 } else {
1049 /* Calculate the location for quadrant, remembering to get
1050 the alignment right. Assumes that &(block[0]) is at least
1051 2-byte aligned -- this should be ok since block is really
1052 the first section of arr2.
1053 */
1054 i = nblock+BZ_N_OVERSHOOT;
1055 if (i & 1) i++;
1056 quadrant = (UInt16*)(&(block[i]));
1057
1058 /* (wfact-1) / 3 puts the default-factor-30
1059 transition point at very roughly the same place as
1060 with v0.1 and v0.9.0.
1061 Not that it particularly matters any more, since the
1062 resulting compressed stream is now the same regardless
1063 of whether or not we use the main sort or fallback sort.
1064 */
1065 if (wfact < 1 ) wfact = 1;
1066 if (wfact > 100) wfact = 100;
1067 budgetInit = nblock * ((wfact-1) / 3);
1068 budget = budgetInit;
1069
1070 mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
1071 if (verb >= 3)
1072 VPrintf3 ( " %d work, %d block, ratio %5.2f\n",
1073 budgetInit - budget,
1074 nblock,
1075 (float)(budgetInit - budget) /
1076 (float)(nblock==0 ? 1 : nblock) );
1077 if (budget < 0) {
1078 if (verb >= 2)
1079 VPrintf0 ( " too repetitive; using fallback"
1080 " sorting algorithm\n" );
1081 fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
1082 }
1083 }
1084
1085 s->origPtr = -1;
1086 for (i = 0; i < s->nblock; i++)
1087 if (ptr[i] == 0)
1088 { s->origPtr = i; break; };
1089
1090 AssertH( s->origPtr != -1, 1003 );
1091}
#define BZ_N_OVERSHOOT
#define VPrintf3(zf, za1, za2, za3)
#define AssertH(cond, errcode)
#define VPrintf0(zf)
UChar * block
Int32 nblock
Int32 workFactor
UInt32 * ftab
UInt32 * ptr
UInt32 * arr1
Int32 verbosity
UInt32 * arr2
Int32 origPtr
Here is the caller graph for this function:

◆ BZ2_bsInitWrite()

void BZ2_bsInitWrite ( EState * s)
extern

Definition at line 40 of file compress.c.

41{
42 s->bsLive = 0;
43 s->bsBuff = 0;
44}
Int32 bsLive
UInt32 bsBuff
Here is the caller graph for this function:

◆ BZ2_bz__AssertH__fail()

void BZ2_bz__AssertH__fail ( int errcode)
extern

Definition at line 52 of file bzlib.c.

53{
54 fprintf(stderr,
55 "\n\nbzip2/libbzip2: internal error number %d.\n"
56 "This is a bug in bzip2/libbzip2, %s.\n"
57 "Please report it to me at: jseward@bzip.org. If this happened\n"
58 "when you were using some program which uses libbzip2 as a\n"
59 "component, you should also report this bug to the author(s)\n"
60 "of that program. Please make an effort to report this bug;\n"
61 "timely and accurate bug reports eventually lead to higher\n"
62 "quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
63 errcode,
65 );
66
67 if (errcode == 1007) {
68 fprintf(stderr,
69 "\n*** A special note about internal error number 1007 ***\n"
70 "\n"
71 "Experience suggests that a common cause of i.e. 1007\n"
72 "is unreliable memory or other hardware. The 1007 assertion\n"
73 "just happens to cross-check the results of huge numbers of\n"
74 "memory reads/writes, and so acts (unintendedly) as a stress\n"
75 "test of your memory system.\n"
76 "\n"
77 "I suggest the following: try compressing the file again,\n"
78 "possibly monitoring progress in detail with the -vv flag.\n"
79 "\n"
80 "* If the error cannot be reproduced, and/or happens at different\n"
81 " points in compression, you may have a flaky memory system.\n"
82 " Try a memory-test program. I have used Memtest86\n"
83 " (www.memtest86.com). At the time of writing it is free (GPLd).\n"
84 " Memtest86 tests memory much more thorougly than your BIOSs\n"
85 " power-on test, and may find failures that the BIOS doesn't.\n"
86 "\n"
87 "* If the error can be repeatably reproduced, this is a bug in\n"
88 " bzip2, and I would very much like to hear about it. Please\n"
89 " let me know, and, ideally, save a copy of the file causing the\n"
90 " problem -- without which I will be unable to investigate it.\n"
91 "\n"
92 );
93 }
94
95 exit(3);
96}
const char *BZ_API BZ2_bzlibVersion(void)
Definition bzlib.c:1377
VOID_HACK exit()
Here is the call graph for this function:

◆ BZ2_compressBlock()

void BZ2_compressBlock ( EState * s,
Bool is_last_block )
extern

Definition at line 605 of file compress.c.

606{
607 if (s->nblock > 0) {
608
610 s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
611 s->combinedCRC ^= s->blockCRC;
612 if (s->blockNo > 1) s->numZ = 0;
613
614 if (s->verbosity >= 2)
615 VPrintf4( " block %d: crc = 0x%08x, "
616 "combined CRC = 0x%08x, size = %d\n",
617 s->blockNo, s->blockCRC, s->combinedCRC, s->nblock );
618
619 BZ2_blockSort ( s );
620 }
621
622 s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]);
623
624 /*-- If this is the first block, create the stream header. --*/
625 if (s->blockNo == 1) {
626 BZ2_bsInitWrite ( s );
627 bsPutUChar ( s, BZ_HDR_B );
628 bsPutUChar ( s, BZ_HDR_Z );
629 bsPutUChar ( s, BZ_HDR_h );
630 bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) );
631 }
632
633 if (s->nblock > 0) {
634
635 bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 );
636 bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 );
637 bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 );
638
639 /*-- Now the block's CRC, so it is in a known place. --*/
640 bsPutUInt32 ( s, s->blockCRC );
641
642 /*--
643 Now a single bit indicating (non-)randomisation.
644 As of version 0.9.5, we use a better sorting algorithm
645 which makes randomisation unnecessary. So always set
646 the randomised bit to 'no'. Of course, the decoder
647 still needs to be able to handle randomised blocks
648 so as to maintain backwards compatibility with
649 older versions of bzip2.
650 --*/
651 bsW(s,1,0);
652
653 bsW ( s, 24, s->origPtr );
654 generateMTFValues ( s );
655 sendMTFValues ( s );
656 }
657
658
659 /*-- If this is the last block, add the stream trailer. --*/
660 if (is_last_block) {
661
662 bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 );
663 bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 );
664 bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 );
665 bsPutUInt32 ( s, s->combinedCRC );
666 if (s->verbosity >= 2)
667 VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC );
668 bsFinishWrite ( s );
669 }
670}
void BZ2_blockSort(EState *s)
Definition blocksort.c:1033
#define BZ_HDR_Z
#define BZ_HDR_B
#define VPrintf4(zf, za1, za2, za3, za4)
#define BZ_HDR_h
#define BZ_HDR_0
#define BZ_FINALISE_CRC(crcVar)
#define VPrintf1(zf, za1)
ABC_NAMESPACE_IMPL_START void BZ2_bsInitWrite(EState *s)
Definition compress.c:40
UInt32 combinedCRC
UInt32 blockCRC
Int32 numZ
Int32 blockSize100k
Int32 blockNo
UChar * zbits
Here is the call graph for this function:

◆ BZ2_decompress()

Int32 BZ2_decompress ( DState * s)
extern

Definition at line 113 of file decompress.c.

114{
115 UChar uc;
116 Int32 retVal;
117 Int32 minLen, maxLen;
118 bz_stream* strm = s->strm;
119
120 /* stuff that needs to be saved/restored */
121 Int32 i;
122 Int32 j;
123 Int32 t;
124 Int32 alphaSize;
125 Int32 nGroups;
126 Int32 nSelectors;
127 Int32 EOB;
128 Int32 groupNo;
129 Int32 groupPos;
130 Int32 nextSym;
131 Int32 nblockMAX;
132 Int32 nblock;
133 Int32 es;
134 Int32 N;
135 Int32 curr;
136 Int32 zt;
137 Int32 zn;
138 Int32 zvec;
139 Int32 zj;
140 Int32 gSel;
141 Int32 gMinlen;
142 Int32* gLimit;
143 Int32* gBase;
144 Int32* gPerm;
145
146 if (s->state == BZ_X_MAGIC_1) {
147 /*initialise the save area*/
148 s->save_i = 0;
149 s->save_j = 0;
150 s->save_t = 0;
151 s->save_alphaSize = 0;
152 s->save_nGroups = 0;
153 s->save_nSelectors = 0;
154 s->save_EOB = 0;
155 s->save_groupNo = 0;
156 s->save_groupPos = 0;
157 s->save_nextSym = 0;
158 s->save_nblockMAX = 0;
159 s->save_nblock = 0;
160 s->save_es = 0;
161 s->save_N = 0;
162 s->save_curr = 0;
163 s->save_zt = 0;
164 s->save_zn = 0;
165 s->save_zvec = 0;
166 s->save_zj = 0;
167 s->save_gSel = 0;
168 s->save_gMinlen = 0;
169 s->save_gLimit = NULL;
170 s->save_gBase = NULL;
171 s->save_gPerm = NULL;
172 }
173
174 /*restore from the save area*/
175 i = s->save_i;
176 j = s->save_j;
177 t = s->save_t;
178 alphaSize = s->save_alphaSize;
179 nGroups = s->save_nGroups;
180 nSelectors = s->save_nSelectors;
181 EOB = s->save_EOB;
182 groupNo = s->save_groupNo;
183 groupPos = s->save_groupPos;
184 nextSym = s->save_nextSym;
185 nblockMAX = s->save_nblockMAX;
186 nblock = s->save_nblock;
187 es = s->save_es;
188 N = s->save_N;
189 curr = s->save_curr;
190 zt = s->save_zt;
191 zn = s->save_zn;
192 zvec = s->save_zvec;
193 zj = s->save_zj;
194 gSel = s->save_gSel;
195 gMinlen = s->save_gMinlen;
196 gLimit = s->save_gLimit;
197 gBase = s->save_gBase;
198 gPerm = s->save_gPerm;
199
200 retVal = BZ_OK;
201
202 switch (s->state) {
203
206
209
212
214 if (s->blockSize100k < (BZ_HDR_0 + 1) ||
215 s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
216 s->blockSize100k -= BZ_HDR_0;
217
218 if (s->smallDecompress) {
219 s->ll16 = (unsigned short *)BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
220 s->ll4 = (unsigned char *)BZALLOC(
221 ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
222 );
223 if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
224 } else {
225 s->tt = (unsigned *)BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
226 if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
227 }
228
230
231 if (uc == 0x17) goto endhdr_2;
232 if (uc != 0x31) RETURN(BZ_DATA_ERROR);
234 if (uc != 0x41) RETURN(BZ_DATA_ERROR);
236 if (uc != 0x59) RETURN(BZ_DATA_ERROR);
238 if (uc != 0x26) RETURN(BZ_DATA_ERROR);
240 if (uc != 0x53) RETURN(BZ_DATA_ERROR);
242 if (uc != 0x59) RETURN(BZ_DATA_ERROR);
243
244 s->currBlockNo++;
245 if (s->verbosity >= 2)
246 VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
247
248 s->storedBlockCRC = 0;
250 s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
252 s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
254 s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
256 s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
257
259
260 s->origPtr = 0;
262 s->origPtr = (s->origPtr << 8) | ((Int32)uc);
264 s->origPtr = (s->origPtr << 8) | ((Int32)uc);
266 s->origPtr = (s->origPtr << 8) | ((Int32)uc);
267
268 if (s->origPtr < 0)
270 if (s->origPtr > 10 + 100000*s->blockSize100k)
272
273 /*--- Receive the mapping table ---*/
274 for (i = 0; i < 16; i++) {
276 if (uc == 1)
277 s->inUse16[i] = True; else
278 s->inUse16[i] = False;
279 }
280
281 for (i = 0; i < 256; i++) s->inUse[i] = False;
282
283 for (i = 0; i < 16; i++)
284 if (s->inUse16[i])
285 for (j = 0; j < 16; j++) {
287 if (uc == 1) s->inUse[i * 16 + j] = True;
288 }
289 makeMaps_d ( s );
290 if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
291 alphaSize = s->nInUse+2;
292
293 /*--- Now the selectors ---*/
294 GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
295 if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
296 GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
297 if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
298 for (i = 0; i < nSelectors; i++) {
299 j = 0;
300 while (True) {
302 if (uc == 0) break;
303 j++;
304 if (j >= nGroups) RETURN(BZ_DATA_ERROR);
305 }
306 s->selectorMtf[i] = j;
307 }
308
309 /*--- Undo the MTF values for the selectors. ---*/
310 {
311 UChar pos[BZ_N_GROUPS], tmp, v;
312 for (v = 0; v < nGroups; v++) pos[v] = v;
313
314 for (i = 0; i < nSelectors; i++) {
315 v = s->selectorMtf[i];
316 tmp = pos[v];
317 while (v > 0) { pos[v] = pos[v-1]; v--; }
318 pos[0] = tmp;
319 s->selector[i] = tmp;
320 }
321 }
322
323 /*--- Now the coding tables ---*/
324 for (t = 0; t < nGroups; t++) {
325 GET_BITS(BZ_X_CODING_1, curr, 5);
326 for (i = 0; i < alphaSize; i++) {
327 while (True) {
328 if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
330 if (uc == 0) break;
332 if (uc == 0) curr++; else curr--;
333 }
334 s->len[t][i] = curr;
335 }
336 }
337
338 /*--- Create the Huffman decoding tables ---*/
339 for (t = 0; t < nGroups; t++) {
340 minLen = 32;
341 maxLen = 0;
342 for (i = 0; i < alphaSize; i++) {
343 if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
344 if (s->len[t][i] < minLen) minLen = s->len[t][i];
345 }
347 &(s->limit[t][0]),
348 &(s->base[t][0]),
349 &(s->perm[t][0]),
350 &(s->len[t][0]),
351 minLen, maxLen, alphaSize
352 );
353 s->minLens[t] = minLen;
354 }
355
356 /*--- Now the MTF values ---*/
357
358 EOB = s->nInUse+1;
359 nblockMAX = 100000 * s->blockSize100k;
360 groupNo = -1;
361 groupPos = 0;
362
363 for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
364
365 /*-- MTF init --*/
366 {
367 Int32 ii, jj, kk;
368 kk = MTFA_SIZE-1;
369 for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
370 for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
371 s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
372 kk--;
373 }
374 s->mtfbase[ii] = kk + 1;
375 }
376 }
377 /*-- end MTF init --*/
378
379 nblock = 0;
381
382 while (True) {
383
384 if (nextSym == EOB) break;
385
386 if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
387
388 es = -1;
389 N = 1;
390 do {
391 if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
392 if (nextSym == BZ_RUNB) es = es + (1+1) * N;
393 N = N * 2;
395 }
396 while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
397
398 es++;
399 uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
400 s->unzftab[uc] += es;
401
402 if (s->smallDecompress)
403 while (es > 0) {
404 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
405 s->ll16[nblock] = (UInt16)uc;
406 nblock++;
407 es--;
408 }
409 else
410 while (es > 0) {
411 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
412 s->tt[nblock] = (UInt32)uc;
413 nblock++;
414 es--;
415 };
416
417 continue;
418
419 } else {
420
421 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
422
423 /*-- uc = MTF ( nextSym-1 ) --*/
424 {
425 Int32 ii, jj, kk, pp, lno, off;
426 UInt32 nn;
427 nn = (UInt32)(nextSym - 1);
428
429 if (nn < MTFL_SIZE) {
430 /* avoid general-case expense */
431 pp = s->mtfbase[0];
432 uc = s->mtfa[pp+nn];
433 while (nn > 3) {
434 Int32 z = pp+nn;
435 s->mtfa[(z) ] = s->mtfa[(z)-1];
436 s->mtfa[(z)-1] = s->mtfa[(z)-2];
437 s->mtfa[(z)-2] = s->mtfa[(z)-3];
438 s->mtfa[(z)-3] = s->mtfa[(z)-4];
439 nn -= 4;
440 }
441 while (nn > 0) {
442 s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
443 };
444 s->mtfa[pp] = uc;
445 } else {
446 /* general case */
447 lno = nn / MTFL_SIZE;
448 off = nn % MTFL_SIZE;
449 pp = s->mtfbase[lno] + off;
450 uc = s->mtfa[pp];
451 while (pp > s->mtfbase[lno]) {
452 s->mtfa[pp] = s->mtfa[pp-1]; pp--;
453 };
454 s->mtfbase[lno]++;
455 while (lno > 0) {
456 s->mtfbase[lno]--;
457 s->mtfa[s->mtfbase[lno]]
458 = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
459 lno--;
460 }
461 s->mtfbase[0]--;
462 s->mtfa[s->mtfbase[0]] = uc;
463 if (s->mtfbase[0] == 0) {
464 kk = MTFA_SIZE-1;
465 for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
466 for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
467 s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
468 kk--;
469 }
470 s->mtfbase[ii] = kk + 1;
471 }
472 }
473 }
474 }
475 /*-- end uc = MTF ( nextSym-1 ) --*/
476
477 s->unzftab[s->seqToUnseq[uc]]++;
478 if (s->smallDecompress)
479 s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
480 s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]);
481 nblock++;
482
484 continue;
485 }
486 }
487
488 /* Now we know what nblock is, we can do a better sanity
489 check on s->origPtr.
490 */
491 if (s->origPtr < 0 || s->origPtr >= nblock)
493
494 /*-- Set up cftab to facilitate generation of T^(-1) --*/
495 s->cftab[0] = 0;
496 for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
497 for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
498 for (i = 0; i <= 256; i++) {
499 if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
500 /* s->cftab[i] can legitimately be == nblock */
502 }
503 }
504
505 s->state_out_len = 0;
506 s->state_out_ch = 0;
508 s->state = BZ_X_OUTPUT;
509 if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
510
511 if (s->smallDecompress) {
512
513 /*-- Make a copy of cftab, used in generation of T --*/
514 for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
515
516 /*-- compute the T vector --*/
517 for (i = 0; i < nblock; i++) {
518 uc = (UChar)(s->ll16[i]);
519 SET_LL(i, s->cftabCopy[uc]);
520 s->cftabCopy[uc]++;
521 }
522
523 /*-- Compute T^(-1) by pointer reversal on T --*/
524 i = s->origPtr;
525 j = GET_LL(i);
526 do {
527 Int32 tmp = GET_LL(j);
528 SET_LL(j, i);
529 i = j;
530 j = tmp;
531 }
532 while (i != s->origPtr);
533
534 s->tPos = s->origPtr;
535 s->nblock_used = 0;
536 if (s->blockRandomised) {
538 BZ_GET_SMALL(s->k0); s->nblock_used++;
540 } else {
541 BZ_GET_SMALL(s->k0); s->nblock_used++;
542 }
543
544 } else {
545
546 /*-- compute the T^(-1) vector --*/
547 for (i = 0; i < nblock; i++) {
548 uc = (UChar)(s->tt[i] & 0xff);
549 s->tt[s->cftab[uc]] |= (i << 8);
550 s->cftab[uc]++;
551 }
552
553 s->tPos = s->tt[s->origPtr] >> 8;
554 s->nblock_used = 0;
555 if (s->blockRandomised) {
557 BZ_GET_FAST(s->k0); s->nblock_used++;
559 } else {
560 BZ_GET_FAST(s->k0); s->nblock_used++;
561 }
562
563 }
564
565 RETURN(BZ_OK);
566
567
568
569 endhdr_2:
570
572 if (uc != 0x72) RETURN(BZ_DATA_ERROR);
574 if (uc != 0x45) RETURN(BZ_DATA_ERROR);
576 if (uc != 0x38) RETURN(BZ_DATA_ERROR);
578 if (uc != 0x50) RETURN(BZ_DATA_ERROR);
580 if (uc != 0x90) RETURN(BZ_DATA_ERROR);
581
582 s->storedCombinedCRC = 0;
584 s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
586 s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
588 s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
590 s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
591
592 s->state = BZ_X_IDLE;
594
595 default: AssertH ( False, 4001 );
596 }
597
598 AssertH ( False, 4002 );
599
600 save_state_and_return:
601
602 s->save_i = i;
603 s->save_j = j;
604 s->save_t = t;
605 s->save_alphaSize = alphaSize;
606 s->save_nGroups = nGroups;
607 s->save_nSelectors = nSelectors;
608 s->save_EOB = EOB;
609 s->save_groupNo = groupNo;
610 s->save_groupPos = groupPos;
611 s->save_nextSym = nextSym;
612 s->save_nblockMAX = nblockMAX;
613 s->save_nblock = nblock;
614 s->save_es = es;
615 s->save_N = N;
616 s->save_curr = curr;
617 s->save_zt = zt;
618 s->save_zn = zn;
619 s->save_zvec = zvec;
620 s->save_zj = zj;
621 s->save_gSel = gSel;
622 s->save_gMinlen = gMinlen;
623 s->save_gLimit = gLimit;
624 s->save_gBase = gBase;
625 s->save_gPerm = gPerm;
626
627 return retVal;
628}
#define BZ_MEM_ERROR
Definition bzlib.h:41
#define BZ_DATA_ERROR_MAGIC
Definition bzlib.h:43
#define BZ_OK
Definition bzlib.h:34
#define BZ_DATA_ERROR
Definition bzlib.h:42
#define BZ_STREAM_END
Definition bzlib.h:38
#define BZ_X_MTF_4
#define BZ_X_IDLE
#define BZ_N_GROUPS
#define BZ_X_ENDHDR_5
#define BZ_GET_FAST(cccc)
#define BZ_X_MTF_5
#define BZ_X_SELECTOR_1
#define BZ_X_MTF_3
#define BZ_X_ORIGPTR_3
#define BZ_X_MAGIC_1
#define SET_LL(i, n)
#define BZ_X_BLKHDR_1
#define False
#define BZALLOC(nnn)
#define BZ_X_BLKHDR_2
#define MTFL_SIZE
#define BZ_RAND_UPD_MASK
#define BZ_X_MAPPING_1
#define BZ_X_ORIGPTR_1
#define BZ_X_RANDBIT
#define BZ_X_ORIGPTR_2
#define BZ_X_MAGIC_3
#define BZ_RAND_MASK
#define BZ_X_MTF_6
#define BZ_X_BLKHDR_5
#define BZ_GET_SMALL(cccc)
#define BZ_X_CODING_2
#define BZ_X_ENDHDR_4
#define BZ_X_BCRC_1
#define BZ_X_MAGIC_2
#define BZ_X_CCRC_2
#define BZ_X_CODING_3
#define BZ_X_ENDHDR_2
#define BZ_X_MAGIC_4
#define BZ_RAND_INIT_MASK
#define BZ_RUNA
#define BZ_X_MTF_1
#define MTFA_SIZE
#define BZ_X_SELECTOR_2
void BZ2_hbCreateDecodeTables(Int32 *, Int32 *, Int32 *, UChar *, Int32, Int32, Int32)
Definition huffman.c:173
#define BZ_X_MTF_2
#define BZ_X_BLKHDR_6
#define BZ_X_BCRC_4
#define BZ_X_CODING_1
#define BZ_X_ENDHDR_3
#define BZ_X_BLKHDR_4
#define BZ_X_BLKHDR_3
#define BZ_X_CCRC_3
#define BZ_INITIALISE_CRC(crcVar)
#define BZ_X_CCRC_1
#define BZ_X_ENDHDR_6
#define BZ_X_OUTPUT
#define BZ_X_BCRC_2
#define BZ_X_BCRC_3
#define BZ_X_CCRC_4
#define BZ_X_MAPPING_2
#define BZ_RUNB
#define BZ_X_SELECTOR_3
#define GET_UCHAR(lll, uuu)
Definition decompress.c:74
#define RETURN(rrr)
Definition decompress.c:47
#define GET_MTF_VAL(label1, label2, lval)
Definition decompress.c:81
#define GET_BIT(lll, uuu)
Definition decompress.c:77
#define GET_BITS(lll, vvv, nnn)
Definition decompress.c:50
bool pos
Definition globals.c:30
if(last==0)
Definition sparse_int.h:34
UInt32 calculatedBlockCRC
Int32 save_zn
bz_stream * strm
UChar selector[BZ_MAX_SELECTORS]
Bool smallDecompress
Int32 base[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]
UChar mtfa[MTFA_SIZE]
Int32 save_nextSym
Int32 save_alphaSize
Int32 save_t
UInt32 storedBlockCRC
Int32 save_zt
UInt32 storedCombinedCRC
Int32 * save_gLimit
Int32 save_nblock
Int32 save_i
Int32 origPtr
Int32 save_j
Int32 save_gMinlen
Int32 save_EOB
Int32 state_out_len
Int32 currBlockNo
UInt32 * tt
Int32 nblock_used
Int32 state
Int32 save_nGroups
Int32 unzftab[256]
Int32 cftab[257]
Int32 verbosity
Int32 perm[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]
Int32 save_nSelectors
UChar len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]
UChar * ll4
UInt32 tPos
Int32 save_zvec
UChar seqToUnseq[256]
UInt16 * ll16
Int32 minLens[BZ_N_GROUPS]
Int32 * save_gPerm
UChar state_out_ch
Int32 save_gSel
Bool inUse[256]
Int32 save_curr
Int32 save_N
Int32 save_groupPos
UChar selectorMtf[BZ_MAX_SELECTORS]
Int32 mtfbase[256/MTFL_SIZE]
Int32 save_zj
Int32 save_groupNo
Int32 nInUse
Bool inUse16[16]
Int32 blockSize100k
Int32 save_nblockMAX
Int32 limit[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]
Int32 * save_gBase
Bool blockRandomised
Int32 save_es
Int32 cftabCopy[257]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BZ2_hbAssignCodes()

void BZ2_hbAssignCodes ( Int32 * code,
UChar * length,
Int32 minLen,
Int32 maxLen,
Int32 alphaSize )
extern

Definition at line 155 of file huffman.c.

160{
161 Int32 n, vec, i;
162
163 vec = 0;
164 for (n = minLen; n <= maxLen; n++) {
165 for (i = 0; i < alphaSize; i++)
166 if (length[i] == n) { code[i] = vec; vec++; };
167 vec <<= 1;
168 }
169}

◆ BZ2_hbCreateDecodeTables()

void BZ2_hbCreateDecodeTables ( Int32 * limit,
Int32 * base,
Int32 * perm,
UChar * length,
Int32 minLen,
Int32 maxLen,
Int32 alphaSize )
extern

Definition at line 173 of file huffman.c.

180{
181 Int32 pp, i, j, vec;
182
183 pp = 0;
184 for (i = minLen; i <= maxLen; i++)
185 for (j = 0; j < alphaSize; j++)
186 if (length[j] == i) { perm[pp] = j; pp++; };
187
188 for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
189 for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
190
191 for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
192
193 for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
194 vec = 0;
195
196 for (i = minLen; i <= maxLen; i++) {
197 vec += (base[i+1] - base[i]);
198 limit[i] = vec-1;
199 vec <<= 1;
200 }
201 for (i = minLen + 1; i <= maxLen; i++)
202 base[i] = ((limit[i-1] + 1) << 1) - base[i];
203}
#define BZ_MAX_CODE_LEN
Here is the caller graph for this function:

◆ BZ2_hbMakeCodeLengths()

void BZ2_hbMakeCodeLengths ( UChar * len,
Int32 * freq,
Int32 alphaSize,
Int32 maxLen )
extern

Definition at line 66 of file huffman.c.

70{
71 /*--
72 Nodes and heap entries run from 1. Entry 0
73 for both the heap and nodes is a sentinel.
74 --*/
75 Int32 nNodes, nHeap, n1, n2, i, j, k;
76 Bool tooLong;
77
79 Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
80 Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
81
82 for (i = 0; i < alphaSize; i++)
83 weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
84
85 while (True) {
86
87 nNodes = alphaSize;
88 nHeap = 0;
89
90 heap[0] = 0;
91 weight[0] = 0;
92 parent[0] = -2;
93
94 for (i = 1; i <= alphaSize; i++) {
95 parent[i] = -1;
96 nHeap++;
97 heap[nHeap] = i;
98 UPHEAP(nHeap);
99 }
100
101 AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
102
103 while (nHeap > 1) {
104 n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
105 n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
106 nNodes++;
107 parent[n1] = parent[n2] = nNodes;
108 weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
109 parent[nNodes] = -1;
110 nHeap++;
111 heap[nHeap] = nNodes;
112 UPHEAP(nHeap);
113 }
114
115 AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
116
117 tooLong = False;
118 for (i = 1; i <= alphaSize; i++) {
119 j = 0;
120 k = i;
121 while (parent[k] >= 0) { k = parent[k]; j++; }
122 len[i-1] = j;
123 if (j > maxLen) tooLong = True;
124 }
125
126 if (! tooLong) break;
127
128 /* 17 Oct 04: keep-going condition for the following loop used
129 to be 'i < alphaSize', which missed the last element,
130 theoretically leading to the possibility of the compressor
131 looping. However, this count-scaling step is only needed if
132 one of the generated Huffman code words is longer than
133 maxLen, which up to and including version 1.0.2 was 20 bits,
134 which is extremely unlikely. In version 1.0.3 maxLen was
135 changed to 17 bits, which has minimal effect on compression
136 ratio, but does mean this scaling step is used from time to
137 time, enough to verify that it works.
138
139 This means that bzip2-1.0.3 and later will only produce
140 Huffman codes with a maximum length of 17 bits. However, in
141 order to preserve backwards compatibility with bitstreams
142 produced by versions pre-1.0.3, the decompressor must still
143 handle lengths of up to 20. */
144
145 for (i = 1; i <= alphaSize; i++) {
146 j = weight[i] >> 8;
147 j = 1 + (j / 2);
148 weight[i] = j << 8;
149 }
150 }
151}
unsigned char Bool
#define BZ_MAX_ALPHA_SIZE
#define UPHEAP(z)
Definition huffman.c:36
#define DOWNHEAP(z)
Definition huffman.c:47
#define ADDWEIGHTS(zw1, zw2)
Definition huffman.c:32
Definition heap.h:19

◆ BZ2_indexIntoF()

Int32 BZ2_indexIntoF ( Int32 indx,
Int32 * cftab )

Definition at line 698 of file bzlib.c.

699{
700 Int32 nb, na, mid;
701 nb = 0;
702 na = 256;
703 do {
704 mid = (nb + na) >> 1;
705 if (indx >= cftab[mid]) nb = mid; else na = mid;
706 }
707 while (na - nb != 1);
708 return nb;
709}

Variable Documentation

◆ BZ2_crc32Table

UInt32 BZ2_crc32Table[256]
extern

Definition at line 34 of file crctable.c.

34 {
35
36 /*-- Ugly, innit? --*/
37
38 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
39 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
40 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
41 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
42 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
43 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
44 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
45 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
46 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
47 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
48 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
49 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
50 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
51 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
52 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
53 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
54 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
55 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
56 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
57 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
58 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
59 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
60 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
61 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
62 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
63 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
64 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
65 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
66 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
67 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
68 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
69 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
70 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
71 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
72 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
73 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
74 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
75 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
76 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
77 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
78 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
79 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
80 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
81 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
82 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
83 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
84 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
85 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
86 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
87 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
88 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
89 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
90 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
91 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
92 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
93 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
94 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
95 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
96 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
97 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
98 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
99 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
100 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
101 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
102};

◆ BZ2_rNums

Int32 BZ2_rNums[512]
extern

Definition at line 29 of file randtable.c.

29 {
30 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
31 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
32 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
33 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
34 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
35 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
36 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
37 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
38 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
39 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
40 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
41 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
42 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
43 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
44 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
45 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
46 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
47 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
48 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
49 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
50 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
51 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
52 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
53 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
54 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
55 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
56 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
57 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
58 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
59 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
60 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
61 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
62 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
63 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
64 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
65 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
66 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
67 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
68 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
69 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
70 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
71 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
72 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
73 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
74 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
75 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
76 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
77 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
78 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
79 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
80 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
81 936, 638
82};