ReactOS  0.4.13-dev-563-g0561610
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.6, 6-Sept-2010"
 
#define True   ((Bool)1)
 
#define False   ((Bool)0)
 
#define __inline__   /* */
 
#define AssertH(cond, errcode)   { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
 
#define AssertD(cond, msg)   /* */
 
#define VPrintf0(zf)   fprintf(stderr,zf)
 
#define VPrintf1(zf, za1)   fprintf(stderr,zf,za1)
 
#define VPrintf2(zf, za1, za2)   fprintf(stderr,zf,za1,za2)
 
#define VPrintf3(zf, za1, za2, za3)   fprintf(stderr,zf,za1,za2,za3)
 
#define VPrintf4(zf, za1, za2, za3, za4)   fprintf(stderr,zf,za1,za2,za3,za4)
 
#define VPrintf5(zf, za1, za2, za3, za4, za5)   fprintf(stderr,zf,za1,za2,za3,za4,za5)
 
#define BZALLOC(nnn)   (strm->bzalloc)(strm->opaque,(nnn),1)
 
#define BZFREE(ppp)   (strm->bzfree)(strm->opaque,(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)   ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
 
#define SET_LL(i, n)
 
#define GET_LL(i)   (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
 
#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 53 of file bzlib_private.h.

◆ AssertD

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

Definition at line 70 of file bzlib_private.h.

◆ AssertH

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

Definition at line 59 of file bzlib_private.h.

◆ BZ_FINALISE_CRC

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

Definition at line 162 of file bzlib_private.h.

◆ BZ_G_SIZE

#define BZ_G_SIZE   50

Definition at line 122 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;
DWORD UInt32
Definition: chm_lib.c:106
unsigned char UChar
Definition: bzlib_private.h:43
GLdouble s
Definition: gl.h:2039
#define True
Definition: bzlib_private.h:49

Definition at line 444 of file bzlib_private.h.

◆ 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;
DWORD UInt32
Definition: chm_lib.c:106
unsigned char UChar
Definition: bzlib_private.h:43
#define True
Definition: bzlib_private.h:49

Definition at line 451 of file bzlib_private.h.

◆ 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);
DWORD UInt32
Definition: chm_lib.c:106
Int32 BZ2_indexIntoF(Int32, Int32 *)
Definition: bzlib.c:697
GLdouble s
Definition: gl.h:2039
#define True
Definition: bzlib_private.h:49
#define GET_LL(i)

Definition at line 475 of file bzlib_private.h.

◆ BZ_HDR_0

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

Definition at line 111 of file bzlib_private.h.

◆ BZ_HDR_B

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

Definition at line 108 of file bzlib_private.h.

◆ BZ_HDR_h

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

Definition at line 110 of file bzlib_private.h.

◆ BZ_HDR_Z

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

Definition at line 109 of file bzlib_private.h.

◆ BZ_INITIALISE_CRC

#define BZ_INITIALISE_CRC (   crcVar)
Value:
{ \
crcVar = 0xffffffffL; \
}
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 157 of file bzlib_private.h.

◆ BZ_M_FINISHING

#define BZ_M_FINISHING   4

Definition at line 181 of file bzlib_private.h.

◆ BZ_M_FLUSHING

#define BZ_M_FLUSHING   3

Definition at line 180 of file bzlib_private.h.

◆ BZ_M_IDLE

#define BZ_M_IDLE   1

Definition at line 178 of file bzlib_private.h.

◆ BZ_M_RUNNING

#define BZ_M_RUNNING   2

Definition at line 179 of file bzlib_private.h.

◆ BZ_MAX_ALPHA_SIZE

#define BZ_MAX_ALPHA_SIZE   258

Definition at line 115 of file bzlib_private.h.

◆ BZ_MAX_CODE_LEN

#define BZ_MAX_CODE_LEN   23

Definition at line 116 of file bzlib_private.h.

◆ BZ_MAX_SELECTORS

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

Definition at line 125 of file bzlib_private.h.

◆ BZ_N_GROUPS

#define BZ_N_GROUPS   6

Definition at line 121 of file bzlib_private.h.

◆ BZ_N_ITERS

#define BZ_N_ITERS   4

Definition at line 123 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 189 of file bzlib_private.h.

◆ BZ_N_QSORT

#define BZ_N_QSORT   12

Definition at line 187 of file bzlib_private.h.

◆ BZ_N_RADIX

#define BZ_N_RADIX   2

Definition at line 186 of file bzlib_private.h.

◆ BZ_N_SHELL

#define BZ_N_SHELL   18

Definition at line 188 of file bzlib_private.h.

◆ BZ_RAND_DECLS

#define BZ_RAND_DECLS
Value:
Int32 rNToGo; \
Int32 rTPos \
LONG Int32
Definition: chm_lib.c:105

Definition at line 133 of file bzlib_private.h.

