ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
deflate.c File Reference
#include "deflate.h"
+ Include dependency graph for deflate.c:

Go to the source code of this file.

Classes

struct  config_s
 

Macros

#define NIL   0
 
#define TOO_FAR   4096
 
#define RANK(f)   (((f) * 2) - ((f) > 4 ? 9 : 0))
 
#define UPDATE_HASH(s, h, c)   (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
 
#define INSERT_STRING(s, str, match_head)
 
#define CLEAR_HASH(s)
 
#define HCRC_UPDATE(beg)
 
#define check_match(s, start, match, length)
 
#define FLUSH_BLOCK_ONLY(s, last)
 
#define FLUSH_BLOCK(s, last)
 
#define MAX_STORED   65535
 
#define MIN(a, b)   ((a) > (b) ? (b) : (a))
 

Typedefs

typedef block_state compress_func OF ((deflate_state *s, int flush))
 
typedef struct config_s config
 

Enumerations

enum  block_state { need_more, block_done, finish_started, finish_done }
 

Functions

local int deflateStateCheck OF ((z_streamp strm))
 
local void slide_hash OF ((deflate_state *s))
 
local block_state deflate_stored OF ((deflate_state *s, int flush))
 
local void putShortMSB OF ((deflate_state *s, uInt b))
 
local unsigned read_buf OF ((z_streamp strm, Bytef *buf, unsigned size))
 
local uInt longest_match OF ((deflate_state *s, IPos cur_match))
 
local void slide_hash (deflate_state *s)
 
int ZEXPORT deflateInit_ (z_streamp strm, int level, const char *version, int stream_size)
 
int ZEXPORT deflateInit2_ (z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)
 
local int deflateStateCheck (z_streamp strm)
 
int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
 
int ZEXPORT deflateGetDictionary (z_streamp strm, Bytef *dictionary, uInt *dictLength)
 
int ZEXPORT deflateResetKeep (z_streamp strm)
 
int ZEXPORT deflateReset (z_streamp strm)
 
int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head)
 
int ZEXPORT deflatePending (z_streamp strm, unsigned *pending, int *bits)
 
int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
 
int ZEXPORT deflateParams (z_streamp strm, int level, int strategy)
 
int ZEXPORT deflateTune (z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)
 
uLong ZEXPORT deflateBound (z_streamp strm, uLong sourceLen)
 
local void putShortMSB (deflate_state *s, uInt b)
 
local void flush_pending (z_streamp strm)
 
int ZEXPORT deflate (z_streamp strm, int flush)
 
int ZEXPORT deflateEnd (z_streamp strm)
 
int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
 
local unsigned read_buf (z_streamp strm, Bytef *buf, unsigned size)
 
local void lm_init (deflate_state *s)
 
local uInt longest_match (deflate_state *s, IPos cur_match)
 
local void fill_window (deflate_state *s)
 
local block_state deflate_stored (deflate_state *s, int flush)
 
local block_state deflate_fast (deflate_state *s, int flush)
 
local block_state deflate_slow (deflate_state *s, int flush)
 
local block_state deflate_rle (deflate_state *s, int flush)
 
local block_state deflate_huff (deflate_state *s, int flush)
 

Variables

const char deflate_copyright []
 
local const config configuration_table [10]
 

Macro Definition Documentation

#define check_match (   s,
  start,
  match,
  length 
)

Definition at line 1468 of file deflate.c.

View newest version in sPHENIX GitHub at line 1468 of file deflate.c

Referenced by deflate_fast(), deflate_rle(), and deflate_slow().

#define CLEAR_HASH (   s)
Value:
s->head[s->hash_size-1] = NIL; \
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));

Definition at line 191 of file deflate.c.

View newest version in sPHENIX GitHub at line 191 of file deflate.c

Referenced by deflate(), deflateParams(), deflateSetDictionary(), and lm_init().

#define FLUSH_BLOCK (   s,
  last 
)
Value:
{ \
FLUSH_BLOCK_ONLY(s, last); \
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
}

Definition at line 1616 of file deflate.c.

View newest version in sPHENIX GitHub at line 1616 of file deflate.c

Referenced by deflate_fast(), deflate_huff(), deflate_rle(), and deflate_slow().

#define FLUSH_BLOCK_ONLY (   s,
  last 
)
Value:
{ \
_tr_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \
(last)); \
s->block_start = s->strstart; \
flush_pending(s->strm); \
Tracev((stderr,"[FLUSH]")); \
}

