internal bool _tr_tally(int dist, int lc)
{
pending[_distanceOffset + last_lit * 2] = unchecked((byte) ( (uint)dist >> 8 ) );
pending[_distanceOffset + last_lit * 2 + 1] = unchecked((byte)dist);
pending[_lengthOffset + 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.LengthCode[lc] + InternalConstants.LITERALS + 1) * 2]++;
dyn_dtree[ZTree.DistanceCode(dist) * 2]++;
}
if ((last_lit & 0x1fff) == 0 && (int)compressionLevel > 2)
{
// Compute an upper bound for the compressed length
int out_length = last_lit << 3;
int in_length = strstart - block_start;
int dcode;
for (dcode = 0; dcode < InternalConstants.D_CODES; dcode++)
{
out_length = (int)(out_length + (int)dyn_dtree[dcode * 2] * (5L + ZTree.ExtraDistanceBits[dcode]));
}
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.
}