Lines Matching defs:in
4 * For conditions of distribution and use, see copyright notice in puff.h
20 * assumed to be 16 bits, for arrays in order to to conserve memory. The code
23 * In the comments below are "Format notes" that describe the inflate process
39 * - Simplify offs[] index in construct()
54 * - Add braces in puff() for else do [Gailly]
67 * - Add option in TEST code for puff to write the data
68 * - Add option in TEST code to skip input bytes
72 * 2.2 25 Apr 2010 - Fix bug in variable initializations [Oberhumer]
79 * 2.3 21 Jan 2013 - Check for invalid code length codes in dynamic blocks
91 #define MAXBITS 15 /* maximum bits in a code */
105 const unsigned char *in; /* input buffer */
106 unsigned long inlen; /* available input at in */
109 int bitcnt; /* number of bits in bit buffer */
117 * eight bits in the buffer. bits() works properly for need == 0.
121 * - Bits are stored in bytes from the least significant bit to the most
135 val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */
154 * bits in the byte that has the last bit of the type, as many as seven, are
175 len = s->in[s->incnt++];
176 len |= s->in[s->incnt++] << 8;
177 if (s->in[s->incnt++] != (~len & 0xff) ||
178 s->in[s->incnt++] != ((~len >> 8) & 0xff))
181 /* copy len bytes from in to out */
188 s->out[s->outcnt++] = s->in[s->incnt++];
201 * each length, which for a canonical code are stepped through in order.
202 * symbol[] are the symbol values in canonical order, where the number of
203 * entries is the sum of the counts in count[]. The decoding process can be
204 * seen in the function decode() below.
219 * - The codes as stored in the compressed data are bit-reversed relative to
222 * build the code value reversed from what is in the stream in order to
224 * scheme (as used in zlib) does not need to do this reversal.
232 * in the deflate format. See the format notes for fixed() and dynamic().
237 int len; /* current number of bits in code */
241 int index; /* index of first code of length len in symbol table */
265 int len; /* current number of bits in code */
269 int index; /* index of first code of length len in symbol table */
271 int left; /* bits left in next or left to process */
300 bitbuf = s->in[s->incnt++];
323 * of the n symbols not in the code. So n - h->count[0] is the number of
325 * one symbol, which is an error in a dynamic block.
327 * Assumption: for all i in 0..n-1, 0 <= length[i] <= MAXBITS
328 * This is assured by the construction of the length arrays in dynamic() and
334 * codes and any code with a single symbol which in deflate is coded as one
337 * - Within a given code length, the symbols are kept in ascending order for
345 short offs[MAXBITS+1]; /* offsets in symbol table for each length */
370 * put symbols in
390 * coded distance to represent a string that occurs earlier in the
398 * to represent all of those. Lengths 3..10 and 258 are in fact represented
402 * length symbol. These are in the static arrays below, lens[] for the base
406 * often in highly redundant files. Note that 258 can also be coded as the
415 * corresponding number of extra bits are below in the static arrays dist[]
420 * copy is from distance bytes back in the output stream, copying for length
434 * defined to do the wrong thing in this case.
518 * which the size of the code descriptions in a dynamic block exceeds the
522 * can be seen in the "for" loops below.
525 * and should result in an error if received. This cannot be implemented
526 * simply as an incomplete code since those two symbols are in the "middle"
532 * in an error if received. Since all of the distance codes are the same
588 * the actual bits of the codes are generated in an unambiguous way simply
589 * from the number of bits in each code. Therefore the code descriptions
592 * - The code lengths are stored in order for the symbols, so lengths are
596 * - If a symbol is not used in the block, this is represented by a zero as
598 * that no code should be created for this symbol. There is no way in the
601 * - The maximum number of bits in a code is 15, so the possible lengths for
606 * code, then in fact that code could be represented with zero bits. However
607 * in deflate, that code has to be at least one bit. So for example, if
608 * only a single distance base symbol appears in a block, then it will be
609 * represented by a single code of length one, in particular one 0 bit. This
611 * and should result in an error. So incomplete distance codes of one symbol
624 * are themselves compressed using Huffman codes and run-length encoding. In
639 * a better name!) in the code descriptions. For the literal/length and
641 * code. The code length code lengths are received in a permuted order (see
644 * to be seen in a dynamic code description, hence what may appear initially
660 * decoding actual compressed data in the block.
662 * - For reference, a "typical" size for the code description in a dynamic
667 int nlen, ndist, ncode; /* number of lengths in descriptor */
683 /* get number of lengths in each table, check lengths */
710 if (symbol < 16) /* length in 0..15 */
752 * On success, the return value of puff() is zero. If there is an error in the
753 * source data, i.e. it is not in the deflate format, then a negative value is
755 * output space, then a positive error is returned. In that case, destlen and
757 * provision of more input data or more output space. In the case of invalid
762 * no output written. For this dest must be (unsigned char *)0. In this case,
780 * -10: invalid literal/length or distance code in fixed or dynamic block
781 * -11: distance is too far back in fixed or dynamic block
789 * - The leftover bits in the last byte of the deflate data after the last
808 s.in = source;