private int decodeNumber(Decode RD) { return(UnpackUtility.decodeNumber(this, RD)); }
private void unpack29(bool solid) { int[] DDecode = new int[Compress.DC]; byte[] DBits = new byte[Compress.DC]; int Bits; if (DDecode[1] == 0) { int Dist = 0, BitLength = 0, Slot = 0; for (int I = 0; I < DBitLengthCounts.Length; I++, BitLength++) { int count = DBitLengthCounts[I]; for (int J = 0; J < count; J++, Slot++, Dist += (1 << BitLength)) { DDecode[Slot] = Dist; DBits[Slot] = (byte)BitLength; } } } fileExtracted = true; if (!suspended) { unpInitData(solid); if (!unpReadBuf()) { return; } if ((!solid || !tablesRead) && !readTables()) { return; } } if (ppmError) { return; } while (true) { unpPtr &= Compress.MAXWINMASK; if (inAddr > readBorder) { if (!unpReadBuf()) { break; } } // System.out.println(((wrPtr - unpPtr) & // Compress.MAXWINMASK)+":"+wrPtr+":"+unpPtr); if (((wrPtr - unpPtr) & Compress.MAXWINMASK) < 260 && wrPtr != unpPtr) { UnpWriteBuf(); if (destUnpSize <= 0) { return; } if (suspended) { fileExtracted = false; return; } } if (unpBlockType == BlockTypes.BLOCK_PPM) { int Ch = ppm.decodeChar(); if (Ch == -1) { ppmError = true; break; } if (Ch == ppmEscChar) { int NextCh = ppm.decodeChar(); if (NextCh == 0) { if (!readTables()) { break; } continue; } if (NextCh == 2 || NextCh == -1) { break; } if (NextCh == 3) { if (!readVMCodePPM()) { break; } continue; } if (NextCh == 4) { int Distance = 0, Length = 0; bool failed = false; for (int I = 0; I < 4 && !failed; I++) { int ch = ppm.decodeChar(); if (ch == -1) { failed = true; } else { if (I == 3) { // Bug fixed Length = ch & 0xff; } else { // Bug fixed Distance = (Distance << 8) + (ch & 0xff); } } } if (failed) { break; } copyString(Length + 32, Distance + 2); continue; } if (NextCh == 5) { int Length = ppm.decodeChar(); if (Length == -1) { break; } copyString(Length + 4, 1); continue; } } window[unpPtr++] = (byte)Ch; continue; } //int Number = this.decodeNumber(LD); int Number = UnpackUtility.decodeNumber(this, LD); if (Number < 256) { window[unpPtr++] = (byte)Number; continue; } if (Number >= 271) { int Length = LDecode[Number -= 271] + 3; if ((Bits = LBits[Number]) > 0) { Length += Utility.URShift(GetBits(), (16 - Bits)); AddBits(Bits); } //int DistNumber = this.decodeNumber(DD); int DistNumber = UnpackUtility.decodeNumber(this, DD); int Distance = DDecode[DistNumber] + 1; if ((Bits = DBits[DistNumber]) > 0) { if (DistNumber > 9) { if (Bits > 4) { Distance += ((Utility.URShift(GetBits(), (20 - Bits))) << 4); AddBits(Bits - 4); } if (lowDistRepCount > 0) { lowDistRepCount--; Distance += prevLowDist; } else { //int LowDist = this.decodeNumber(LDD); int LowDist = UnpackUtility.decodeNumber(this, LDD); if (LowDist == 16) { lowDistRepCount = Compress.LOW_DIST_REP_COUNT - 1; Distance += prevLowDist; } else { Distance += LowDist; prevLowDist = LowDist; } } } else { Distance += Utility.URShift(GetBits(), (16 - Bits)); AddBits(Bits); } } if (Distance >= 0x2000) { Length++; if (Distance >= 0x40000L) { Length++; } } insertOldDist(Distance); insertLastMatch(Length, Distance); copyString(Length, Distance); continue; } if (Number == 256) { if (!readEndOfBlock()) { break; } continue; } if (Number == 257) { if (!readVMCode()) { break; } continue; } if (Number == 258) { if (lastLength != 0) { copyString(lastLength, lastDist); } continue; } if (Number < 263) { int DistNum = Number - 259; int Distance = oldDist[DistNum]; for (int I = DistNum; I > 0; I--) { oldDist[I] = oldDist[I - 1]; } oldDist[0] = Distance; //int LengthNumber = this.decodeNumber(RD); int LengthNumber = UnpackUtility.decodeNumber(this, RD); int Length = LDecode[LengthNumber] + 2; if ((Bits = LBits[LengthNumber]) > 0) { Length += Utility.URShift(GetBits(), (16 - Bits)); AddBits(Bits); } insertLastMatch(Length, Distance); copyString(Length, Distance); continue; } if (Number < 272) { int Distance = SDDecode[Number -= 263] + 1; if ((Bits = SDBits[Number]) > 0) { Distance += Utility.URShift(GetBits(), (16 - Bits)); AddBits(Bits); } insertOldDist(Distance); insertLastMatch(2, Distance); copyString(2, Distance); continue; } } UnpWriteBuf(); }
private int decodeNumber(BitDecode BD) { return(UnpackUtility.decodeNumber(this, BD)); }
private void unpack29(bool solid) { int num5; bool flag2; int[] numArray = new int[60]; byte[] buffer = new byte[60]; if (numArray[1] == 0) { int num2 = 0; int num3 = 0; int index = 0; num5 = 0; while (num5 < DBitLengthCounts.Length) { int num6 = DBitLengthCounts[num5]; int num7 = 0; while (num7 < num6) { numArray[index] = num2; buffer[index] = (byte)num3; num7++; index++; num2 += ((int)1) << num3; } num5++; num3++; } } this.fileExtracted = true; if (!base.suspended) { this.unpInitData(solid); if (!base.unpReadBuf() || !((solid && this.tablesRead) || this.readTables())) { return; } } if (this.ppmError) { return; } Label_0751: flag2 = true; base.unpPtr &= Compress.MAXWINMASK; if ((base.inAddr <= base.readBorder) || base.unpReadBuf()) { int num10; int num11; if ((((base.wrPtr - base.unpPtr) & Compress.MAXWINMASK) < 260) && (base.wrPtr != base.unpPtr)) { this.UnpWriteBuf(); if (base.destUnpSize <= 0L) { return; } if (base.suspended) { this.fileExtracted = false; return; } } if (this.unpBlockType == BlockTypes.BLOCK_PPM) { int num8 = this.ppm.decodeChar(); if (num8 == -1) { this.ppmError = true; goto Label_0759; } if (num8 == this.ppmEscChar) { switch (this.ppm.decodeChar()) { case 0: if (this.readTables()) { goto Label_0751; } goto Label_0759; case 2: case -1: goto Label_0759; case 3: if (this.readVMCodePPM()) { goto Label_0751; } goto Label_0759; case 4: { num10 = 0; num11 = 0; bool flag = false; for (num5 = 0; (num5 < 4) && !flag; num5++) { int num12 = this.ppm.decodeChar(); if (num12 == -1) { flag = true; } else if (num5 == 3) { num11 = num12 & 0xff; } else { num10 = (num10 << 8) + (num12 & 0xff); } } if (flag) { goto Label_0759; } this.copyString(num11 + 0x20, num10 + 2); goto Label_0751; } case 5: num11 = this.ppm.decodeChar(); if (num11 == -1) { goto Label_0759; } this.copyString(num11 + 4, 1); goto Label_0751; } } base.window[base.unpPtr++] = (byte)num8; } else { int num13 = UnpackUtility.decodeNumber(this, base.LD); if (num13 < 0x100) { base.window[base.unpPtr++] = (byte)num13; } else { int num; if (num13 >= 0x10f) { num11 = Unpack20.LDecode[num13 -= 0x10f] + 3; num = Unpack20.LBits[num13]; if (num > 0) { num11 += Utility.URShift(base.GetBits(), (int)(0x10 - num)); base.AddBits(num); } int num14 = UnpackUtility.decodeNumber(this, base.DD); num10 = numArray[num14] + 1; num = buffer[num14]; if (num > 0) { if (num14 > 9) { if (num > 4) { num10 += Utility.URShift(base.GetBits(), (int)(20 - num)) << 4; base.AddBits(num - 4); } if (this.lowDistRepCount > 0) { this.lowDistRepCount--; num10 += this.prevLowDist; } else { int num15 = UnpackUtility.decodeNumber(this, base.LDD); if (num15 == 0x10) { this.lowDistRepCount = 15; num10 += this.prevLowDist; } else { num10 += num15; this.prevLowDist = num15; } } } else { num10 += Utility.URShift(base.GetBits(), (int)(0x10 - num)); base.AddBits(num); } } if (num10 >= 0x2000) { num11++; if (num10 >= 0x40000L) { num11++; } } this.insertOldDist(num10); this.insertLastMatch(num11, num10); this.copyString(num11, num10); } else { switch (num13) { case 0x100: if (this.readEndOfBlock()) { goto Label_0751; } goto Label_0759; case 0x101: if (this.readVMCode()) { goto Label_0751; } goto Label_0759; case 0x102: if (base.lastLength != 0) { this.copyString(base.lastLength, base.lastDist); } goto Label_0751; } if (num13 < 0x107) { int num16 = num13 - 0x103; num10 = base.oldDist[num16]; for (num5 = num16; num5 > 0; num5--) { base.oldDist[num5] = base.oldDist[num5 - 1]; } base.oldDist[0] = num10; int num17 = UnpackUtility.decodeNumber(this, base.RD); num11 = Unpack20.LDecode[num17] + 2; num = Unpack20.LBits[num17]; if (num > 0) { num11 += Utility.URShift(base.GetBits(), (int)(0x10 - num)); base.AddBits(num); } this.insertLastMatch(num11, num10); this.copyString(num11, num10); } else if (num13 < 0x110) { num10 = Unpack20.SDDecode[num13 -= 0x107] + 1; num = Unpack20.SDBits[num13]; if (num > 0) { num10 += Utility.URShift(base.GetBits(), (int)(0x10 - num)); base.AddBits(num); } this.insertOldDist(num10); this.insertLastMatch(2, num10); this.copyString(2, num10); } } } } goto Label_0751; } Label_0759: this.UnpWriteBuf(); }