◆ BZ_RAND_INIT_MASK

#define BZ_RAND_INIT_MASK
Value:
s->rNToGo = 0; \
s->rTPos = 0 \
GLdouble s
Definition: gl.h:2039

Definition at line 137 of file bzlib_private.h.

◆ BZ_RAND_MASK

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

Definition at line 141 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:26
GLdouble s
Definition: gl.h:2039

Definition at line 143 of file bzlib_private.h.

◆ BZ_RUNA

#define BZ_RUNA   0

Definition at line 118 of file bzlib_private.h.

◆ BZ_RUNB

#define BZ_RUNB   1

Definition at line 119 of file bzlib_private.h.

◆ BZ_S_INPUT

#define BZ_S_INPUT   2

Definition at line 184 of file bzlib_private.h.

◆ BZ_S_OUTPUT

#define BZ_S_OUTPUT   1

Definition at line 183 of file bzlib_private.h.

◆ BZ_UPDATE_CRC

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

Definition at line 167 of file bzlib_private.h.

◆ BZ_VERSION

#define BZ_VERSION   "1.0.6, 6-Sept-2010"

Definition at line 39 of file bzlib_private.h.

◆ BZ_X_BCRC_1

#define BZ_X_BCRC_1   20

Definition at line 304 of file bzlib_private.h.

◆ BZ_X_BCRC_2

#define BZ_X_BCRC_2   21

Definition at line 305 of file bzlib_private.h.

◆ BZ_X_BCRC_3

#define BZ_X_BCRC_3   22

Definition at line 306 of file bzlib_private.h.

◆ BZ_X_BCRC_4

#define BZ_X_BCRC_4   23

Definition at line 307 of file bzlib_private.h.

◆ BZ_X_BLKHDR_1

#define BZ_X_BLKHDR_1   14

Definition at line 298 of file bzlib_private.h.

◆ BZ_X_BLKHDR_2

#define BZ_X_BLKHDR_2   15

Definition at line 299 of file bzlib_private.h.

◆ BZ_X_BLKHDR_3

#define BZ_X_BLKHDR_3   16

Definition at line 300 of file bzlib_private.h.

◆ BZ_X_BLKHDR_4

#define BZ_X_BLKHDR_4   17

Definition at line 301 of file bzlib_private.h.

◆ BZ_X_BLKHDR_5

#define BZ_X_BLKHDR_5   18

Definition at line 302 of file bzlib_private.h.

◆ BZ_X_BLKHDR_6

#define BZ_X_BLKHDR_6   19

Definition at line 303 of file bzlib_private.h.

◆ BZ_X_CCRC_1

#define BZ_X_CCRC_1   47

Definition at line 331 of file bzlib_private.h.

◆ BZ_X_CCRC_2

#define BZ_X_CCRC_2   48

Definition at line 332 of file bzlib_private.h.

◆ BZ_X_CCRC_3

#define BZ_X_CCRC_3   49

Definition at line 333 of file bzlib_private.h.

◆ BZ_X_CCRC_4

#define BZ_X_CCRC_4   50

Definition at line 334 of file bzlib_private.h.

◆ BZ_X_CODING_1

#define BZ_X_CODING_1   33

Definition at line 317 of file bzlib_private.h.

◆ BZ_X_CODING_2

#define BZ_X_CODING_2   34

Definition at line 318 of file bzlib_private.h.

◆ BZ_X_CODING_3

#define BZ_X_CODING_3   35

Definition at line 319 of file bzlib_private.h.

◆ BZ_X_ENDHDR_2

#define BZ_X_ENDHDR_2   42

Definition at line 326 of file bzlib_private.h.

◆ BZ_X_ENDHDR_3

#define BZ_X_ENDHDR_3   43

Definition at line 327 of file bzlib_private.h.

◆ BZ_X_ENDHDR_4

#define BZ_X_ENDHDR_4   44

Definition at line 328 of file bzlib_private.h.

◆ BZ_X_ENDHDR_5

#define BZ_X_ENDHDR_5   45

Definition at line 329 of file bzlib_private.h.

◆ BZ_X_ENDHDR_6

#define BZ_X_ENDHDR_6   46

Definition at line 330 of file bzlib_private.h.

◆ BZ_X_IDLE

#define BZ_X_IDLE   1

Definition at line 291 of file bzlib_private.h.

◆ BZ_X_MAGIC_1

#define BZ_X_MAGIC_1   10

Definition at line 294 of file bzlib_private.h.

◆ BZ_X_MAGIC_2

#define BZ_X_MAGIC_2   11

Definition at line 295 of file bzlib_private.h.

◆ BZ_X_MAGIC_3

#define BZ_X_MAGIC_3   12

Definition at line 296 of file bzlib_private.h.

◆ BZ_X_MAGIC_4

#define BZ_X_MAGIC_4   13

Definition at line 297 of file bzlib_private.h.

