private void BuildTree(short code, int start, int length, ref short avail) { int num1 = length - this.tableBits; int tableBitMask = this.tableBitMask; int index = start & this.tableMask; short[] numArray = this.table; do { short num2 = numArray[index]; if (num2 == (short)0) { num2 = -avail; numArray[index] = num2; ++avail; } if (num2 > (short)0) { InflateTree.InvalidHuffmanData(); } numArray = (start & tableBitMask) == 0 ? this.left : this.right; tableBitMask <<= 1; index = (int)-num2; --num1; }while (num1 != 0); numArray[index] = code; }
public int GetNextSymbol(InputBitsBuffer input) { uint num = input.Get16Bits(); if (input.AvailableBits == 0) { return(-1); } int index1 = (int)this.table[(long)num & (long)this.tableMask]; if (index1 < 0) { uint tableBitMask = (uint)this.tableBitMask; do { int index2 = -index1; index1 = ((int)num & (int)tableBitMask) != 0 ? (int)this.right[index2] : (int)this.left[index2]; tableBitMask <<= 1; }while (index1 < 0); } int codeLength = (int)this.codeLengthArray[index1]; if (codeLength <= 0) { InflateTree.InvalidHuffmanData(); } if (codeLength > input.AvailableBits) { return(-1); } input.SkipBits(codeLength); return(index1); }
private void DuplicateCode(short code, int start, int length) { int num1 = 1 << length; if (start >= num1) { InflateTree.InvalidHuffmanData(); } int num2 = 1 << this.tableBits - length; for (int index = 0; index < num2; ++index) { this.table[start] = code; start += num1; } }