public void Code(
Stream inStream,
Stream outStream,
long inSize,
long outSize,
ICodeProgress progress)
{
this.Init(inStream, outStream);
Base.State state = new Base.State();
state.Init();
uint distance = 0;
uint num1 = 0;
uint num2 = 0;
uint num3 = 0;
ulong num4 = 0;
ulong num5 = (ulong)outSize;
if (num4 < num5)
{
if (this.m_IsMatchDecoders[(state.Index << 4)].Decode(this.m_RangeDecoder) != 0U)
{
throw new DataErrorException();
}
state.UpdateChar();
this.m_OutWindow.PutByte(this.m_LiteralDecoder.DecodeNormal(this.m_RangeDecoder, 0U, (byte)0));
++num4;
}
while (num4 < num5)
{
uint posState = (uint)num4 & this.m_PosStateMask;
if (this.m_IsMatchDecoders[((state.Index << 4) + posState)].Decode(this.m_RangeDecoder) == 0U)
{
byte prevByte = this.m_OutWindow.GetByte(0U);
this.m_OutWindow.PutByte(state.IsCharState() ? this.m_LiteralDecoder.DecodeNormal(this.m_RangeDecoder, (uint)num4, prevByte) : this.m_LiteralDecoder.DecodeWithMatchByte(this.m_RangeDecoder, (uint)num4, prevByte, this.m_OutWindow.GetByte(distance)));
state.UpdateChar();
++num4;
}
else
{
uint len;
if (this.m_IsRepDecoders[state.Index].Decode(this.m_RangeDecoder) == 1U)
{
if (this.m_IsRepG0Decoders[state.Index].Decode(this.m_RangeDecoder) == 0U)
{
if (this.m_IsRep0LongDecoders[((state.Index << 4) + posState)].Decode(this.m_RangeDecoder) == 0U)
{
state.UpdateShortRep();
this.m_OutWindow.PutByte(this.m_OutWindow.GetByte(distance));
++num4;
continue;
}
}
else
{
uint num6;
if (this.m_IsRepG1Decoders[state.Index].Decode(this.m_RangeDecoder) == 0U)
{
num6 = num1;
}
else
{
if (this.m_IsRepG2Decoders[state.Index].Decode(this.m_RangeDecoder) == 0U)
{
num6 = num2;
}
else
{
num6 = num3;
num3 = num2;
}
num2 = num1;
}
num1 = distance;
distance = num6;
}
len = this.m_RepLenDecoder.Decode(this.m_RangeDecoder, posState) + 2U;
state.UpdateRep();
}
else
{
num3 = num2;
num2 = num1;
num1 = distance;
len = 2U + this.m_LenDecoder.Decode(this.m_RangeDecoder, posState);
state.UpdateMatch();
uint num6 = this.m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(this.m_RangeDecoder);
if (num6 >= 4U)
{
int NumBitLevels = (int)(num6 >> 1) - 1;
uint num7 = (uint)((2 | (int)num6 & 1) << NumBitLevels);
distance = num6 >= 14U ? num7 + (this.m_RangeDecoder.DecodeDirectBits(NumBitLevels - 4) << 4) + this.m_PosAlignDecoder.ReverseDecode(this.m_RangeDecoder) : num7 + BitTreeDecoder.ReverseDecode(this.m_PosDecoders, (uint)((int)num7 - (int)num6 - 1), this.m_RangeDecoder, NumBitLevels);
}
else
{
distance = num6;
}
}
if ((ulong)distance >= (ulong)this.m_OutWindow.TrainSize + num4 || distance >= this.m_DictionarySizeCheck)
{
if (distance != uint.MaxValue)
{
throw new DataErrorException();
}
break;
}
this.m_OutWindow.CopyBlock(distance, len);
num4 += (ulong)len;
}
}
this.m_OutWindow.Flush();
this.m_OutWindow.ReleaseStream();
this.m_RangeDecoder.ReleaseStream();
}