internal bool _tr_tally(int dist, int lc) { this.pending_buf[this.d_buf + (this.last_lit * 2)] = (byte)(dist >> 8); this.pending_buf[(this.d_buf + (this.last_lit * 2)) + 1] = (byte)dist; this.pending_buf[this.l_buf + this.last_lit] = (byte)lc; this.last_lit++; if (dist == 0) { this.dyn_ltree[lc * 2] = (short)(this.dyn_ltree[lc * 2] + 1); } else { this.matches++; dist--; this.dyn_ltree[((ZTree._length_code[lc] + 0x100) + 1) * 2] = (short)(this.dyn_ltree[((ZTree._length_code[lc] + 0x100) + 1) * 2] + 1); this.dyn_dtree[ZTree.d_code(dist) * 2] = (short)(this.dyn_dtree[ZTree.d_code(dist) * 2] + 1); } if (((this.last_lit & 0x1fff) == 0) && (this.level > 2)) { int num = this.last_lit * 8; int num2 = this.strstart - this.block_start; for (int i = 0; i < 30; i++) { num += (int)(this.dyn_dtree[i * 2] * (5L + ZTree.extra_dbits[i])); } num = num >> 3; if ((this.matches < (this.last_lit / 2)) && (num < (num2 / 2))) { return(true); } } return(this.last_lit == (this.lit_bufsize - 1)); }
internal bool _tr_tally(int dist, int lc) { pending_buf[d_buf + last_lit * 2] = (byte)(dist >> 8); pending_buf[d_buf + last_lit * 2 + 1] = (byte)dist; pending_buf[l_buf + last_lit] = (byte)lc; last_lit++; if (dist == 0) { dyn_ltree[lc * 2]++; } else { matches++; dist--; dyn_ltree[(ZTree._length_code[lc] + 256 + 1) * 2]++; dyn_dtree[ZTree.d_code(dist) * 2]++; } if ((last_lit & 0x1FFF) == 0 && level > 2) { int num = last_lit * 8; int num2 = strstart - block_start; for (int i = 0; i < 30; i++) { num += (int)(dyn_dtree[i * 2] * (5L + (long)ZTree.extra_dbits[i])); } num >>= 3; if (matches < last_lit / 2 && num < num2 / 2) { return(true); } } return(last_lit == lit_bufsize - 1); }
internal void compress_block(short[] ltree, short[] dtree) { int num3 = 0; if (this.last_lit != 0) { do { int dist = ((this.pending_buf[this.d_buf + (num3 * 2)] << 8) & 0xff00) | (this.pending_buf[(this.d_buf + (num3 * 2)) + 1] & 0xff); int c = this.pending_buf[this.l_buf + num3] & 0xff; num3++; if (dist == 0) { this.send_code(c, ltree); } else { int index = ZTree._length_code[c]; this.send_code((index + 0x100) + 1, ltree); int length = ZTree.extra_lbits[index]; if (length != 0) { c -= ZTree.base_length[index]; this.send_bits(c, length); } dist--; index = ZTree.d_code(dist); this.send_code(index, dtree); length = ZTree.extra_dbits[index]; if (length != 0) { dist -= ZTree.base_dist[index]; this.send_bits(dist, length); } } }while (num3 < this.last_lit); } this.send_code(0x100, ltree); this.last_eob_len = ltree[0x201]; }
internal void compress_block(short[] ltree, short[] dtree) { int num = 0; if (last_lit != 0) { do { int num2 = ((pending_buf[d_buf + num * 2] << 8) & 0xFF00) | (pending_buf[d_buf + num * 2 + 1] & 0xFF); int num3 = pending_buf[l_buf + num] & 0xFF; num++; if (num2 == 0) { send_code(num3, ltree); } else { int num4 = ZTree._length_code[num3]; send_code(num4 + 256 + 1, ltree); int num5 = ZTree.extra_lbits[num4]; if (num5 != 0) { num3 -= ZTree.base_length[num4]; send_bits(num3, num5); } num2--; num4 = ZTree.d_code(num2); send_code(num4, dtree); num5 = ZTree.extra_dbits[num4]; if (num5 != 0) { num2 -= ZTree.base_dist[num4]; send_bits(num2, num5); } } }while (num < last_lit); } send_code(256, ltree); last_eob_len = ltree[513]; }