static InflaterHuffmanTree() { byte[] codeLengths = new byte[0x120]; int num = 0; while (num < 0x90) { codeLengths[num++] = 8; } while (num < 0x100) { codeLengths[num++] = 9; } while (num < 280) { codeLengths[num++] = 7; } while (num < 0x120) { codeLengths[num++] = 8; } defLitLenTree = new SimpleZip.InflaterHuffmanTree(codeLengths); codeLengths = new byte[0x20]; num = 0; while (num < 0x20) { codeLengths[num++] = 5; } defDistTree = new SimpleZip.InflaterHuffmanTree(codeLengths); }
private bool DecodeHuffman() { int freeSpace = this.outputWindow.GetFreeSpace(); while (freeSpace >= 0x102) { int num2; switch (this.mode) { case 7: goto Label_0051; case 8: goto Label_00B7; case 9: goto Label_0106; case 10: goto Label_0138; default: { continue; } } Label_0037: this.outputWindow.Write(num2); if (--freeSpace < 0x102) { return true; } Label_0051: if (((num2 = this.litlenTree.GetSymbol(this.input)) & -256) == 0) { goto Label_0037; } if (num2 < 0x101) { if (num2 < 0) { return false; } this.distTree = null; this.litlenTree = null; this.mode = 2; return true; } this.repLength = CPLENS[num2 - 0x101]; this.neededBits = CPLEXT[num2 - 0x101]; Label_00B7: if (this.neededBits > 0) { this.mode = 8; int num3 = this.input.PeekBits(this.neededBits); if (num3 < 0) { return false; } this.input.DropBits(this.neededBits); this.repLength += num3; } this.mode = 9; Label_0106: num2 = this.distTree.GetSymbol(this.input); if (num2 < 0) { return false; } this.repDist = CPDIST[num2]; this.neededBits = CPDEXT[num2]; Label_0138: if (this.neededBits > 0) { this.mode = 10; int num4 = this.input.PeekBits(this.neededBits); if (num4 < 0) { return false; } this.input.DropBits(this.neededBits); this.repDist += num4; } this.outputWindow.Repeat(this.repLength, this.repDist); freeSpace -= this.repLength; this.mode = 7; } return true; }
public bool Decode(SimpleZip.StreamManipulator input) { int num2; int num3; Label_0000: switch (this.mode) { case 0: this.lnum = input.PeekBits(5); if (this.lnum >= 0) { this.lnum += 0x101; input.DropBits(5); this.mode = 1; break; } return false; case 1: break; case 2: goto Label_00B9; case 3: goto Label_013B; case 4: goto Label_01A8; case 5: goto Label_01DE; default: goto Label_0000; } this.dnum = input.PeekBits(5); if (this.dnum < 0) { return false; } this.dnum++; input.DropBits(5); this.num = this.lnum + this.dnum; this.litdistLens = new byte[this.num]; this.mode = 2; Label_00B9: this.blnum = input.PeekBits(4); if (this.blnum < 0) { return false; } this.blnum += 4; input.DropBits(4); this.blLens = new byte[0x13]; this.ptr = 0; this.mode = 3; Label_013B: while (this.ptr < this.blnum) { int num = input.PeekBits(3); if (num < 0) { return false; } input.DropBits(3); this.blLens[BL_ORDER[this.ptr]] = (byte) num; this.ptr++; } this.blTree = new SimpleZip.InflaterHuffmanTree(this.blLens); this.blLens = null; this.ptr = 0; this.mode = 4; Label_01A8: while (((num2 = this.blTree.GetSymbol(input)) & -16) == 0) { this.litdistLens[this.ptr++] = this.lastLen = (byte) num2; if (this.ptr == this.num) { return true; } } if (num2 < 0) { return false; } if (num2 >= 0x11) { this.lastLen = 0; } this.repSymbol = num2 - 0x10; this.mode = 5; Label_01DE: num3 = repBits[this.repSymbol]; int num4 = input.PeekBits(num3); if (num4 < 0) { return false; } input.DropBits(num3); num4 += repMin[this.repSymbol]; while (num4-- > 0) { this.litdistLens[this.ptr++] = this.lastLen; } if (this.ptr == this.num) { return true; } this.mode = 4; goto Label_0000; }
private bool Decode() { int num3; switch (this.mode) { 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; goto Label_00DC; case 1: this.litlenTree = SimpleZip.InflaterHuffmanTree.defLitLenTree; this.distTree = SimpleZip.InflaterHuffmanTree.defDistTree; this.mode = 7; goto Label_00DC; case 2: this.dynHeader = new SimpleZip.InflaterDynHeader(); this.mode = 6; goto Label_00DC; } break; } 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_010F; } return false; case 4: goto Label_010F; case 5: goto Label_0137; case 6: if (this.dynHeader.Decode(this.input)) { this.litlenTree = this.dynHeader.BuildLitLenTree(); this.distTree = this.dynHeader.BuildDistTree(); this.mode = 7; goto Label_01BB; } return false; case 7: case 8: case 9: case 10: goto Label_01BB; case 12: return false; default: return false; } Label_00DC: return true; Label_010F: if (this.input.PeekBits(0x10) < 0) { return false; } this.input.DropBits(0x10); this.mode = 5; Label_0137: 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_01BB: return this.DecodeHuffman(); }