コード例 #1
0
ファイル: InflaterBlocks.cs プロジェクト: bininc/CommLiby
 private void ProcessTypeFixed(CompressionStream zip, InflaterBlocksContext state)
 {
     int[]   bl = new int[1];
     int[]   bd = new int[1];
     int[][] tl = new int[1][];
     int[][] td = new int[1][];
     InflaterTree.InflateTreeFixed(bl, bd, tl, td, zip);
     this.codes = new InflaterCodes(bl[0], bd[0], tl[0], td[0], zip);
     state.ShiftRight(3);
     this.mode = 6;
 }
コード例 #2
0
ファイル: InflaterBlocks.cs プロジェクト: bininc/CommLiby
        private int ProcessDTree(CompressionStream zip, InflaterBlocksContext state, int res)
        {
            while (true)
            {
                state.Temp = this.table;
                if (this.index < 258 + (state.Temp & 31) + (state.Temp >> 5 & 31))
                {
                    for (state.Temp = this.bitLengthTreeDepth[0]; state.Bits < state.Temp; state.Bits += 8)
                    {
                        if (state.BytesCount != 0)
                        {
                            res = 0;
                            --state.BytesCount;
                            state.BitBuf |= ((int)zip.Input[state.Input++] & (int)byte.MaxValue) << state.Bits;
                        }
                        else
                        {
                            this.TransferBlocksState(zip, state);
                            state.IsReturn = true;
                            return(this.InflateFlush(zip, res));
                        }
                    }
                    state.Temp = this.hufts[(this.bitLengthDecodeTree[0] + (state.BitBuf & InflaterBlocks.inflateMask[state.Temp])) * 3 + 1];
                    int huft = this.hufts[(this.bitLengthDecodeTree[0] + (state.BitBuf & InflaterBlocks.inflateMask[state.Temp])) * 3 + 2];
                    if (huft < 16)
                    {
                        state.ShiftRight(state.Temp);
                        this.blens[this.index++] = huft;
                    }
                    else
                    {
                        int v    = huft == 18 ? 7 : huft - 14;
                        int num1 = huft == 18 ? 11 : 3;
                        for (; state.Bits < state.Temp + v; state.Bits += 8)
                        {
                            if (state.BytesCount != 0)
                            {
                                res = 0;
                                --state.BytesCount;
                                state.BitBuf |= ((int)zip.Input[state.Input++] & (int)byte.MaxValue) << state.Bits;
                            }
                            else
                            {
                                this.TransferBlocksState(zip, state);
                                state.IsReturn = true;
                                return(this.InflateFlush(zip, res));
                            }
                        }
                        state.ShiftRight(state.Temp);
                        int num2 = num1 + (state.BitBuf & InflaterBlocks.inflateMask[v]);
                        state.ShiftRight(v);
                        int index = this.index;
                        state.Temp = this.table;
                        if (index + num2 <= 258 + (state.Temp & 31) + (state.Temp >> 5 & 31) && (huft != 16 || index >= 1))
                        {
                            int num3 = huft == 16 ? this.blens[index - 1] : 0;
                            do
                            {
                                this.blens[index++] = num3;
                            }while (--num2 != 0);
                            this.index = index;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    goto label_20;
                }
            }
            this.blens       = (int[])null;
            this.mode        = 9;
            zip.ErrorMessage = "invalid bit length repeat";
            res = -3;
            this.TransferBlocksState(zip, state);
            state.IsReturn = true;
            return(this.InflateFlush(zip, res));

label_20:
            this.bitLengthDecodeTree[0] = -1;
            int[] bl = new int[1];
            int[] bd = new int[1];
            int[] tl = new int[1];
            int[] td = new int[1];
            bl[0]      = 9;
            bd[0]      = 6;
            state.Temp = this.table;
            state.Temp = InflaterTree.InflateTreeDynamic(257 + (state.Temp & 31), 1 + (state.Temp >> 5 & 31), this.blens, bl, bd, tl, td, this.hufts, zip);
            if (state.Temp != 0)
            {
                if (state.Temp == -3)
                {
                    this.blens = (int[])null;
                    this.mode  = 9;
                }
                res = state.Temp;
                this.TransferBlocksState(zip, state);
                state.IsReturn = true;
                return(this.InflateFlush(zip, res));
            }
            this.codes = new InflaterCodes(bl[0], bd[0], this.hufts, tl[0], this.hufts, td[0], zip);
            this.mode  = 6;
            return(0);
        }