internal PpmdProperties(int allocatorSize, int modelOrder, SharpCompress.Compressor.PPMd.I1.ModelRestorationMethod modelRestorationMethod) { this.Version = PpmdVersion.I1; this.AllocatorSize = allocatorSize; this.ModelOrder = modelOrder; this.ModelRestorationMethod = modelRestorationMethod; }
internal ZipArchiveEntry(ZipArchive archive, SharpCompress.Archive.Zip.ZipArchiveEntry entry) { if (archive == null) throw new ArgumentNullException("archive"); if (entry == null) throw new ArgumentNullException("entry"); Archive = archive; this.entry = entry; }
public MemoryStream GetUnCompressStream(SharpCompress.Archive.Zip.ZipArchiveEntry entry) { MemoryStream tempStream = new MemoryStream(); //SharpCompress.Archive.IArchiveEntryExtensions.WriteTo(entry, tempStream); using (var entryStream = entry.OpenEntryStream()) { const int bufSize = 1024 * 16;//16k byte[] buf = new byte[bufSize]; int bytesRead = 0; while ((bytesRead = entryStream.Read(buf, 0, bufSize)) > 0) tempStream.Write(buf, 0, bytesRead); } tempStream.Position = 0; return tempStream; }
internal static void PPMDSwap(SharpCompress.Compressor.PPMd.H.State ptr1, SharpCompress.Compressor.PPMd.H.State ptr2) { byte[] memory = ptr1.Memory; byte[] buffer2 = ptr2.Memory; int num = 0; int address = ptr1.Address; for (int i = ptr2.Address; num < 6; i++) { byte num4 = memory[address]; memory[address] = buffer2[i]; buffer2[i] = num4; num++; address++; } }
public void Encode(SharpCompress.Compressor.LZMA.RangeCoder.Encoder rangeEncoder, byte symbol) { uint index = 1; for (int i = 7; i >= 0; i--) { uint num3 = (uint) ((symbol >> i) & 1); this.m_Encoders[index].Encode(rangeEncoder, num3); index = (index << 1) | num3; } }
public CompressedPage(SharpCompress.Archive.IArchiveEntry Entry) { this.Entry = Entry; }
public void Encode(SharpCompress.Compressor.LZMA.RangeCoder.Encoder rangeEncoder, uint symbol, uint posState) { base.Encode(rangeEncoder, symbol, posState); if ((this._counters[posState] -= 1) == 0) { this.UpdateTable(posState); } }
public byte DecodeWithMatchByte(SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte, byte matchByte) { return this.m_Coders[this.GetState(pos, prevByte)].DecodeWithMatchByte(rangeDecoder, matchByte); }
public byte DecodeWithMatchByte(SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder, byte matchByte) { uint index = 1; do { uint num2 = (uint) ((matchByte >> 7) & 1); matchByte = (byte) (matchByte << 1); uint num3 = this.m_Decoders[(int) ((IntPtr) (((1 + num2) << 8) + index))].Decode(rangeDecoder); index = (index << 1) | num3; if (num2 != num3) { while (index < 0x100) { index = (index << 1) | this.m_Decoders[index].Decode(rangeDecoder); } break; } } while (index < 0x100); return (byte) index; }
private int createSuccessors(bool Skip, SharpCompress.Compressor.PPMd.H.State p1) { StateRef firstState = this.tempStateRef2; SharpCompress.Compressor.PPMd.H.State pStats = this.tempState1.Initialize(this.Heap); PPMContext context = this.tempPPMContext1.Initialize(this.Heap); context.Address = this.minContext.Address; PPMContext context2 = this.tempPPMContext2.Initialize(this.Heap); context2.Address = this.foundState.GetSuccessor(); SharpCompress.Compressor.PPMd.H.State state2 = this.tempState2.Initialize(this.Heap); int num = 0; bool flag = false; if (!Skip) { this.ps[num++] = this.foundState.Address; if (context.getSuffix() == 0) { flag = true; } } if (flag) { goto Label_01E0; } bool flag2 = false; if (p1.Address != 0) { state2.Address = p1.Address; context.Address = context.getSuffix(); flag2 = true; } Label_00F2: if (!flag2) { context.Address = context.getSuffix(); if (context.NumStats != 1) { state2.Address = context.FreqData.GetStats(); if (state2.Symbol != this.foundState.Symbol) { do { state2.IncrementAddress(); } while (state2.Symbol != this.foundState.Symbol); } } else { state2.Address = context.getOneState().Address; } } flag2 = false; if (state2.GetSuccessor() != context2.Address) { context.Address = state2.GetSuccessor(); } else { this.ps[num++] = state2.Address; if (context.getSuffix() != 0) { goto Label_00F2; } } Label_01E0: if (num != 0) { firstState.Symbol = this.Heap[context2.Address]; firstState.SetSuccessor((int) (context2.Address + 1)); if (context.NumStats != 1) { if (context.Address <= this.subAlloc.PText) { return 0; } state2.Address = context.FreqData.GetStats(); if (state2.Symbol != firstState.Symbol) { do { state2.IncrementAddress(); } while (state2.Symbol != firstState.Symbol); } int num2 = state2.Freq - 1; int num3 = (context.FreqData.SummFreq - context.NumStats) - num2; firstState.Freq = 1 + (((2 * num2) <= num3) ? (((5 * num2) > num3) ? 1 : 0) : ((((2 * num2) + (3 * num3)) - 1) / (2 * num3))); } else { firstState.Freq = context.getOneState().Freq; } do { pStats.Address = this.ps[--num]; context.Address = context.createChild(this, pStats, firstState); if (context.Address == 0) { return 0; } } while (num != 0); } return context.Address; }
public uint Decode(SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder, uint posState) { if (this.m_Choice.Decode(rangeDecoder) == 0) { return this.m_LowCoder[posState].Decode(rangeDecoder); } uint num = 8; if (this.m_Choice2.Decode(rangeDecoder) == 0) { num += this.m_MidCoder[posState].Decode(rangeDecoder); } else { num += 8; num += this.m_HighCoder.Decode(rangeDecoder); } return num; }
internal RarHeaderFactory(SharpCompress.IO.StreamingMode mode, SharpCompress.Common.Options options, string password) { this.StreamingMode = mode; this.Options = options; this.Password = password; }
private static string ConvertPath(string path, SharpCompress.Common.Rar.Headers.HostOS os) { return path.Replace('\\', '/'); }
internal int getArrayIndex(ModelPPM Model, SharpCompress.Compressor.PPMd.H.State rs) { PPMContext context = this.getTempPPMContext(Model.SubAlloc.Heap); context.Address = this.getSuffix(); int num = 0; num += Model.PrevSuccess; num += Model.getNS2BSIndx()[context.NumStats - 1]; num += Model.HiBitsFlag + (2 * Model.getHB2Flag()[rs.Symbol]); return (num + (Utility.URShift(Model.RunLength, 0x1a) & 0x20)); }
private bool Options_HasFlag(SharpCompress.Common.Options options) { return ((this.Options & options) == options); }
internal int createChild(ModelPPM model, SharpCompress.Compressor.PPMd.H.State pStats, StateRef firstState) { PPMContext successor = this.getTempPPMContext(model.SubAlloc.Heap); successor.Address = model.SubAlloc.allocContext(); if (successor != null) { successor.NumStats = 1; successor.setOneState(firstState); successor.setSuffix(this); pStats.SetSuccessor(successor); } return successor.Address; }
internal Volume(System.IO.Stream stream, SharpCompress.Common.Options options) { this.actualStream = stream; this.Options = options; }
internal virtual void SetStats(SharpCompress.Compressor.PPMd.H.State state) { this.SetStats(state.Address); }
public void EncodeMatched(SharpCompress.Compressor.LZMA.RangeCoder.Encoder rangeEncoder, byte matchByte, byte symbol) { uint num = 1; bool flag = true; for (int i = 7; i >= 0; i--) { uint num3 = (uint) ((symbol >> i) & 1); uint index = num; if (flag) { uint num5 = (uint) ((matchByte >> i) & 1); index += (uint) ((1 + num5) << 8); flag = num5 == num3; } this.m_Encoders[index].Encode(rangeEncoder, num3); num = (num << 1) | num3; } }
private bool FileFlags_HasFlag(SharpCompress.Common.Rar.Headers.FileFlags fileFlags) { return (((this.FileFlags & fileFlags)) == fileFlags); }
public int decodeChar(SharpCompress.Compressor.LZMA.RangeCoder.Decoder decoder) { SharpCompress.Compressor.PPMd.H.State state; int num; int threshold; int num3; byte symbol; if (this.minContext.NumStats != 1) { state = this.tempState1.Initialize(this.Heap); state.Address = this.minContext.FreqData.GetStats(); if ((threshold = (int) decoder.GetThreshold((uint) this.minContext.FreqData.SummFreq)) < (num3 = state.Freq)) { decoder.Decode(0, (uint) state.Freq); symbol = (byte) state.Symbol; this.minContext.update1_0(this, state.Address); this.nextContext(); return symbol; } this.prevSuccess = 0; num = this.minContext.NumStats - 1; do { state.IncrementAddress(); if ((num3 += state.Freq) > threshold) { decoder.Decode((uint) (num3 - state.Freq), (uint) state.Freq); symbol = (byte) state.Symbol; this.minContext.update1(this, state.Address); this.nextContext(); return symbol; } } while (--num > 0); if (threshold >= this.minContext.FreqData.SummFreq) { return -2; } this.hiBitsFlag = this.HB2Flag[this.foundState.Symbol]; decoder.Decode((uint) num3, (uint) (this.minContext.FreqData.SummFreq - num3)); for (num = 0; num < 0x100; num++) { this.charMask[num] = -1; } this.charMask[state.Symbol] = 0; num = this.minContext.NumStats - 1; do { state.DecrementAddress(); this.charMask[state.Symbol] = 0; } while (--num > 0); } else { SharpCompress.Compressor.PPMd.H.State rs = this.tempState1.Initialize(this.Heap); rs.Address = this.minContext.getOneState().Address; this.hiBitsFlag = this.getHB2Flag()[this.foundState.Symbol]; int index = rs.Freq - 1; int num6 = this.minContext.getArrayIndex(this, rs); int summ = this.binSumm[index][num6]; if (decoder.DecodeBit((uint) summ, 14) == 0) { this.binSumm[index][num6] = ((summ + INTERVAL) - this.minContext.getMean(summ, 7, 2)) & 0xffff; this.foundState.Address = rs.Address; symbol = (byte) rs.Symbol; rs.IncrementFreq((rs.Freq < 0x80) ? 1 : 0); this.prevSuccess = 1; this.incRunLength(1); this.nextContext(); return symbol; } summ = (summ - this.minContext.getMean(summ, 7, 2)) & 0xffff; this.binSumm[index][num6] = summ; this.initEsc = PPMContext.ExpEscape[Utility.URShift(summ, 10)]; for (num = 0; num < 0x100; num++) { this.charMask[num] = -1; } this.charMask[rs.Symbol] = 0; this.prevSuccess = 0; } while (true) { int num8; state = this.tempState1.Initialize(this.Heap); int numStats = this.minContext.NumStats; do { this.orderFall++; this.minContext.Address = this.minContext.getSuffix(); if ((this.minContext.Address <= this.subAlloc.PText) || (this.minContext.Address > this.subAlloc.HeapEnd)) { return -1; } } while (this.minContext.NumStats == numStats); num3 = 0; state.Address = this.minContext.FreqData.GetStats(); num = 0; int num9 = this.minContext.NumStats - numStats; do { int num11 = this.charMask[state.Symbol]; num3 += state.Freq & num11; this.minContext.ps[num] = state.Address; state.IncrementAddress(); num -= num11; } while (num != num9); SEE2Context context = this.minContext.makeEscFreq(this, numStats, out num8); num8 += num3; threshold = (int) decoder.GetThreshold((uint) num8); if (threshold < num3) { SharpCompress.Compressor.PPMd.H.State state3 = this.tempState2.Initialize(this.Heap); num3 = 0; num = 0; state3.Address = this.minContext.ps[num]; while ((num3 += state3.Freq) <= threshold) { num++; state3.Address = this.minContext.ps[num]; } state.Address = state3.Address; decoder.Decode((uint) (num3 - state.Freq), (uint) state.Freq); context.update(); symbol = (byte) state.Symbol; this.minContext.update2(this, state.Address); this.updateModel(); return symbol; } if (threshold >= num8) { return -2; } decoder.Decode((uint) num3, (uint) (num8 - num3)); context.Summ += num8; do { state.Address = this.minContext.ps[--num]; this.charMask[state.Symbol] = 0; } while (num != 0); } }
internal void SetValues(SharpCompress.Compressor.PPMd.H.State ptr) { Array.Copy(ptr.Memory, ptr.Address, base.Memory, this.Address, 6); }
internal bool Code(int dictionarySize, OutWindow outWindow, SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder) { int num = Math.Max(dictionarySize, 1); outWindow.CopyPending(); while (outWindow.HasSpace) { uint posState = ((uint) outWindow.Total) & this.m_PosStateMask; if (this.m_IsMatchDecoders[(this.state.Index << 4) + posState].Decode(rangeDecoder) == 0) { byte num3; byte @byte = outWindow.GetByte(0); if (!this.state.IsCharState()) { num3 = this.m_LiteralDecoder.DecodeWithMatchByte(rangeDecoder, (uint) outWindow.Total, @byte, outWindow.GetByte((int) this.rep0)); } else { num3 = this.m_LiteralDecoder.DecodeNormal(rangeDecoder, (uint) outWindow.Total, @byte); } outWindow.PutByte(num3); this.state.UpdateChar(); } else { uint num5; if (this.m_IsRepDecoders[this.state.Index].Decode(rangeDecoder) == 1) { if (this.m_IsRepG0Decoders[this.state.Index].Decode(rangeDecoder) == 0) { if (this.m_IsRep0LongDecoders[(this.state.Index << 4) + posState].Decode(rangeDecoder) == 0) { this.state.UpdateShortRep(); outWindow.PutByte(outWindow.GetByte((int) this.rep0)); continue; } } else { uint num6; if (this.m_IsRepG1Decoders[this.state.Index].Decode(rangeDecoder) == 0) { num6 = this.rep1; } else { if (this.m_IsRepG2Decoders[this.state.Index].Decode(rangeDecoder) == 0) { num6 = this.rep2; } else { num6 = this.rep3; this.rep3 = this.rep2; } this.rep2 = this.rep1; } this.rep1 = this.rep0; this.rep0 = num6; } num5 = this.m_RepLenDecoder.Decode(rangeDecoder, posState) + 2; this.state.UpdateRep(); } else { this.rep3 = this.rep2; this.rep2 = this.rep1; this.rep1 = this.rep0; num5 = 2 + this.m_LenDecoder.Decode(rangeDecoder, posState); this.state.UpdateMatch(); uint num7 = this.m_PosSlotDecoder[Base.GetLenToPosState(num5)].Decode(rangeDecoder); if (num7 >= 4) { int numBitLevels = ((int) (num7 >> 1)) - 1; this.rep0 = (uint) ((2 | (num7 & 1)) << (numBitLevels & 0x1f)); if (num7 < 14) { this.rep0 += BitTreeDecoder.ReverseDecode(this.m_PosDecoders, (this.rep0 - num7) - 1, rangeDecoder, numBitLevels); } else { this.rep0 += rangeDecoder.DecodeDirectBits(numBitLevels - 4) << 4; this.rep0 += this.m_PosAlignDecoder.ReverseDecode(rangeDecoder); } } else { this.rep0 = num7; } } if ((this.rep0 >= outWindow.Total) || (this.rep0 >= num)) { if (this.rep0 != uint.MaxValue) { throw new DataErrorException(); } return true; } outWindow.CopyBlock((int) this.rep0, (int) num5); } } return false; }
internal static IEnumerable<TarEntry> GetEntries(StreamingMode mode, Stream stream, SharpCompress.Common.CompressionType compressionType) { foreach (TarHeader iteratorVariable0 in TarHeaderFactory.ReadHeader(mode, stream)) { if (iteratorVariable0 == null) { continue; } if (mode == StreamingMode.Seekable) { yield return new TarEntry(new TarFilePart(iteratorVariable0, stream), compressionType); continue; } yield return new TarEntry(new TarFilePart(iteratorVariable0, null), compressionType); } }
public byte DecodeNormal(SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte) { return this.m_Coders[this.GetState(pos, prevByte)].DecodeNormal(rangeDecoder); }
internal TarEntry(TarFilePart filePart, SharpCompress.Common.CompressionType type) { this.filePart = filePart; this.type = type; }
public byte DecodeNormal(SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder) { uint index = 1; do { index = (index << 1) | this.m_Decoders[index].Decode(rangeDecoder); } while (index < 0x100); return (byte) index; }
public void Encode(SharpCompress.Compressor.LZMA.RangeCoder.Encoder rangeEncoder, uint symbol, uint posState) { if (symbol < 8) { this._choice.Encode(rangeEncoder, 0); this._lowCoder[posState].Encode(rangeEncoder, symbol); } else { symbol -= 8; this._choice.Encode(rangeEncoder, 1); if (symbol < 8) { this._choice2.Encode(rangeEncoder, 0); this._midCoder[posState].Encode(rangeEncoder, symbol); } else { this._choice2.Encode(rangeEncoder, 1); this._highCoder.Encode(rangeEncoder, symbol - 8); } } }
protected ZipHeader(SharpCompress.Common.Zip.Headers.ZipHeaderType type) { this.ZipHeaderType = type; this.HasData = true; }
private static ArchiveFormat ToArchiveFormat (SharpCompress.Common.ArchiveType type) { switch (type) { case SharpCompress.Common.ArchiveType.GZip: return ArchiveFormat.GZip; case SharpCompress.Common.ArchiveType.Zip: return ArchiveFormat.Zip; case SharpCompress.Common.ArchiveType.Rar: return ArchiveFormat.Rar; case SharpCompress.Common.ArchiveType.Tar: return ArchiveFormat.Tar; case SharpCompress.Common.ArchiveType.SevenZip: return ArchiveFormat.SevenZip; default: return ArchiveFormat.Unknown; } }