diff options
Diffstat (limited to 'infcodes.c')
-rw-r--r-- | infcodes.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -6,6 +6,7 @@ | |||
6 | #include "zutil.h" | 6 | #include "zutil.h" |
7 | #include "inftrees.h" | 7 | #include "inftrees.h" |
8 | #include "infutil.h" | 8 | #include "infutil.h" |
9 | #include "inffast.h" | ||
9 | #include "infcodes.h" | 10 | #include "infcodes.h" |
10 | 11 | ||
11 | /* simplify the use of the inflate_huft type with some defines */ | 12 | /* simplify the use of the inflate_huft type with some defines */ |
@@ -98,7 +99,19 @@ int r; | |||
98 | while (1) switch (c->mode) | 99 | while (1) switch (c->mode) |
99 | { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ | 100 | { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ |
100 | case START: /* x: set up for LEN */ | 101 | case START: /* x: set up for LEN */ |
101 | /* %%% check for avail in and out to do fast loop %%% */ | 102 | #ifndef SLOW |
103 | if (m >= 258 && n >= 10) | ||
104 | { | ||
105 | UPDATE | ||
106 | r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); | ||
107 | LOAD | ||
108 | if (r != Z_OK) | ||
109 | { | ||
110 | c->mode = r == Z_STREAM_END ? WASH : BAD; | ||
111 | break; | ||
112 | } | ||
113 | } | ||
114 | #endif /* !SLOW */ | ||
102 | c->sub.code.need = c->lbits; | 115 | c->sub.code.need = c->lbits; |
103 | c->sub.code.tree = c->ltree; | 116 | c->sub.code.tree = c->ltree; |
104 | c->mode = LEN; | 117 | c->mode = LEN; |
@@ -112,14 +125,14 @@ int r; | |||
112 | if (e == -128) /* invalid code */ | 125 | if (e == -128) /* invalid code */ |
113 | { | 126 | { |
114 | c->mode = BAD; | 127 | c->mode = BAD; |
115 | z->msg = "invalid huffman code"; | 128 | z->msg = "invalid literal/length code"; |
116 | r = Z_DATA_ERROR; | 129 | r = Z_DATA_ERROR; |
117 | LEAVE | 130 | LEAVE |
118 | } | 131 | } |
119 | e = -e; | 132 | e = -e; |
120 | if (e & 64) /* end of block */ | 133 | if (e & 64) /* end of block */ |
121 | { | 134 | { |
122 | c->mode = END; | 135 | c->mode = WASH; |
123 | break; | 136 | break; |
124 | } | 137 | } |
125 | c->sub.code.need = e; | 138 | c->sub.code.need = e; |
@@ -153,7 +166,7 @@ int r; | |||
153 | if (e == -128) | 166 | if (e == -128) |
154 | { | 167 | { |
155 | c->mode = BAD; | 168 | c->mode = BAD; |
156 | z->msg = "invalid huffman code"; | 169 | z->msg = "invalid distance code"; |
157 | r = Z_DATA_ERROR; | 170 | r = Z_DATA_ERROR; |
158 | LEAVE | 171 | LEAVE |
159 | } | 172 | } |
@@ -171,7 +184,7 @@ int r; | |||
171 | DUMPBITS(j) | 184 | DUMPBITS(j) |
172 | c->mode = COPY; | 185 | c->mode = COPY; |
173 | case COPY: /* o: copying bytes in window, waiting for space */ | 186 | case COPY: /* o: copying bytes in window, waiting for space */ |
174 | f = q - s->window < c->sub.copy.dist ? | 187 | f = (uInt)(q - s->window) < c->sub.copy.dist ? |
175 | s->end - (c->sub.copy.dist - (q - s->window)) : | 188 | s->end - (c->sub.copy.dist - (q - s->window)) : |
176 | q - c->sub.copy.dist; | 189 | q - c->sub.copy.dist; |
177 | while (c->len) | 190 | while (c->len) |