ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Classes | Public Member Functions | List of all members
SevenZipReduced.Compression.LZMA.Decoder Class Reference
Inheritance diagram for SevenZipReduced.Compression.LZMA.Decoder:
Inheritance graph
[legend]
Collaboration diagram for SevenZipReduced.Compression.LZMA.Decoder:
Collaboration graph
[legend]

Public Member Functions

void Code (System.IO.Stream inStream, System.IO.Stream outStream, Int64 inSize, Int64 outSize, ICodeProgress progress)
 Codes streams. More...
 
void SetDecoderProperties (byte[] properties)
 
bool Train (System.IO.Stream stream)
 

Detailed Description

Definition at line 9 of file LzmaDecoder.cs.

Member Function Documentation

void SevenZipReduced.Compression.LZMA.Decoder.Code ( System.IO.Stream  inStream,
System.IO.Stream  outStream,
Int64  inSize,
Int64  outSize,
ICodeProgress  progress 
)
inline

Codes streams.

Parameters
inStreaminput Stream.
outStreamoutput Stream.
inSizeinput Size. -1 if unknown.
outSizeoutput Size. -1 if unknown.
progresscallback progress reference.
Exceptions
SevenZipReduced.DataErrorExceptionif input stream is not valid

Implements SevenZipReduced.ICoder.

Definition at line 230 of file LzmaDecoder.cs.

232  {
233  Init(inStream, outStream);
234 
235  Base.State state = new Base.State();
236  state.Init();
237  uint rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0;
238 
239  UInt64 nowPos64 = 0;
240  UInt64 outSize64 = (UInt64)outSize;
241  if (nowPos64 < outSize64)
242  {
243  if (m_IsMatchDecoders[state.Index << Base.kNumPosStatesBitsMax].Decode(m_RangeDecoder) != 0)
244  throw new DataErrorException();
245  state.UpdateChar();
246  byte b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, 0, 0);
247  m_OutWindow.PutByte(b);
248  nowPos64++;
249  }
250  while (nowPos64 < outSize64)
251  {
252  // UInt64 next = Math.Min(nowPos64 + (1 << 18), outSize64);
253  // while(nowPos64 < next)
254  {
255  uint posState = (uint)nowPos64 & m_PosStateMask;
256  if (m_IsMatchDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0)
257  {
258  byte b;
259  byte prevByte = m_OutWindow.GetByte(0);
260  if (!state.IsCharState())
261  b = m_LiteralDecoder.DecodeWithMatchByte(m_RangeDecoder,
262  (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0));
263  else
264  b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte);
265  m_OutWindow.PutByte(b);
266  state.UpdateChar();
267  nowPos64++;
268  }
269  else
270  {
271  uint len;
272  if (m_IsRepDecoders[state.Index].Decode(m_RangeDecoder) == 1)
273  {
274  if (m_IsRepG0Decoders[state.Index].Decode(m_RangeDecoder) == 0)
275  {
276  if (m_IsRep0LongDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0)
277  {
278  state.UpdateShortRep();
279  m_OutWindow.PutByte(m_OutWindow.GetByte(rep0));
280  nowPos64++;
281  continue;
282  }
283  }
284  else
285  {
286  UInt32 distance;
287  if (m_IsRepG1Decoders[state.Index].Decode(m_RangeDecoder) == 0)
288  {
289  distance = rep1;
290  }
291  else
292  {
293  if (m_IsRepG2Decoders[state.Index].Decode(m_RangeDecoder) == 0)
294  distance = rep2;
295  else
296  {
297  distance = rep3;
298  rep3 = rep2;
299  }
300  rep2 = rep1;
301  }
302  rep1 = rep0;
303  rep0 = distance;
304  }
305  len = m_RepLenDecoder.Decode(m_RangeDecoder, posState) + Base.kMatchMinLen;
306  state.UpdateRep();
307  }
308  else
309  {
310  rep3 = rep2;
311  rep2 = rep1;
312  rep1 = rep0;
313  len = Base.kMatchMinLen + m_LenDecoder.Decode(m_RangeDecoder, posState);
314  state.UpdateMatch();
315  uint posSlot = m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(m_RangeDecoder);
316  if (posSlot >= Base.kStartPosModelIndex)
317  {
318  int numDirectBits = (int)((posSlot >> 1) - 1);
319  rep0 = ((2 | (posSlot & 1)) << numDirectBits);
320  if (posSlot < Base.kEndPosModelIndex)
321  rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders,
322  rep0 - posSlot - 1, m_RangeDecoder, numDirectBits);
323  else
324  {
325  rep0 += (m_RangeDecoder.DecodeDirectBits(
326  numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits);
327  rep0 += m_PosAlignDecoder.ReverseDecode(m_RangeDecoder);
328  }
329  }
330  else
331  rep0 = posSlot;
332  }
333  if (rep0 >= m_OutWindow.TrainSize + nowPos64 || rep0 >= m_DictionarySizeCheck)
334  {
335  if (rep0 == 0xFFFFFFFF)
336  break;
337  throw new DataErrorException();
338  }
339  m_OutWindow.CopyBlock(rep0, len);
340  nowPos64 += len;
341  }
342  }
343  }
344  m_OutWindow.Flush();
345  m_OutWindow.ReleaseStream();
346  m_RangeDecoder.ReleaseStream();
347  }

The documentation for this class was generated from the following file: