internal bool _tr_tally(int dist, int lc) { pending[_distanceOffset + last_lit * 2] = (byte)((uint)dist >> 8); pending[_distanceOffset + last_lit * 2 + 1] = (byte)dist; pending[_lengthOffset + last_lit] = (byte)lc; last_lit++; if (dist == 0) { dyn_ltree[lc * 2]++; } else { matches++; dist--; dyn_ltree[(ZTree.LengthCode[lc] + InternalConstants.LITERALS + 1) * 2]++; dyn_dtree[ZTree.DistanceCode(dist) * 2]++; } if ((last_lit & 0x1FFF) == 0 && compressionLevel > CompressionLevel.Level2) { int num = last_lit << 3; int num2 = strstart - block_start; for (int i = 0; i < InternalConstants.D_CODES; i++) { num = (int)(num + dyn_dtree[i * 2] * (5L + (long)ZTree.ExtraDistanceBits[i])); } num >>= 3; if (matches < last_lit / 2 && num < num2 / 2) { return(true); } } return(last_lit == lit_bufsize - 1 || last_lit == lit_bufsize); }
internal void send_compressed_block(short[] ltree, short[] dtree) { int num = 0; if (last_lit != 0) { do { int num2 = _distanceOffset + num * 2; int num3 = ((pending[num2] << 8) & 0xFF00) | (pending[num2 + 1] & 0xFF); int num4 = pending[_lengthOffset + num] & 0xFF; num++; if (num3 == 0) { send_code(num4, ltree); } else { int num5 = ZTree.LengthCode[num4]; send_code(num5 + InternalConstants.LITERALS + 1, ltree); int num6 = ZTree.ExtraLengthBits[num5]; if (num6 != 0) { num4 -= ZTree.LengthBase[num5]; send_bits(num4, num6); } num3--; num5 = ZTree.DistanceCode(num3); send_code(num5, dtree); num6 = ZTree.ExtraDistanceBits[num5]; if (num6 != 0) { num3 -= ZTree.DistanceBase[num5]; send_bits(num3, num6); } } }while (num < last_lit); } send_code(END_BLOCK, ltree); last_eob_len = ltree[END_BLOCK * 2 + 1]; }