5128eecc9f 2011-02-23 kinaba: /* deflate.h -- internal compression state 5128eecc9f 2011-02-23 kinaba: * Copyright (C) 1995-1998 Jean-loup Gailly 5128eecc9f 2011-02-23 kinaba: * For conditions of distribution and use, see copyright notice in zlib.h 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* WARNING: this file should *not* be used by applications. It is 5128eecc9f 2011-02-23 kinaba: part of the implementation of the compression library and is 5128eecc9f 2011-02-23 kinaba: subject to change. Applications should only use zlib.h. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* @(#) $Id$ */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #ifndef _DEFLATE_H 5128eecc9f 2011-02-23 kinaba: #define _DEFLATE_H 5128eecc9f 2011-02-23 kinaba: #ifndef KI_GZ_NO_COMPRESSION 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #include "zutil.h" 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* =========================================================================== 5128eecc9f 2011-02-23 kinaba: * Internal compression state. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define LENGTH_CODES 29 5128eecc9f 2011-02-23 kinaba: /* number of length codes, not counting the special END_BLOCK code */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define LITERALS 256 5128eecc9f 2011-02-23 kinaba: /* number of literal bytes 0..255 */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define L_CODES (LITERALS+1+LENGTH_CODES) 5128eecc9f 2011-02-23 kinaba: /* number of Literal or Length codes, including the END_BLOCK code */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define D_CODES 30 5128eecc9f 2011-02-23 kinaba: /* number of distance codes */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define BL_CODES 19 5128eecc9f 2011-02-23 kinaba: /* number of codes used to transfer the bit lengths */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define HEAP_SIZE (2*L_CODES+1) 5128eecc9f 2011-02-23 kinaba: /* maximum heap size */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define MAX_BITS 15 5128eecc9f 2011-02-23 kinaba: /* All codes must not exceed MAX_BITS bits */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define INIT_STATE 42 5128eecc9f 2011-02-23 kinaba: #define BUSY_STATE 113 5128eecc9f 2011-02-23 kinaba: #define FINISH_STATE 666 5128eecc9f 2011-02-23 kinaba: /* Stream status */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* Data structure describing a single value and its code string. */ 5128eecc9f 2011-02-23 kinaba: typedef struct ct_data_s { 5128eecc9f 2011-02-23 kinaba: union { 5128eecc9f 2011-02-23 kinaba: ush freq; /* frequency count */ 5128eecc9f 2011-02-23 kinaba: ush code; /* bit string */ 5128eecc9f 2011-02-23 kinaba: } fc; 5128eecc9f 2011-02-23 kinaba: union { 5128eecc9f 2011-02-23 kinaba: ush dad; /* father node in Huffman tree */ 5128eecc9f 2011-02-23 kinaba: ush len; /* length of bit string */ 5128eecc9f 2011-02-23 kinaba: } dl; 5128eecc9f 2011-02-23 kinaba: } FAR ct_data; 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define Freq fc.freq 5128eecc9f 2011-02-23 kinaba: #define Code fc.code 5128eecc9f 2011-02-23 kinaba: #define Dad dl.dad 5128eecc9f 2011-02-23 kinaba: #define Len dl.len 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: typedef struct static_tree_desc_s static_tree_desc; 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: typedef struct tree_desc_s { 5128eecc9f 2011-02-23 kinaba: ct_data *dyn_tree; /* the dynamic tree */ 5128eecc9f 2011-02-23 kinaba: int max_code; /* largest code with non zero frequency */ 5128eecc9f 2011-02-23 kinaba: static_tree_desc *stat_desc; /* the corresponding static tree */ 5128eecc9f 2011-02-23 kinaba: } FAR tree_desc; 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: typedef ush Pos; 5128eecc9f 2011-02-23 kinaba: typedef Pos FAR Posf; 5128eecc9f 2011-02-23 kinaba: typedef unsigned IPos; 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* A Pos is an index in the character window. We use short instead of int to 5128eecc9f 2011-02-23 kinaba: * save space in the various tables. IPos is used only for parameter passing. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: typedef struct internal_state { 5128eecc9f 2011-02-23 kinaba: z_streamp strm; /* pointer back to this zlib stream */ 5128eecc9f 2011-02-23 kinaba: int status; /* as the name implies */ 5128eecc9f 2011-02-23 kinaba: Bytef *pending_buf; /* output still pending */ 5128eecc9f 2011-02-23 kinaba: ulg pending_buf_size; /* size of pending_buf */ 5128eecc9f 2011-02-23 kinaba: Bytef *pending_out; /* next pending byte to output to the stream */ 5128eecc9f 2011-02-23 kinaba: int pending; /* nb of bytes in the pending buffer */ 5128eecc9f 2011-02-23 kinaba: int noheader; /* suppress zlib header and adler32 */ 5128eecc9f 2011-02-23 kinaba: Byte data_type; /* UNKNOWN, BINARY or ASCII */ 5128eecc9f 2011-02-23 kinaba: Byte method; /* STORED (for zip only) or DEFLATED */ 5128eecc9f 2011-02-23 kinaba: int last_flush; /* value of flush param for previous deflate call */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* used by deflate.c: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt w_size; /* LZ77 window size (32K by default) */ 5128eecc9f 2011-02-23 kinaba: uInt w_bits; /* log2(w_size) (8..16) */ 5128eecc9f 2011-02-23 kinaba: uInt w_mask; /* w_size - 1 */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: Bytef *window; 5128eecc9f 2011-02-23 kinaba: /* Sliding window. Input bytes are read into the second half of the window, 5128eecc9f 2011-02-23 kinaba: * and move to the first half later to keep a dictionary of at least wSize 5128eecc9f 2011-02-23 kinaba: * bytes. With this organization, matches are limited to a distance of 5128eecc9f 2011-02-23 kinaba: * wSize-MAX_MATCH bytes, but this ensures that IO is always 5128eecc9f 2011-02-23 kinaba: * performed with a length multiple of the block size. Also, it limits 5128eecc9f 2011-02-23 kinaba: * the window size to 64K, which is quite useful on MSDOS. 5128eecc9f 2011-02-23 kinaba: * To do: use the user input buffer as sliding window. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: ulg window_size; 5128eecc9f 2011-02-23 kinaba: /* Actual size of window: 2*wSize, except when the user input buffer 5128eecc9f 2011-02-23 kinaba: * is directly used as sliding window. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: Posf *prev; 5128eecc9f 2011-02-23 kinaba: /* Link to older string with same hash index. To limit the size of this 5128eecc9f 2011-02-23 kinaba: * array to 64K, this link is maintained only for the last 32K strings. 5128eecc9f 2011-02-23 kinaba: * An index in this array is thus a window index modulo 32K. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: Posf *head; /* Heads of the hash chains or NIL. */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt ins_h; /* hash index of string to be inserted */ 5128eecc9f 2011-02-23 kinaba: uInt hash_size; /* number of elements in hash table */ 5128eecc9f 2011-02-23 kinaba: uInt hash_bits; /* log2(hash_size) */ 5128eecc9f 2011-02-23 kinaba: uInt hash_mask; /* hash_size-1 */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt hash_shift; 5128eecc9f 2011-02-23 kinaba: /* Number of bits by which ins_h must be shifted at each input 5128eecc9f 2011-02-23 kinaba: * step. It must be such that after MIN_MATCH steps, the oldest 5128eecc9f 2011-02-23 kinaba: * byte no longer takes part in the hash key, that is: 5128eecc9f 2011-02-23 kinaba: * hash_shift * MIN_MATCH >= hash_bits 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: long block_start; 5128eecc9f 2011-02-23 kinaba: /* Window position at the beginning of the current output block. Gets 5128eecc9f 2011-02-23 kinaba: * negative when the window is moved backwards. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt match_length; /* length of best match */ 5128eecc9f 2011-02-23 kinaba: IPos prev_match; /* previous match */ 5128eecc9f 2011-02-23 kinaba: int match_available; /* set if previous match exists */ 5128eecc9f 2011-02-23 kinaba: uInt strstart; /* start of string to insert */ 5128eecc9f 2011-02-23 kinaba: uInt match_start; /* start of matching string */ 5128eecc9f 2011-02-23 kinaba: uInt lookahead; /* number of valid bytes ahead in window */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt prev_length; 5128eecc9f 2011-02-23 kinaba: /* Length of the best match at previous step. Matches not greater than this 5128eecc9f 2011-02-23 kinaba: * are discarded. This is used in the lazy match evaluation. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt max_chain_length; 5128eecc9f 2011-02-23 kinaba: /* To speed up deflation, hash chains are never searched beyond this 5128eecc9f 2011-02-23 kinaba: * length. A higher limit improves compression ratio but degrades the 5128eecc9f 2011-02-23 kinaba: * speed. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt max_lazy_match; 5128eecc9f 2011-02-23 kinaba: /* Attempt to find a better match only when the current match is strictly 5128eecc9f 2011-02-23 kinaba: * smaller than this value. This mechanism is used only for compression 5128eecc9f 2011-02-23 kinaba: * levels >= 4. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: # define max_insert_length max_lazy_match 5128eecc9f 2011-02-23 kinaba: /* Insert new strings in the hash table only if the match length is not 5128eecc9f 2011-02-23 kinaba: * greater than this length. This saves time but degrades compression. 5128eecc9f 2011-02-23 kinaba: * max_insert_length is used only for compression levels <= 3. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: int level; /* compression level (1..9) */ 5128eecc9f 2011-02-23 kinaba: int strategy; /* favor or force Huffman coding*/ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt good_match; 5128eecc9f 2011-02-23 kinaba: /* Use a faster search when the previous match is longer than this */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: int nice_match; /* Stop searching when current match exceeds this */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* used by trees.c: */ 5128eecc9f 2011-02-23 kinaba: /* Didn't use ct_data typedef below to supress compiler warning */ 5128eecc9f 2011-02-23 kinaba: struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ 5128eecc9f 2011-02-23 kinaba: struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ 5128eecc9f 2011-02-23 kinaba: struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: struct tree_desc_s l_desc; /* desc. for literal tree */ 5128eecc9f 2011-02-23 kinaba: struct tree_desc_s d_desc; /* desc. for distance tree */ 5128eecc9f 2011-02-23 kinaba: struct tree_desc_s bl_desc; /* desc. for bit length tree */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: ush bl_count[MAX_BITS+1]; 5128eecc9f 2011-02-23 kinaba: /* number of codes at each bit length for an optimal tree */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ 5128eecc9f 2011-02-23 kinaba: int heap_len; /* number of elements in the heap */ 5128eecc9f 2011-02-23 kinaba: int heap_max; /* element of largest frequency */ 5128eecc9f 2011-02-23 kinaba: /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. 5128eecc9f 2011-02-23 kinaba: * The same heap array is used to build all trees. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uch depth[2*L_CODES+1]; 5128eecc9f 2011-02-23 kinaba: /* Depth of each subtree used as tie breaker for trees of equal frequency 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uchf *l_buf; /* buffer for literals or lengths */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt lit_bufsize; 5128eecc9f 2011-02-23 kinaba: /* Size of match buffer for literals/lengths. There are 4 reasons for 5128eecc9f 2011-02-23 kinaba: * limiting lit_bufsize to 64K: 5128eecc9f 2011-02-23 kinaba: * - frequencies can be kept in 16 bit counters 5128eecc9f 2011-02-23 kinaba: * - if compression is not successful for the first block, all input 5128eecc9f 2011-02-23 kinaba: * data is still in the window so we can still emit a stored block even 5128eecc9f 2011-02-23 kinaba: * when input comes from standard input. (This can also be done for 5128eecc9f 2011-02-23 kinaba: * all blocks if lit_bufsize is not greater than 32K.) 5128eecc9f 2011-02-23 kinaba: * - if compression is not successful for a file smaller than 64K, we can 5128eecc9f 2011-02-23 kinaba: * even emit a stored file instead of a stored block (saving 5 bytes). 5128eecc9f 2011-02-23 kinaba: * This is applicable only for zip (not gzip or zlib). 5128eecc9f 2011-02-23 kinaba: * - creating new Huffman trees less frequently may not provide fast 5128eecc9f 2011-02-23 kinaba: * adaptation to changes in the input data statistics. (Take for 5128eecc9f 2011-02-23 kinaba: * example a binary file with poorly compressible code followed by 5128eecc9f 2011-02-23 kinaba: * a highly compressible string table.) Smaller buffer sizes give 5128eecc9f 2011-02-23 kinaba: * fast adaptation but have of course the overhead of transmitting 5128eecc9f 2011-02-23 kinaba: * trees more frequently. 5128eecc9f 2011-02-23 kinaba: * - I can't count above 4 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: uInt last_lit; /* running index in l_buf */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: ushf *d_buf; 5128eecc9f 2011-02-23 kinaba: /* Buffer for distances. To simplify the code, d_buf and l_buf have 5128eecc9f 2011-02-23 kinaba: * the same number of elements. To use different lengths, an extra flag 5128eecc9f 2011-02-23 kinaba: * array would be necessary. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: ulg opt_len; /* bit length of current block with optimal trees */ 5128eecc9f 2011-02-23 kinaba: ulg static_len; /* bit length of current block with static trees */ 5128eecc9f 2011-02-23 kinaba: uInt matches; /* number of string matches in current block */ 5128eecc9f 2011-02-23 kinaba: int last_eob_len; /* bit length of EOB code for last block */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #ifdef DEBUG 5128eecc9f 2011-02-23 kinaba: ulg compressed_len; /* total bit length of compressed file mod 2^32 */ 5128eecc9f 2011-02-23 kinaba: ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ 5128eecc9f 2011-02-23 kinaba: #endif 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: ush bi_buf; 5128eecc9f 2011-02-23 kinaba: /* Output buffer. bits are inserted starting at the bottom (least 5128eecc9f 2011-02-23 kinaba: * significant bits). 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: int bi_valid; 5128eecc9f 2011-02-23 kinaba: /* Number of valid bits in bi_buf. All bits above the last valid bit 5128eecc9f 2011-02-23 kinaba: * are always zero. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: } FAR deflate_state; 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* Output a byte on the stream. 5128eecc9f 2011-02-23 kinaba: * IN assertion: there is enough room in pending_buf. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) 5128eecc9f 2011-02-23 kinaba: /* Minimum amount of lookahead, except at the end of the input file. 5128eecc9f 2011-02-23 kinaba: * See deflate.c for comments about the MIN_MATCH+1. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) 5128eecc9f 2011-02-23 kinaba: /* In order to simplify the code, particularly on 16 bit machines, match 5128eecc9f 2011-02-23 kinaba: * distances are limited to MAX_DIST instead of WSIZE. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* in trees.c */ 5128eecc9f 2011-02-23 kinaba: void _tr_init OF((deflate_state *s)); 5128eecc9f 2011-02-23 kinaba: int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); 5128eecc9f 2011-02-23 kinaba: void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, 5128eecc9f 2011-02-23 kinaba: int eof)); 5128eecc9f 2011-02-23 kinaba: void _tr_align OF((deflate_state *s)); 5128eecc9f 2011-02-23 kinaba: void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, 5128eecc9f 2011-02-23 kinaba: int eof)); 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #define d_code(dist) \ 5128eecc9f 2011-02-23 kinaba: ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) 5128eecc9f 2011-02-23 kinaba: /* Mapping from a distance to a distance code. dist is the distance - 1 and 5128eecc9f 2011-02-23 kinaba: * must not have side effects. _dist_code[256] and _dist_code[257] are never 5128eecc9f 2011-02-23 kinaba: * used. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #ifndef DEBUG 5128eecc9f 2011-02-23 kinaba: /* Inline versions of _tr_tally for speed: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #if defined(GEN_TREES_H) || !defined(STDC) 5128eecc9f 2011-02-23 kinaba: extern uch _length_code[]; 5128eecc9f 2011-02-23 kinaba: extern uch _dist_code[]; 5128eecc9f 2011-02-23 kinaba: #else 5128eecc9f 2011-02-23 kinaba: extern const uch _length_code[]; 5128eecc9f 2011-02-23 kinaba: extern const uch _dist_code[]; 5128eecc9f 2011-02-23 kinaba: #endif 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: # define _tr_tally_lit(s, c, flush) \ 5128eecc9f 2011-02-23 kinaba: { uch cc = (c); \ 5128eecc9f 2011-02-23 kinaba: s->d_buf[s->last_lit] = 0; \ 5128eecc9f 2011-02-23 kinaba: s->l_buf[s->last_lit++] = cc; \ 5128eecc9f 2011-02-23 kinaba: s->dyn_ltree[cc].Freq++; \ 5128eecc9f 2011-02-23 kinaba: flush = (s->last_lit == s->lit_bufsize-1); \ 5128eecc9f 2011-02-23 kinaba: } 5128eecc9f 2011-02-23 kinaba: # define _tr_tally_dist(s, distance, length, flush) \ 5128eecc9f 2011-02-23 kinaba: { uch len = (length); \ 5128eecc9f 2011-02-23 kinaba: ush dist = (distance); \ 5128eecc9f 2011-02-23 kinaba: s->d_buf[s->last_lit] = dist; \ 5128eecc9f 2011-02-23 kinaba: s->l_buf[s->last_lit++] = len; \ 5128eecc9f 2011-02-23 kinaba: dist--; \ 5128eecc9f 2011-02-23 kinaba: s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ 5128eecc9f 2011-02-23 kinaba: s->dyn_dtree[d_code(dist)].Freq++; \ 5128eecc9f 2011-02-23 kinaba: flush = (s->last_lit == s->lit_bufsize-1); \ 5128eecc9f 2011-02-23 kinaba: } 5128eecc9f 2011-02-23 kinaba: #else 5128eecc9f 2011-02-23 kinaba: # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) 5128eecc9f 2011-02-23 kinaba: # define _tr_tally_dist(s, distance, length, flush) \ 5128eecc9f 2011-02-23 kinaba: flush = _tr_tally(s, distance, length) 5128eecc9f 2011-02-23 kinaba: #endif 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #endif /* KI_GZ_NO_COMPRESSION */ 5128eecc9f 2011-02-23 kinaba: #endif