public DeflaterEngine(DeflaterPending pending) { this.pending = pending; huffman = new DeflaterHuffman(pending); adler = new Adler32(); window = new byte[0x10000]; head = new short[0x8000]; prev = new short[0x8000]; blockStart = strstart = 1; }
public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength) { this._dh = dh; MinNumCodes = minCodes; this._maxLength = maxLength; Freqs = new short[elems]; _blCounts = new int[maxLength]; }
private void BuildTree(byte[] codeLengths) { int[] numArray = new int[0x10]; int[] numArray2 = new int[0x10]; for (int i = 0; i < codeLengths.Length; i++) { int index = codeLengths[i]; if (index > 0) { numArray[index]++; } } int toReverse = 0; int num4 = 0x200; for (int j = 1; j <= 15; j++) { numArray2[j] = toReverse; toReverse += numArray[j] << (0x10 - j); if (j >= 10) { int num6 = numArray2[j] & 0x1ff80; int num7 = toReverse & 0x1ff80; num4 += (num7 - num6) >> (0x10 - j); } } _tree = new short[num4]; int num8 = 0x200; for (int k = 15; k >= 10; k--) { int num10 = toReverse & 0x1ff80; toReverse -= numArray[k] << (0x10 - k); int num11 = toReverse & 0x1ff80; for (int n = num11; n < num10; n += 0x80) { _tree[DeflaterHuffman.BitReverse(n)] = (short)((-num8 << 4) | k); num8 += 1 << (k - 9); } } for (int m = 0; m < codeLengths.Length; m++) { int num14 = codeLengths[m]; if (num14 != 0) { toReverse = numArray2[num14]; int num15 = DeflaterHuffman.BitReverse(toReverse); if (num14 <= 9) { do { _tree[num15] = (short)((m << 4) | num14); num15 += 1 << num14; }while (num15 < 0x200); } else { int num16 = _tree[num15 & 0x1ff]; int num17 = 1 << (num16 & 15); num16 = -(num16 >> 4); do { _tree[num16 | (num15 >> 9)] = (short)((m << 4) | num14); num15 += 1 << num14; }while (num15 < num17); } numArray2[num14] = toReverse + (1 << (0x10 - num14)); } } }