◆ BZ_X_MAPPING_1

#define BZ_X_MAPPING_1   28

Definition at line 312 of file bzlib_private.h.

◆ BZ_X_MAPPING_2

#define BZ_X_MAPPING_2   29

Definition at line 313 of file bzlib_private.h.

◆ BZ_X_MTF_1

#define BZ_X_MTF_1   36

Definition at line 320 of file bzlib_private.h.

◆ BZ_X_MTF_2

#define BZ_X_MTF_2   37

Definition at line 321 of file bzlib_private.h.

◆ BZ_X_MTF_3

#define BZ_X_MTF_3   38

Definition at line 322 of file bzlib_private.h.

◆ BZ_X_MTF_4

#define BZ_X_MTF_4   39

Definition at line 323 of file bzlib_private.h.

◆ BZ_X_MTF_5

#define BZ_X_MTF_5   40

Definition at line 324 of file bzlib_private.h.

◆ BZ_X_MTF_6

#define BZ_X_MTF_6   41

Definition at line 325 of file bzlib_private.h.

◆ BZ_X_ORIGPTR_1

#define BZ_X_ORIGPTR_1   25

Definition at line 309 of file bzlib_private.h.

◆ BZ_X_ORIGPTR_2

#define BZ_X_ORIGPTR_2   26

Definition at line 310 of file bzlib_private.h.

◆ BZ_X_ORIGPTR_3

#define BZ_X_ORIGPTR_3   27

Definition at line 311 of file bzlib_private.h.

◆ BZ_X_OUTPUT

#define BZ_X_OUTPUT   2

Definition at line 292 of file bzlib_private.h.

◆ BZ_X_RANDBIT

#define BZ_X_RANDBIT   24

Definition at line 308 of file bzlib_private.h.

◆ BZ_X_SELECTOR_1

#define BZ_X_SELECTOR_1   30

Definition at line 314 of file bzlib_private.h.

◆ BZ_X_SELECTOR_2

#define BZ_X_SELECTOR_2   31

Definition at line 315 of file bzlib_private.h.

◆ BZ_X_SELECTOR_3

#define BZ_X_SELECTOR_3   32

Definition at line 316 of file bzlib_private.h.

◆ BZALLOC

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

Definition at line 102 of file bzlib_private.h.

◆ BZFREE

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

Definition at line 103 of file bzlib_private.h.

◆ False

#define False   ((Bool)0)

Definition at line 50 of file bzlib_private.h.

◆ GET_LL

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

Definition at line 472 of file bzlib_private.h.

◆ GET_LL4

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

Definition at line 464 of file bzlib_private.h.

◆ MTFA_SIZE

#define MTFA_SIZE   4096

Definition at line 340 of file bzlib_private.h.

◆ MTFL_SIZE

#define MTFL_SIZE   16

Definition at line 341 of file bzlib_private.h.

◆ SET_LL

#define SET_LL (   i,
  n 
)
Value:
{ s->ll16[i] = (UInt16)(n & 0x0000ffff); \
SET_LL4(i, n >> 16); \
}
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLdouble s
Definition: gl.h:2039
unsigned short UInt16
Definition: bzlib_private.h:47

Definition at line 467 of file bzlib_private.h.

◆ 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); \
}
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLdouble s
Definition: gl.h:2039

Definition at line 458 of file bzlib_private.h.

◆ True

#define True   ((Bool)1)

Definition at line 49 of file bzlib_private.h.

◆ VPrintf0

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

Definition at line 73 of file bzlib_private.h.

◆ VPrintf1

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

Definition at line 75 of file bzlib_private.h.

◆ VPrintf2

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

Definition at line 77 of file bzlib_private.h.

◆ VPrintf3

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

Definition at line 79 of file bzlib_private.h.

◆ VPrintf4

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

Definition at line 81 of file bzlib_private.h.

◆ VPrintf5

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

Definition at line 83 of file bzlib_private.h.

Typedef Documentation

◆ Bool

typedef unsigned char Bool

Definition at line 42 of file bzlib_private.h.

◆ Char

typedef char Char

Definition at line 41 of file bzlib_private.h.

◆ Int16

typedef short Int16

Definition at line 46 of file bzlib_private.h.

◆ Int32

typedef int Int32

Definition at line 44 of file bzlib_private.h.

◆ UChar

typedef unsigned char UChar

Definition at line 43 of file bzlib_private.h.

◆ UInt16

typedef unsigned short UInt16

Definition at line 47 of file bzlib_private.h.

◆ UInt32

typedef unsigned int UInt32

Definition at line 45 of file bzlib_private.h.

Function Documentation

◆ BZ2_blockSort()

void BZ2_blockSort ( EState )

Definition at line 1031 of file blocksort.c.

