Beispiel #1
0
 internal static int DistanceCode(int dist) =>
 ((dist >= 0x100) ? ((int)_dist_code[0x100 + SharedUtils.URShift(dist, 7)]) : ((int)_dist_code[dist]));
Beispiel #2
0
 internal static int DistanceCode(int dist)
 {
     return((int)((dist >= 256) ? ZTree._dist_code[256 + SharedUtils.URShift(dist, 7)] : ZTree._dist_code[dist]));
 }
Beispiel #3
0
        private int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v)
        {
            int num  = 0;
            int num2 = n;

            do
            {
                c[b[bindex + num]]++;
                num++;
                num2--;
            }while (num2 != 0);
            if (c[0] == n)
            {
                t[0] = -1;
                m[0] = 0;
                return(0);
            }
            int num3 = m[0];
            int i;

            for (i = 1; i <= 15 && c[i] == 0; i++)
            {
            }
            int j = i;

            if (num3 < i)
            {
                num3 = i;
            }
            num2 = 15;
            while (num2 != 0 && c[num2] == 0)
            {
                num2--;
            }
            int num4 = num2;

            if (num3 > num2)
            {
                num3 = num2;
            }
            m[0] = num3;
            int num5 = 1 << i;

            while (i < num2)
            {
                if ((num5 -= c[i]) < 0)
                {
                    return(-3);
                }
                i++;
                num5 <<= 1;
            }
            if ((num5 -= c[num2]) < 0)
            {
                return(-3);
            }
            c[num2] += num5;
            i        = (x[1] = 0);
            num      = 1;
            int num6 = 2;

            while (--num2 != 0)
            {
                i = (x[num6] = i + c[num]);
                num6++;
                num++;
            }
            num2 = 0;
            num  = 0;
            do
            {
                if ((i = b[bindex + num]) != 0)
                {
                    v[x[i]++] = num2;
                }
                num++;
            }while (++num2 < n);
            n    = x[num4];
            num2 = (x[0] = 0);
            num  = 0;
            int num7 = -1;
            int num8 = -num3;

            u[0] = 0;
            int num9  = 0;
            int num10 = 0;

            for (; j <= num4; j++)
            {
                int num11 = c[j];
                while (num11-- != 0)
                {
                    int num13;
                    while (j > num8 + num3)
                    {
                        num7++;
                        num8 += num3;
                        num10 = num4 - num8;
                        num10 = ((num10 <= num3) ? num10 : num3);
                        if ((num13 = 1 << (i = j - num8)) > num11 + 1)
                        {
                            num13 -= num11 + 1;
                            num6   = j;
                            if (i < num10)
                            {
                                while (++i < num10 && (num13 <<= 1) > c[++num6])
                                {
                                    num13 -= c[num6];
                                }
                            }
                        }
                        num10 = 1 << i;
                        if (hn[0] + num10 > 1440)
                        {
                            return(-3);
                        }
                        num9   = (u[num7] = hn[0]);
                        hn[0] += num10;
                        if (num7 != 0)
                        {
                            x[num7] = num2;
                            r[0]    = (sbyte)i;
                            r[1]    = (sbyte)num3;
                            i       = SharedUtils.URShift(num2, num8 - num3);
                            r[2]    = num9 - u[num7 - 1] - i;
                            Array.Copy(r, 0, hp, (u[num7 - 1] + i) * 3, 3);
                        }
                        else
                        {
                            t[0] = num9;
                        }
                    }
                    r[1] = (sbyte)(j - num8);
                    if (num >= n)
                    {
                        r[0] = 192;
                    }
                    else if (v[num] < s)
                    {
                        r[0] = (sbyte)((v[num] >= 256) ? 96 : 0);
                        r[2] = v[num++];
                    }
                    else
                    {
                        r[0] = (sbyte)(e[v[num] - s] + 16 + 64);
                        r[2] = d[v[num++] - s];
                    }
                    num13 = 1 << j - num8;
                    for (i = SharedUtils.URShift(num2, num8); i < num10; i += num13)
                    {
                        Array.Copy(r, 0, hp, (num9 + i) * 3, 3);
                    }
                    i = 1 << j - 1;
                    while ((num2 & i) != 0)
                    {
                        num2 ^= i;
                        i     = SharedUtils.URShift(i, 1);
                    }
                    num2 ^= i;
                    int num16 = (1 << num8) - 1;
                    while ((num2 & num16) != x[num7])
                    {
                        num7--;
                        num8 -= num3;
                        num16 = (1 << num8) - 1;
                    }
                }
            }
            return((num5 != 0 && num4 != 1) ? (-5) : 0);
        }
Beispiel #4
0
 /// <summary>
 /// Map from a distance to a distance code.
 /// </summary>
 /// <remarks>
 /// No side effects. _dist_code[256] and _dist_code[257] are never used.
 /// </remarks>
 internal static int DistanceCode(int dist)
 {
     return((dist < 256)
         ? _dist_code[dist]
         : _dist_code[256 + SharedUtils.URShift(dist, 7)]);
 }