Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-08-03 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:53 +0300
commit33ccab7e728a996800e166d849fe1e92a17e1afe (patch)
treee9d1148bae1da8127a3eefbc217aafd736fb74af /CPP/7zip/Compress
parentd14d4dcdefbef6695a618c3cdac05ba2ede5572e (diff)
4.52 beta
Diffstat (limited to 'CPP/7zip/Compress')
-rwxr-xr-xCPP/7zip/Compress/Lzx/LzxDecoder.cpp31
-rwxr-xr-xCPP/7zip/Compress/Lzx/LzxDecoder.h23
2 files changed, 18 insertions, 36 deletions
diff --git a/CPP/7zip/Compress/Lzx/LzxDecoder.cpp b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
index 8beb879b..5ed05b53 100755
--- a/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
+++ b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
@@ -1,4 +1,4 @@
-// LzxDecoder.cpp
+ // LzxDecoder.cpp
#include "StdAfx.h"
@@ -18,7 +18,7 @@ const int kLenIdNeedInit = -2;
CDecoder::CDecoder(bool wimMode):
_keepHistory(false),
- m_AlignPos(0),
+ _skipByte(false),
_wimMode(wimMode)
{
m_x86ConvertOutStreamSpec = new Cx86ConvertOutStream;
@@ -94,6 +94,10 @@ bool CDecoder::ReadTables(void)
{
Byte newLevels[kMaxTableSize];
{
+ if (_skipByte)
+ m_InBitStream.DirectReadByte();
+ m_InBitStream.Normalize();
+
int blockType = (int)ReadBits(kNumBlockTypeBits);
if (blockType > kBlockTypeUncompressed)
return false;
@@ -106,6 +110,9 @@ bool CDecoder::ReadTables(void)
m_UnCompressedBlockSize = m_InBitStream.ReadBitsBig(kUncompressedBlockSizeNumBits);
m_IsUncompressedBlock = (blockType == kBlockTypeUncompressed);
+
+ _skipByte = (m_IsUncompressedBlock && ((m_UnCompressedBlockSize & 1) != 0));
+
if (m_IsUncompressedBlock)
{
ReadBits(16 - m_InBitStream.GetBitPosition());
@@ -170,12 +177,12 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
if (_remainLen == kLenIdNeedInit)
{
_remainLen = 0;
- if (_keepHistory && m_IsUncompressedBlock && m_UnCompressedBlockSize > 0)
- m_InBitStream.InitDirect();
- else
- m_InBitStream.InitNormal();
+ m_InBitStream.Init();
+ if (!_keepHistory || !m_IsUncompressedBlock)
+ m_InBitStream.Normalize();
if (!_keepHistory)
{
+ _skipByte = false;
m_UnCompressedBlockSize = 0;
ClearPrevLevels();
UInt32 i86TranslationSize = 12000000;
@@ -196,9 +203,6 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
}
}
- if (curSize == 0)
- return S_OK;
-
while(_remainLen > 0 && curSize > 0)
{
m_OutWindowStream.PutByte(m_OutWindowStream.GetByte(m_RepDistances[0]));
@@ -209,8 +213,8 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
while(curSize > 0)
{
if (m_UnCompressedBlockSize == 0)
- if (!ReadTables())
- return S_FALSE;
+ if (!ReadTables())
+ return S_FALSE;
UInt32 next = (Int32)MyMin(m_UnCompressedBlockSize, curSize);
curSize -= next;
m_UnCompressedBlockSize -= next;
@@ -221,11 +225,6 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
m_OutWindowStream.PutByte(m_InBitStream.DirectReadByte());
next--;
}
- if (m_UnCompressedBlockSize == 0)
- {
- m_InBitStream.Align(m_AlignPos);
- // m_AlignPos = 0;
- }
}
else while(next > 0)
{
diff --git a/CPP/7zip/Compress/Lzx/LzxDecoder.h b/CPP/7zip/Compress/Lzx/LzxDecoder.h
index 7c549f45..777067e0 100755
--- a/CPP/7zip/Compress/Lzx/LzxDecoder.h
+++ b/CPP/7zip/Compress/Lzx/LzxDecoder.h
@@ -33,14 +33,7 @@ public:
void SetStream(ISequentialInStream *s) { m_Stream.SetStream(s); }
void ReleaseStream() { m_Stream.ReleaseStream(); }
- void InitNormal()
- {
- m_Stream.Init();
- m_BitPos = kNumBigValueBits;
- Normalize();
- }
-
- void InitDirect()
+ void Init()
{
m_Stream.Init();
m_BitPos = kNumBigValueBits;
@@ -100,12 +93,6 @@ public:
Byte DirectReadByte() { return m_Stream.ReadByte(); }
- void Align(int alignPos)
- {
- if (((m_Stream.GetProcessedSize() + alignPos) & 1) != 0)
- m_Stream.ReadByte();
- Normalize();
- }
};
}
@@ -137,7 +124,7 @@ class CDecoder :
bool _keepHistory;
int _remainLen;
- int m_AlignPos;
+ bool _skipByte;
bool _wimMode;
@@ -171,11 +158,7 @@ public:
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
HRESULT SetParams(int numDictBits);
- void SetKeepHistory(bool keepHistory, int alignPos)
- {
- _keepHistory = keepHistory;
- m_AlignPos = alignPos;
- }
+ void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
};
}}