Definition at line 1604 of file deflate.c.

View newest version in sPHENIX GitHub at line 1604 of file deflate.c

Referenced by deflate_slow().

#define HCRC_UPDATE (   beg)
Value:
do { \
if (s->gzhead->hcrc && s->pending > (beg)) \
strm->adler = crc32(strm->adler, s->pending_buf + (beg), \
s->pending - (beg)); \
} while (0)

Definition at line 754 of file deflate.c.

View newest version in sPHENIX GitHub at line 754 of file deflate.c

Referenced by deflate().

#define INSERT_STRING (   s,
  str,
  match_head 
)
Value:
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
s->head[s->ins_h] = (Pos)(str))

Definition at line 181 of file deflate.c.

View newest version in sPHENIX GitHub at line 181 of file deflate.c

Referenced by deflate_fast(), and deflate_slow().

#define MAX_STORED   65535

Definition at line 1622 of file deflate.c.

View newest version in sPHENIX GitHub at line 1622 of file deflate.c

Referenced by deflate_stored().

#define MIN (   a,
  b 
)    ((a) > (b) ? (b) : (a))

Definition at line 1625 of file deflate.c.

View newest version in sPHENIX GitHub at line 1625 of file deflate.c

Referenced by deflate_stored(), and Packet_gl1::iValue().

#define NIL   0

Definition at line 106 of file deflate.c.

View newest version in sPHENIX GitHub at line 106 of file deflate.c

Referenced by deflate_fast(), deflate_slow(), longest_match(), and slide_hash().

#define RANK (   f)    (((f) * 2) - ((f) > 4 ? 9 : 0))

Definition at line 154 of file deflate.c.

View newest version in sPHENIX GitHub at line 154 of file deflate.c

Referenced by deflate().

#define TOO_FAR   4096

Definition at line 110 of file deflate.c.

View newest version in sPHENIX GitHub at line 110 of file deflate.c

Referenced by deflate_slow().

#define UPDATE_HASH (   s,
  h,
  c 
)    (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)

Definition at line 162 of file deflate.c.

View newest version in sPHENIX GitHub at line 162 of file deflate.c

Referenced by deflate_fast(), deflateSetDictionary(), and fill_window().

Typedef Documentation

typedef struct config_s config
typedef block_state compress_func OF((deflate_state *s, int flush))

Definition at line 72 of file deflate.c.

View newest version in sPHENIX GitHub at line 72 of file deflate.c

Enumeration Type Documentation

Enumerator:
need_more 
block_done 
finish_started 
finish_done 

Definition at line 65 of file deflate.c.

View newest version in sPHENIX GitHub at line 65 of file deflate.c

Function Documentation

int ZEXPORT deflate ( z_streamp  strm,
int  flush 
)

Definition at line 762 of file deflate.c.

View newest version in sPHENIX GitHub at line 762 of file deflate.c

References _tr_align(), _tr_stored_block(), adler32(), block_done, internal_state::block_start, BUSY_STATE, CLEAR_HASH, COMMENT_STATE, field_utils::copy(), crc32(), deflate_huff(), deflate_rle(), deflate_stored(), deflateStateCheck(), ERR_RETURN, EXTRA_STATE, finish_done, finish_started, FINISH_STATE, flush_pending(), internal_state::gzhead, internal_state::gzindex, GZIP_STATE, HCRC_STATE, HCRC_UPDATE, INIT_STATE, internal_state::insert, L, internal_state::last_flush, left, internal_state::level, internal_state::lookahead, NAME_STATE, need_more, OS_CODE, internal_state::pending, internal_state::pending_buf, internal_state::pending_buf_size, PRESET_DICT, put_byte, putShortMSB(), RANK, internal_state::status, internal_state::strategy, internal_state::strstart, internal_state::w_bits, while(), internal_state::wrap, Z_BLOCK, Z_BUF_ERROR, Z_DEFLATED, Z_FINISH, Z_FULL_FLUSH, Z_HUFFMAN_ONLY, Z_NO_FLUSH, Z_NULL, Z_OK, Z_PARTIAL_FLUSH, Z_RLE, Z_STREAM_END, Z_STREAM_ERROR, and zmemcpy().

