xref: /rk3399_ARM-atf/lib/zlib/inftrees.h (revision fd39217a740d1ef672cce8e204a34d1e4b9fd428)
1221b1638SMasahiro Yamada /* inftrees.h -- header to use inftrees.c
2221b1638SMasahiro Yamada  * Copyright (C) 1995-2005, 2010 Mark Adler
3221b1638SMasahiro Yamada  * For conditions of distribution and use, see copyright notice in zlib.h
4221b1638SMasahiro Yamada  */
5221b1638SMasahiro Yamada 
6221b1638SMasahiro Yamada /* WARNING: this file should *not* be used by applications. It is
7221b1638SMasahiro Yamada    part of the implementation of the compression library and is
8221b1638SMasahiro Yamada    subject to change. Applications should only use zlib.h.
9221b1638SMasahiro Yamada  */
10221b1638SMasahiro Yamada 
11221b1638SMasahiro Yamada /* Structure for decoding tables.  Each entry provides either the
12221b1638SMasahiro Yamada    information needed to do the operation requested by the code that
13221b1638SMasahiro Yamada    indexed that table entry, or it provides a pointer to another
14221b1638SMasahiro Yamada    table that indexes more bits of the code.  op indicates whether
15221b1638SMasahiro Yamada    the entry is a pointer to another table, a literal, a length or
16221b1638SMasahiro Yamada    distance, an end-of-block, or an invalid code.  For a table
17221b1638SMasahiro Yamada    pointer, the low four bits of op is the number of index bits of
18221b1638SMasahiro Yamada    that table.  For a length or distance, the low four bits of op
19221b1638SMasahiro Yamada    is the number of extra bits to get after the code.  bits is
20221b1638SMasahiro Yamada    the number of bits in this code or part of the code to drop off
21221b1638SMasahiro Yamada    of the bit buffer.  val is the actual byte to output in the case
22221b1638SMasahiro Yamada    of a literal, the base length or distance, or the offset from
23221b1638SMasahiro Yamada    the current table to the next table.  Each entry is four bytes. */
24221b1638SMasahiro Yamada typedef struct {
25221b1638SMasahiro Yamada     unsigned char op;           /* operation, extra bits, table bits */
26221b1638SMasahiro Yamada     unsigned char bits;         /* bits in this part of the code */
27221b1638SMasahiro Yamada     unsigned short val;         /* offset in table or code value */
28221b1638SMasahiro Yamada } code;
29221b1638SMasahiro Yamada 
30221b1638SMasahiro Yamada /* op values as set by inflate_table():
31221b1638SMasahiro Yamada     00000000 - literal
32221b1638SMasahiro Yamada     0000tttt - table link, tttt != 0 is the number of table index bits
33221b1638SMasahiro Yamada     0001eeee - length or distance, eeee is the number of extra bits
34221b1638SMasahiro Yamada     01100000 - end of block
35221b1638SMasahiro Yamada     01000000 - invalid code
36221b1638SMasahiro Yamada  */
37221b1638SMasahiro Yamada 
38221b1638SMasahiro Yamada /* Maximum size of the dynamic table.  The maximum number of code structures is
39221b1638SMasahiro Yamada    1444, which is the sum of 852 for literal/length codes and 592 for distance
40221b1638SMasahiro Yamada    codes.  These values were found by exhaustive searches using the program
41a194255dSDaniel Boulby    examples/enough.c found in the zlib distribution.  The arguments to that
42221b1638SMasahiro Yamada    program are the number of symbols, the initial root table size, and the
43221b1638SMasahiro Yamada    maximum bit length of a code.  "enough 286 9 15" for literal/length codes
44221b1638SMasahiro Yamada    returns returns 852, and "enough 30 6 15" for distance codes returns 592.
45221b1638SMasahiro Yamada    The initial root table size (9 or 6) is found in the fifth argument of the
46221b1638SMasahiro Yamada    inflate_table() calls in inflate.c and infback.c.  If the root table size is
47221b1638SMasahiro Yamada    changed, then these maximum sizes would be need to be recalculated and
48221b1638SMasahiro Yamada    updated. */
49221b1638SMasahiro Yamada #define ENOUGH_LENS 852
50221b1638SMasahiro Yamada #define ENOUGH_DISTS 592
51221b1638SMasahiro Yamada #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
52221b1638SMasahiro Yamada 
53221b1638SMasahiro Yamada /* Type of code to build for inflate_table() */
54221b1638SMasahiro Yamada typedef enum {
55221b1638SMasahiro Yamada     CODES,
56221b1638SMasahiro Yamada     LENS,
57221b1638SMasahiro Yamada     DISTS
58221b1638SMasahiro Yamada } codetype;
59221b1638SMasahiro Yamada 
60*fd39217aSManish Pandey int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
61221b1638SMasahiro Yamada                                 unsigned codes, code FAR * FAR *table,
62*fd39217aSManish Pandey                                 unsigned FAR *bits, unsigned short FAR *work);
63