| 1 | /* |
|---|
| 2 | * $Id: //suprahd/releases/suprahd_163/suprahd_ztvapp640_163/drivers/graphics/ZLIB/infutil.h#1 $ |
|---|
| 3 | * $Revision: #1 $ |
|---|
| 4 | * $DateTime: 2006/02/24 17:51:46 $ |
|---|
| 5 | * $Change: 42566 $ |
|---|
| 6 | * $Author: pryush.sharma $ |
|---|
| 7 | */ |
|---|
| 8 | |
|---|
| 9 | /* infutil.h -- types and macros common to blocks and codes |
|---|
| 10 | * Copyright (C) 1995-1998 Mark Adler |
|---|
| 11 | * For conditions of distribution and use, see copyright notice in zlib.h |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | /* WARNING: this file should *not* be used by applications. It is |
|---|
| 15 | part of the implementation of the compression library and is |
|---|
| 16 | subject to change. Applications should only use zlib.h. |
|---|
| 17 | */ |
|---|
| 18 | |
|---|
| 19 | #ifndef _INFUTIL_H |
|---|
| 20 | #define _INFUTIL_H |
|---|
| 21 | |
|---|
| 22 | typedef enum { |
|---|
| 23 | TYPE, /* get type bits (3, including end bit) */ |
|---|
| 24 | LENS, /* get lengths for stored */ |
|---|
| 25 | STORED, /* processing stored block */ |
|---|
| 26 | TABLE, /* get table lengths */ |
|---|
| 27 | BTREE, /* get bit lengths tree for a dynamic block */ |
|---|
| 28 | DTREE, /* get length, distance trees for a dynamic block */ |
|---|
| 29 | CODES, /* processing fixed or dynamic block */ |
|---|
| 30 | DRY, /* output remaining window bytes */ |
|---|
| 31 | DONE, /* finished last block, done */ |
|---|
| 32 | BAD} /* got a data error--stuck here */ |
|---|
| 33 | inflate_block_mode; |
|---|
| 34 | |
|---|
| 35 | /* inflate blocks semi-private state */ |
|---|
| 36 | struct inflate_blocks_state { |
|---|
| 37 | |
|---|
| 38 | /* mode */ |
|---|
| 39 | inflate_block_mode mode; /* current inflate_block mode */ |
|---|
| 40 | |
|---|
| 41 | /* mode dependent information */ |
|---|
| 42 | union { |
|---|
| 43 | uInt left; /* if STORED, bytes left to copy */ |
|---|
| 44 | struct { |
|---|
| 45 | uInt table; /* table lengths (14 bits) */ |
|---|
| 46 | uInt index; /* index into blens (or border) */ |
|---|
| 47 | uIntf *blens; /* bit lengths of codes */ |
|---|
| 48 | uInt bb; /* bit length tree depth */ |
|---|
| 49 | inflate_huft *tb; /* bit length decoding tree */ |
|---|
| 50 | } trees; /* if DTREE, decoding info for trees */ |
|---|
| 51 | struct { |
|---|
| 52 | inflate_codes_statef |
|---|
| 53 | *codes; |
|---|
| 54 | } decode; /* if CODES, current state */ |
|---|
| 55 | } sub; /* submode */ |
|---|
| 56 | uInt last; /* true if this block is the last block */ |
|---|
| 57 | |
|---|
| 58 | /* mode independent information */ |
|---|
| 59 | uInt bitk; /* bits in bit buffer */ |
|---|
| 60 | uLong bitb; /* bit buffer */ |
|---|
| 61 | inflate_huft *hufts; /* single malloc for tree space */ |
|---|
| 62 | Bytef *window; /* sliding window */ |
|---|
| 63 | Bytef *end; /* one byte after sliding window */ |
|---|
| 64 | Bytef *read; /* window read pointer */ |
|---|
| 65 | Bytef *write; /* window write pointer */ |
|---|
| 66 | check_func checkfn; /* check function */ |
|---|
| 67 | uLong check; /* check on output */ |
|---|
| 68 | |
|---|
| 69 | }; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | /* defines for inflate input/output */ |
|---|
| 73 | /* update pointers and return */ |
|---|
| 74 | #define UPDBITS {s->bitb=b;s->bitk=k;} |
|---|
| 75 | #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} |
|---|
| 76 | #define UPDOUT {s->write=q;} |
|---|
| 77 | #define UPDATE_ZLIB {UPDBITS UPDIN UPDOUT} |
|---|
| 78 | #define LEAVE {UPDATE_ZLIB return inflate_flush(s,z,r);} |
|---|
| 79 | /* get bytes and bits */ |
|---|
| 80 | #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} |
|---|
| 81 | #define NEEDBYTE {if(n)r=Z_OK;else LEAVE} |
|---|
| 82 | #define NEXTBYTE (n--,*p++) |
|---|
| 83 | #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} |
|---|
| 84 | #define DUMPBITS(j) {b>>=(j);k-=(j);} |
|---|
| 85 | /* output bytes */ |
|---|
| 86 | #define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q) |
|---|
| 87 | #define LOADOUT {q=s->write;m=(uInt)WAVAIL;} |
|---|
| 88 | #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} |
|---|
| 89 | #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} |
|---|
| 90 | #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} |
|---|
| 91 | #define OUTBYTE(a) {*q++=(Byte)(a);m--;} |
|---|
| 92 | /* load local pointers */ |
|---|
| 93 | #define LOAD {LOADIN LOADOUT} |
|---|
| 94 | |
|---|
| 95 | /* masks for lower bits (size given to avoid silly warnings with Visual C++) */ |
|---|
| 96 | extern uInt inflate_mask[17]; |
|---|
| 97 | |
|---|
| 98 | /* copy as much as possible from the sliding window to the output area */ |
|---|
| 99 | extern int inflate_flush OF(( |
|---|
| 100 | inflate_blocks_statef *, |
|---|
| 101 | z_streamp , |
|---|
| 102 | int)); |
|---|
| 103 | |
|---|
| 104 | struct internal_state {int dummy;}; /* for buggy compilers */ |
|---|
| 105 | |
|---|
| 106 | #endif |
|---|