Referenced by compress2(), deflateParams(), cheprep::DeflateOutputStreamBuffer::finish(), gz_comp(), and cheprep::DeflateOutputStreamBuffer::overflow().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

local block_state deflate_fast ( deflate_state s,
int  flush 
)

Definition at line 1823 of file deflate.c.

View newest version in sPHENIX GitHub at line 1823 of file deflate.c

References _tr_tally_dist, _tr_tally_lit, block_done, check_match, fill_window(), finish_done, FLUSH_BLOCK, INSERT_STRING, longest_match(), MAX_DIST, MIN_LOOKAHEAD, MIN_MATCH, need_more, NIL, Tracevv, UPDATE_HASH, Z_FINISH, and Z_NO_FLUSH.

+ Here is the call graph for this function:

local block_state deflate_huff ( deflate_state s,
int  flush 
)

Definition at line 2129 of file deflate.c.

View newest version in sPHENIX GitHub at line 2129 of file deflate.c

References _tr_tally_lit, block_done, fill_window(), finish_done, FLUSH_BLOCK, need_more, Tracevv, Z_FINISH, and Z_NO_FLUSH.

Referenced by deflate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

local block_state deflate_rle ( deflate_state s,
int  flush 
)

Definition at line 2056 of file deflate.c.

View newest version in sPHENIX GitHub at line 2056 of file deflate.c

References _tr_tally_dist, _tr_tally_lit, Assert, block_done, check_match, fill_window(), finish_done, FLUSH_BLOCK, MAX_MATCH, MIN_MATCH, need_more, internal_state::prev, Tracevv, internal_state::window, Z_FINISH, and Z_NO_FLUSH.

Referenced by deflate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

local block_state deflate_slow ( deflate_state s,
int  flush 
)

Definition at line 1925 of file deflate.c.

View newest version in sPHENIX GitHub at line 1925 of file deflate.c

References _tr_tally_dist, _tr_tally_lit, Assert, block_done, check_match, fill_window(), finish_done, FLUSH_BLOCK, FLUSH_BLOCK_ONLY, INSERT_STRING, longest_match(), MAX_DIST, MIN_LOOKAHEAD, MIN_MATCH, need_more, NIL, TOO_FAR, Tracevv, Z_FILTERED, Z_FINISH, and Z_NO_FLUSH.

+ Here is the call graph for this function:

local block_state deflate_stored ( deflate_state s,
int  flush 
)

Definition at line 1642 of file deflate.c.

View newest version in sPHENIX GitHub at line 1642 of file deflate.c

References _tr_stored_block(), block_done, finish_done, finish_started, flush_pending(), if(), L, left, MAX_STORED, MIN, need_more, read_buf(), Z_FINISH, Z_NO_FLUSH, and zmemcpy().

Referenced by deflate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uLong ZEXPORT deflateBound ( z_streamp  strm,
uLong  sourceLen 
)

Definition at line 651 of file deflate.c.

View newest version in sPHENIX GitHub at line 651 of file deflate.c

References deflateStateCheck(), internal_state::gzhead, internal_state::hash_bits, internal_state::strstart, internal_state::w_bits, internal_state::wrap, and Z_NULL.

+ Here is the call graph for this function:

int ZEXPORT deflateCopy ( z_streamp  dest,
z_streamp  source 
)

Definition at line 1101 of file deflate.c.

View newest version in sPHENIX GitHub at line 1101 of file deflate.c

References deflateEnd(), deflateStateCheck(), Z_MEM_ERROR, Z_NULL, Z_OK, Z_STREAM_ERROR, ZALLOC, and zmemcpy().

+ Here is the call graph for this function:

int ZEXPORT deflateEnd ( z_streamp  strm)

Definition at line 1075 of file deflate.c.

View newest version in sPHENIX GitHub at line 1075 of file deflate.c

References BUSY_STATE, deflateStateCheck(), internal_state::status, TRY_FREE, Z_DATA_ERROR, Z_NULL, Z_OK, Z_STREAM_ERROR, and ZFREE.

Referenced by compress2(), deflateCopy(), deflateInit2_(), cheprep::DeflateOutputStreamBuffer::finish(), and gzclose_w().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ZEXPORT deflateGetDictionary ( z_streamp  strm,
Bytef *  dictionary,
uInt *  dictLength 
)

Definition at line 444 of file deflate.c.

View newest version in sPHENIX GitHub at line 444 of file deflate.c

