DistanceCode() 정적인 개인적인 메소드

Map from a distance to a distance code.
No side effects. _dist_code[256] and _dist_code[257] are never used.
static private DistanceCode ( int dist ) : int
dist int
리턴 int
예제 #1
0
 internal bool _tr_tally(int dist, int lc)
 {
     pending[_distanceOffset + last_lit * 2]     = (byte)((uint)dist >> 8);
     pending[_distanceOffset + last_lit * 2 + 1] = (byte)dist;
     pending[_lengthOffset + last_lit]           = (byte)lc;
     last_lit++;
     if (dist == 0)
     {
         dyn_ltree[lc * 2]++;
     }
     else
     {
         matches++;
         dist--;
         dyn_ltree[(Tree.LengthCode[lc] + InternalConstants.LITERALS + 1) * 2]++;
         dyn_dtree[Tree.DistanceCode(dist) * 2]++;
     }
     if ((last_lit & 0x1FFF) == 0 && compressionLevel > CompressionLevel.Level2)
     {
         int num  = last_lit << 3;
         int num2 = strstart - block_start;
         for (int i = 0; i < InternalConstants.D_CODES; i++)
         {
             num = (int)(num + dyn_dtree[i * 2] * (5L + (long)Tree.ExtraDistanceBits[i]));
         }
         num >>= 3;
         if (matches < last_lit / 2 && num < num2 / 2)
         {
             return(true);
         }
     }
     return(last_lit == lit_bufsize - 1 || last_lit == lit_bufsize);
 }
예제 #2
0
        internal void send_compressed_block(short[] ltree, short[] dtree)
        {
            int num = 0;

            if (this.last_lit != 0)
            {
                while (true)
                {
                    int num2 = this._distanceOffset + num * 2;
                    int num3 = (this.pending[num2] << 8 & 65280) | (this.pending[num2 + 1] & 0xFF);
                    int num4 = this.pending[this._lengthOffset + num] & 0xFF;
                    num++;
                    if (num3 == 0)
                    {
                        this.send_code(num4, ltree);
                    }
                    else
                    {
                        int num5 = Tree.LengthCode[num4];
                        this.send_code(num5 + InternalConstants.LITERALS + 1, ltree);
                        int num6 = Tree.ExtraLengthBits[num5];
                        if (num6 != 0)
                        {
                            num4 -= Tree.LengthBase[num5];
                            this.send_bits(num4, num6);
                        }
                        num3--;
                        num5 = Tree.DistanceCode(num3);
                        this.send_code(num5, dtree);
                        num6 = Tree.ExtraDistanceBits[num5];
                        if (num6 != 0)
                        {
                            num3 -= Tree.DistanceBase[num5];
                            this.send_bits(num3, num6);
                        }
                    }
                    if (num >= this.last_lit)
                    {
                        break;
                    }
                }
            }
            this.send_code(DeflateManager.END_BLOCK, ltree);
            this.last_eob_len = ltree[DeflateManager.END_BLOCK * 2 + 1];
        }
예제 #3
0
        internal void send_compressed_block(short[] ltree, short[] dtree)
        {
            int num = 0;

            if (last_lit != 0)
            {
                do
                {
                    int num2 = _distanceOffset + num * 2;
                    int num3 = ((pending[num2] << 8) & 0xFF00) | (pending[num2 + 1] & 0xFF);
                    int num4 = pending[_lengthOffset + num] & 0xFF;
                    num++;
                    if (num3 == 0)
                    {
                        send_code(num4, ltree);
                    }
                    else
                    {
                        int num5 = Tree.LengthCode[num4];
                        send_code(num5 + InternalConstants.LITERALS + 1, ltree);
                        int num6 = Tree.ExtraLengthBits[num5];
                        if (num6 != 0)
                        {
                            num4 -= Tree.LengthBase[num5];
                            send_bits(num4, num6);
                        }
                        num3--;
                        num5 = Tree.DistanceCode(num3);
                        send_code(num5, dtree);
                        num6 = Tree.ExtraDistanceBits[num5];
                        if (num6 != 0)
                        {
                            num3 -= Tree.DistanceBase[num5];
                            send_bits(num3, num6);
                        }
                    }
                }while (num < last_lit);
            }
            send_code(END_BLOCK, ltree);
            last_eob_len = ltree[END_BLOCK * 2 + 1];
        }
