📄 infblocks.java
字号:
{ bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } ; n--; b |= (z.next_in[p++] & 0xff) << k; k += 8; } blens[border[index++]] = b & 7; { b >>>= (3); k -= (3); } } while (index < 19) { blens[border[index++]] = 0; } bb[0] = 7; t = InfTree.inflate_trees_bits(blens, bb, tb, hufts, z); if (t != Z_OK) { r = t; if (r == Z_DATA_ERROR) { blens = null; mode = BAD; } bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } index = 0; mode = DTREE; case DTREE: while (true) { t = table; if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) { break; } int[] h; int i, j, c; t = bb[0]; while (k < (t)) { if (n != 0) { r = Z_OK; } else { bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } ; n--; b |= (z.next_in[p++] & 0xff) << k; k += 8; } if (tb[0] == -1) { //System.err.println("null..."); } //t=hufts[(tb[0]+(b&inflate_mask[t]))*3+1]; t = hufts.get((tb[0] + (b & inflate_mask[t])) * 3 + 1); //c=hufts[(tb[0]+(b&inflate_mask[t]))*3+2]; c = hufts.get((tb[0] + (b & inflate_mask[t])) * 3 + 2); if (c < 16) { b >>>= (t); k -= (t); blens[index++] = c; } else { // c == 16..18 i = c == 18 ? 7 : c - 14; j = c == 18 ? 11 : 3; while (k < (t + i)) { if (n != 0) { r = Z_OK; } else { bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } ; n--; b |= (z.next_in[p++] & 0xff) << k; k += 8; } b >>>= (t); k -= (t); j += (b & inflate_mask[i]); b >>>= (i); k -= (i); i = index; t = table; if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { blens = null; mode = BAD; z.msg = "invalid bit length repeat"; r = Z_DATA_ERROR; bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } c = c == 16 ? blens[i - 1] : 0; do { blens[i++] = c; } while (--j != 0); index = i; } } tb[0] = -1; { int[] bl = new int[1]; int[] bd = new int[1]; int[] tl = new int[1]; int[] td = new int[1]; InfCodes c; bl[0] = 9; // must be <= 9 for lookahead assumptions bd[0] = 6; // must be <= 9 for lookahead assumptions t = table; t = InfTree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl, bd, tl, td, hufts, z); if (t != Z_OK) { if (t == Z_DATA_ERROR) { blens = null; mode = BAD; } r = t; bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } codes = new InfCodes(bl[0], bd[0], hufts, tl[0], hufts, td[0], z); } blens = null; mode = CODES; case CODES: bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; if ((r = codes.proc(this, z, r)) != Z_STREAM_END) { return inflate_flush(z, r); } r = Z_OK; codes.free(z); p = z.next_in_index; n = z.avail_in; b = bitb; k = bitk; q = write; m = (int) (q < read ? read - q - 1 : end - q); if (last == 0) { mode = TYPE; break; } mode = DRY; case DRY: write = q; r = inflate_flush(z, r); q = write; m = (int) (q < read ? read - q - 1 : end - q); if (read != write) { bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } mode = DONE; case DONE: r = Z_STREAM_END; bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); case BAD: r = Z_DATA_ERROR; bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); default: r = Z_STREAM_ERROR; bitb = b; bitk = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q; return inflate_flush(z, r); } } } void free(ZStream z) { reset(z, null); window = null; hufts = null; //ZFREE(z, s); } void set_dictionary(byte[] d, int start, int n) { //System.arraycopy(d, start, window, 0, n); byte_array.Copy(d, start, window, 0, n); read = write = n; } // Returns true if inflate is currently at the end of a block generated // by Z_SYNC_FLUSH or Z_FULL_FLUSH. int sync_point() { return mode == LENS ? 1 : 0; } // copy as much as possible from the sliding window to the output area int inflate_flush(ZStream z, int r) { int n; int p; int q; // local copies of source and destination pointers p = z.next_out_index; q = read; // compute number of bytes to copy as far as end of window n = (int) ((q <= write ? write : end) - q); if (n > z.avail_out) { n = z.avail_out; } if (n != 0 && r == Z_BUF_ERROR) { r = Z_OK; } // update counters z.avail_out -= n; z.total_out += n; // update check information if (checkfn != null) { z.adler = check = z._adler.adler32(check, window, q, n); } // copy as far as end of window //System.arraycopy(window, q, z.next_out, p, n); byte_array.Copy(window, q, z.next_out, p, n); p += n; q += n; // see if more to copy at beginning of window if (q == end) { // wrap pointers q = 0; if (write == end) { write = 0; } // compute bytes to copy n = write - q; if (n > z.avail_out) { n = z.avail_out; } if (n != 0 && r == Z_BUF_ERROR) { r = Z_OK; } // update counters z.avail_out -= n; z.total_out += n; // update check information if (checkfn != null) { z.adler = check = z._adler.adler32(check, window, q, n); } // copy //System.arraycopy(window, q, z.next_out, p, n); byte_array.Copy(window, q, z.next_out, p, n); p += n; q += n; } // update pointers z.next_out_index = p; read = q; // done return r; }//------------------------------------------------------------------- // protected void finalize(){ // //------- // if(DEBUG>0){ // if(window!=null)System.out.println("InfBlocks.finalize() window.totalAllocated()="+window.totalAllocated()); // }//if(DEBUG>0) // //------- // } private static final int_array new_int(int len, int blocklen, String name) { System.out.println("Dynamic array of " + name + " = new int[" + len + "] allocated in InfBlocks"); return new int_array(len); } private static final short[] new_short(int len, String name) { System.out.println("Array of " + name + " = new short[" + len + "] allocated in InfBlocks"); return new short[len]; } private static final byte_array new_byte(int len, String name) { System.out.println("Dynamic array of " + name + " = new byte[" + len + "] allocated in InfBlocks"); return new byte_array(len); }//-------------------------------------------------------------------}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -