35#define LENGTH_CODES 29
41#define L_CODES (LITERALS+1+LENGTH_CODES)
50#define HEAP_SIZE (2*L_CODES+1)
65#define COMMENT_STATE 91
68#define FINISH_STATE 666
73typedef struct ct_data_s {
91typedef struct tree_desc_s {
94 const static_tree_desc *stat_desc;
106typedef struct internal_state {
183# define max_insert_length max_lazy_match
200 struct ct_data_s dyn_ltree[HEAP_SIZE];
201 struct ct_data_s dyn_dtree[2*D_CODES+1];
202 struct ct_data_s bl_tree[2*BL_CODES+1];
204 struct tree_desc_s l_desc;
205 struct tree_desc_s d_desc;
206 struct tree_desc_s bl_desc;
208 ush bl_count[MAX_BITS+1];
211 int heap[2*L_CODES+1];
218 uch depth[2*L_CODES+1];
284#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
287#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
292#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
297#define WIN_INIT MAX_MATCH
303int ZLIB_INTERNAL _tr_tally(
deflate_state *s,
unsigned dist,
unsigned lc);
304void ZLIB_INTERNAL _tr_flush_block(
deflate_state *s, charf *buf,
305 ulg stored_len,
int last);
308void ZLIB_INTERNAL _tr_stored_block(
deflate_state *s, charf *buf,
309 ulg stored_len,
int last);
311#define d_code(dist) \
312 ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
321#if defined(GEN_TREES_H) || !defined(STDC)
322 extern uch ZLIB_INTERNAL _length_code[];
323 extern uch ZLIB_INTERNAL _dist_code[];
325 extern const uch ZLIB_INTERNAL _length_code[];
326 extern const uch ZLIB_INTERNAL _dist_code[];
330# define _tr_tally_lit(s, c, flush) \
332 s->d_buf[s->sym_next] = 0; \
333 s->l_buf[s->sym_next++] = cc; \
334 s->dyn_ltree[cc].Freq++; \
335 flush = (s->sym_next == s->sym_end); \
337# define _tr_tally_dist(s, distance, length, flush) \
338 { uch len = (uch)(length); \
339 ush dist = (ush)(distance); \
340 s->d_buf[s->sym_next] = dist; \
341 s->l_buf[s->sym_next++] = len; \
343 s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
344 s->dyn_dtree[d_code(dist)].Freq++; \
345 flush = (s->sym_next == s->sym_end); \
348# define _tr_tally_lit(s, c, flush) \
350 s->sym_buf[s->sym_next++] = 0; \
351 s->sym_buf[s->sym_next++] = 0; \
352 s->sym_buf[s->sym_next++] = cc; \
353 s->dyn_ltree[cc].Freq++; \
354 flush = (s->sym_next == s->sym_end); \
356# define _tr_tally_dist(s, distance, length, flush) \
357 { uch len = (uch)(length); \
358 ush dist = (ush)(distance); \
359 s->sym_buf[s->sym_next++] = (uch)dist; \
360 s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
361 s->sym_buf[s->sym_next++] = len; \
363 s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
364 s->dyn_dtree[d_code(dist)].Freq++; \
365 flush = (s->sym_next == s->sym_end); \
369# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
370# define _tr_tally_dist(s, distance, length, flush) \
371 flush = _tr_tally(s, distance, length)
Data structure describing a single value and its code string.
Definition deflate.h:73
ush len
length of bit string
Definition deflate.h:80
ush freq
frequency count
Definition deflate.h:75
ush dad
father node in Huffman tree
Definition deflate.h:79
ush code
bit string
Definition deflate.h:76
Deflate internal state.
Definition deflate.h:106
int last_flush
value of flush param for previous deflate call
Definition deflate.h:117
Posf * head
Heads of the hash chains or NIL.
Definition deflate.h:144
uInt prev_length
Length of the best match at previous step.
Definition deflate.h:167
int heap_len
number of elements in the heap
Definition deflate.h:212
uInt sym_end
symbol table full when sym_next reaches this
Definition deflate.h:251
Bytef * pending_buf
output still pending
Definition deflate.h:109
uInt w_size
LZ77 window size (32K by default)
Definition deflate.h:121
int level
compression level (1..9)
Definition deflate.h:189
uInt w_bits
log2(w_size) (8..16)
Definition deflate.h:122
uInt hash_mask
hash_size-1
Definition deflate.h:149
Bytef * window
Sliding window.
Definition deflate.h:125
ulg pending
nb of bytes in the pending buffer
Definition deflate.h:112
uInt match_length
length of best match
Definition deflate.h:160
uInt max_lazy_match
Attempt to find a better match only when the current match is strictly smaller than this value.
Definition deflate.h:178
uInt lookahead
number of valid bytes ahead in window
Definition deflate.h:165
IPos prev_match
previous match
Definition deflate.h:161
uInt insert
bytes at end of window left to insert
Definition deflate.h:256
uInt strstart
start of string to insert
Definition deflate.h:163
uInt matches
number of string matches in current block
Definition deflate.h:255
Bytef * pending_out
next pending byte to output to the stream
Definition deflate.h:111
int status
as the name implies
Definition deflate.h:108
z_streamp strm
pointer back to this zlib stream
Definition deflate.h:107
uInt sym_next
running index in symbol buffer
Definition deflate.h:250
ulg opt_len
bit length of current block with optimal trees
Definition deflate.h:253
Posf * prev
Link to older string with same hash index.
Definition deflate.h:139
uInt hash_bits
log2(hash_size)
Definition deflate.h:148
uInt match_start
start of matching string
Definition deflate.h:164
uchf * sym_buf
buffer for distances and literals/lengths
Definition deflate.h:226
int bi_valid
Number of valid bits in bi_buf.
Definition deflate.h:267
int match_available
set if previous match exists
Definition deflate.h:162
ulg window_size
Actual size of window: 2*wSize, except when the user input buffer is directly used as sliding window.
Definition deflate.h:136
uInt w_mask
w_size - 1
Definition deflate.h:123
uInt hash_size
number of elements in hash table
Definition deflate.h:147
int heap_max
element of largest frequency
Definition deflate.h:213
ulg static_len
bit length of current block with static trees
Definition deflate.h:254
int wrap
bit 0 true for zlib, bit 1 true for gzip
Definition deflate.h:113
ulg gzindex
where in extra, name, or comment
Definition deflate.h:115
ush bi_buf
Output buffer.
Definition deflate.h:263
uInt max_chain_length
To speed up deflation, hash chains are never searched beyond this length.
Definition deflate.h:172
uInt hash_shift
Number of bits by which ins_h must be shifted at each input step.
Definition deflate.h:151
ulg pending_buf_size
size of pending_buf
Definition deflate.h:110
uInt ins_h
hash index of string to be inserted
Definition deflate.h:146
Byte method
can only be DEFLATED
Definition deflate.h:116
int nice_match
Stop searching when current match exceeds this.
Definition deflate.h:195
long block_start
Window position at the beginning of the current output block.
Definition deflate.h:156
uInt lit_bufsize
Size of match buffer for literals/lengths.
Definition deflate.h:229
gz_headerp gzhead
gzip header information to write
Definition deflate.h:114
ulg high_water
High water mark offset in window for initialized bytes – bytes above this are set to zero in order to...
Definition deflate.h:272
int strategy
favor or force Huffman coding
Definition deflate.h:190
uInt good_match
Use a faster search when the previous match is longer than this.
Definition deflate.h:192
Compressed stream state information.
Definition zlib.h:136
Internal interface and configuration of the compression library.