1032 {
1033  UInt32* ptr = s->ptr;
1034  UChar* block = s->block;
1035  UInt32* ftab = s->ftab;
1036  Int32 nblock = s->nblock;
1037  Int32 verb = s->verbosity;
1038  Int32 wfact = s->workFactor;
1039  UInt16* quadrant;
1040  Int32 budget;
1041  Int32 budgetInit;
1042  Int32 i;
1043 
1044  if (nblock < 10000) {
1045  fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
1046  } else {
1047  /* Calculate the location for quadrant, remembering to get
1048  the alignment right. Assumes that &(block[0]) is at least
1049  2-byte aligned -- this should be ok since block is really
1050  the first section of arr2.
1051  */
1052  i = nblock+BZ_N_OVERSHOOT;
1053  if (i & 1) i++;
1054  quadrant = (UInt16*)(&(block[i]));
1055 
1056  /* (wfact-1) / 3 puts the default-factor-30
1057  transition point at very roughly the same place as
1058  with v0.1 and v0.9.0.
1059  Not that it particularly matters any more, since the
1060  resulting compressed stream is now the same regardless
1061  of whether or not we use the main sort or fallback sort.
1062  */
1063  if (wfact < 1 ) wfact = 1;
1064  if (wfact > 100) wfact = 100;
1065  budgetInit = nblock * ((wfact-1) / 3);
1066  budget = budgetInit;
1067 
1068  mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
1069  if (verb >= 3)
1070  VPrintf3 ( " %d work, %d block, ratio %5.2f\n",
1071  budgetInit - budget,
1072  nblock,
1073  (float)(budgetInit - budget) /
1074  (float)(nblock==0 ? 1 : nblock) );
1075  if (budget < 0) {
1076  if (verb >= 2)
1077  VPrintf0 ( " too repetitive; using fallback"
1078  " sorting algorithm\n" );
1079  fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
1080  }
1081  }
1082 
1083  s->origPtr = -1;
1084  for (i = 0; i < s->nblock; i++)
1085  if (ptr[i] == 0)
1086  { s->origPtr = i; break; };
1087 
1088  AssertH( s->origPtr != -1, 1003 );
1089 }
static unsigned int block
Definition: xmlmemory.c:118
DWORD UInt32
Definition: chm_lib.c:106
BYTE UChar
Definition: chm_lib.c:102
USHORT UInt16
Definition: chm_lib.c:104
#define BZ_N_OVERSHOOT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define AssertH(cond, errcode)
Definition: bzlib_private.h:59
static PVOID ptr
Definition: dispmode.c:27
GLdouble s
Definition: gl.h:2039
#define VPrintf0(zf)
Definition: bzlib_private.h:73
#define VPrintf3(zf, za1, za2, za3)
Definition: bzlib_private.h:79
static void fallbackSort(UInt32 *fmap, UInt32 *eclass, UInt32 *bhtab, Int32 nblock, Int32 verb)
Definition: blocksort.c:212
LONG Int32
Definition: chm_lib.c:105
static void mainSort(UInt32 *ptr, UChar *block, UInt16 *quadrant, UInt32 *ftab, Int32 nblock, Int32 verb, Int32 *budget)
Definition: blocksort.c:751

Referenced by BZ2_compressBlock().

◆ BZ2_bsInitWrite()

void BZ2_bsInitWrite ( EState )

Definition at line 37 of file compress.c.

38 {
39  s->bsLive = 0;
40  s->bsBuff = 0;
41 }
GLdouble s
Definition: gl.h:2039

Referenced by BZ2_compressBlock().

◆ BZ2_bz__AssertH__fail()

void BZ2_bz__AssertH__fail ( int  errcode)

Definition at line 48 of file bzlib.c.

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

◆ BZ2_compressBlock()

void BZ2_compressBlock ( EState ,
Bool   
)

Definition at line 602 of file compress.c.

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

Referenced by handle_compress().

◆ BZ2_decompress()

Int32 BZ2_decompress ( DState )

Definition at line 106 of file decompress.c.

