Lines Matching refs: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
53 /* end of block literal code */
64 static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
67 static const int extra_dbits[D_CODES] /* extra bits for each distance code */
70 static const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
102 /* length code for each normalized match length (0 == MIN_MATCH) */
105 /* First normalized length for each code (0 = MIN_MATCH) */
108 /* First normalized distance for each code (0 = distance of 1) */
112 const int *extra_bits; /* extra bits for each code or NULL */
151 /* Send a code of the given tree. c and tree must not have side effects */
161 /* Mapping from a distance to a distance code. dist is the distance - 1 and
177 int code; /* code value */
184 /* Initialize the mapping length (0..255) -> length code (0..28) */
186 for (code = 0; code < LENGTH_CODES-1; code++) {
187 base_length[code] = length;
188 for (n = 0; n < (1<<extra_lbits[code]); n++) {
189 length_code[length++] = (uch)code;
194 * in two different ways: code 284 + 5 bits or code 285, so we
197 length_code[length-1] = (uch)code;
199 /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
201 for (code = 0 ; code < 16; code++) {
202 base_dist[code] = dist;
203 for (n = 0; n < (1<<extra_dbits[code]); n++) {
204 dist_code[dist++] = (uch)code;
209 for ( ; code < D_CODES; code++) {
210 base_dist[code] = dist << 7;
211 for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
212 dist_code[256 + dist++] = (uch)code;
225 * tree construction to get a canonical Huffman tree (longest code
423 Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
438 * OUT assertion: the field code is set for all tree elements of non
439 * zero code length.
443 int max_code, /* largest code with non zero frequency */
447 ush next_code[MAX_BITS+1]; /* next code value for each bit length */
448 ush code = 0; /* running code value */
450 int n; /* code index */
452 /* The distribution counts are first used to generate the code values
456 next_code[bits] = code = (code + bl_count[bits-1]) << 1;
458 /* Check that the bit counts in bl_count are consistent. The last code
461 Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
477 * Construct one Huffman tree and assigns the code bit strings and lengths.
480 * OUT assertions: the fields len and code are set to the optimal bit length
481 * and corresponding code. The length opt_len is updated; static_len is
493 int max_code = -1; /* largest code with non zero frequency */
511 /* The pkzip format requires that at least one distance code exists,
513 * possible code. So to avoid special checks later on we force at least
575 int max_code /* and its largest code of non zero frequency */
580 int curlen; /* length of current code */
581 int nextlen = tree[0].Len; /* length of next code */
582 int count = 0; /* repeat count of the current code */
621 int max_code /* and its largest code of non zero frequency */
626 int curlen; /* length of current code */
627 int nextlen = tree[0].Len; /* length of next code */
628 int count = 0; /* repeat count of the current code */
668 * bl_order of the last bit length code to send.
674 int max_blindex; /* index of last bit length code of non zero freq */
723 Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
752 /* Send just the `stored block' type code without any length bytes or data.
767 * The current inflate code requires 9 bits of lookahead. If the
768 * last two codes for the previous block (real code plus EOB) were coded
770 * the last real code. In this case we send two empty static blocks instead
772 * To simplify the code, we assume the worst case of last real code encoded
784 * (10 - bi_valid) bits. The lookahead for the last real code (before
810 int max_blindex = 0; /* index of last bit length code of non zero freq */
831 * in bl_order of the last bit length code to send.
973 unsigned code; /* the code to send */
984 code = length_code[lc];
985 send_code(s, code+LITERALS+1, ltree); /* send the length code */
986 extra = extra_lbits[code];
988 lc -= base_length[code];
992 code = d_code(dist);
993 Assert (code < D_CODES, "bad d_code");
995 send_code(s, code, dtree); /* send the distance code */
996 extra = extra_dbits[code];
998 dist -= base_dist[code];