Mercurial > hg > CbC > CbC_gcc
annotate zlib/inffast.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | ae3a4bfb450b |
children | 04ced10e8804 |
rev | line source |
---|---|
51
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 /* inffast.c -- fast decoding |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 * Copyright (C) 1995-2004 Mark Adler |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 * For conditions of distribution and use, see copyright notice in zlib.h |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 #include "zutil.h" |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 #include "inftrees.h" |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 #include "inflate.h" |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 #include "inffast.h" |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 #ifndef ASMINF |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 /* Allow machine dependent optimization for post-increment or pre-increment. |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 Based on testing to date, |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 Pre-increment preferred for: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 - PowerPC G3 (Adler) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 - MIPS R5000 (Randers-Pehrson) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 Post-increment preferred for: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 - none |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 No measurable difference: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 - Pentium III (Anderson) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 - M68060 (Nikl) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 #ifdef POSTINC |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 # define OFF 0 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 # define PUP(a) *(a)++ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 #else |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 # define OFF 1 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 # define PUP(a) *++(a) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 #endif |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 /* |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 Decode literal, length, and distance codes and write out the resulting |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 literal and match bytes until either not enough input or output is |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 available, an end-of-block is encountered, or a data error is encountered. |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 When large enough input and output buffers are supplied to inflate(), for |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 example, a 16K input buffer and a 64K output buffer, more than 95% of the |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 inflate execution time is spent in this routine. |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 Entry assumptions: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 state->mode == LEN |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 strm->avail_in >= 6 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 strm->avail_out >= 258 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 start >= strm->avail_out |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 state->bits < 8 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 On return, state->mode is one of: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 LEN -- ran out of enough output space or enough available input |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 TYPE -- reached end of block code, inflate() to interpret next block |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 BAD -- error in block data |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 Notes: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 - The maximum input bits used by a length/distance pair is 15 bits for the |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 length code, 5 bits for the length extra, 15 bits for the distance code, |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 and 13 bits for the distance extra. This totals 48 bits, or six bytes. |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 Therefore if strm->avail_in >= 6, then there is enough input to avoid |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 checking for available input while decoding. |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 - The maximum bytes that a single length/distance pair can output is 258 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 bytes, which is the maximum length that can be coded. inflate_fast() |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 requires strm->avail_out >= 258 for each loop to avoid checking for |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 output space. |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 void inflate_fast(strm, start) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 z_streamp strm; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 unsigned start; /* inflate()'s starting value for strm->avail_out */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 struct inflate_state FAR *state; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 unsigned char FAR *in; /* local strm->next_in */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 unsigned char FAR *last; /* while in < last, enough input available */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 unsigned char FAR *out; /* local strm->next_out */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 unsigned char FAR *end; /* while out < end, enough space available */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 #ifdef INFLATE_STRICT |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 unsigned dmax; /* maximum distance from zlib header */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 #endif |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 unsigned wsize; /* window size or zero if not using window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
81 unsigned whave; /* valid bytes in the window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 unsigned write; /* window write index */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 unsigned long hold; /* local strm->hold */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 unsigned bits; /* local strm->bits */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 code const FAR *lcode; /* local strm->lencode */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 code const FAR *dcode; /* local strm->distcode */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 unsigned lmask; /* mask for first level of length codes */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 unsigned dmask; /* mask for first level of distance codes */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 code this; /* retrieved table entry */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 unsigned op; /* code bits, operation, extra bits, or */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 /* window position, window bytes to copy */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 unsigned len; /* match length, unused bytes */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 unsigned dist; /* match distance */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 unsigned char FAR *from; /* where to copy match from */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 /* copy state to local variables */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 state = (struct inflate_state FAR *)strm->state; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 in = strm->next_in - OFF; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 last = in + (strm->avail_in - 5); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 out = strm->next_out - OFF; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 beg = out - (start - strm->avail_out); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 end = out + (strm->avail_out - 257); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 #ifdef INFLATE_STRICT |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 dmax = state->dmax; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 #endif |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 wsize = state->wsize; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 whave = state->whave; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 write = state->write; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 window = state->window; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111 hold = state->hold; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 bits = state->bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 lcode = state->lencode; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 dcode = state->distcode; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 lmask = (1U << state->lenbits) - 1; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 dmask = (1U << state->distbits) - 1; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 /* decode literals and length/distances until end-of-block or not enough |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 input data or output space */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 do { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 if (bits < 15) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 hold += (unsigned long)(PUP(in)) << bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 bits += 8; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 hold += (unsigned long)(PUP(in)) << bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 bits += 8; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 this = lcode[hold & lmask]; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 dolen: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 op = (unsigned)(this.bits); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 hold >>= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 bits -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 op = (unsigned)(this.op); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 if (op == 0) { /* literal */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 "inflate: literal '%c'\n" : |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 "inflate: literal 0x%02x\n", this.val)); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 PUP(out) = (unsigned char)(this.val); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 else if (op & 16) { /* length base */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 len = (unsigned)(this.val); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 op &= 15; /* number of extra bits */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 if (op) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 if (bits < op) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 hold += (unsigned long)(PUP(in)) << bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 bits += 8; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 len += (unsigned)hold & ((1U << op) - 1); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148 hold >>= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 bits -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 Tracevv((stderr, "inflate: length %u\n", len)); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 if (bits < 15) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 hold += (unsigned long)(PUP(in)) << bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
154 bits += 8; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 hold += (unsigned long)(PUP(in)) << bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 bits += 8; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 this = dcode[hold & dmask]; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 dodist: |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 op = (unsigned)(this.bits); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 hold >>= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 bits -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 op = (unsigned)(this.op); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 if (op & 16) { /* distance base */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 dist = (unsigned)(this.val); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 op &= 15; /* number of extra bits */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 if (bits < op) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 hold += (unsigned long)(PUP(in)) << bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169 bits += 8; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170 if (bits < op) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 hold += (unsigned long)(PUP(in)) << bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
172 bits += 8; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
173 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 dist += (unsigned)hold & ((1U << op) - 1); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 #ifdef INFLATE_STRICT |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 if (dist > dmax) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 strm->msg = (char *)"invalid distance too far back"; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 state->mode = BAD; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 break; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 #endif |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 hold >>= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 bits -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 Tracevv((stderr, "inflate: distance %u\n", dist)); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 op = (unsigned)(out - beg); /* max distance in output */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 if (dist > op) { /* see if copy from window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 op = dist - op; /* distance back in window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 if (op > whave) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 strm->msg = (char *)"invalid distance too far back"; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
191 state->mode = BAD; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
192 break; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 from = window - OFF; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
195 if (write == 0) { /* very common case */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 from += wsize - op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 if (op < len) { /* some from window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 len -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199 do { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 } while (--op); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 from = out - dist; /* rest from output */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 else if (write < op) { /* wrap around window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206 from += wsize + write - op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
207 op -= write; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 if (op < len) { /* some from end of window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 len -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
210 do { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
211 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 } while (--op); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 from = window - OFF; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 if (write < len) { /* some from start of window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 op = write; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
216 len -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 do { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 } while (--op); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 from = out - dist; /* rest from output */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224 else { /* contiguous in window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 from += write - op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 if (op < len) { /* some from window */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 len -= op; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 do { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
230 } while (--op); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
231 from = out - dist; /* rest from output */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
232 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
233 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
234 while (len > 2) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
235 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
237 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
238 len -= 3; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
239 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 if (len) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242 if (len > 1) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
244 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
245 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 else { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247 from = out - dist; /* copy direct from output */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
248 do { /* minimum length is three */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
250 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
252 len -= 3; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
253 } while (len > 2); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
254 if (len) { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
255 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
256 if (len > 1) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
257 PUP(out) = PUP(from); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
258 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
259 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
260 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
261 else if ((op & 64) == 0) { /* 2nd level distance code */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
262 this = dcode[this.val + (hold & ((1U << op) - 1))]; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
263 goto dodist; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
265 else { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
266 strm->msg = (char *)"invalid distance code"; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
267 state->mode = BAD; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
268 break; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
269 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
270 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
271 else if ((op & 64) == 0) { /* 2nd level length code */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
272 this = lcode[this.val + (hold & ((1U << op) - 1))]; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
273 goto dolen; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
274 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
275 else if (op & 32) { /* end-of-block */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
276 Tracevv((stderr, "inflate: end of block\n")); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 state->mode = TYPE; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
278 break; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
279 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280 else { |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
281 strm->msg = (char *)"invalid literal/length code"; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
282 state->mode = BAD; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
283 break; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
284 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
285 } while (in < last && out < end); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
286 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
287 /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
288 len = bits >> 3; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
289 in -= len; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
290 bits -= len << 3; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291 hold &= (1U << bits) - 1; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
292 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
293 /* update state and return */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
294 strm->next_in = in + OFF; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
295 strm->next_out = out + OFF; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296 strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 strm->avail_out = (unsigned)(out < end ? |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
298 257 + (end - out) : 257 - (out - end)); |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
299 state->hold = hold; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
300 state->bits = bits; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
301 return; |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 } |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
303 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
304 /* |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305 inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
306 - Using bit fields for code structure |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
307 - Different op definition to avoid & for extra bits (do & for table bits) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
308 - Three separate decoding do-loops for direct, window, and write == 0 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
309 - Special case for distance > 1 copies to do overlapped load and store copy |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
310 - Explicit branch predictions (based on measured branch probabilities) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
311 - Deferring match copy and interspersed it with decoding subsequent codes |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
312 - Swapping literal/length else |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
313 - Swapping window/direct else |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
314 - Larger unrolled copy loops (three is about right) |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
315 - Moving len -= 3 statement into middle of loop |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
316 */ |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
317 |
ae3a4bfb450b
add some files of version 4.4.3 that have been forgotten.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
318 #endif /* !ASMINF */ |