Lines Matching defs:code
13 * Each code tree is stored in a compressed form which is itself
14 * a Huffman encoding of the lengths of all the code strings (in
15 * ascending order by source values). The actual code strings are
51 /* end of block literal code */
62 local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
65 local const int extra_dbits[D_CODES] /* extra bits for each distance code */
68 local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
105 /* length code for each normalized match length (0 == MIN_MATCH) */
108 /* First normalized length for each code (0 = MIN_MATCH) */
111 /* First normalized distance for each code (0 = distance of 1) */
119 const intf *extra_bits; /* extra bits for each code or NULL */
159 * Reverse the first len bits of a code, using straightforward code (a faster
163 local unsigned bi_reverse(unsigned code, int len)
167 res |= code & 1;
168 code >>= 1, res <<= 1;
211 * OUT assertion: the field code is set for all tree elements of non
212 * zero code length.
216 ush next_code[MAX_BITS+1]; /* next code value for each bit length */
217 unsigned code = 0; /* running code value */
219 int n; /* code index */
221 /* The distribution counts are first used to generate the code values
225 code = (code + bl_count[bits - 1]) << 1;
226 next_code[bits] = (ush)code;
228 /* Check that the bit counts in bl_count are consistent. The last code
231 Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
252 /* Send a code of the given tree. c and tree must not have side effects */
315 int code; /* code value */
331 /* Initialize the mapping length (0..255) -> length code (0..28) */
333 for (code = 0; code < LENGTH_CODES-1; code++) {
334 base_length[code] = length;
335 for (n = 0; n < (1 << extra_lbits[code]); n++) {
336 _length_code[length++] = (uch)code;
341 * in two different ways: code 284 + 5 bits or code 285, so we
344 _length_code[length - 1] = (uch)code;
346 /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
348 for (code = 0 ; code < 16; code++) {
349 base_dist[code] = dist;
350 for (n = 0; n < (1 << extra_dbits[code]); n++) {
351 _dist_code[dist++] = (uch)code;
356 for ( ; code < D_CODES; code++) {
357 base_dist[code] = dist << 7;
358 for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {
359 _dist_code[256 + dist++] = (uch)code;
372 * tree construction to get a canonical Huffman tree (longest code
623 Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
637 * Construct one Huffman tree and assigns the code bit strings and lengths.
640 * OUT assertions: the fields len and code are set to the optimal bit length
641 * and corresponding code. The length opt_len is updated; static_len is
650 int max_code = -1; /* largest code with non zero frequency */
668 /* The pkzip format requires that at least one distance code exists,
670 * possible code. So to avoid special checks later on we force at least
734 int curlen; /* length of current code */
735 int nextlen = tree[0].Len; /* length of next code */
736 int count = 0; /* repeat count of the current code */
776 int curlen; /* length of current code */
777 int nextlen = tree[0].Len; /* length of next code */
778 int count = 0; /* repeat count of the current code */
818 * bl_order of the last bit length code to send.
822 int max_blindex; /* index of last bit length code of non zero freq */
867 Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
928 unsigned code; /* the code to send */
945 code = _length_code[lc];
946 send_code(s, code + LITERALS + 1, ltree); /* send length code */
947 extra = extra_lbits[code];
949 lc -= base_length[code];
953 code = d_code(dist);
954 Assert (code < D_CODES, "bad d_code");
956 send_code(s, code, dtree); /* send the distance code */
957 extra = extra_dbits[code];
959 dist -= (unsigned)base_dist[code];
1024 int max_blindex = 0; /* index of last bit length code of non zero freq */
1046 * in bl_order of the last bit length code to send.