private uint[] CalculateHuffmanCode() { uint[] numArray1 = new uint[17]; foreach (int codeLength in this.codeLengthArray) { ++numArray1[codeLength]; } numArray1[0] = 0U; uint[] numArray2 = new uint[17]; uint num = 0; for (int index = 1; index <= 16; ++index) { num = (uint)((int)num + (int)numArray1[index - 1] << 1); numArray2[index] = num; } uint[] numArray3 = new uint[288]; for (int index = 0; index < this.codeLengthArray.Length; ++index) { int codeLength = (int)this.codeLengthArray[index]; if (codeLength > 0) { numArray3[index] = FastEncoderStatics.BitReverse(numArray2[codeLength], codeLength); ++numArray2[codeLength]; } } return(numArray3); }
internal static void WriteMatch(int matchLen, int matchPos, OutputBuffer output) { Debug.Assert(matchLen >= 3 && matchLen <= 258, "Illegal currentMatch length!"); uint num1 = FastEncoderStatics.FastEncoderLiteralCodeInfo[254 + matchLen]; int n1 = (int)num1 & 31; Debug.Assert((uint)n1 > 0U, "Invalid Match Length!"); if (n1 <= 16) { output.WriteBits(n1, num1 >> 5); } else { output.WriteBits(16, num1 >> 5 & (uint)ushort.MaxValue); output.WriteBits(n1 - 16, num1 >> 21); } uint num2 = FastEncoderStatics.FastEncoderDistanceCodeInfo[FastEncoderStatics.GetSlot(matchPos)]; output.WriteBits((int)num2 & 15, num2 >> 8); int n2 = (int)(num2 >> 4) & 15; if ((uint)n2 <= 0U) { return; } output.WriteBits(n2, (uint)matchPos & FastEncoderStatics.BitMask[n2]); }