Mercurial > 510Connectbot
annotate src/com/jcraft/jzlib/InfBlocks.java @ 419:9045b1af94e5
revert notifyUser() changes
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 29 Oct 2014 15:25:32 -0700 |
parents | 46c2115ae1c8 |
children |
rev | line source |
---|---|
0 | 1 /* -*-mode:java; c-basic-offset:2; -*- */ |
2 /* | |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
3 Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved. |
0 | 4 |
5 Redistribution and use in source and binary forms, with or without | |
6 modification, are permitted provided that the following conditions are met: | |
7 | |
8 1. Redistributions of source code must retain the above copyright notice, | |
9 this list of conditions and the following disclaimer. | |
10 | |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
11 2. Redistributions in binary form must reproduce the above copyright |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
12 notice, this list of conditions and the following disclaimer in |
0 | 13 the documentation and/or other materials provided with the distribution. |
14 | |
15 3. The names of the authors may not be used to endorse or promote products | |
16 derived from this software without specific prior written permission. | |
17 | |
18 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |
19 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
20 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, | |
21 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, | |
22 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | |
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 */ | |
29 /* | |
30 * This program is based on zlib-1.1.3, so all credit should go authors | |
31 * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) | |
32 * and contributors of zlib. | |
33 */ | |
34 | |
35 package com.jcraft.jzlib; | |
36 | |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
37 final class InfBlocks{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
38 static final private int MANY=1440; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
39 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
40 // And'ing with mask[n] masks the lower n bits |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
41 static final private int[] inflate_mask = { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
42 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
43 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
44 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
45 0x00007fff, 0x0000ffff |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
46 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
47 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
48 // Table for deflate from PKZIP's appnote.txt. |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
49 static final int[] border = { // Order of the bit length code lengths |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
50 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
51 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
52 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
53 static final private int Z_OK=0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
54 static final private int Z_STREAM_END=1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
55 static final private int Z_NEED_DICT=2; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
56 static final private int Z_ERRNO=-1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
57 static final private int Z_STREAM_ERROR=-2; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
58 static final private int Z_DATA_ERROR=-3; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
59 static final private int Z_MEM_ERROR=-4; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
60 static final private int Z_BUF_ERROR=-5; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
61 static final private int Z_VERSION_ERROR=-6; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
62 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
63 static final private int TYPE=0; // get type bits (3, including end bit) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
64 static final private int LENS=1; // get lengths for stored |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
65 static final private int STORED=2;// processing stored block |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
66 static final private int TABLE=3; // get table lengths |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
67 static final private int BTREE=4; // get bit lengths tree for a dynamic block |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
68 static final private int DTREE=5; // get length, distance trees for a dynamic block |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
69 static final private int CODES=6; // processing fixed or dynamic block |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
70 static final private int DRY=7; // output remaining window bytes |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
71 static final private int DONE=8; // finished last block, done |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
72 static final private int BAD=9; // ot a data error--stuck here |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
73 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
74 int mode; // current inflate_block mode |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
75 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
76 int left; // if STORED, bytes left to copy |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
77 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
78 int table; // table lengths (14 bits) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
79 int index; // index into blens (or border) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
80 int[] blens; // bit lengths of codes |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
81 int[] bb=new int[1]; // bit length tree depth |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
82 int[] tb=new int[1]; // bit length decoding tree |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
83 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
84 int[] bl=new int[1]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
85 int[] bd=new int[1]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
86 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
87 int[][] tl=new int[1][]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
88 int[][] td=new int[1][]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
89 int[] tli=new int[1]; // tl_index |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
90 int[] tdi=new int[1]; // td_index |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
91 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
92 private final InfCodes codes; // if CODES, current state |
0 | 93 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
94 int last; // true if this block is the last block |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
95 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
96 // mode independent information |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
97 int bitk; // bits in bit buffer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
98 int bitb; // bit buffer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
99 int[] hufts; // single malloc for tree space |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
100 byte[] window; // sliding window |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
101 int end; // one byte after sliding window |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
102 int read; // window read pointer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
103 int write; // window write pointer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
104 private boolean check; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
105 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
106 private final InfTree inftree=new InfTree(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
107 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
108 private final ZStream z; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
109 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
110 InfBlocks(ZStream z, int w){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
111 this.z=z; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
112 this.codes=new InfCodes(this.z, this); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
113 hufts=new int[MANY*3]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
114 window=new byte[w]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
115 end=w; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
116 this.check = (z.istate.wrap==0) ? false : true; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
117 mode = TYPE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
118 reset(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
119 } |
0 | 120 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
121 void reset(){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
122 if(mode==BTREE || mode==DTREE){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
123 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
124 if(mode==CODES){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
125 codes.free(z); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
126 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
127 mode=TYPE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
128 bitk=0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
129 bitb=0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
130 read=write=0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
131 if(check){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
132 z.adler.reset(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
133 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
134 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
135 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
136 int proc(int r){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
137 int t; // temporary storage |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
138 int b; // bit buffer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
139 int k; // bits in bit buffer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
140 int p; // input data pointer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
141 int n; // bytes available there |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
142 int q; // output window write pointer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
143 int m; // bytes to end of window or read pointer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
144 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
145 // copy input/output information to locals (UPDATE macro restores) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
146 {p=z.next_in_index;n=z.avail_in;b=bitb;k=bitk;} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
147 {q=write;m=(int)(q<read?read-q-1:end-q);} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
148 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
149 // process input based on current state |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
150 while(true){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
151 switch (mode){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
152 case TYPE: |
0 | 153 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
154 while(k<(3)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
155 if(n!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
156 r=Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
157 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
158 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
159 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
160 z.avail_in=n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
161 z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
162 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
163 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
164 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
165 n--; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
166 b|=(z.next_in[p++]&0xff)<<k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
167 k+=8; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
168 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
169 t = (int)(b & 7); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
170 last = t & 1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
171 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
172 switch (t >>> 1){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
173 case 0: // stored |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
174 {b>>>=(3);k-=(3);} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
175 t = k & 7; // go to byte boundary |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
176 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
177 {b>>>=(t);k-=(t);} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
178 mode = LENS; // get length of stored block |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
179 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
180 case 1: // fixed |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
181 InfTree.inflate_trees_fixed(bl, bd, tl, td, z); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
182 codes.init(bl[0], bd[0], tl[0], 0, td[0], 0); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
183 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
184 {b>>>=(3);k-=(3);} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
185 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
186 mode = CODES; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
187 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
188 case 2: // dynamic |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
189 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
190 {b>>>=(3);k-=(3);} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
191 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
192 mode = TABLE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
193 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
194 case 3: // illegal |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
195 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
196 {b>>>=(3);k-=(3);} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
197 mode = BAD; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
198 z.msg = "invalid block type"; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
199 r = Z_DATA_ERROR; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
200 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
201 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
202 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
203 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
204 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
205 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
206 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
207 case LENS: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
208 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
209 while(k<(32)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
210 if(n!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
211 r=Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
212 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
213 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
214 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
215 z.avail_in=n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
216 z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
217 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
218 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
219 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
220 n--; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
221 b|=(z.next_in[p++]&0xff)<<k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
222 k+=8; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
223 } |
0 | 224 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
225 if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
226 mode = BAD; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
227 z.msg = "invalid stored block lengths"; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
228 r = Z_DATA_ERROR; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
229 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
230 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
231 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
232 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
233 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
234 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
235 left = (b & 0xffff); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
236 b = k = 0; // dump bits |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
237 mode = left!=0 ? STORED : (last!=0 ? DRY : TYPE); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
238 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
239 case STORED: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
240 if (n == 0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
241 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
242 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
243 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
244 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
245 } |
0 | 246 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
247 if(m==0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
248 if(q==end&&read!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
249 q=0; m=(int)(q<read?read-q-1:end-q); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
250 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
251 if(m==0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
252 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
253 r=inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
254 q=write;m=(int)(q<read?read-q-1:end-q); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
255 if(q==end&&read!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
256 q=0; m=(int)(q<read?read-q-1:end-q); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
257 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
258 if(m==0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
259 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
260 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
261 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
262 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
263 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
264 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
265 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
266 r=Z_OK; |
0 | 267 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
268 t = left; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
269 if(t>n) t = n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
270 if(t>m) t = m; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
271 System.arraycopy(z.next_in, p, window, q, t); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
272 p += t; n -= t; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
273 q += t; m -= t; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
274 if ((left -= t) != 0) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
275 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
276 mode = last!=0 ? DRY : TYPE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
277 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
278 case TABLE: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
279 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
280 while(k<(14)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
281 if(n!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
282 r=Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
283 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
284 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
285 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
286 z.avail_in=n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
287 z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
288 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
289 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
290 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
291 n--; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
292 b|=(z.next_in[p++]&0xff)<<k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
293 k+=8; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
294 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
295 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
296 table = t = (b & 0x3fff); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
297 if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
298 { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
299 mode = BAD; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
300 z.msg = "too many length or distance symbols"; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
301 r = Z_DATA_ERROR; |
0 | 302 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
303 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
304 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
305 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
306 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
307 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
308 t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
309 if(blens==null || blens.length<t){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
310 blens=new int[t]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
311 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
312 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
313 for(int i=0; i<t; i++){blens[i]=0;} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
314 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
315 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
316 {b>>>=(14);k-=(14);} |
0 | 317 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
318 index = 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
319 mode = BTREE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
320 case BTREE: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
321 while (index < 4 + (table >>> 10)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
322 while(k<(3)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
323 if(n!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
324 r=Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
325 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
326 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
327 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
328 z.avail_in=n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
329 z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
330 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
331 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
332 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
333 n--; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
334 b|=(z.next_in[p++]&0xff)<<k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
335 k+=8; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
336 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
337 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
338 blens[border[index++]] = b&7; |
0 | 339 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
340 {b>>>=(3);k-=(3);} |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
341 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
342 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
343 while(index < 19){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
344 blens[border[index++]] = 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
345 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
346 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
347 bb[0] = 7; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
348 t = inftree.inflate_trees_bits(blens, bb, tb, hufts, z); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
349 if (t != Z_OK){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
350 r = t; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
351 if (r == Z_DATA_ERROR){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
352 blens=null; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
353 mode = BAD; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
354 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
355 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
356 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
357 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
358 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
359 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
360 } |
0 | 361 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
362 index = 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
363 mode = DTREE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
364 case DTREE: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
365 while (true){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
366 t = table; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
367 if(!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
368 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
369 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
370 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
371 int[] h; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
372 int i, j, c; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
373 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
374 t = bb[0]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
375 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
376 while(k<(t)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
377 if(n!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
378 r=Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
379 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
380 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
381 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
382 z.avail_in=n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
383 z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
384 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
385 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
386 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
387 n--; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
388 b|=(z.next_in[p++]&0xff)<<k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
389 k+=8; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
390 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
391 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
392 if(tb[0]==-1){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
393 //System.err.println("null..."); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
394 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
395 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
396 t=hufts[(tb[0]+(b&inflate_mask[t]))*3+1]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
397 c=hufts[(tb[0]+(b&inflate_mask[t]))*3+2]; |
0 | 398 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
399 if (c < 16){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
400 b>>>=(t);k-=(t); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
401 blens[index++] = c; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
402 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
403 else { // c == 16..18 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
404 i = c == 18 ? 7 : c - 14; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
405 j = c == 18 ? 11 : 3; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
406 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
407 while(k<(t+i)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
408 if(n!=0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
409 r=Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
410 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
411 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
412 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
413 z.avail_in=n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
414 z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
415 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
416 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
417 }; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
418 n--; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
419 b|=(z.next_in[p++]&0xff)<<k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
420 k+=8; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
421 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
422 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
423 b>>>=(t);k-=(t); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
424 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
425 j += (b & inflate_mask[i]); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
426 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
427 b>>>=(i);k-=(i); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
428 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
429 i = index; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
430 t = table; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
431 if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
432 (c == 16 && i < 1)){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
433 blens=null; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
434 mode = BAD; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
435 z.msg = "invalid bit length repeat"; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
436 r = Z_DATA_ERROR; |
0 | 437 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
438 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
439 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
440 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
441 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
442 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
443 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
444 c = c == 16 ? blens[i-1] : 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
445 do{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
446 blens[i++] = c; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
447 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
448 while (--j!=0); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
449 index = i; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
450 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
451 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
452 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
453 tb[0]=-1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
454 { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
455 bl[0] = 9; // must be <= 9 for lookahead assumptions |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
456 bd[0] = 6; // must be <= 9 for lookahead assumptions |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
457 t = table; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
458 t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
459 1 + ((t >> 5) & 0x1f), |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
460 blens, bl, bd, tli, tdi, hufts, z); |
0 | 461 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
462 if (t != Z_OK){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
463 if (t == Z_DATA_ERROR){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
464 blens=null; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
465 mode = BAD; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
466 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
467 r = t; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
468 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
469 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
470 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
471 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
472 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
473 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
474 codes.init(bl[0], bd[0], hufts, tli[0], hufts, tdi[0]); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
475 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
476 mode = CODES; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
477 case CODES: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
478 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
479 z.avail_in=n; z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
480 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
481 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
482 if ((r = codes.proc(r)) != Z_STREAM_END){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
483 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
484 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
485 r = Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
486 codes.free(z); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
487 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
488 p=z.next_in_index; n=z.avail_in;b=bitb;k=bitk; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
489 q=write;m=(int)(q<read?read-q-1:end-q); |
0 | 490 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
491 if (last==0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
492 mode = TYPE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
493 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
494 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
495 mode = DRY; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
496 case DRY: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
497 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
498 r=inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
499 q=write; m=(int)(q<read?read-q-1:end-q); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
500 if (read != write){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
501 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
502 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
503 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
504 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
505 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
506 mode = DONE; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
507 case DONE: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
508 r = Z_STREAM_END; |
0 | 509 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
510 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
511 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
512 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
513 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
514 case BAD: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
515 r = Z_DATA_ERROR; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
516 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
517 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
518 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
519 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
520 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
521 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
522 default: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
523 r = Z_STREAM_ERROR; |
0 | 524 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
525 bitb=b; bitk=k; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
526 z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
527 write=q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
528 return inflate_flush(r); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
529 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
530 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
531 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
532 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
533 void free(){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
534 reset(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
535 window=null; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
536 hufts=null; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
537 //ZFREE(z, s); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
538 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
539 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
540 void set_dictionary(byte[] d, int start, int n){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
541 System.arraycopy(d, start, window, 0, n); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
542 read = write = n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
543 } |
0 | 544 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
545 // Returns true if inflate is currently at the end of a block generated |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
546 // by Z_SYNC_FLUSH or Z_FULL_FLUSH. |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
547 int sync_point(){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
548 return mode == LENS ? 1 : 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
549 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
550 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
551 // copy as much as possible from the sliding window to the output area |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
552 int inflate_flush(int r){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
553 int n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
554 int p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
555 int q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
556 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
557 // local copies of source and destination pointers |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
558 p = z.next_out_index; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
559 q = read; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
560 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
561 // compute number of bytes to copy as far as end of window |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
562 n = (int)((q <= write ? write : end) - q); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
563 if(n > z.avail_out) n = z.avail_out; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
564 if(n!=0 && r == Z_BUF_ERROR) r = Z_OK; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
565 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
566 // update counters |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
567 z.avail_out -= n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
568 z.total_out += n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
569 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
570 // update check information |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
571 if(check && n>0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
572 z.adler.update(window, q, n); |
0 | 573 } |
574 | |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
575 // copy as far as end of window |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
576 System.arraycopy(window, q, z.next_out, p, n); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
577 p += n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
578 q += n; |
0 | 579 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
580 // see if more to copy at beginning of window |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
581 if (q == end){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
582 // wrap pointers |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
583 q = 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
584 if (write == end) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
585 write = 0; |
0 | 586 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
587 // compute bytes to copy |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
588 n = write - q; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
589 if (n > z.avail_out) n = z.avail_out; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
590 if (n!=0 && r == Z_BUF_ERROR) r = Z_OK; |
0 | 591 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
592 // update counters |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
593 z.avail_out -= n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
594 z.total_out += n; |
0 | 595 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
596 // update check information |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
597 if(check && n>0){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
598 z.adler.update(window, q, n); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
599 } |
0 | 600 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
601 // copy |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
602 System.arraycopy(window, q, z.next_out, p, n); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
603 p += n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
604 q += n; |
0 | 605 } |
606 | |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
607 // update pointers |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
608 z.next_out_index = p; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
609 read = q; |
0 | 610 |
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
611 // done |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
612 return r; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
613 } |
0 | 614 } |