References deflateStateCheck(), internal_state::lookahead, internal_state::strstart, internal_state::w_size, internal_state::window, Z_NULL, Z_OK, Z_STREAM_ERROR, and zmemcpy().

+ Here is the call graph for this function:

int ZEXPORT deflateInit2_ ( z_streamp  strm,
int  level,
int  method,
int  windowBits,
int  memLevel,
int  strategy,
const char *  version,
int  stream_size 
)
int ZEXPORT deflateInit_ ( z_streamp  strm,
int  level,
const char *  version,
int  stream_size 
)

Definition at line 227 of file deflate.c.

View newest version in sPHENIX GitHub at line 227 of file deflate.c

References DEF_MEM_LEVEL, deflateInit2_(), Z_DEFAULT_STRATEGY, and Z_DEFLATED.

+ Here is the call graph for this function:

int ZEXPORT deflateParams ( z_streamp  strm,
int  level,
int  strategy 
)

Definition at line 567 of file deflate.c.

View newest version in sPHENIX GitHub at line 567 of file deflate.c

References CLEAR_HASH, deflate(), deflateStateCheck(), check_license::err(), func, internal_state::good_match, internal_state::high_water, internal_state::level, internal_state::matches, internal_state::max_chain_length, internal_state::max_lazy_match, internal_state::nice_match, slide_hash(), internal_state::strategy, Z_BLOCK, Z_BUF_ERROR, Z_DEFAULT_COMPRESSION, Z_FIXED, Z_OK, and Z_STREAM_ERROR.

Referenced by gzsetparams().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ZEXPORT deflatePending ( z_streamp  strm,
unsigned *  pending,
int bits 
)

Definition at line 527 of file deflate.c.

View newest version in sPHENIX GitHub at line 527 of file deflate.c

References deflateStateCheck(), Z_NULL, Z_OK, and Z_STREAM_ERROR.

+ Here is the call graph for this function:

int ZEXPORT deflatePrime ( z_streamp  strm,
int  bits,
int  value 
)

Definition at line 541 of file deflate.c.

View newest version in sPHENIX GitHub at line 541 of file deflate.c

References _tr_flush_bits(), internal_state::bi_buf, internal_state::bi_valid, Buf_size, internal_state::d_buf, deflateStateCheck(), internal_state::pending_out, Z_BUF_ERROR, Z_OK, and Z_STREAM_ERROR.

+ Here is the call graph for this function:

int ZEXPORT deflateReset ( z_streamp  strm)

Definition at line 504 of file deflate.c.

View newest version in sPHENIX GitHub at line 504 of file deflate.c

References deflateResetKeep(), lm_init(), and Z_OK.

Referenced by deflateInit2_(), and gz_comp().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ZEXPORT deflateResetKeep ( z_streamp  strm)

Definition at line 466 of file deflate.c.

View newest version in sPHENIX GitHub at line 466 of file deflate.c

References _tr_init(), adler32(), BUSY_STATE, crc32(), deflateStateCheck(), GZIP_STATE, if(), INIT_STATE, L, internal_state::last_flush, internal_state::pending, internal_state::pending_buf, internal_state::pending_out, internal_state::status, internal_state::wrap, Z_NO_FLUSH, Z_NULL, Z_OK, Z_STREAM_ERROR, and Z_UNKNOWN.

Referenced by deflateReset().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ZEXPORT deflateSetDictionary ( z_streamp  strm,
const Bytef *  dictionary,
uInt  dictLength 
)
int ZEXPORT deflateSetHeader ( z_streamp  strm,
gz_headerp  head 
)

Definition at line 516 of file deflate.c.

View newest version in sPHENIX GitHub at line 516 of file deflate.c

References deflateStateCheck(), internal_state::head, Z_OK, and Z_STREAM_ERROR.

+ Here is the call graph for this function:

local int deflateStateCheck ( z_streamp  strm)

Definition at line 352 of file deflate.c.

View newest version in sPHENIX GitHub at line 352 of file deflate.c

References BUSY_STATE, COMMENT_STATE, EXTRA_STATE, FINISH_STATE, GZIP, GZIP_STATE, HCRC_STATE, INIT_STATE, NAME_STATE, internal_state::status, internal_state::strm, and Z_NULL.

