Lines Matching full:codes
49 * - Fix fixed codes table error
63 * 1.8 9 Jan 2004 - Added some comments on no distance codes case
79 * 2.3 21 Jan 2013 - Check for invalid code length codes in dynamic blocks
92 #define MAXLCODES 286 /* maximum number of literal/length codes */
93 #define MAXDCODES 30 /* maximum number of distance codes */
94 #define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */
95 #define FIXLCODES 288 /* number of fixed literal/length codes */
219 * - The codes as stored in the compressed data are bit-reversed relative to
220 * a simple integer ordering of codes of the same lengths. Hence below the
226 * - The first code for the shortest length is all zeros. Subsequent codes of
231 * - Incomplete codes are handled by this decoder, since they are permitted
240 int count; /* number of codes of length len */ in decode()
254 return -10; /* ran out of codes */ in decode()
268 int count; /* number of codes of length len */ in decode()
272 short *next; /* next number of codes */ in decode()
304 return -10; /* ran out of codes */ in decode()
311 * codes. Those tables are the number of codes of each length, and the symbols
320 * codes past the end of the incomplete lengths.
324 * codes. This is useful for checking for incomplete codes that have more than
333 * - Permitted and expected examples of incomplete codes are one of the fixed
334 * codes and any code with a single symbol which in deflate is coded as one
344 int left; /* number of possible codes left of current length */ in construct()
347 /* count number of codes of each length */ in construct()
352 if (h->count[0] == n) /* no codes! */ in construct()
358 left <<= 1; /* one more bit, double codes left */ in construct()
359 left -= h->count[len]; /* deduct count from possible codes */ in construct()
382 * Decode literal/length and distance codes until an end-of-block code.
436 local int codes(struct state *s, in codes() function
443 static const short lens[29] = { /* Size base for length codes 257..285 */ in codes()
446 static const short lext[29] = { /* Extra bits for length codes 257..285 */ in codes()
449 static const short dists[30] = { /* Offset base for distance codes 0..29 */ in codes()
453 static const short dext[30] = { /* Extra bits for distance codes 0..29 */ in codes()
513 * Process a fixed codes block.
519 * benefit of custom codes for that block. For fixed codes, no bits are
521 * codes and distance codes are fixed. The specific lengths for each symbol
531 * - The fixed distance codes also have two invalid symbols that should result
532 * in an error if received. Since all of the distance codes are the same
534 * codes are detected while decoding.
575 return codes(s, &lencode, &distcode); in fixed()
579 * Process a dynamic codes block.
584 * distance codes for that block. New dynamic blocks allow the compressor to
585 * rapidly adapt to changing data with new codes optimized for that data.
587 * - The codes used by the deflate format are "canonical", which means that
588 * the actual bits of the codes are generated in an unambiguous way simply
611 * and should result in an error. So incomplete distance codes of one symbol
612 * should be permitted, and the receipt of invalid codes should be handled.
618 * literal/length codes of one symbol should also be permitted.
620 * - If there are only literal codes and no lengths, then there are no distance
621 * codes. This is represented by one distance code with zero bits.
624 * are themselves compressed using Huffman codes and run-length encoding. In
640 * distance codes, lengths after those provided are considered zero, i.e. no
643 * likely. As it turns out, very short and very long codes are less likely
653 * three counts for the number of code lengths for the literal/length codes,
654 * the distance codes, and the code length codes. This is followed by the
658 * set of lengths using the code length codes. Codes are constructed from
673 struct huffman lencode, distcode; /* length and distance codes */ in dynamic()
674 static const short order[19] = /* permutation of code length codes */ in dynamic()
696 /* build huffman table for code lengths codes (use lencode temporarily) */ in dynamic()
735 /* build huffman table for literal/length codes */ in dynamic()
740 /* build huffman table for distance codes */ in dynamic()
746 return codes(s, &lencode, &distcode); in dynamic()
766 * The return codes are:
773 * -3: dynamic block code description: too many length or distance codes
774 * -4: dynamic block code description: code lengths codes incomplete