This commit is contained in:
Igor Pavlov
2005-05-30 00:00:00 +00:00
committed by Kornel Lesiński
parent 8c1b5c7b7e
commit 3c510ba80b
926 changed files with 40559 additions and 23519 deletions

View File

@@ -19,21 +19,20 @@ class CDecoder
{
protected:
CInBuffer m_Stream;
UINT32 m_BitPos;
UINT32 m_Value;
UInt32 m_BitPos;
UInt32 m_Value;
public:
void InitStream(ISequentialInStream *aStream, BYTE aReservedSize, UINT32 aNumBlocks)
{
m_Stream.Init(aStream, aReservedSize, aNumBlocks);
}
/*
void ReleaseStream()
{ m_Stream.ReleaseStream(); }
*/
UINT64 GetProcessedSize() const
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
void SetStream(ISequentialInStream *s) { m_Stream.SetStream(s); }
void ReleaseStream() { m_Stream.ReleaseStream(); }
void Init(Byte reservedSize, UInt32 numBlocks)
{
m_Stream.Init(reservedSize, numBlocks);
}
UInt64 GetProcessedSize() const
{ return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
UINT32 GetBitPosition() const
{ return UINT32(m_Stream.GetProcessedSize() * 8 - (kNumBigValueBits - m_BitPos)); }
UInt32 GetBitPosition() const
{ return UInt32(m_Stream.GetProcessedSize() * 8 - (kNumBigValueBits - m_BitPos)); }
void Init()
{
@@ -45,65 +44,65 @@ public:
{
for (;m_BitPos >= 16; m_BitPos -= 16)
{
BYTE aByte0 = m_Stream.ReadByte();
BYTE aByte1 = m_Stream.ReadByte();
m_Value = (m_Value << 8) | aByte1;
m_Value = (m_Value << 8) | aByte0;
Byte b0 = m_Stream.ReadByte();
Byte b1 = m_Stream.ReadByte();
m_Value = (m_Value << 8) | b1;
m_Value = (m_Value << 8) | b0;
}
}
UINT32 GetValue(UINT32 aNumBits)
UInt32 GetValue(UInt32 numBits)
{
return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >>
(kNumValueBits - aNumBits);
(kNumValueBits - numBits);
}
void MovePos(UINT32 aNumBits)
void MovePos(UInt32 numBits)
{
m_BitPos += aNumBits;
m_BitPos += numBits;
Normalize();
}
UINT32 ReadBits(UINT32 aNumBits)
UInt32 ReadBits(UInt32 numBits)
{
UINT32 aRes = GetValue(aNumBits);
MovePos(aNumBits);
return aRes;
UInt32 res = GetValue(numBits);
MovePos(numBits);
return res;
}
UINT32 ReadBitsBig(UINT32 aNumBits)
UInt32 ReadBitsBig(UInt32 numBits)
{
UINT32 aNumBits0 = aNumBits / 2;
UINT32 aNumBits1 = aNumBits - aNumBits0;
UINT32 aRes = ReadBits(aNumBits0) << aNumBits1;
return aRes + ReadBits(aNumBits1);
UInt32 numBits0 = numBits / 2;
UInt32 numBits1 = numBits - numBits0;
UInt32 res = ReadBits(numBits0) << numBits1;
return res + ReadBits(numBits1);
}
BYTE DirectReadByte()
Byte DirectReadByte()
{
if (m_BitPos == kNumBigValueBits)
return m_Stream.ReadByte();
BYTE aRes;
Byte res;
switch(m_BitPos)
{
case 0:
aRes = BYTE(m_Value >> 16);
res = Byte(m_Value >> 16);
break;
case 8:
aRes = BYTE(m_Value >> 24);
res = Byte(m_Value >> 24);
break;
case 16:
aRes = BYTE(m_Value);
res = Byte(m_Value);
break;
case 24:
aRes = BYTE(m_Value >> 8);
res = Byte(m_Value >> 8);
break;
}
m_BitPos += 8;
return aRes;
return res;
}
HRESULT ReadBlock(UINT32 &anUncompressedSize, bool &aDataAreCorrect)
{ return m_Stream.ReadBlock(anUncompressedSize, aDataAreCorrect); }
HRESULT ReadBlock(UInt32 &uncompressedSize, bool &dataAreCorrect)
{ return m_Stream.ReadBlock(uncompressedSize, dataAreCorrect); }
};