internal bool _tr_tally(int dist, int lc)
{
pending [d_buf + last_lit * 2] = unchecked((byte)(SharedUtils.URShift (dist, 8)));
pending [d_buf + last_lit * 2 + 1] = unchecked((byte)dist);
pending [l_buf + last_lit] = unchecked((byte)lc);
last_lit++;
if (dist == 0) {
// lc is the unmatched char
dyn_ltree [lc * 2]++;
} else {
matches++;
// Here, lc is the match length - MIN_MATCH
dist--; // dist = match distance - 1
dyn_ltree [(ZTree._length_code [lc] + LITERALS + 1) * 2]++;
dyn_dtree [ZTree.d_code (dist) * 2]++;
}
if ((last_lit & 0x1fff) == 0 && (int)compressionLevel > 2) {
// Compute an upper bound for the compressed length
int out_length = last_lit * 8;
int in_length = strstart - block_start;
int dcode;
for (dcode = 0; dcode < D_CODES; dcode++) {
out_length = (int)(out_length + (int)dyn_dtree [dcode * 2] * (5L + ZTree.extra_dbits [dcode]));
}
out_length = SharedUtils.URShift (out_length, 3);
if ((matches < (last_lit / 2)) && out_length < in_length / 2)
return true;
}
return (last_lit == lit_bufsize - 1) || (last_lit == lit_bufsize);
// dinoch - wraparound?
// We avoid equality with lit_bufsize because of wraparound at 64K
// on 16 bit machines and because stored blocks are restricted to
// 64K-1 bytes.
}