bzip2 code cleanup
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1293 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ce90415670
commit
aee7274442
6 changed files with 204 additions and 295 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "../exehead/config.h"
|
#include "bzlib.h"
|
||||||
#if (defined(EXEHEAD) && defined(NSIS_COMPRESS_USE_BZIP2)) || !defined(EXEHEAD)
|
|
||||||
|
#if (defined(NSIS_COMPRESS_USE_BZIP2) && defined(NSIS_CONFIG_COMPRESSION_SUPPORT)) || !defined(EXEHEAD)
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Block sorting machinery ---*/
|
/*--- Block sorting machinery ---*/
|
||||||
/*--- blocksort.c ---*/
|
/*--- blocksort.c ---*/
|
||||||
|
@ -66,18 +67,13 @@
|
||||||
file implements the algorithm called cache in the paper.
|
file implements the algorithm called cache in the paper.
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
|
|
||||||
#include "bzlib.h"
|
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
/*--- Fallback O(N log(N)^2) sorting ---*/
|
/*--- Fallback O(N log(N)^2) sorting ---*/
|
||||||
/*--- algorithm, for repetitive blocks ---*/
|
/*--- algorithm, for repetitive blocks ---*/
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
static
|
static void fallbackSimpleSort ( UInt32* fmap,
|
||||||
__inline__
|
|
||||||
void fallbackSimpleSort ( UInt32* fmap,
|
|
||||||
UInt32* eclass,
|
UInt32* eclass,
|
||||||
Int32 lo,
|
Int32 lo,
|
||||||
Int32 hi )
|
Int32 hi )
|
||||||
|
@ -379,9 +375,7 @@ void fallbackSort ( UInt32* fmap,
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
static
|
static Bool mainGtU ( UInt32 i1,
|
||||||
__inline__
|
|
||||||
Bool mainGtU ( UInt32 i1,
|
|
||||||
UInt32 i2,
|
UInt32 i2,
|
||||||
UChar* block,
|
UChar* block,
|
||||||
UInt16* quadrant,
|
UInt16* quadrant,
|
||||||
|
@ -616,7 +610,6 @@ void mainSimpleSort ( UInt32* ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
__inline__
|
|
||||||
UChar mmed3 ( UChar a, UChar b, UChar c )
|
UChar mmed3 ( UChar a, UChar b, UChar c )
|
||||||
{
|
{
|
||||||
UChar t;
|
UChar t;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "../exehead/config.h"
|
#include "bzlib.h"
|
||||||
|
|
||||||
#if (defined(NSIS_COMPRESS_USE_BZIP2) && defined(NSIS_CONFIG_COMPRESSION_SUPPORT)) || !defined(EXEHEAD)
|
#if (defined(NSIS_COMPRESS_USE_BZIP2) && defined(NSIS_CONFIG_COMPRESSION_SUPPORT)) || !defined(EXEHEAD)
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Library top-level functions. ---*/
|
/*--- Library top-level functions. ---*/
|
||||||
|
@ -114,8 +115,7 @@ Bool isempty_RL ( EState* s )
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzCompressInit)
|
int BZ2_bzCompressInit( bz_stream* strm,
|
||||||
( bz_stream* strm,
|
|
||||||
int blockSize100k,
|
int blockSize100k,
|
||||||
int verbosity,
|
int verbosity,
|
||||||
int workFactor )
|
int workFactor )
|
||||||
|
@ -356,7 +356,7 @@ Bool handle_compress ( bz_stream* strm )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
|
int BZ2_bzCompress( bz_stream *strm, int action )
|
||||||
{
|
{
|
||||||
Bool progress;
|
Bool progress;
|
||||||
EState* s;
|
EState* s;
|
||||||
|
@ -417,7 +417,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
|
int BZ2_bzCompressEnd( bz_stream *strm )
|
||||||
{
|
{
|
||||||
EState* s;
|
EState* s;
|
||||||
if (strm == NULL) return BZ_PARAM_ERROR;
|
if (strm == NULL) return BZ_PARAM_ERROR;
|
||||||
|
@ -576,9 +576,8 @@ static void unRLE_obuf_to_output_FAST ( DState* s )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzDecompress) ( DState *s )
|
int NSISCALL BZ2_bzDecompress( DState *s )
|
||||||
{
|
{
|
||||||
|
|
||||||
while (True) {
|
while (True) {
|
||||||
if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
|
if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
|
||||||
if (s->state == BZ_X_OUTPUT) {
|
if (s->state == BZ_X_OUTPUT) {
|
||||||
|
|
|
@ -66,12 +66,13 @@
|
||||||
#ifndef _BZLIB_H
|
#ifndef _BZLIB_H
|
||||||
#define _BZLIB_H
|
#define _BZLIB_H
|
||||||
|
|
||||||
#define BZ_NO_STDIO 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../exehead/config.h"
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#define BZ_RUN 0
|
#define BZ_RUN 0
|
||||||
#define BZ_FLUSH 1
|
#define BZ_FLUSH 1
|
||||||
#define BZ_FINISH 2
|
#define BZ_FINISH 2
|
||||||
|
@ -91,102 +92,6 @@ extern "C" {
|
||||||
#define BZ_OUTBUFF_FULL (-8)
|
#define BZ_OUTBUFF_FULL (-8)
|
||||||
#define BZ_CONFIG_ERROR (-9)
|
#define BZ_CONFIG_ERROR (-9)
|
||||||
|
|
||||||
typedef
|
|
||||||
struct {
|
|
||||||
char *next_in;
|
|
||||||
unsigned int avail_in;
|
|
||||||
|
|
||||||
char *next_out;
|
|
||||||
unsigned int avail_out;
|
|
||||||
|
|
||||||
void *state;
|
|
||||||
}
|
|
||||||
bz_stream;
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BZ_IMPORT
|
|
||||||
#define BZ_EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <windows.h>
|
|
||||||
# ifdef small
|
|
||||||
/* windows.h define small to char */
|
|
||||||
# undef small
|
|
||||||
# endif
|
|
||||||
# ifdef BZ_EXPORT
|
|
||||||
# define BZ_API(func) WINAPI func
|
|
||||||
# define BZ_EXTERN extern
|
|
||||||
# else
|
|
||||||
/* import windows dll dynamically */
|
|
||||||
# define BZ_API(func) (WINAPI * func)
|
|
||||||
# define BZ_EXTERN
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define BZ_API(func) func
|
|
||||||
# define BZ_EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-- Core (low-level) library functions --*/
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
|
|
||||||
bz_stream* strm,
|
|
||||||
int blockSize100k,
|
|
||||||
int verbosity,
|
|
||||||
int workFactor
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
|
|
||||||
bz_stream* strm,
|
|
||||||
int action
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
|
|
||||||
bz_stream* strm
|
|
||||||
);
|
|
||||||
|
|
||||||
/*-- General stuff. --*/
|
|
||||||
|
|
||||||
#define BZ_VERSION "1.0.1, 23-June-2000"
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
#define True ((Bool)1)
|
|
||||||
#define False ((Bool)0)
|
|
||||||
|
|
||||||
#ifndef __GNUC__
|
|
||||||
#define __inline__ /* */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AssertD(cond,msg) /* */
|
|
||||||
#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) /* */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef EXEHEAD
|
|
||||||
#include "../exehead/util.h"
|
|
||||||
#define BZALLOC(items) my_GlobalAlloc(items)
|
|
||||||
#else // def EXEHEAD
|
|
||||||
#define BZALLOC(items) GlobalAlloc(GPTR,items)
|
|
||||||
#define mini_memcpy memcpy
|
|
||||||
#endif // def EXEHEAD
|
|
||||||
#define BZFREE(addr) { if (addr) GlobalFree(addr); }
|
|
||||||
|
|
||||||
|
|
||||||
/*-- Constants for the back end. --*/
|
/*-- Constants for the back end. --*/
|
||||||
|
|
||||||
#define BZ_MAX_ALPHA_SIZE 258
|
#define BZ_MAX_ALPHA_SIZE 258
|
||||||
|
@ -201,6 +106,55 @@ typedef unsigned short UInt16;
|
||||||
|
|
||||||
#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
|
#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
#define True ((Bool)1)
|
||||||
|
#define False ((Bool)0)
|
||||||
|
|
||||||
|
#define AssertD(cond,msg) /* */
|
||||||
|
#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) /* */
|
||||||
|
|
||||||
|
#ifndef EXEHEAD
|
||||||
|
|
||||||
|
#define BZALLOC(items) GlobalAlloc(GPTR,items)
|
||||||
|
#define BZFREE(addr) { if (addr) GlobalFree(addr); }
|
||||||
|
#define mini_memcpy memcpy
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *next_in;
|
||||||
|
unsigned int avail_in;
|
||||||
|
|
||||||
|
char *next_out;
|
||||||
|
unsigned int avail_out;
|
||||||
|
|
||||||
|
void *state;
|
||||||
|
} bz_stream;
|
||||||
|
|
||||||
|
/*-- Core (low-level) library functions --*/
|
||||||
|
|
||||||
|
extern int BZ2_bzCompressInit(
|
||||||
|
bz_stream* strm,
|
||||||
|
int blockSize100k,
|
||||||
|
int verbosity,
|
||||||
|
int workFactor
|
||||||
|
);
|
||||||
|
|
||||||
|
extern int BZ2_bzCompress( bz_stream* strm, int action );
|
||||||
|
extern int BZ2_bzCompressEnd(bz_stream* strm );
|
||||||
|
|
||||||
/*-- States and modes for compression. --*/
|
/*-- States and modes for compression. --*/
|
||||||
|
|
||||||
#define BZ_M_IDLE 1
|
#define BZ_M_IDLE 1
|
||||||
|
@ -216,96 +170,84 @@ typedef unsigned short UInt16;
|
||||||
#define BZ_N_SHELL 18
|
#define BZ_N_SHELL 18
|
||||||
#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
|
#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-- Structure holding all the compression-side stuff. --*/
|
/*-- Structure holding all the compression-side stuff. --*/
|
||||||
|
|
||||||
typedef
|
typedef struct {
|
||||||
struct {
|
/* pointer back to the struct bz_stream */
|
||||||
/* pointer back to the struct bz_stream */
|
bz_stream *strm;
|
||||||
bz_stream *strm;
|
|
||||||
|
|
||||||
/* mode this stream is in, and whether inputting */
|
/* mode this stream is in, and whether inputting */
|
||||||
/* or outputting data */
|
/* or outputting data */
|
||||||
Int32 mode;
|
Int32 mode;
|
||||||
Int32 state;
|
Int32 state;
|
||||||
|
|
||||||
/* remembers avail_in when flush/finish requested */
|
/* remembers avail_in when flush/finish requested */
|
||||||
UInt32 avail_in_expect;
|
UInt32 avail_in_expect;
|
||||||
|
|
||||||
/* for doing the block sorting */
|
/* for doing the block sorting */
|
||||||
UInt32* arr1;
|
UInt32* arr1;
|
||||||
UInt32* arr2;
|
UInt32* arr2;
|
||||||
UInt32* ftab;
|
UInt32* ftab;
|
||||||
Int32 origPtr;
|
Int32 origPtr;
|
||||||
|
|
||||||
/* aliases for arr1 and arr2 */
|
/* aliases for arr1 and arr2 */
|
||||||
UInt32* ptr;
|
UInt32* ptr;
|
||||||
UChar* block;
|
UChar* block;
|
||||||
UInt16* mtfv;
|
UInt16* mtfv;
|
||||||
UChar* zbits;
|
UChar* zbits;
|
||||||
|
|
||||||
/* for deciding when to use the fallback sorting algorithm */
|
/* for deciding when to use the fallback sorting algorithm */
|
||||||
Int32 workFactor;
|
Int32 workFactor;
|
||||||
|
|
||||||
/* run-length-encoding of the input */
|
/* run-length-encoding of the input */
|
||||||
UInt32 state_in_ch;
|
UInt32 state_in_ch;
|
||||||
Int32 state_in_len;
|
Int32 state_in_len;
|
||||||
|
|
||||||
/* input and output limits and current posns */
|
/* input and output limits and current posns */
|
||||||
Int32 nblock;
|
Int32 nblock;
|
||||||
Int32 nblockMAX;
|
Int32 nblockMAX;
|
||||||
Int32 numZ;
|
Int32 numZ;
|
||||||
Int32 state_out_pos;
|
Int32 state_out_pos;
|
||||||
|
|
||||||
/* map of bytes used in block */
|
/* map of bytes used in block */
|
||||||
Int32 nInUse;
|
Int32 nInUse;
|
||||||
Bool inUse[256];
|
Bool inUse[256];
|
||||||
UChar unseqToSeq[256];
|
UChar unseqToSeq[256];
|
||||||
|
|
||||||
/* the buffer for bit stream creation */
|
/* the buffer for bit stream creation */
|
||||||
UInt32 bsBuff;
|
UInt32 bsBuff;
|
||||||
Int32 bsLive;
|
Int32 bsLive;
|
||||||
|
|
||||||
/* misc administratium */
|
/* misc administratium */
|
||||||
Int32 blockNo;
|
Int32 blockNo;
|
||||||
|
|
||||||
/* stuff for coding the MTF values */
|
/* stuff for coding the MTF values */
|
||||||
Int32 nMTF;
|
Int32 nMTF;
|
||||||
Int32 mtfFreq [BZ_MAX_ALPHA_SIZE];
|
Int32 mtfFreq [BZ_MAX_ALPHA_SIZE];
|
||||||
UChar selector [BZ_MAX_SELECTORS];
|
UChar selector [BZ_MAX_SELECTORS];
|
||||||
UChar selectorMtf[BZ_MAX_SELECTORS];
|
UChar selectorMtf[BZ_MAX_SELECTORS];
|
||||||
|
|
||||||
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||||
Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||||
Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||||
/* second dimension: only 3 needed; 4 makes index calculations faster */
|
/* second dimension: only 3 needed; 4 makes index calculations faster */
|
||||||
UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4];
|
UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4];
|
||||||
|
|
||||||
}
|
} EState;
|
||||||
EState;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-- externs for compression. --*/
|
/*-- externs for compression. --*/
|
||||||
|
|
||||||
extern void
|
extern void BZ2_blockSort ( EState* );
|
||||||
BZ2_blockSort ( EState* );
|
extern void BZ2_compressBlock ( EState*, Bool );
|
||||||
|
extern void BZ2_bsInitWrite ( EState* );
|
||||||
extern void
|
extern void BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
|
||||||
BZ2_compressBlock ( EState*, Bool );
|
extern void BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
|
||||||
|
|
||||||
extern void
|
|
||||||
BZ2_bsInitWrite ( EState* );
|
|
||||||
|
|
||||||
extern void
|
|
||||||
BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
|
|
||||||
|
|
||||||
extern void
|
|
||||||
BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
|
|
||||||
|
|
||||||
|
#else//EXEHEAD
|
||||||
|
|
||||||
|
#include "../exehead/util.h"
|
||||||
|
|
||||||
/*-- states for decompression. --*/
|
/*-- states for decompression. --*/
|
||||||
|
|
||||||
|
@ -343,96 +285,94 @@ BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
|
||||||
|
|
||||||
/* save area for scalars in the main decompress code */
|
/* save area for scalars in the main decompress code */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Int32 i;
|
Int32 i;
|
||||||
Int32 j;
|
Int32 j;
|
||||||
Int32 t;
|
Int32 t;
|
||||||
Int32 alphaSize;
|
Int32 alphaSize;
|
||||||
Int32 nGroups;
|
Int32 nGroups;
|
||||||
Int32 nSelectors;
|
Int32 nSelectors;
|
||||||
Int32 EOB;
|
Int32 EOB;
|
||||||
Int32 groupNo;
|
Int32 groupNo;
|
||||||
Int32 groupPos;
|
Int32 groupPos;
|
||||||
Int32 nextSym;
|
Int32 nextSym;
|
||||||
Int32 nblockMAX;
|
Int32 nblockMAX;
|
||||||
Int32 nblock;
|
Int32 nblock;
|
||||||
Int32 es;
|
Int32 es;
|
||||||
Int32 N;
|
Int32 N;
|
||||||
Int32 curr;
|
Int32 curr;
|
||||||
Int32 zt;
|
Int32 zt;
|
||||||
Int32 zn;
|
Int32 zn;
|
||||||
Int32 zvec;
|
Int32 zvec;
|
||||||
Int32 zj;
|
Int32 zj;
|
||||||
Int32 gSel;
|
Int32 gSel;
|
||||||
Int32 gMinlen;
|
Int32 gMinlen;
|
||||||
Int32* gLimit;
|
Int32* gLimit;
|
||||||
Int32* gBase;
|
Int32* gBase;
|
||||||
Int32* gPerm;
|
Int32* gPerm;
|
||||||
} DState_save;
|
} DState_save;
|
||||||
|
|
||||||
/*-- Structure holding all the decompression-side stuff. --*/
|
/*-- Structure holding all the decompression-side stuff. --*/
|
||||||
|
|
||||||
typedef
|
typedef struct {
|
||||||
struct {
|
/* pointer back to the struct bz_stream */
|
||||||
/* pointer back to the struct bz_stream */
|
char *next_in;
|
||||||
char *next_in;
|
unsigned int avail_in;
|
||||||
unsigned int avail_in;
|
|
||||||
|
|
||||||
char *next_out;
|
char *next_out;
|
||||||
unsigned int avail_out;
|
unsigned int avail_out;
|
||||||
|
|
||||||
/* state indicator for this stream */
|
/* state indicator for this stream */
|
||||||
char state;
|
char state;
|
||||||
|
|
||||||
UChar state_out_ch;
|
UChar state_out_ch;
|
||||||
Int32 state_out_len;
|
Int32 state_out_len;
|
||||||
Int32 nblock_used;
|
Int32 nblock_used;
|
||||||
Int32 k0;
|
Int32 k0;
|
||||||
UInt32 tPos;
|
UInt32 tPos;
|
||||||
|
|
||||||
/* the buffer for bit stream reading */
|
/* the buffer for bit stream reading */
|
||||||
UInt32 bsBuff;
|
UInt32 bsBuff;
|
||||||
Int32 bsLive;
|
Int32 bsLive;
|
||||||
|
|
||||||
/* for undoing the Burrows-Wheeler transform */
|
/* for undoing the Burrows-Wheeler transform */
|
||||||
Int32 origPtr;
|
Int32 origPtr;
|
||||||
Int32 unzftab[256];
|
Int32 unzftab[256];
|
||||||
Int32 cftab[257];
|
Int32 cftab[257];
|
||||||
Int32 cftabCopy[257];
|
Int32 cftabCopy[257];
|
||||||
|
|
||||||
#ifndef NSIS_COMPRESS_BZIP2_SMALLMODE
|
#ifndef NSIS_COMPRESS_BZIP2_SMALLMODE
|
||||||
/* for undoing the Burrows-Wheeler transform (FAST) */
|
/* for undoing the Burrows-Wheeler transform (FAST) */
|
||||||
UInt32 tt[ NSIS_COMPRESS_BZIP2_LEVEL * 100000 ];
|
UInt32 tt[ NSIS_COMPRESS_BZIP2_LEVEL * 100000 ];
|
||||||
#else
|
#else
|
||||||
/* for undoing the Burrows-Wheeler transform (SMALL) */
|
/* for undoing the Burrows-Wheeler transform (SMALL) */
|
||||||
UInt16 ll16 [ NSIS_COMPRESS_BZIP2_LEVEL*100000 ];
|
UInt16 ll16 [ NSIS_COMPRESS_BZIP2_LEVEL*100000 ];
|
||||||
UChar ll4 [((1 + NSIS_COMPRESS_BZIP2_LEVEL*100000) >> 1) ];
|
UChar ll4 [((1 + NSIS_COMPRESS_BZIP2_LEVEL*100000) >> 1) ];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* map of bytes used in block */
|
/* map of bytes used in block */
|
||||||
Int32 nInUse;
|
Int32 nInUse;
|
||||||
Bool inUse[256];
|
Bool inUse[256];
|
||||||
Bool inUse16[16];
|
Bool inUse16[16];
|
||||||
UChar seqToUnseq[256];
|
UChar seqToUnseq[256];
|
||||||
|
|
||||||
/* for decoding the MTF values */
|
/* for decoding the MTF values */
|
||||||
UChar mtfa [MTFA_SIZE];
|
UChar mtfa [MTFA_SIZE];
|
||||||
Int32 mtfbase[256 / MTFL_SIZE];
|
Int32 mtfbase[256 / MTFL_SIZE];
|
||||||
UChar selector [BZ_MAX_SELECTORS];
|
UChar selector [BZ_MAX_SELECTORS];
|
||||||
UChar selectorMtf[BZ_MAX_SELECTORS];
|
UChar selectorMtf[BZ_MAX_SELECTORS];
|
||||||
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||||
|
|
||||||
Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||||
Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||||
Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||||
Int32 minLens[BZ_N_GROUPS];
|
Int32 minLens[BZ_N_GROUPS];
|
||||||
|
|
||||||
/* save area for scalars in the main decompress code */
|
|
||||||
DState_save save;
|
|
||||||
}
|
|
||||||
DState;
|
|
||||||
|
|
||||||
|
/* save area for scalars in the main decompress code */
|
||||||
|
DState_save save;
|
||||||
|
} DState;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NSIS_COMPRESS_BZIP2_SMALLMODE
|
||||||
/*-- Macros for decompression. --*/
|
/*-- Macros for decompression. --*/
|
||||||
|
|
||||||
#define BZ_GET_FAST(cccc) \
|
#define BZ_GET_FAST(cccc) \
|
||||||
|
@ -445,6 +385,9 @@ typedef
|
||||||
cccc = (UChar)(c_tPos & 0xff); \
|
cccc = (UChar)(c_tPos & 0xff); \
|
||||||
c_tPos >>= 8;
|
c_tPos >>= 8;
|
||||||
|
|
||||||
|
|
||||||
|
#else//NSIS_COMPRESS_BZIP2_SMALLMODE
|
||||||
|
|
||||||
#define SET_LL4(i,n) \
|
#define SET_LL4(i,n) \
|
||||||
{ if (((i) & 0x1) == 0) \
|
{ if (((i) & 0x1) == 0) \
|
||||||
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
|
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
|
||||||
|
@ -466,36 +409,21 @@ typedef
|
||||||
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
|
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
|
||||||
s->tPos = GET_LL(s->tPos);
|
s->tPos = GET_LL(s->tPos);
|
||||||
|
|
||||||
|
extern Int32 BZ2_indexIntoF( Int32, Int32* );
|
||||||
|
|
||||||
|
#endif//smallmode
|
||||||
|
|
||||||
/*-- externs for decompression. --*/
|
/*-- externs for decompression. --*/
|
||||||
|
extern Int32 BZ2_decompress ( DState* );
|
||||||
|
|
||||||
extern Int32
|
extern void BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
|
||||||
BZ2_indexIntoF ( Int32, Int32* );
|
|
||||||
|
|
||||||
extern Int32
|
|
||||||
BZ2_decompress ( DState* );
|
|
||||||
|
|
||||||
extern void
|
|
||||||
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
|
|
||||||
Int32, Int32, Int32 );
|
Int32, Int32, Int32 );
|
||||||
|
|
||||||
|
|
||||||
#define BZ2_bzDecompressInit(s) { (s)->state = BZ_X_BLKHDR_1; }
|
#define BZ2_bzDecompressInit(s) { (s)->state = BZ_X_BLKHDR_1; }
|
||||||
|
int NSISCALL BZ2_bzDecompress(DState *s);
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( DState * s );
|
#endif//EXEHEAD
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
|
|
||||||
|
|
||||||
#ifdef BZ_NO_STDIO
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#include "../exehead/config.h"
|
|
||||||
#if !defined(EXEHEAD)
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Compression machinery (not incl block sorting) ---*/
|
/*--- Compression machinery (not incl block sorting) ---*/
|
||||||
/*--- compress.c ---*/
|
/*--- compress.c ---*/
|
||||||
|
@ -113,9 +111,7 @@ void bsFinishWrite ( EState* s )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
static
|
static void bsW ( EState* s, Int32 n, UInt32 v )
|
||||||
__inline__
|
|
||||||
void bsW ( EState* s, Int32 n, UInt32 v )
|
|
||||||
{
|
{
|
||||||
bsNEEDW ( n );
|
bsNEEDW ( n );
|
||||||
s->bsBuff |= (v << (32 - s->bsLive - n));
|
s->bsBuff |= (v << (32 - s->bsLive - n));
|
||||||
|
@ -656,5 +652,3 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block )
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- end compress.c ---*/
|
/*--- end compress.c ---*/
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "../exehead/config.h"
|
#include "bzlib.h"
|
||||||
#if (defined(NSIS_COMPRESS_USE_BZIP2) && defined(NSIS_CONFIG_COMPRESSION_SUPPORT)) || !defined(EXEHEAD)
|
|
||||||
|
#if defined(NSIS_COMPRESS_USE_BZIP2) && defined(NSIS_CONFIG_COMPRESSION_SUPPORT)
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Decompression machinery ---*/
|
/*--- Decompression machinery ---*/
|
||||||
|
@ -61,10 +62,6 @@
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
|
|
||||||
#include "bzlib.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
#define RETURN(rrr) \
|
#define RETURN(rrr) \
|
||||||
{ retVal = rrr; goto save_state_and_return; };
|
{ retVal = rrr; goto save_state_and_return; };
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "../exehead/config.h"
|
#include "bzlib.h"
|
||||||
|
|
||||||
#if (defined(NSIS_COMPRESS_USE_BZIP2) && defined(NSIS_CONFIG_COMPRESSION_SUPPORT)) || !defined(EXEHEAD)
|
#if (defined(NSIS_COMPRESS_USE_BZIP2) && defined(NSIS_CONFIG_COMPRESSION_SUPPORT)) || !defined(EXEHEAD)
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Huffman coding low-level stuff ---*/
|
/*--- Huffman coding low-level stuff ---*/
|
||||||
|
@ -59,9 +60,6 @@
|
||||||
For more information on these sources, see the manual.
|
For more information on these sources, see the manual.
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
|
|
||||||
#include "bzlib.h"
|
|
||||||
|
|
||||||
#ifndef EXEHEAD
|
#ifndef EXEHEAD
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
|
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue