Lines Matching defs:codes

49  *                      - Fix fixed codes table error
63 * 1.8 9 Jan 2004 - Added some comments on no distance codes case
91 #define MAXLCODES 286 /* maximum number of literal/length codes */
92 #define MAXDCODES 30 /* maximum number of distance codes */
93 #define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */
94 #define FIXLCODES 288 /* number of fixed literal/length codes */
218 * - The codes as stored in the compressed data are bit-reversed relative to
219 * a simple integer ordering of codes of the same lengths. Hence below the
225 * - The first code for the shortest length is all zeros. Subsequent codes of
230 * - Incomplete codes are handled by this decoder, since they are permitted
239 int count; /* number of codes of length len */
253 return -10; /* ran out of codes */
267 int count; /* number of codes of length len */
271 short *next; /* next number of codes */
303 return -10; /* ran out of codes */
310 * codes. Those tables are the number of codes of each length, and the symbols
319 * codes past the end of the incomplete lengths.
323 * codes. This is useful for checking for incomplete codes that have more than
332 * - Permitted and expected examples of incomplete codes are one of the fixed
333 * codes and any code with a single symbol which in deflate is coded as one
343 int left; /* number of possible codes left of current length */
346 /* count number of codes of each length */
351 if (h->count[0] == n) /* no codes! */
357 left <<= 1; /* one more bit, double codes left */
358 left -= h->count[len]; /* deduct count from possible codes */
381 * Decode literal/length and distance codes until an end-of-block code.
435 local int codes(struct state *s,
442 static const short lens[29] = { /* Size base for length codes 257..285 */
445 static const short lext[29] = { /* Extra bits for length codes 257..285 */
448 static const short dists[30] = { /* Offset base for distance codes 0..29 */
452 static const short dext[30] = { /* Extra bits for distance codes 0..29 */
512 * Process a fixed codes block.
518 * benefit of custom codes for that block. For fixed codes, no bits are
520 * codes and distance codes are fixed. The specific lengths for each symbol
530 * - The fixed distance codes also have two invalid symbols that should result
531 * in an error if received. Since all of the distance codes are the same
533 * codes are detected while decoding.
574 return codes(s, &lencode, &distcode);
578 * Process a dynamic codes block.
583 * distance codes for that block. New dynamic blocks allow the compressor to
584 * rapidly adapt to changing data with new codes optimized for that data.
586 * - The codes used by the deflate format are "canonical", which means that
587 * the actual bits of the codes are generated in an unambiguous way simply
610 * and should result in an error. So incomplete distance codes of one symbol
611 * should be permitted, and the receipt of invalid codes should be handled.
617 * literal/length codes of one symbol should also be permitted.
619 * - If there are only literal codes and no lengths, then there are no distance
620 * codes. This is represented by one distance code with zero bits.
623 * are themselves compressed using Huffman codes and run-length encoding. In
639 * distance codes, lengths after those provided are considered zero, i.e. no
642 * likely. As it turns out, very short and very long codes are less likely
652 * three counts for the number of code lengths for the literal/length codes,
653 * the distance codes, and the code length codes. This is followed by the
657 * set of lengths using the code length codes. Codes are constructed from
672 struct huffman lencode, distcode; /* length and distance codes */
673 static const short order[19] = /* permutation of code length codes */
695 /* build huffman table for code lengths codes (use lencode temporarily) */
732 /* build huffman table for literal/length codes */
737 /* build huffman table for distance codes */
743 return codes(s, &lencode, &distcode);
763 * The return codes are:
770 * -3: dynamic block code description: too many length or distance codes
771 * -4: dynamic block code description: code lengths codes incomplete