107 {
108  UChar uc;
109  Int32 retVal;
110  Int32 minLen, maxLen;
111  bz_stream* strm = s->strm;
112 
113  /* stuff that needs to be saved/restored */
114  Int32 i;
115  Int32 j;
116  Int32 t;
117  Int32 alphaSize;
118  Int32 nGroups;
119  Int32 nSelectors;
120  Int32 EOB;
121  Int32 groupNo;
122  Int32 groupPos;
123  Int32 nextSym;
124  Int32 nblockMAX;
125  Int32 nblock;
126  Int32 es;
127  Int32 N;
128  Int32 curr;
129  Int32 zt;
130  Int32 zn;
131  Int32 zvec;
132  Int32 zj;
133  Int32 gSel;
134  Int32 gMinlen;
135  Int32* gLimit;
136  Int32* gBase;
137  Int32* gPerm;
138 
139  if (s->state == BZ_X_MAGIC_1) {
140  /*initialise the save area*/
141  s->save_i = 0;
142  s->save_j = 0;
143  s->save_t = 0;
144  s->save_alphaSize = 0;
145  s->save_nGroups = 0;
146  s->save_nSelectors = 0;
147  s->save_EOB = 0;
148  s->save_groupNo = 0;
149  s->save_groupPos = 0;
150  s->save_nextSym = 0;
151  s->save_nblockMAX = 0;
152  s->save_nblock = 0;
153  s->save_es = 0;
154  s->save_N = 0;
155  s->save_curr = 0;
156  s->save_zt = 0;
157  s->save_zn = 0;
158  s->save_zvec = 0;
159  s->save_zj = 0;
160  s->save_gSel = 0;
161  s->save_gMinlen = 0;
162  s->save_gLimit = NULL;
163  s->save_gBase = NULL;
164  s->save_gPerm = NULL;
165  }
166 
167  /*restore from the save area*/
168  i = s->save_i;
169  j = s->save_j;
170  t = s->save_t;
171  alphaSize = s->save_alphaSize;
172  nGroups = s->save_nGroups;
173  nSelectors = s->save_nSelectors;
174  EOB = s->save_EOB;
175  groupNo = s->save_groupNo;
176  groupPos = s->save_groupPos;
177  nextSym = s->save_nextSym;
178  nblockMAX = s->save_nblockMAX;
179  nblock = s->save_nblock;
180  es = s->save_es;
181  N = s->save_N;
182  curr = s->save_curr;
183  zt = s->save_zt;
184  zn = s->save_zn;
185  zvec = s->save_zvec;
186  zj = s->save_zj;
187  gSel = s->save_gSel;
188  gMinlen = s->save_gMinlen;
189  gLimit = s->save_gLimit;
190  gBase = s->save_gBase;
191  gPerm = s->save_gPerm;
192 
193  retVal = BZ_OK;
194 
195  switch (s->state) {
196 
197  GET_UCHAR(BZ_X_MAGIC_1, uc);
198  if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
199 
200  GET_UCHAR(BZ_X_MAGIC_2, uc);
201  if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
202 
204  if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
205 
206  GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
207  if (s->blockSize100k < (BZ_HDR_0 + 1) ||
210 
211  if (s->smallDecompress) {
212  s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
213  s->ll4 = BZALLOC(
214  ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
215  );
216  if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
217  } else {
218  s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
219  if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
220  }
221 
223 
224  if (uc == 0x17) goto endhdr_2;
225  if (uc != 0x31) RETURN(BZ_DATA_ERROR);
227  if (uc != 0x41) RETURN(BZ_DATA_ERROR);
229  if (uc != 0x59) RETURN(BZ_DATA_ERROR);
231  if (uc != 0x26) RETURN(BZ_DATA_ERROR);
233  if (uc != 0x53) RETURN(BZ_DATA_ERROR);
235  if (uc != 0x59) RETURN(BZ_DATA_ERROR);
236 
237  s->currBlockNo++;
238  if (s->verbosity >= 2)
239  VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
240 
241  s->storedBlockCRC = 0;
242  GET_UCHAR(BZ_X_BCRC_1, uc);
243  s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
244  GET_UCHAR(BZ_X_BCRC_2, uc);
245  s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
246  GET_UCHAR(BZ_X_BCRC_3, uc);
247  s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
248  GET_UCHAR(BZ_X_BCRC_4, uc);
249  s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
250 
251  GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
252 
253  s->origPtr = 0;
255  s->origPtr = (s->origPtr << 8) | ((Int32)uc);
257  s->origPtr = (s->origPtr << 8) | ((Int32)uc);
259  s->origPtr = (s->origPtr << 8) | ((Int32)uc);
260 
261  if (s->origPtr < 0)
263  if (s->origPtr > 10 + 100000*s->blockSize100k)
265 
266  /*--- Receive the mapping table ---*/
267  for (i = 0; i < 16; i++) {
268  GET_BIT(BZ_X_MAPPING_1, uc);
269  if (uc == 1)
270  s->inUse16[i] = True; else
271  s->inUse16[i] = False;
272  }
273 
274  for (i = 0; i < 256; i++) s->inUse[i] = False;
275 
276  for (i = 0; i < 16; i++)
277  if (s->inUse16[i])
278  for (j = 0; j < 16; j++) {
279  GET_BIT(BZ_X_MAPPING_2, uc);
280  if (uc == 1) s->inUse[i * 16 + j] = True;
281  }
282  makeMaps_d ( s );
283  if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
284  alphaSize = s->nInUse+2;
285 
286  /*--- Now the selectors ---*/
287  GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
288  if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
289  GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
290  if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
291  for (i = 0; i < nSelectors; i++) {
292  j = 0;
293  while (True) {
295  if (uc == 0) break;
296  j++;
297  if (j >= nGroups) RETURN(BZ_DATA_ERROR);
298  }
299  s->selectorMtf[i] = j;
300  }
301 
302  /*--- Undo the MTF values for the selectors. ---*/
303  {
304  UChar pos[BZ_N_GROUPS], tmp, v;
305  for (v = 0; v < nGroups; v++) pos[v] = v;
306 
307  for (i = 0; i < nSelectors; i++) {
308  v = s->selectorMtf[i];
309  tmp = pos[v];
310  while (v > 0) { pos[v] = pos[v-1]; v--; }
311  pos[0] = tmp;
312  s->selector[i] = tmp;
313  }
314  }
315 
316  /*--- Now the coding tables ---*/
317  for (t = 0; t < nGroups; t++) {
318  GET_BITS(BZ_X_CODING_1, curr, 5);
319  for (i = 0; i < alphaSize; i++) {
320  while (True) {
321  if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
322  GET_BIT(BZ_X_CODING_2, uc);
323  if (uc == 0) break;
324  GET_BIT(BZ_X_CODING_3, uc);
325  if (uc == 0) curr++; else curr--;
326  }
327  s->len[t][i] = curr;
328  }
329  }
330 
331  /*--- Create the Huffman decoding tables ---*/
332  for (t = 0; t < nGroups; t++) {
333  minLen = 32;
334  maxLen = 0;
335  for (i = 0; i < alphaSize; i++) {
336  if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
337  if (s->len[t][i] < minLen) minLen = s->len[t][i];
338  }
340  &(s->limit[t][0]),
341  &(s->base[t][0]),
342  &(s->perm[t][0]),
343  &(s->len[t][0]),
344  minLen, maxLen, alphaSize
345  );
346  s->minLens[t] = minLen;
347  }
348 
349  /*--- Now the MTF values ---*/
350 
351  EOB = s->nInUse+1;
352  nblockMAX = 100000 * s->blockSize100k;
353  groupNo = -1;
354  groupPos = 0;
355 
356  for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
357 
358  /*-- MTF init --*/
359  {
360  Int32 ii, jj, kk;
361  kk = MTFA_SIZE-1;
362  for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
363  for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
364  s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
365  kk--;
366  }
367  s->mtfbase[ii] = kk + 1;
368  }
369  }
370  /*-- end MTF init --*/
371 
372  nblock = 0;
373  GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
374 
375  while (True) {
376 
377  if (nextSym == EOB) break;
378 
379  if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
380 
381  es = -1;
382  N = 1;
383  do {
384  /* Check that N doesn't get too big, so that es doesn't
385  go negative. The maximum value that can be
386  RUNA/RUNB encoded is equal to the block size (post
387  the initial RLE), viz, 900k, so bounding N at 2
388  million should guard against overflow without
389  rejecting any legitimate inputs. */
390  if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR);
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;
394  GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
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 
483  GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
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  /* Check: unzftab entries in range. */
496  for (i = 0; i <= 255; i++) {
497  if (s->unzftab[i] < 0 || s->unzftab[i] > nblock)
499  }
500  /* Actually generate cftab. */
501  s->cftab[0] = 0;
502  for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
503  for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
504  /* Check: cftab entries in range. */
505  for (i = 0; i <= 256; i++) {
506  if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
507  /* s->cftab[i] can legitimately be == nblock */
509  }
510  }
511  /* Check: cftab entries non-descending. */
512  for (i = 1; i <= 256; i++) {
513  if (s->cftab[i-1] > s->cftab[i]) {
515  }
516  }
517 
518  s->state_out_len = 0;
519  s->state_out_ch = 0;
520  BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
521  s->state = BZ_X_OUTPUT;
522  if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
523 
524  if (s->smallDecompress) {
525 
526  /*-- Make a copy of cftab, used in generation of T --*/
527  for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
528 
529  /*-- compute the T vector --*/
530  for (i = 0; i < nblock; i++) {
531  uc = (UChar)(s->ll16[i]);
532  SET_LL(i, s->cftabCopy[uc]);
533  s->cftabCopy[uc]++;
534  }
535 
536  /*-- Compute T^(-1) by pointer reversal on T --*/
537  i = s->origPtr;
538  j = GET_LL(i);
539  do {
540  Int32 tmp = GET_LL(j);
541  SET_LL(j, i);
542  i = j;
543  j = tmp;
544  }
545  while (i != s->origPtr);
546 
547  s->tPos = s->origPtr;
548  s->nblock_used = 0;
549  if (s->blockRandomised) {
551  BZ_GET_SMALL(s->k0); s->nblock_used++;
553  } else {
554  BZ_GET_SMALL(s->k0); s->nblock_used++;
555  }
556 
557  } else {
558 
559  /*-- compute the T^(-1) vector --*/
560  for (i = 0; i < nblock; i++) {
561  uc = (UChar)(s->tt[i] & 0xff);
562  s->tt[s->cftab[uc]] |= (i << 8);
563  s->cftab[uc]++;
564  }
565 
566  s->tPos = s->tt[s->origPtr] >> 8;
567  s->nblock_used = 0;
568  if (s->blockRandomised) {
570  BZ_GET_FAST(s->k0); s->nblock_used++;
572  } else {
573  BZ_GET_FAST(s->k0); s->nblock_used++;
574  }
575 
576  }
577 
578  RETURN(BZ_OK);
579 
580 
581 
582  endhdr_2:
583 
585  if (uc != 0x72) RETURN(BZ_DATA_ERROR);
587  if (uc != 0x45) RETURN(BZ_DATA_ERROR);
589  if (uc != 0x38) RETURN(BZ_DATA_ERROR);
591  if (uc != 0x50) RETURN(BZ_DATA_ERROR);
593  if (uc != 0x90) RETURN(BZ_DATA_ERROR);
594 
595  s->storedCombinedCRC = 0;
596  GET_UCHAR(BZ_X_CCRC_1, uc);
597  s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
598  GET_UCHAR(BZ_X_CCRC_2, uc);
599  s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
600  GET_UCHAR(BZ_X_CCRC_3, uc);
601  s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
602  GET_UCHAR(BZ_X_CCRC_4, uc);
603  s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
604 
605  s->state = BZ_X_IDLE;
607 
608  default: AssertH ( False, 4001 );
609  }
610 
611  AssertH ( False, 4002 );
612 
613  save_state_and_return:
614 
615  s->save_i = i;
616  s->save_j = j;
617  s->save_t = t;
618  s->save_alphaSize = alphaSize;
619  s->save_nGroups = nGroups;
620  s->save_nSelectors = nSelectors;
621  s->save_EOB = EOB;
622  s->save_groupNo = groupNo;
623  s->save_groupPos = groupPos;
624  s->save_nextSym = nextSym;
625  s->save_nblockMAX = nblockMAX;
626  s->save_nblock = nblock;
627  s->save_es = es;
628  s->save_N = N;
629  s->save_curr = curr;
630  s->save_zt = zt;
631  s->save_zn = zn;
632  s->save_zvec = zvec;
633  s->save_zj = zj;
634  s->save_gSel = gSel;
635  s->save_gMinlen = gMinlen;
636  s->save_gLimit = gLimit;
637  s->save_gBase = gBase;
638  s->save_gPerm = gPerm;
639 
640  return retVal;
641 }
#define MTFA_SIZE
#define BZ_X_CCRC_3
#define BZ_MEM_ERROR
Definition: bzlib.h:40
#define BZ_X_CODING_1
#define BZ_X_ENDHDR_2
#define GET_BIT(lll, uuu)
Definition: decompress.c:70
#define SET_LL(i, n)
#define BZ_X_MAGIC_4
#define BZ_X_MAGIC_1
DWORD UInt32
Definition: chm_lib.c:106
#define BZ_RAND_INIT_MASK
#define BZ_X_BCRC_1
#define BZ_DATA_ERROR_MAGIC
Definition: bzlib.h:42
#define BZ_GET_FAST(cccc)
#define BZ_X_ORIGPTR_2
GLdouble GLdouble t
Definition: gl.h:2047
#define BZ_X_CCRC_4
#define VPrintf1(zf, za1)
Definition: bzlib_private.h:75
#define BZ_HDR_B
Definition: bzip2recover.c:74
#define GET_UCHAR(lll, uuu)
Definition: decompress.c:67
#define BZ_RAND_MASK
#define BZ_X_MTF_5
Int32 blockSize100k
Definition: bzip2.c:186
BYTE UChar
Definition: chm_lib.c:102
#define BZ_X_MAPPING_2
USHORT UInt16
Definition: chm_lib.c:104
#define BZ_X_CODING_2
#define BZ_X_RANDBIT
static void makeMaps_d(DState *s)
Definition: decompress.c:27
#define BZ_X_MAGIC_2
#define BZ_RUNB
#define BZ_HDR_h
Definition: bzip2recover.c:76
#define BZALLOC(nnn)
#define BZ_HDR_0
Definition: bzip2recover.c:77
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define UInt32
Definition: interfaces.hpp:73
#define BZ_X_BLKHDR_3
#define BZ_X_CCRC_1
#define AssertH(cond, errcode)
Definition: bzlib_private.h:59
#define BZ_X_ENDHDR_3
#define pp
Definition: hlsl.yy.c:978
#define BZ_HDR_Z
Definition: bzip2recover.c:75
GLdouble GLdouble z
Definition: glext.h:5874
smooth NULL
Definition: ftsmooth.c:416
#define GET_BITS(lll, vvv, nnn)
Definition: decompress.c:43
#define BZ_X_BLKHDR_2
#define BZ_X_CODING_3
#define BZ_X_BLKHDR_5
#define BZ_X_SELECTOR_3
#define BZ_OK
Definition: bzlib.h:33
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define BZ_X_OUTPUT
#define BZ_X_BCRC_2
#define True
Definition: types.h:24
#define False
Definition: types.h:25
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define BZ_STREAM_END
Definition: bzlib.h:37
#define BZ_X_SELECTOR_2
#define BZ_X_CCRC_2
#define UInt16
Definition: interfaces.hpp:74
#define for
Definition: utility.h:88
#define BZ_X_BCRC_3
#define BZ_X_MTF_1
#define BZ_X_ORIGPTR_3
#define BZ_RAND_UPD_MASK
#define BZ_X_MTF_3
#define BZ_X_SELECTOR_1
GLdouble s
Definition: gl.h:2039
#define BZ_X_ENDHDR_4
#define BZ_RUNA
#define BZ_X_ENDHDR_6
#define BZ_N_GROUPS
#define VPrintf0(zf)
Definition: bzlib_private.h:73
#define BZ_X_BLKHDR_1
#define BZ_DATA_ERROR
Definition: bzlib.h:41
const GLdouble * v
Definition: gl.h:2040
#define BZ_X_BLKHDR_4
#define BZ_INITIALISE_CRC(crcVar)
#define BZ_X_BCRC_4
#define BZ_X_MAPPING_1
LONG Int32
Definition: chm_lib.c:105
#define BZ_X_MTF_4
#define BZ_X_MAGIC_3
#define BZ_X_MTF_6
#define GET_LL(i)
#define BZ_X_ORIGPTR_1
#define MTFL_SIZE
#define BZ_X_IDLE
#define es
Definition: i386-dis.c:431
#define BZ_X_BLKHDR_6
#define GET_MTF_VAL(label1, label2, lval)
Definition: decompress.c:74
void BZ2_hbCreateDecodeTables(Int32 *, Int32 *, Int32 *, UChar *, Int32, Int32, Int32)
Definition: huffman.c:170
#define RETURN(rrr)
Definition: decompress.c:40
#define BZ_GET_SMALL(cccc)
#define BZ_X_ENDHDR_5
#define BZ_X_MTF_2
off
Definition: i386-dis.c:3909

