OLD | NEW |
1 /* deflate.h -- internal compression state | 1 /* deflate.h -- internal compression state |
2 * Copyright (C) 1995-2012 Jean-loup Gailly | 2 * Copyright (C) 1995-2010 Jean-loup Gailly |
3 * For conditions of distribution and use, see copyright notice in zlib.h | 3 * For conditions of distribution and use, see copyright notice in zlib.h |
4 */ | 4 */ |
5 | 5 |
6 /* WARNING: this file should *not* be used by applications. It is | 6 /* WARNING: this file should *not* be used by applications. It is |
7 part of the implementation of the compression library and is | 7 part of the implementation of the compression library and is |
8 subject to change. Applications should only use zlib.h. | 8 subject to change. Applications should only use zlib.h. |
9 */ | 9 */ |
10 | 10 |
11 /* @(#) $Id$ */ | 11 /* @(#) $Id$ */ |
12 | 12 |
(...skipping 28 matching lines...) Expand all Loading... |
41 | 41 |
42 #define BL_CODES 19 | 42 #define BL_CODES 19 |
43 /* number of codes used to transfer the bit lengths */ | 43 /* number of codes used to transfer the bit lengths */ |
44 | 44 |
45 #define HEAP_SIZE (2*L_CODES+1) | 45 #define HEAP_SIZE (2*L_CODES+1) |
46 /* maximum heap size */ | 46 /* maximum heap size */ |
47 | 47 |
48 #define MAX_BITS 15 | 48 #define MAX_BITS 15 |
49 /* All codes must not exceed MAX_BITS bits */ | 49 /* All codes must not exceed MAX_BITS bits */ |
50 | 50 |
51 #define Buf_size 16 | |
52 /* size of bit buffer in bi_buf */ | |
53 | |
54 #define INIT_STATE 42 | 51 #define INIT_STATE 42 |
55 #define EXTRA_STATE 69 | 52 #define EXTRA_STATE 69 |
56 #define NAME_STATE 73 | 53 #define NAME_STATE 73 |
57 #define COMMENT_STATE 91 | 54 #define COMMENT_STATE 91 |
58 #define HCRC_STATE 103 | 55 #define HCRC_STATE 103 |
59 #define BUSY_STATE 113 | 56 #define BUSY_STATE 113 |
60 #define FINISH_STATE 666 | 57 #define FINISH_STATE 666 |
61 /* Stream status */ | 58 /* Stream status */ |
62 | 59 |
63 | 60 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 typedef struct internal_state { | 97 typedef struct internal_state { |
101 z_streamp strm; /* pointer back to this zlib stream */ | 98 z_streamp strm; /* pointer back to this zlib stream */ |
102 int status; /* as the name implies */ | 99 int status; /* as the name implies */ |
103 Bytef *pending_buf; /* output still pending */ | 100 Bytef *pending_buf; /* output still pending */ |
104 ulg pending_buf_size; /* size of pending_buf */ | 101 ulg pending_buf_size; /* size of pending_buf */ |
105 Bytef *pending_out; /* next pending byte to output to the stream */ | 102 Bytef *pending_out; /* next pending byte to output to the stream */ |
106 uInt pending; /* nb of bytes in the pending buffer */ | 103 uInt pending; /* nb of bytes in the pending buffer */ |
107 int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ | 104 int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ |
108 gz_headerp gzhead; /* gzip header information to write */ | 105 gz_headerp gzhead; /* gzip header information to write */ |
109 uInt gzindex; /* where in extra, name, or comment */ | 106 uInt gzindex; /* where in extra, name, or comment */ |
110 Byte method; /* can only be DEFLATED */ | 107 Byte method; /* STORED (for zip only) or DEFLATED */ |
111 int last_flush; /* value of flush param for previous deflate call */ | 108 int last_flush; /* value of flush param for previous deflate call */ |
| 109 |
112 unsigned zalign(16) crc0[4 * 5]; | 110 unsigned zalign(16) crc0[4 * 5]; |
| 111 |
113 /* used by deflate.c: */ | 112 /* used by deflate.c: */ |
114 | 113 |
115 uInt w_size; /* LZ77 window size (32K by default) */ | 114 uInt w_size; /* LZ77 window size (32K by default) */ |
116 uInt w_bits; /* log2(w_size) (8..16) */ | 115 uInt w_bits; /* log2(w_size) (8..16) */ |
117 uInt w_mask; /* w_size - 1 */ | 116 uInt w_mask; /* w_size - 1 */ |
118 | 117 |
119 Bytef *window; | 118 Bytef *window; |
120 /* Sliding window. Input bytes are read into the second half of the window, | 119 /* Sliding window. Input bytes are read into the second half of the window, |
121 * and move to the first half later to keep a dictionary of at least wSize | 120 * and move to the first half later to keep a dictionary of at least wSize |
122 * bytes. With this organization, matches are limited to a distance of | 121 * bytes. With this organization, matches are limited to a distance of |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 188 |
190 int level; /* compression level (1..9) */ | 189 int level; /* compression level (1..9) */ |
191 int strategy; /* favor or force Huffman coding*/ | 190 int strategy; /* favor or force Huffman coding*/ |
192 | 191 |
193 uInt good_match; | 192 uInt good_match; |
194 /* Use a faster search when the previous match is longer than this */ | 193 /* Use a faster search when the previous match is longer than this */ |
195 | 194 |
196 int nice_match; /* Stop searching when current match exceeds this */ | 195 int nice_match; /* Stop searching when current match exceeds this */ |
197 | 196 |
198 /* used by trees.c: */ | 197 /* used by trees.c: */ |
199 /* Didn't use ct_data typedef below to suppress compiler warning */ | 198 /* Didn't use ct_data typedef below to supress compiler warning */ |
200 struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ | 199 struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ |
201 struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ | 200 struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ |
202 struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ | 201 struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ |
203 | 202 |
204 struct tree_desc_s l_desc; /* desc. for literal tree */ | 203 struct tree_desc_s l_desc; /* desc. for literal tree */ |
205 struct tree_desc_s d_desc; /* desc. for distance tree */ | 204 struct tree_desc_s d_desc; /* desc. for distance tree */ |
206 struct tree_desc_s bl_desc; /* desc. for bit length tree */ | 205 struct tree_desc_s bl_desc; /* desc. for bit length tree */ |
207 | 206 |
208 ush bl_count[MAX_BITS+1]; | 207 ush bl_count[MAX_BITS+1]; |
209 /* number of codes at each bit length for an optimal tree */ | 208 /* number of codes at each bit length for an optimal tree */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 244 |
246 ushf *d_buf; | 245 ushf *d_buf; |
247 /* Buffer for distances. To simplify the code, d_buf and l_buf have | 246 /* Buffer for distances. To simplify the code, d_buf and l_buf have |
248 * the same number of elements. To use different lengths, an extra flag | 247 * the same number of elements. To use different lengths, an extra flag |
249 * array would be necessary. | 248 * array would be necessary. |
250 */ | 249 */ |
251 | 250 |
252 ulg opt_len; /* bit length of current block with optimal trees */ | 251 ulg opt_len; /* bit length of current block with optimal trees */ |
253 ulg static_len; /* bit length of current block with static trees */ | 252 ulg static_len; /* bit length of current block with static trees */ |
254 uInt matches; /* number of string matches in current block */ | 253 uInt matches; /* number of string matches in current block */ |
255 uInt insert; /* bytes at end of window left to insert */ | 254 int last_eob_len; /* bit length of EOB code for last block */ |
256 | 255 |
257 #ifdef DEBUG | 256 #ifdef DEBUG |
258 ulg compressed_len; /* total bit length of compressed file mod 2^32 */ | 257 ulg compressed_len; /* total bit length of compressed file mod 2^32 */ |
259 ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ | 258 ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ |
260 #endif | 259 #endif |
261 | 260 |
262 ush bi_buf; | 261 ush bi_buf; |
263 /* Output buffer. bits are inserted starting at the bottom (least | 262 /* Output buffer. bits are inserted starting at the bottom (least |
264 * significant bits). | 263 * significant bits). |
265 */ | 264 */ |
(...skipping 29 matching lines...) Expand all Loading... |
295 | 294 |
296 #define WIN_INIT MAX_MATCH | 295 #define WIN_INIT MAX_MATCH |
297 /* Number of bytes after end of data in window to initialize in order to avoid | 296 /* Number of bytes after end of data in window to initialize in order to avoid |
298 memory checker errors from longest match routines */ | 297 memory checker errors from longest match routines */ |
299 | 298 |
300 /* in trees.c */ | 299 /* in trees.c */ |
301 void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); | 300 void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); |
302 int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); | 301 int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); |
303 void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, | 302 void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, |
304 ulg stored_len, int last)); | 303 ulg stored_len, int last)); |
305 void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); | |
306 void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); | 304 void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); |
307 void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, | 305 void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, |
308 ulg stored_len, int last)); | 306 ulg stored_len, int last)); |
309 | 307 |
310 #define d_code(dist) \ | 308 #define d_code(dist) \ |
311 ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) | 309 ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) |
312 /* Mapping from a distance to a distance code. dist is the distance - 1 and | 310 /* Mapping from a distance to a distance code. dist is the distance - 1 and |
313 * must not have side effects. _dist_code[256] and _dist_code[257] are never | 311 * must not have side effects. _dist_code[256] and _dist_code[257] are never |
314 * used. | 312 * used. |
315 */ | 313 */ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 void ZLIB_INTERNAL crc_fold_init(deflate_state* const s); | 350 void ZLIB_INTERNAL crc_fold_init(deflate_state* const s); |
353 void ZLIB_INTERNAL crc_fold_copy(deflate_state* const s, | 351 void ZLIB_INTERNAL crc_fold_copy(deflate_state* const s, |
354 unsigned char* dst, | 352 unsigned char* dst, |
355 const unsigned char* src, | 353 const unsigned char* src, |
356 long len); | 354 long len); |
357 unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state* const s); | 355 unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state* const s); |
358 | 356 |
359 void ZLIB_INTERNAL fill_window_sse(deflate_state* s); | 357 void ZLIB_INTERNAL fill_window_sse(deflate_state* s); |
360 | 358 |
361 #endif /* DEFLATE_H */ | 359 #endif /* DEFLATE_H */ |
OLD | NEW |