Home | History | Annotate | Download | only in zlib

Lines Matching refs:Code

15  *      Each code tree is stored in a compressed form which is itself
16 * a Huffman encoding of the lengths of all the code strings (in
17 * ascending order by source values). The actual code strings are
53 /* end of block literal code */
64 local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
67 local const int extra_dbits[D_CODES] /* extra bits for each distance code */
70 local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
107 /* length code for each normalized match length (0 == MIN_MATCH) */
110 /* First normalized length for each code (0 = MIN_MATCH) */
113 /* First normalized distance for each code (0 = distance of 1) */
121 const intf *extra_bits; /* extra bits for each code or NULL */
152 * Reverse the first len bits of a code, using straightforward code (a faster
156 local unsigned bi_reverse(unsigned code, int len) {
159 res |= code & 1;
160 code >>= 1, res <<= 1;
201 * OUT assertion: the field code is set for all tree elements of non
202 * zero code length.
205 ush next_code[MAX_BITS+1]; /* next code value for each bit length */
206 unsigned code = 0; /* running code value */
208 int n; /* code index */
210 /* The distribution counts are first used to generate the code values
214 code = (code + bl_count[bits - 1]) << 1;
215 next_code[bits] = (ush)code;
217 /* Check that the bit counts in bl_count are consistent. The last code
220 Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
228 tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
231 n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
240 # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
241 /* Send a code of the given tree. c and tree must not have side effects */
246 send_bits(s, tree[c].Code, tree[c].Len); }
302 int code; /* code value */
318 /* Initialize the mapping length (0..255) -> length code (0..28) */
320 for (code = 0; code < LENGTH_CODES-1; code++) {
321 base_length[code] = length;
322 for (n = 0; n < (1 << extra_lbits[code]); n++) {
323 _length_code[length++] = (uch)code;
328 * in two different ways: code 284 + 5 bits or code 285, so we
331 _length_code[length - 1] = (uch)code;
333 /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
335 for (code = 0 ; code < 16; code++) {
336 base_dist[code] = dist;
337 for (n = 0; n < (1 << extra_dbits[code]); n++) {
338 _dist_code[dist++] = (uch)code;
343 for ( ; code < D_CODES; code++) {
344 base_dist[code] = dist << 7;
345 for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {
346 _dist_code[256 + dist++] = (uch)code;
359 * tree construction to get a canonical Huffman tree (longest code
367 static_dtree[n].Code = bi_reverse((unsigned)n, 5);
399 fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
405 fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
606 Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
620 * Construct one Huffman tree and assigns the code bit strings and lengths.
623 * OUT assertions: the fields len and code are set to the optimal bit length
624 * and corresponding code. The length opt_len is updated; static_len is
632 int max_code = -1; /* largest code with non zero frequency */
650 /* The pkzip format requires that at least one distance code exists,
652 * possible code. So to avoid special checks later on we force at least
715 int curlen; /* length of current code */
716 int nextlen = tree[0].Len; /* length of next code */
717 int count = 0; /* repeat count of the current code */
756 int curlen; /* length of current code */
757 int nextlen = tree[0].Len; /* length of next code */
758 int count = 0; /* repeat count of the current code */
798 * bl_order of the last bit length code to send.
801 int max_blindex; /* index of last bit length code of non zero freq */
845 Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
905 unsigned code; /* the code to send */
922 code = _length_code[lc];
923 send_code(s, code + LITERALS + 1, ltree); /* send length code */
924 extra = extra_lbits[code];
926 lc -= base_length[code];
930 code = d_code(dist);
931 Assert (code < D_CODES, "bad d_code");
933 send_code(s, code, dtree); /* send the distance code */
934 extra = extra_dbits[code];
936 dist -= (unsigned)base_dist[code];
1000 int max_blindex = 0; /* index of last bit length code of non zero freq */
1022 * in bl_order of the last bit length code to send.