Referenced by BZ2_bzDecompress().

◆ BZ2_hbAssignCodes()

void BZ2_hbAssignCodes ( Int32 ,
UChar ,
Int32  ,
Int32  ,
Int32   
)

Definition at line 152 of file huffman.c.

157 {
158  Int32 n, vec, i;
159 
160  vec = 0;
161  for (n = minLen; n <= maxLen; n++) {
162  for (i = 0; i < alphaSize; i++)
163  if (length[i] == n) { code[i] = vec; vec++; };
164  vec <<= 1;
165  }
166 }
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
FT_Vector * vec
Definition: ftbbox.c:448
LONG Int32
Definition: chm_lib.c:105

Referenced by sendMTFValues().

◆ BZ2_hbCreateDecodeTables()

void BZ2_hbCreateDecodeTables ( Int32 ,
Int32 ,
Int32 ,
UChar ,
Int32  ,
Int32  ,
Int32   
)

Definition at line 170 of file huffman.c.

177 {
178  Int32 pp, i, j, vec;
179 
180  pp = 0;
181  for (i = minLen; i <= maxLen; i++)
182  for (j = 0; j < alphaSize; j++)
183  if (length[j] == i) { perm[pp] = j; pp++; };
184 
185  for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
186  for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
187 
188  for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
189 
190  for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
191  vec = 0;
192 
193  for (i = minLen; i <= maxLen; i++) {
194  vec += (base[i+1] - base[i]);
195  limit[i] = vec-1;
196  vec <<= 1;
197  }
198  for (i = minLen + 1; i <= maxLen; i++)
199  base[i] = ((limit[i-1] + 1) << 1) - base[i];
200 }
GLint limit
Definition: glext.h:10326
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define pp
Definition: hlsl.yy.c:978
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
FT_Vector * vec
Definition: ftbbox.c:448
LONG Int32
Definition: chm_lib.c:105
#define BZ_MAX_CODE_LEN

Referenced by BZ2_decompress().

◆ BZ2_hbMakeCodeLengths()

void BZ2_hbMakeCodeLengths ( UChar ,
Int32 ,
Int32  ,
Int32   
)

Definition at line 63 of file huffman.c.

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

Referenced by sendMTFValues().

◆ BZ2_indexIntoF()

Int32 BZ2_indexIntoF ( Int32  ,
Int32  
)

Definition at line 697 of file bzlib.c.

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

Variable Documentation

◆ BZ2_crc32Table

UInt32 BZ2_crc32Table[256]

Definition at line 31 of file crctable.c.

◆ BZ2_rNums

Int32 BZ2_rNums[512]

Definition at line 26 of file randtable.c.