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