本文整理汇总了C++中CState::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CState::Init方法的具体用法?C++ CState::Init怎么用?C++ CState::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CState
的用法示例。
在下文中一共展示了CState::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Code
UINT32 CLZMADecoder::Code(CLZMAStateP lzmaState)
{
m_RangeDecoder.Init(lzmaState);
m_OutWindowStream.Init(lzmaState);
int i;
for (i = 0; i < sizeof(m_Decoders) / sizeof(CBitDecoder); i++)
{
((CBitDecoder *) &m_Decoders)[i].Init();
}
m_LiteralDecoder.Init();
for (i = 0; i < kNumLenToPosStates; i++)
m_PosSlotDecoder[i].Init();
m_PosDecoder.Init();
m_PosAlignDecoder.Init();
// m_LenDecoder.Init(m_PosStateMask + 1);
// m_RepMatchLenDecoder.Init(m_PosStateMask + 1);
m_LenDecoder.Init();
m_RepMatchLenDecoder.Init();
////////////////////////
// code
CState state;
state.Init();
bool peviousIsMatch = false;
BYTE previousByte = 0;
// kNumRepDistances == 4
UINT32 repDistances[kNumRepDistances] = {1, 1, 1, 1};
/*for(i = 0 ; i < kNumRepDistances; i++)
repDistances[i] = 1;*/
UINT32 nowPos = 0;
while(nowPos < 0xFFFFFFFF)
{
int posState = nowPos & m_PosStateMask;
if (!m_Decoders.MainChoiceDecoders[state.Index][posState].Decode(&m_RangeDecoder))
{
state.UpdateChar();
if(peviousIsMatch)
{
BYTE matchByte = m_OutWindowStream.GetOneByte(0 - repDistances[0]);
previousByte = m_LiteralDecoder.DecodeWithMatchByte(&m_RangeDecoder,
nowPos, previousByte, matchByte);
peviousIsMatch = false;
}
else
previousByte = m_LiteralDecoder.DecodeNormal(&m_RangeDecoder,
nowPos, previousByte);
m_OutWindowStream.PutOneByte(previousByte);
nowPos++;
}
else
{
peviousIsMatch = true;
UINT32 distance;
int len;
if(m_Decoders.MatchChoiceDecoders[state.Index].Decode(&m_RangeDecoder))
{
if(!m_Decoders.MatchRepChoiceDecoders[state.Index].Decode(&m_RangeDecoder))
{
if(!m_Decoders.MatchRepShortChoiceDecoders[state.Index][posState].Decode(&m_RangeDecoder))
{
state.UpdateShortRep();
previousByte = m_OutWindowStream.GetOneByte(0 - repDistances[0]);
m_OutWindowStream.PutOneByte(previousByte);
nowPos++;
continue;
}
distance = repDistances[0];
}
else
{
if(!m_Decoders.MatchRep1ChoiceDecoders[state.Index].Decode(&m_RangeDecoder))
distance = repDistances[1];
else
{
if (!m_Decoders.MatchRep2ChoiceDecoders[state.Index].Decode(&m_RangeDecoder))
distance = repDistances[2];
else
{
distance = repDistances[3];
repDistances[3] = repDistances[2];
}
repDistances[2] = repDistances[1];
}
repDistances[1] = repDistances[0];
repDistances[0] = distance;
}
len = m_RepMatchLenDecoder.Decode(&m_RangeDecoder, posState);
state.UpdateRep();
//.........这里部分代码省略.........
示例2: CodeReal
HRESULT CDecoder::CodeReal(ISequentialInStream *anInStream,
ISequentialOutStream *anOutStream,
const UINT64 *, const UINT64 *anOutSize)
{
if (anOutSize == NULL)
return E_INVALIDARG;
Init(anInStream, anOutStream);
CState aState;
aState.Init();
bool aPeviousIsMatch = false;
BYTE aPreviousByte = 0;
UINT32 aRepDistances[kNumRepDistances];
for(UINT32 i = 0 ; i < kNumRepDistances; i++)
aRepDistances[i] = 0;
UINT64 aNowPos64 = 0;
UINT64 aSize = *anOutSize;
while(aNowPos64 < aSize)
{
UINT64 aNext = MyMin(aNowPos64 + (1 << 18), aSize);
while(aNowPos64 < aNext)
{
UINT32 aPosState = UINT32(aNowPos64) & m_PosStateMask;
if (m_MainChoiceDecoders[aState.m_Index][aPosState].Decode(&m_RangeDecoder) == (UINT32) kMainChoiceLiteralIndex)
{
// aCounts[0]++;
aState.UpdateChar();
if(aPeviousIsMatch)
{
BYTE aMatchByte = m_OutWindowStream.GetOneByte(0 - aRepDistances[0] - 1);
aPreviousByte = m_LiteralDecoder.DecodeWithMatchByte(&m_RangeDecoder,
UINT32(aNowPos64), aPreviousByte, aMatchByte);
aPeviousIsMatch = false;
}
else
aPreviousByte = m_LiteralDecoder.DecodeNormal(&m_RangeDecoder,
UINT32(aNowPos64), aPreviousByte);
m_OutWindowStream.PutOneByte(aPreviousByte);
aNowPos64++;
}
else
{
aPeviousIsMatch = true;
UINT32 aDistance, aLen;
if(m_MatchChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) ==
(UINT32) kMatchChoiceRepetitionIndex)
{
if(m_MatchRepChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) == 0)
{
if(m_MatchRepShortChoiceDecoders[aState.m_Index][aPosState].Decode(&m_RangeDecoder) == 0)
{
aState.UpdateShortRep();
aPreviousByte = m_OutWindowStream.GetOneByte(0 - aRepDistances[0] - 1);
m_OutWindowStream.PutOneByte(aPreviousByte);
aNowPos64++;
// aCounts[3 + 4]++;
continue;
}
// aCounts[3 + 0]++;
aDistance = aRepDistances[0];
}
else
{
if(m_MatchRep1ChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) == 0)
{
aDistance = aRepDistances[1];
aRepDistances[1] = aRepDistances[0];
// aCounts[3 + 1]++;
}
else
{
if (m_MatchRep2ChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) == 0)
{
// aCounts[3 + 2]++;
aDistance = aRepDistances[2];
}
else
{
// aCounts[3 + 3]++;
aDistance = aRepDistances[3];
aRepDistances[3] = aRepDistances[2];
}
aRepDistances[2] = aRepDistances[1];
aRepDistances[1] = aRepDistances[0];
}
aRepDistances[0] = aDistance;
}
aLen = m_RepMatchLenDecoder.Decode(&m_RangeDecoder, aPosState) + kMatchMinLen;
// aCounts[aLen]++;
aState.UpdateRep();
}
else
{
aLen = kMatchMinLen + m_LenDecoder.Decode(&m_RangeDecoder, aPosState);
aState.UpdateMatch();
UINT32 aPosSlot = m_PosSlotDecoder[GetLenToPosState(aLen)].Decode(&m_RangeDecoder);
// aCounts[aPosSlot]++;
if (aPosSlot >= (UINT32) kStartPosModelIndex)
//.........这里部分代码省略.........