Blame zlib-src/inftrees.h

Packit d03632
/* inftrees.h -- header to use inftrees.c
Packit d03632
 * Copyright (C) 1995-2005, 2010 Mark Adler
Packit d03632
 * For conditions of distribution and use, see copyright notice in zlib.h
Packit d03632
 */
Packit d03632
Packit d03632
/* WARNING: this file should *not* be used by applications. It is
Packit d03632
   part of the implementation of the compression library and is
Packit d03632
   subject to change. Applications should only use zlib.h.
Packit d03632
 */
Packit d03632
Packit d03632
/* Structure for decoding tables.  Each entry provides either the
Packit d03632
   information needed to do the operation requested by the code that
Packit d03632
   indexed that table entry, or it provides a pointer to another
Packit d03632
   table that indexes more bits of the code.  op indicates whether
Packit d03632
   the entry is a pointer to another table, a literal, a length or
Packit d03632
   distance, an end-of-block, or an invalid code.  For a table
Packit d03632
   pointer, the low four bits of op is the number of index bits of
Packit d03632
   that table.  For a length or distance, the low four bits of op
Packit d03632
   is the number of extra bits to get after the code.  bits is
Packit d03632
   the number of bits in this code or part of the code to drop off
Packit d03632
   of the bit buffer.  val is the actual byte to output in the case
Packit d03632
   of a literal, the base length or distance, or the offset from
Packit d03632
   the current table to the next table.  Each entry is four bytes. */
Packit d03632
typedef struct {
Packit d03632
    unsigned char op;           /* operation, extra bits, table bits */
Packit d03632
    unsigned char bits;         /* bits in this part of the code */
Packit d03632
    unsigned short val;         /* offset in table or code value */
Packit d03632
} code;
Packit d03632
Packit d03632
/* op values as set by inflate_table():
Packit d03632
    00000000 - literal
Packit d03632
    0000tttt - table link, tttt != 0 is the number of table index bits
Packit d03632
    0001eeee - length or distance, eeee is the number of extra bits
Packit d03632
    01100000 - end of block
Packit d03632
    01000000 - invalid code
Packit d03632
 */
Packit d03632
Packit d03632
/* Maximum size of the dynamic table.  The maximum number of code structures is
Packit d03632
   1444, which is the sum of 852 for literal/length codes and 592 for distance
Packit d03632
   codes.  These values were found by exhaustive searches using the program
Packit d03632
   examples/enough.c found in the zlib distribtution.  The arguments to that
Packit d03632
   program are the number of symbols, the initial root table size, and the
Packit d03632
   maximum bit length of a code.  "enough 286 9 15" for literal/length codes
Packit d03632
   returns returns 852, and "enough 30 6 15" for distance codes returns 592.
Packit d03632
   The initial root table size (9 or 6) is found in the fifth argument of the
Packit d03632
   inflate_table() calls in inflate.c and infback.c.  If the root table size is
Packit d03632
   changed, then these maximum sizes would be need to be recalculated and
Packit d03632
   updated. */
Packit d03632
#define ENOUGH_LENS 852
Packit d03632
#define ENOUGH_DISTS 592
Packit d03632
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
Packit d03632
Packit d03632
/* Type of code to build for inflate_table() */
Packit d03632
typedef enum {
Packit d03632
    CODES,
Packit d03632
    LENS,
Packit d03632
    DISTS
Packit d03632
} codetype;
Packit d03632
Packit d03632
int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
Packit d03632
                             unsigned codes, code FAR * FAR *table,
Packit d03632
                             unsigned FAR *bits, unsigned short FAR *work));