Home | History | Annotate | Download | only in net

Lines Matching defs:tree

342         ush  dad;        /* father node in Huffman tree */
355 ct_data *dyn_tree; /* the dynamic tree */
357 static_tree_desc *stat_desc; /* the corresponding static tree */
465 struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
466 struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
467 struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
469 struct tree_desc_s l_desc; /* desc. for literal tree */
470 struct tree_desc_s d_desc; /* desc. for distance tree */
471 struct tree_desc_s bl_desc; /* desc. for bit length tree */
474 /* number of codes at each bit length for an optimal tree */
1982 * Each code tree is stored in a compressed form which is itself
2061 /* The static literal tree. Since the bit lengths are imposed, there is no
2063 * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
2068 /* The static distance tree. (Actually a trivial tree since all codes use
2222 const ct_data *static_tree; /* static tree or NULL */
2225 int elems; /* max number of elements in the tree */
2244 local void pqdownheap(deflate_state *s, ct_data *tree, int k);
2246 local void gen_codes(ct_data *tree, int max_code, ushf *bl_count);
2248 local void scan_tree(deflate_state *s, ct_data *tree, int max_code);
2249 local void send_tree(deflate_state *s, ct_data *tree, int max_code);
2267 # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
2268 /* Send a code of the given tree. c and tree must not have side effects */
2271 # define send_code(s, c, tree) \
2273 send_bits(s, tree[c].Code, tree[c].Len); }
2340 int n; /* iterates over tree elements */
2346 /* number of codes at each bit length for an optimal tree */
2390 /* Construct the codes of the static literal tree */
2398 * tree construction to get a canonical Huffman tree (longest code
2403 /* The static distance tree is trivial: */
2478 * Initialize the tree data structures for a new zlib stream.
2510 int n; /* iterates over tree elements */
2523 /* Index within the heap array of least frequent node in the Huffman tree */
2530 #define pqremove(s, tree, top) \
2534 pqdownheap(s, tree, SMALLEST); \
2538 * Compares to subtrees, using the tree depth as tie breaker when
2541 #define smaller(tree, n, m, depth) \
2542 (tree[n].Freq < tree[m].Freq || \
2543 (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
2546 * Restore the heap property by moving down the tree starting at node k,
2552 ct_data *tree, /* the tree to restore */
2560 smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
2564 if (smaller(tree, v, s->heap[j], s->depth)) break;
2569 /* And continue down the tree, setting j to the left son of k */
2576 * Compute the optimal bit lengths for a tree and update the total bit length
2579 * above are the tree nodes sorted by increasing frequency.
2586 tree_desc *desc) /* the tree descriptor */
2588 ct_data *tree = desc->dyn_tree;
2595 int n, m; /* iterate over the tree elements */
2604 * overflow in the case of the bit length tree).
2606 tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
2610 bits = tree[tree[n].Dad].Len + 1;
2612 tree[n].Len = (ush)bits;
2613 /* We overwrite tree[n].Dad which is no longer needed */
2620 f = tree[n].Freq;
2633 s->bl_count[bits]--; /* move one leaf down the tree */
2652 if (tree[m].Len != (unsigned) bits) {
2653 Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
2654 s->opt_len += ((long)bits - (long)tree[m].Len)
2655 *(long)tree[m].Freq;
2656 tree[m].Len = (ush)bits;
2664 * Generate the codes for a given tree and bit counts (which need not be
2667 * the given tree and the field len is set for all tree elements.
2668 * OUT assertion: the field code is set for all tree elements of non
2671 local void gen_codes (ct_data *tree, /* the tree to decorate */
2694 int len = tree[n].Len;
2697 tree[n].Code = bi_reverse(next_code[len]++, len);
2699 Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
2700 n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
2705 * Construct one Huffman tree and assigns the code bit strings and lengths.
2707 * IN assertion: the field freq is set for all tree elements.
2713 tree_desc *desc) /* the tree descriptor */
2715 ct_data *tree = desc->dyn_tree;
2729 if (tree[n].Freq != 0) {
2733 tree[n].Len = 0;
2744 tree[node].Freq = 1;
2751 /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
2754 for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
2756 /* Construct the Huffman tree by repeatedly combining the least two
2759 node = elems; /* next internal node of the tree */
2761 pqremove(s, tree, n); /* n = node of least frequency */
2768 tree[node].Freq = tree[n].Freq + tree[m].Freq;
2770 tree[n].Dad = tree[m].Dad = (ush)node;
2772 if (tree == s->bl_tree) {
2774 node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
2779 pqdownheap(s, tree, SMALLEST);
2791 gen_codes ((ct_data *)tree, max_code, s->bl_count);
2795 * Scan a literal or distance tree to determine the frequencies of the codes
2796 * in the bit length tree.
2799 ct_data *tree, /* the tree to be scanned */
2802 int n; /* iterates over all tree elements */
2805 int nextlen = tree[0].Len; /* length of next code */
2811 tree[max_code+1].Len = (ush)0xffff; /* guard */
2814 curlen = nextlen; nextlen = tree[n+1].Len;
2839 * Send a literal or distance tree in compressed form, using the codes in
2843 ct_data *tree, /* the tree to be scanned */
2846 int n; /* iterates over all tree elements */
2849 int nextlen = tree[0].Len; /* length of next code */
2854 /* tree[max_code+1].Len = -1; */ /* guard already set */
2858 curlen = nextlen; nextlen = tree[n+1].Len;
2889 * Construct the Huffman tree for the bit lengths and return the index in
2900 /* Build the bit length tree: */
2902 /* opt_len now includes the length of the tree representations, except
2913 /* Update opt_len to include the bit length tree and counts */
2923 * lengths of the bit length codes, the literal tree and the distance tree.
2927 int lcodes, int dcodes, int blcodes) /* number of codes for each tree */
2942 Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
2944 send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
2945 Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
2947 send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
2948 Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
3040 * the compressed block data, excluding the tree representations.
3043 /* Build the bit length tree for the above two trees, and get the index
3168 const ct_data *ltree, /* literal tree */
3169 const ct_data *dtree) /* distance tree */
3798 /* Maximum size of dynamic tree. The maximum found in a long but non-
3807 uIntf *, /* bits tree desired/actual depth */
3808 inflate_huft * FAR *, /* bits tree result */
3818 inflate_huft * FAR *, /* literal/length tree result */
3819 inflate_huft * FAR *, /* distance tree result */
3826 inflate_huft * FAR *, /* literal/length tree result */
3827 inflate_huft * FAR *, /* distance tree result */
3882 BTREE, /* get bit lengths tree for a dynamic block */
3903 uInt bb; /* bit length tree depth */
3904 inflate_huft *tb; /* bit length decoding tree */
3916 inflate_huft *hufts; /* single malloc for tree space */
3996 end-of-block. Note however that the static length tree defines
4010 10. In the tree reconstruction algorithm, Code = Code + Increment
4208 Tracev((stderr, "inflate: bits tree ok\n"));
4720 uIntf *bb, /* bits tree desired/actual depth */
4721 inflate_huft * FAR *tb, /* bits tree result */
4734 z->msg = "oversubscribed dynamic bit lengths tree";
4737 z->msg = "incomplete dynamic bit lengths tree";
4750 inflate_huft * FAR *tl, /* literal/length tree result */
4751 inflate_huft * FAR *td, /* distance tree result */
4763 /* build literal/length tree */
4768 z->msg = "oversubscribed literal/length tree";
4771 z->msg = "incomplete literal/length tree";
4778 /* build distance tree */
4783 z->msg = "oversubscribed distance tree";
4789 z->msg = "incomplete distance tree";
4794 z->msg = "empty distance tree with lengths";
4979 inflate_huft * FAR *tl, /* literal/length tree result */
4980 inflate_huft * FAR *td, /* distance tree result */
5096 inflate_huft *tree; /* pointer into tree */
5098 } code; /* if LEN or DIST, where in tree */
5109 inflate_huft *ltree; /* literal/length/eob tree */
5110 inflate_huft *dtree; /* distance tree */
5169 c->sub.code.tree = c->ltree;
5175 t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
5197 c->sub.code.tree = t + t->base;
5216 c->sub.code.tree = c->dtree;
5223 t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
5236 c->sub.code.tree = t + t->base;
5445 uInt ml; /* mask for literal/length tree */
5446 uInt md; /* mask for distance tree */