예제 #4
0
        internal void send_compressed_block(short[] ltree, short[] dtree)
        {
            int lx = 0;

            if (last_lit != 0)
            {
                do
                {
                    int ix        = _distanceOffset + lx * 2;
                    int distance3 = ((pending[ix] << 8) & 0xFF00) | (pending[ix + 1] & 0xFF);
                    int lc2       = pending[_lengthOffset + lx] & 0xFF;
                    lx++;
                    if (distance3 == 0)
                    {
                        send_code(lc2, ltree);
                        continue;
                    }
                    int code2 = Tree.LengthCode[lc2];
                    send_code(code2 + InternalConstants.LITERALS + 1, ltree);
                    int extra2 = Tree.ExtraLengthBits[code2];
                    if (extra2 != 0)
                    {
                        lc2 -= Tree.LengthBase[code2];
                        send_bits(lc2, extra2);
                    }
                    distance3--;
                    code2 = Tree.DistanceCode(distance3);
                    send_code(code2, dtree);
                    extra2 = Tree.ExtraDistanceBits[code2];
                    if (extra2 != 0)
                    {
                        distance3 -= Tree.DistanceBase[code2];
                        send_bits(distance3, extra2);
                    }
                }while (lx < last_lit);
            }
            send_code(END_BLOCK, ltree);
            last_eob_len = ltree[END_BLOCK * 2 + 1];
        }
 internal bool _tr_tally(int dist, int lc)
 {
     this.pending[this._distanceOffset + this.last_lit * 2]     = (byte)((uint)dist >> 8);
     this.pending[this._distanceOffset + this.last_lit * 2 + 1] = (byte)dist;
     this.pending[this._lengthOffset + this.last_lit]           = (byte)lc;
     this.last_lit++;
     if (dist == 0)
     {
         short[] array = this.dyn_ltree;
         int     num   = lc * 2;
         array[num] += 1;
     }
     else
     {
         this.matches++;
         dist--;
         short[] array2 = this.dyn_ltree;
         int     num2   = ((int)Tree.LengthCode[lc] + InternalConstants.LITERALS + 1) * 2;
         array2[num2] += 1;
         short[] array3 = this.dyn_dtree;
         int     num3   = Tree.DistanceCode(dist) * 2;
         array3[num3] += 1;
     }
     if ((this.last_lit & 8191) == 0 && this.compressionLevel > CompressionLevel.Level2)
     {
         int num4 = this.last_lit << 3;
         int num5 = this.strstart - this.block_start;
         for (int i = 0; i < InternalConstants.D_CODES; i++)
         {
             num4 = (int)((long)num4 + (long)this.dyn_dtree[i * 2] * (5L + (long)Tree.ExtraDistanceBits[i]));
         }
         num4 >>= 3;
         if (this.matches < this.last_lit / 2 && num4 < num5 / 2)
         {
             return(true);
         }
     }
     return(this.last_lit == this.lit_bufsize - 1 || this.last_lit == this.lit_bufsize);
 }
예제 #6
0
 internal bool _tr_tally(int dist, int lc)
 {
     pending[_distanceOffset + last_lit * 2]     = (byte)((uint)dist >> 8);
     pending[_distanceOffset + last_lit * 2 + 1] = (byte)dist;
     pending[_lengthOffset + last_lit]           = (byte)lc;
     last_lit++;
     if (dist == 0)
     {
         dyn_ltree[lc * 2]++;
     }
     else
     {
         matches++;
         dist--;
         dyn_ltree[(Tree.LengthCode[lc] + InternalConstants.LITERALS + 1) * 2]++;
         dyn_dtree[Tree.DistanceCode(dist) * 2]++;
     }
     if ((last_lit & 0x1FFF) == 0 && compressionLevel > CompressionLevel.Level2)
     {
         int out_length2 = last_lit << 3;
         int in_length   = strstart - block_start;
         for (int dcode = 0; dcode < InternalConstants.D_CODES; dcode++)
         {
             out_length2 = (int)(out_length2 + dyn_dtree[dcode * 2] * (5L + (long)Tree.ExtraDistanceBits[dcode]));
         }
         out_length2 >>= 3;
         if (matches < last_lit / 2 && out_length2 < in_length / 2)
         {
             return(true);
         }
     }
     if (last_lit != lit_bufsize - 1)
     {
         return(last_lit == lit_bufsize);
     }
     return(true);
 }