예제 #1
0
파일: FastEncoder.cs 프로젝트: supermax/TMS
        internal static void WriteMatch(int matchLen, int matchPos, OutputBuffer output)
        {
            Debug.Assert(matchLen >= FastEncoderWindow.MinMatch && matchLen <= FastEncoderWindow.MaxMatch,
                         "Illegal currentMatch length!");

            // Get the code information for a match code
            var codeInfo =
                FastEncoderStatics.FastEncoderLiteralCodeInfo[
                    FastEncoderStatics.NumChars + 1 - FastEncoderWindow.MinMatch + matchLen];
            var codeLen = (int)codeInfo & 31;

            Debug.Assert(codeLen != 0, "Invalid Match Length!");
            if (codeLen <= 16)
            {
                output.WriteBits(codeLen, codeInfo >> 5);
            }
            else
            {
                output.WriteBits(16, (codeInfo >> 5) & 65535);
                output.WriteBits(codeLen - 16, codeInfo >> (5 + 16));
            }

            // Get the code information for a distance code
            codeInfo = FastEncoderStatics.FastEncoderDistanceCodeInfo[FastEncoderStatics.GetSlot(matchPos)];
            output.WriteBits((int)(codeInfo & 15), codeInfo >> 8);
            var extraBits = (int)(codeInfo >> 4) & 15;

            if (extraBits != 0)
            {
                output.WriteBits(extraBits, (uint)matchPos & FastEncoderStatics.BitMask[extraBits]);
            }
        }
예제 #2
0
        internal static void WriteMatch(int matchLen, int matchPos, OutputBuffer output)
        {
            uint num  = FastEncoderStatics.FastEncoderLiteralCodeInfo[254 + matchLen];
            int  num2 = (int)(num & 31u);

            if (num2 <= 16)
            {
                output.WriteBits(num2, num >> 5);
            }
            else
            {
                output.WriteBits(16, num >> 5 & 65535u);
                output.WriteBits(num2 - 16, num >> 21);
            }
            num = FastEncoderStatics.FastEncoderDistanceCodeInfo[FastEncoderStatics.GetSlot(matchPos)];
            output.WriteBits((int)(num & 15u), num >> 8);
            int num3 = (int)(num >> 4 & 15u);

            if (num3 != 0)
            {
                output.WriteBits(num3, (uint)(matchPos & (int)FastEncoderStatics.BitMask[num3]));
            }
        }