Exemplo n.º 1
0
 public void CompressBlock()
 {
     for (int i = 0; i < this.last_lit; i++)
     {
         int num  = (int)(this.l_buf[i] & byte.MaxValue);
         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);
 }
Exemplo n.º 2
0
        public bool TallyDist(int distance, int length)
        {
            this.d_buf[this.last_lit]   = (short)distance;
            this.l_buf[this.last_lit++] = (byte)(length - 3);
            int num = DeflaterHuffman.Lcode(length - 3);

            short[] freqs = this.literalTree.freqs;
            int     num2  = num;

            freqs[num2] += 1;
            if (num >= 265 && num < 285)
            {
                this.extra_bits += (num - 261) / 4;
            }
            int num3 = DeflaterHuffman.Dcode(distance - 1);

            short[] freqs2 = this.distTree.freqs;
            int     num4   = num3;

            freqs2[num4] += 1;
            if (num3 >= 4)
            {
                this.extra_bits += num3 / 2 - 1;
            }
            return(this.IsFull());
        }