Codes streams.
233 Init(inStream, outStream);
235 Base.State state =
new Base.State();
237 uint rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0;
240 UInt64 outSize64 = (UInt64)outSize;
241 if (nowPos64 < outSize64)
243 if (m_IsMatchDecoders[state.Index << Base.kNumPosStatesBitsMax].Decode(m_RangeDecoder) != 0)
244 throw new DataErrorException();
246 byte b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, 0, 0);
247 m_OutWindow.PutByte(b);
250 while (nowPos64 < outSize64)
255 uint posState = (uint)nowPos64 & m_PosStateMask;
256 if (m_IsMatchDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0)
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));
264 b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte);
265 m_OutWindow.PutByte(b);
272 if (m_IsRepDecoders[state.Index].Decode(m_RangeDecoder) == 1)
274 if (m_IsRepG0Decoders[state.Index].Decode(m_RangeDecoder) == 0)
276 if (m_IsRep0LongDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0)
278 state.UpdateShortRep();
279 m_OutWindow.PutByte(m_OutWindow.GetByte(rep0));
287 if (m_IsRepG1Decoders[state.Index].Decode(m_RangeDecoder) == 0)
293 if (m_IsRepG2Decoders[state.Index].Decode(m_RangeDecoder) == 0)
305 len = m_RepLenDecoder.Decode(m_RangeDecoder, posState) + Base.kMatchMinLen;
313 len = Base.kMatchMinLen + m_LenDecoder.Decode(m_RangeDecoder, posState);
315 uint posSlot = m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(m_RangeDecoder);
316 if (posSlot >= Base.kStartPosModelIndex)
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);
325 rep0 += (m_RangeDecoder.DecodeDirectBits(
326 numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits);
327 rep0 += m_PosAlignDecoder.ReverseDecode(m_RangeDecoder);
333 if (rep0 >= m_OutWindow.TrainSize + nowPos64 || rep0 >= m_DictionarySizeCheck)
335 if (rep0 == 0xFFFFFFFF)
337 throw new DataErrorException();
339 m_OutWindow.CopyBlock(rep0, len);
345 m_OutWindow.ReleaseStream();
346 m_RangeDecoder.ReleaseStream();