zlib 0.94
This commit is contained in:
62
trees.c
62
trees.c
@@ -110,7 +110,7 @@ local int base_dist[D_CODES];
|
||||
|
||||
struct static_tree_desc_s {
|
||||
ct_data *static_tree; /* static tree or NULL */
|
||||
int *extra_bits; /* extra bits for each code or NULL */
|
||||
intf *extra_bits; /* extra bits for each code or NULL */
|
||||
int extra_base; /* base index for extra_bits */
|
||||
int elems; /* max number of elements in the tree */
|
||||
int max_length; /* max bit length for the codes */
|
||||
@@ -129,25 +129,25 @@ local static_tree_desc static_bl_desc =
|
||||
* Local (static) routines in this file.
|
||||
*/
|
||||
|
||||
local void ct_static_init __P((void));
|
||||
local void init_block __P((deflate_state *s));
|
||||
local void pqdownheap __P((deflate_state *s, ct_data *tree, int k));
|
||||
local void gen_bitlen __P((deflate_state *s, tree_desc *desc));
|
||||
local void gen_codes __P((ct_data *tree, int max_code, ush bl_count[]));
|
||||
local void build_tree __P((deflate_state *s, tree_desc *desc));
|
||||
local void scan_tree __P((deflate_state *s, ct_data *tree, int max_code));
|
||||
local void send_tree __P((deflate_state *s, ct_data *tree, int max_code));
|
||||
local int build_bl_tree __P((deflate_state *s));
|
||||
local void send_all_trees __P((deflate_state *s, int lcodes, int dcodes,
|
||||
local void ct_static_init OF((void));
|
||||
local void init_block OF((deflate_state *s));
|
||||
local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
|
||||
local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
|
||||
local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
|
||||
local void build_tree OF((deflate_state *s, tree_desc *desc));
|
||||
local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||
local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||
local int build_bl_tree OF((deflate_state *s));
|
||||
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
||||
int blcodes));
|
||||
local void compress_block __P((deflate_state *s, ct_data *ltree,
|
||||
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
||||
ct_data *dtree));
|
||||
local void set_data_type __P((deflate_state *s));
|
||||
local void send_bits __P((deflate_state *s, int value, int length));
|
||||
local unsigned bi_reverse __P((unsigned value, int length));
|
||||
local void bi_windup __P((deflate_state *s));
|
||||
local void copy_block __P((deflate_state *s, char *buf, unsigned len,
|
||||
int header));
|
||||
local void set_data_type OF((deflate_state *s));
|
||||
local void send_bits OF((deflate_state *s, int value, int length));
|
||||
local unsigned bi_reverse OF((unsigned value, int length));
|
||||
local void bi_windup OF((deflate_state *s));
|
||||
local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
|
||||
int header));
|
||||
|
||||
#ifndef DEBUG
|
||||
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
|
||||
@@ -356,7 +356,7 @@ local void gen_bitlen(s, desc)
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
int max_code = desc->max_code;
|
||||
ct_data *stree = desc->stat_desc->static_tree;
|
||||
int *extra = desc->stat_desc->extra_bits;
|
||||
intf *extra = desc->stat_desc->extra_bits;
|
||||
int base = desc->stat_desc->extra_base;
|
||||
int max_length = desc->stat_desc->max_length;
|
||||
int h; /* heap index */
|
||||
@@ -439,7 +439,7 @@ local void gen_bitlen(s, desc)
|
||||
local void gen_codes (tree, max_code, bl_count)
|
||||
ct_data *tree; /* the tree to decorate */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
ush bl_count[]; /* number of codes at each bit length */
|
||||
ushf *bl_count; /* number of codes at each bit length */
|
||||
{
|
||||
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
||||
ush code = 0; /* running code value */
|
||||
@@ -487,8 +487,7 @@ local void build_tree(s, desc)
|
||||
int elems = desc->stat_desc->elems;
|
||||
int n, m; /* iterate over heap elements */
|
||||
int max_code = -1; /* largest code with non zero frequency */
|
||||
int node = elems; /* next internal node of the tree */
|
||||
int new; /* new node being created */
|
||||
int node; /* new node being created */
|
||||
|
||||
/* Construct the initial heap, with least frequent element in
|
||||
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
|
||||
@@ -511,11 +510,11 @@ local void build_tree(s, desc)
|
||||
* two codes of non zero frequency.
|
||||
*/
|
||||
while (s->heap_len < 2) {
|
||||
new = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
|
||||
tree[new].Freq = 1;
|
||||
s->depth[new] = 0;
|
||||
s->opt_len--; if (stree) s->static_len -= stree[new].Len;
|
||||
/* new is 0 or 1 so it does not have extra bits */
|
||||
node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
|
||||
tree[node].Freq = 1;
|
||||
s->depth[node] = 0;
|
||||
s->opt_len--; if (stree) s->static_len -= stree[node].Len;
|
||||
/* node is 0 or 1 so it does not have extra bits */
|
||||
}
|
||||
desc->max_code = max_code;
|
||||
|
||||
@@ -527,6 +526,7 @@ local void build_tree(s, desc)
|
||||
/* Construct the Huffman tree by repeatedly combining the least two
|
||||
* frequent nodes.
|
||||
*/
|
||||
node = elems; /* next internal node of the tree */
|
||||
do {
|
||||
pqremove(s, tree, n); /* n = node of least frequency */
|
||||
m = s->heap[SMALLEST]; /* m = node of next least frequency */
|
||||
@@ -727,7 +727,7 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
|
||||
*/
|
||||
void ct_stored_block(s, buf, stored_len, eof)
|
||||
deflate_state *s;
|
||||
char *buf; /* input block */
|
||||
charf *buf; /* input block */
|
||||
ulg stored_len; /* length of input block */
|
||||
int eof; /* true if this is the last block for a file */
|
||||
{
|
||||
@@ -756,7 +756,7 @@ void ct_align(s)
|
||||
*/
|
||||
ulg ct_flush_block(s, buf, stored_len, eof)
|
||||
deflate_state *s;
|
||||
char *buf; /* input block, or NULL if too old */
|
||||
charf *buf; /* input block, or NULL if too old */
|
||||
ulg stored_len; /* length of input block */
|
||||
int eof; /* true if this is the last block for a file */
|
||||
{
|
||||
@@ -804,7 +804,7 @@ ulg ct_flush_block(s, buf, stored_len, eof)
|
||||
if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) {
|
||||
# endif
|
||||
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
|
||||
if (buf == (char*)0) error ("block vanished");
|
||||
if (buf == (charf*)0) error ("block vanished");
|
||||
|
||||
copy_block(buf, (unsigned)stored_len, 0); /* without header */
|
||||
s->compressed_len = stored_len << 3;
|
||||
@@ -1049,7 +1049,7 @@ local void bi_windup(s)
|
||||
*/
|
||||
local void copy_block(s, buf, len, header)
|
||||
deflate_state *s;
|
||||
char *buf; /* the input data */
|
||||
charf *buf; /* the input data */
|
||||
unsigned len; /* its length */
|
||||
int header; /* true if block header must be written */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user