示例#1
0
        private bool Decode()
        {
            int num2;
            int num3;
            switch (this.mode)
            {
                case 0:
                    return this.DecodeHeader();

                case 1:
                    return this.DecodeDict();

                case 2:
                    if (!this.isLastBlock)
                    {
                        int num = this.input.PeekBits(3);
                        if (num < 0)
                        {
                            return false;
                        }
                        this.input.DropBits(3);
                        if ((num & 1) != 0)
                        {
                            this.isLastBlock = true;
                        }
                        switch ((num >> 1))
                        {
                            case 0:
                                this.input.SkipToByteBoundary();
                                this.mode = 3;
                                break;

                            case 1:
                                this.litlenTree = InflaterHuffmanTree.defLitLenTree;
                                this.distTree = InflaterHuffmanTree.defDistTree;
                                this.mode = 7;
                                break;

                            case 2:
                                this.dynHeader = new InflaterDynHeader();
                                this.mode = 6;
                                break;
                        }
                        throw new FormatException("Unknown block type " + num);
                    }
                    if (!this.nowrap)
                    {
                        this.input.SkipToByteBoundary();
                        this.neededBits = 0x20;
                        this.mode = 11;
                        return true;
                    }
                    this.mode = 12;
                    return false;

                case 3:
                    this.uncomprLen = this.input.PeekBits(0x10);
                    if (this.uncomprLen >= 0)
                    {
                        this.input.DropBits(0x10);
                        this.mode = 4;
                        goto Label_0193;
                    }
                    return false;

                case 4:
                    goto Label_0193;

                case 5:
                    goto Label_01DC;

                case 6:
                    if (this.dynHeader.Decode(this.input))
                    {
                        this.litlenTree = this.dynHeader.BuildLitLenTree();
                        this.distTree = this.dynHeader.BuildDistTree();
                        this.mode = 7;
                        goto Label_0268;
                    }
                    return false;

                case 7:
                case 8:
                case 9:
                case 10:
                    goto Label_0268;

                case 11:
                    return this.DecodeChksum();

                case 12:
                    return false;

                default:
                    throw new FormatException();
            }
            return true;
            Label_0193:
            num2 = this.input.PeekBits(0x10);
            if (num2 < 0)
            {
                return false;
            }
            this.input.DropBits(0x10);
            if (num2 != (this.uncomprLen ^ 0xffff))
            {
                throw new FormatException("broken uncompressed block");
            }
            this.mode = 5;
            Label_01DC:
            num3 = this.outputWindow.CopyStored(this.input, this.uncomprLen);
            this.uncomprLen -= num3;
            if (this.uncomprLen == 0)
            {
                this.mode = 2;
                return true;
            }
            return !this.input.IsNeedingInput;
            Label_0268:
            return this.DecodeHuffman();
        }
示例#2
0
 public void Reset()
 {
     this.mode = this.nowrap ? 2 : 0;
     this.totalIn = this.totalOut = 0;
     this.input.Reset();
     this.outputWindow.Reset();
     this.dynHeader = null;
     this.litlenTree = null;
     this.distTree = null;
     this.isLastBlock = false;
     this.adler.Reset();
 }