Referenced by deflate(), deflateBound(), deflateCopy(), deflateEnd(), deflateGetDictionary(), deflateParams(), deflatePending(), deflatePrime(), deflateResetKeep(), deflateSetDictionary(), deflateSetHeader(), and deflateTune().

+ Here is the caller graph for this function:

int ZEXPORT deflateTune ( z_streamp  strm,
int  good_length,
int  max_lazy,
int  nice_length,
int  max_chain 
)

Definition at line 616 of file deflate.c.

View newest version in sPHENIX GitHub at line 616 of file deflate.c

References deflateStateCheck(), internal_state::good_match, internal_state::max_chain_length, internal_state::max_lazy_match, internal_state::nice_match, Z_OK, and Z_STREAM_ERROR.

+ Here is the call graph for this function:

local void fill_window ( deflate_state s)

Definition at line 1481 of file deflate.c.

View newest version in sPHENIX GitHub at line 1481 of file deflate.c

References Assert, if(), init(), MAX_DIST, MIN_LOOKAHEAD, MIN_MATCH, n, read_buf(), slide_hash(), UPDATE_HASH, WIN_INIT, zmemcpy(), and zmemzero().

Referenced by deflate_fast(), deflate_huff(), deflate_rle(), deflate_slow(), and deflateSetDictionary().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

local void flush_pending ( z_streamp  strm)

Definition at line 729 of file deflate.c.

View newest version in sPHENIX GitHub at line 729 of file deflate.c

References _tr_flush_bits(), internal_state::pending, internal_state::pending_buf, internal_state::pending_out, and zmemcpy().

Referenced by deflate(), and deflate_stored().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

local void lm_init ( deflate_state s)

Definition at line 1193 of file deflate.c.

View newest version in sPHENIX GitHub at line 1193 of file deflate.c

References CLEAR_HASH, L, MIN_MATCH, and internal_state::window_size.

Referenced by deflateReset().

+ Here is the caller graph for this function:

local uInt longest_match ( deflate_state s,
IPos  cur_match 
)

Definition at line 1235 of file deflate.c.

View newest version in sPHENIX GitHub at line 1235 of file deflate.c

References Assert, int(), internal_state::max_chain_length, MAX_DIST, MAX_MATCH, MIN_LOOKAHEAD, internal_state::nice_match, NIL, internal_state::prev, internal_state::strstart, and internal_state::window.

Referenced by deflate_fast(), and deflate_slow().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

local void putShortMSB OF ( (deflate_state *s, uInt b )
local unsigned read_buf OF ( (z_streamp strm, Bytef *buf, unsigned size)  )
local uInt longest_match OF ( (deflate_state *s, IPos cur_match)  )
local void putShortMSB ( deflate_state s,
uInt  b 
)

Definition at line 715 of file deflate.c.

View newest version in sPHENIX GitHub at line 715 of file deflate.c

References put_byte.

Referenced by deflate().

+ Here is the caller graph for this function:

local unsigned read_buf ( z_streamp  strm,
Bytef *  buf,
unsigned  size 
)

Definition at line 1163 of file deflate.c.

View newest version in sPHENIX GitHub at line 1163 of file deflate.c

References adler32(), crc32(), and zmemcpy().

Referenced by deflate_stored(), and fill_window().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

local void slide_hash ( deflate_state s)

Definition at line 200 of file deflate.c.

View newest version in sPHENIX GitHub at line 200 of file deflate.c

References m, n, and NIL.

Referenced by deflateParams(), and fill_window().

+ Here is the caller graph for this function:

Variable Documentation

local const config configuration_table[10]
Initial value:
= {
{0, 0, 0, 0, deflate_stored},
{4, 4, 8, 4, deflate_fast},
{4, 5, 16, 8, deflate_fast},
{4, 6, 32, 32, deflate_fast},
{4, 4, 16, 16, deflate_slow},
{8, 16, 32, 32, deflate_slow},
{8, 16, 128, 128, deflate_slow},
{8, 32, 128, 256, deflate_slow},
{32, 128, 258, 1024, deflate_slow},
{32, 258, 258, 4096, deflate_slow}}

Definition at line 133 of file deflate.c.

View newest version in sPHENIX GitHub at line 133 of file deflate.c

const char deflate_copyright[]
Initial value:
=
" deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "

Definition at line 53 of file deflate.c.

View newest version in sPHENIX GitHub at line 53 of file deflate.c