1 Clazz.declarePackage ("JU");
2 c$ = Clazz.decorateAsClass (function () {
19 Clazz.instantialize (this, arguments);
21 Clazz.makeConstructor (c$,
25 }, "JU.ZStream,JU.InfBlocks");
26 Clazz.defineMethod (c$, "init",
27 function (bl, bd, tl, tl_index, td, td_index) {
32 this.ltree_index = tl_index;
34 this.dtree_index = td_index;
36 }, "~N,~N,~A,~N,~A,~N");
37 Clazz.defineMethod (c$, "proc",
49 p = this.z.next_in_index;
54 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
58 if (m >= 258 && n >= 10) {
62 this.z.total_in += p - this.z.next_in_index;
63 this.z.next_in_index = p;
65 r = this.inflate_fast (this.lbits, this.dbits, this.ltree, this.ltree_index, this.dtree, this.dtree_index, this.s, this.z);
66 p = this.z.next_in_index;
71 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
73 this.mode = r == 1 ? 7 : 9;
75 }}this.need = this.lbits;
76 this.tree = this.ltree;
77 this.tree_index = this.ltree_index;
87 this.z.total_in += p - this.z.next_in_index;
88 this.z.next_in_index = p;
90 return this.s.inflate_flush (r);
92 b |= (this.z.next_in[p++] & 0xff) << k;
95 tindex = (this.tree_index + (b & JU.InfCodes.inflate_mask[j])) * 3;
96 b >>>= (this.tree[tindex + 1]);
97 k -= (this.tree[tindex + 1]);
98 e = this.tree[tindex];
100 this.lit = this.tree[tindex + 2];
103 }if ((e & 16) != 0) {
105 this.len = this.tree[tindex + 2];
108 }if ((e & 64) == 0) {
110 this.tree_index = Clazz.doubleToInt (tindex / 3) + this.tree[tindex + 2];
112 }if ((e & 32) != 0) {
116 this.z.msg = "invalid literal/length code";
121 this.z.total_in += p - this.z.next_in_index;
122 this.z.next_in_index = p;
124 return this.s.inflate_flush (r);
133 this.z.total_in += p - this.z.next_in_index;
134 this.z.next_in_index = p;
136 return this.s.inflate_flush (r);
138 b |= (this.z.next_in[p++] & 0xff) << k;
141 this.len += (b & JU.InfCodes.inflate_mask[j]);
144 this.need = this.dbits;
145 this.tree = this.dtree;
146 this.tree_index = this.dtree_index;
156 this.z.total_in += p - this.z.next_in_index;
157 this.z.next_in_index = p;
159 return this.s.inflate_flush (r);
161 b |= (this.z.next_in[p++] & 0xff) << k;
164 tindex = (this.tree_index + (b & JU.InfCodes.inflate_mask[j])) * 3;
165 b >>= this.tree[tindex + 1];
166 k -= this.tree[tindex + 1];
167 e = (this.tree[tindex]);
170 this.dist = this.tree[tindex + 2];
173 }if ((e & 64) == 0) {
175 this.tree_index = Clazz.doubleToInt (tindex / 3) + this.tree[tindex + 2];
178 this.z.msg = "invalid distance code";
183 this.z.total_in += p - this.z.next_in_index;
184 this.z.next_in_index = p;
186 return this.s.inflate_flush (r);
195 this.z.total_in += p - this.z.next_in_index;
196 this.z.next_in_index = p;
198 return this.s.inflate_flush (r);
200 b |= (this.z.next_in[p++] & 0xff) << k;
203 this.dist += (b & JU.InfCodes.inflate_mask[j]);
212 while (this.len != 0) {
214 if (q == this.s.end && this.s.read != 0) {
216 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
219 r = this.s.inflate_flush (r);
221 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
222 if (q == this.s.end && this.s.read != 0) {
224 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
229 this.z.total_in += p - this.z.next_in_index;
230 this.z.next_in_index = p;
232 return this.s.inflate_flush (r);
233 }}}this.s.window[q++] = this.s.window[f++];
235 if (f == this.s.end) f = 0;
242 if (q == this.s.end && this.s.read != 0) {
244 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
247 r = this.s.inflate_flush (r);
249 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
250 if (q == this.s.end && this.s.read != 0) {
252 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
257 this.z.total_in += p - this.z.next_in_index;
258 this.z.next_in_index = p;
260 return this.s.inflate_flush (r);
262 this.s.window[q++] = this.lit;
272 r = this.s.inflate_flush (r);
274 m = q < this.s.read ? this.s.read - q - 1 : this.s.end - q;
275 if (this.s.read != this.s.write) {
279 this.z.total_in += p - this.z.next_in_index;
280 this.z.next_in_index = p;
282 return this.s.inflate_flush (r);
289 this.z.total_in += p - this.z.next_in_index;
290 this.z.next_in_index = p;
292 return this.s.inflate_flush (r);
298 this.z.total_in += p - this.z.next_in_index;
299 this.z.next_in_index = p;
301 return this.s.inflate_flush (r);
307 this.z.total_in += p - this.z.next_in_index;
308 this.z.next_in_index = p;
310 return this.s.inflate_flush (r);
314 Clazz.defineMethod (c$, "free",
317 Clazz.defineMethod (c$, "inflate_fast",
318 function (bl, bd, tl, tl_index, td, td_index, s, z) {
340 m = q < s.read ? s.read - q - 1 : s.end - q;
341 ml = JU.InfCodes.inflate_mask[bl];
342 md = JU.InfCodes.inflate_mask[bd];
346 b |= (z.next_in[p++] & 0xff) << k;
352 tp_index_t_3 = (tp_index + t) * 3;
353 if ((e = tp[tp_index_t_3]) == 0) {
354 b >>= (tp[tp_index_t_3 + 1]);
355 k -= (tp[tp_index_t_3 + 1]);
356 s.window[q++] = tp[tp_index_t_3 + 2];
360 b >>= (tp[tp_index_t_3 + 1]);
361 k -= (tp[tp_index_t_3 + 1]);
364 c = tp[tp_index_t_3 + 2] + (b & JU.InfCodes.inflate_mask[e]);
369 b |= (z.next_in[p++] & 0xff) << k;
375 tp_index_t_3 = (tp_index + t) * 3;
376 e = tp[tp_index_t_3];
378 b >>= (tp[tp_index_t_3 + 1]);
379 k -= (tp[tp_index_t_3 + 1]);
384 b |= (z.next_in[p++] & 0xff) << k;
387 d = tp[tp_index_t_3 + 2] + (b & JU.InfCodes.inflate_mask[e]);
393 if (q - r > 0 && 2 > (q - r)) {
394 s.window[q++] = s.window[r++];
395 s.window[q++] = s.window[r++];
398 System.arraycopy (s.window, r, s.window, q, 2);
410 if (q - r > 0 && e > (q - r)) {
412 s.window[q++] = s.window[r++];
415 System.arraycopy (s.window, r, s.window, q, e);
420 }}if (q - r > 0 && c > (q - r)) {
422 s.window[q++] = s.window[r++];
425 System.arraycopy (s.window, r, s.window, q, c);
430 } else if ((e & 64) == 0) {
431 t += tp[tp_index_t_3 + 2];
432 t += (b & JU.InfCodes.inflate_mask[e]);
433 tp_index_t_3 = (tp_index + t) * 3;
434 e = tp[tp_index_t_3];
436 z.msg = "invalid distance code";
438 c = (k >> 3) < c ? k >> 3 : c;
445 z.total_in += p - z.next_in_index;
451 }if ((e & 64) == 0) {
452 t += tp[tp_index_t_3 + 2];
453 t += (b & JU.InfCodes.inflate_mask[e]);
454 tp_index_t_3 = (tp_index + t) * 3;
455 if ((e = tp[tp_index_t_3]) == 0) {
456 b >>= (tp[tp_index_t_3 + 1]);
457 k -= (tp[tp_index_t_3 + 1]);
458 s.window[q++] = tp[tp_index_t_3 + 2];
461 }} else if ((e & 32) != 0) {
463 c = (k >> 3) < c ? k >> 3 : c;
470 z.total_in += p - z.next_in_index;
475 z.msg = "invalid literal/length code";
477 c = (k >> 3) < c ? k >> 3 : c;
484 z.total_in += p - z.next_in_index;
489 } while (m >= 258 && n >= 10);
491 c = (k >> 3) < c ? k >> 3 : c;
498 z.total_in += p - z.next_in_index;
502 }, "~N,~N,~A,~N,~A,~N,JU.InfBlocks,JU.ZStream");
503 Clazz.defineStatics (c$,
504 "inflate_mask", Clazz.newIntArray (-1, [0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff]),
507 "Z_STREAM_ERROR", -2,