ICSharpCode.SharpZipLib.Zip.Compression.DeflaterHuffman.Lcode C# (CSharp) Method

Lcode() static private method

static private Lcode ( int length ) : int
length int
return int
        static int Lcode(int length)
        {
            if (length == 255) {
                return 285;
            }

            int code = 257;
            while (length >= 8) {
                code += 4;
                length >>= 1;
            }
            return code + length;
        }

Usage Example

 public void CompressBlock()
 {
     for (int i = 0; i < this.last_lit; i++)
     {
         int num  = (int)(this.l_buf[i] & 255);
         int num2 = (int)this.d_buf[i];
         if (num2-- != 0)
         {
             int num3 = DeflaterHuffman.Lcode(num);
             this.literalTree.WriteSymbol(num3);
             int num4 = (num3 - 261) / 4;
             if (num4 > 0 && num4 <= 5)
             {
                 this.pending.WriteBits(num & (1 << num4) - 1, num4);
             }
             int num5 = DeflaterHuffman.Dcode(num2);
             this.distTree.WriteSymbol(num5);
             num4 = num5 / 2 - 1;
             if (num4 > 0)
             {
                 this.pending.WriteBits(num2 & (1 << num4) - 1, num4);
             }
         }
         else
         {
             this.literalTree.WriteSymbol(num);
         }
     }
     this.literalTree.WriteSymbol(256);
 }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.Compression.DeflaterHuffman::Lcode