diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2014-11-23 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:51 +0300 |
commit | f08f4dcc3c02464c17753b3feafcfe5243b9e236 (patch) | |
tree | b0e1b15bc5368d92dff422e8ec0818564a2b00b8 /CPP/7zip/Compress/DeflateDecoder.h | |
parent | 83f8ddcc5b2161e1e3c49666265257fca8aeb12c (diff) |
9.349.34
Diffstat (limited to 'CPP/7zip/Compress/DeflateDecoder.h')
-rw-r--r--[-rwxr-xr-x] | CPP/7zip/Compress/DeflateDecoder.h | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/CPP/7zip/Compress/DeflateDecoder.h b/CPP/7zip/Compress/DeflateDecoder.h index 56ab2bea..856a5771 100755..100644 --- a/CPP/7zip/Compress/DeflateDecoder.h +++ b/CPP/7zip/Compress/DeflateDecoder.h @@ -18,6 +18,9 @@ namespace NCompress { namespace NDeflate { namespace NDecoder { +const int kLenIdFinished = -1; +const int kLenIdNeedInit = -2; + class CCoder: public ICompressCoder, public ICompressGetInStreamProcessedSize, @@ -29,6 +32,7 @@ class CCoder: public CMyUnknownImp { CLzOutWindow m_OutWindowStream; + CMyComPtr<ISequentialInStream> m_InStreamRef; NBitl::CDecoder<CInBuffer> m_InBitStream; NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedMainTableSize> m_MainDecoder; NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedDistTableSize> m_DistDecoder; @@ -36,22 +40,23 @@ class CCoder: UInt32 m_StoredBlockSize; + UInt32 _numDistLevels; bool m_FinalBlock; bool m_StoredMode; - UInt32 _numDistLevels; - bool _deflateNSIS; bool _deflate64Mode; bool _keepHistory; + bool _needFinishInput; + bool _needInitInStream; + bool _needReadTable; Int32 _remainLen; UInt32 _rep0; - bool _needReadTable; - UInt32 ReadBits(int numBits); + UInt32 ReadBits(unsigned numBits); - bool DeCodeLevelTable(Byte *values, int numSymbols); + bool DeCodeLevelTable(Byte *values, unsigned numSymbols); bool ReadTables(); HRESULT Flush() { return m_OutWindowStream.Flush(); } @@ -65,12 +70,11 @@ class CCoder: { if (NeedFlush) _coder->Flush(); - _coder->ReleaseOutStream(); } }; friend class CCoderReleaser; - HRESULT CodeSpec(UInt32 curSize); + HRESULT CodeSpec(UInt32 curSize, bool finishInputStream); public: bool ZlibMode; Byte ZlibFooter[4]; @@ -78,12 +82,11 @@ public: CCoder(bool deflate64Mode, bool deflateNSIS = false); virtual ~CCoder() {}; - void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; } + void Set_KeepHistory(bool keepHistory) { _keepHistory = keepHistory; } + void Set_NeedFinishInput(bool needFinishInput) { _needFinishInput = needFinishInput; } - void ReleaseOutStream() - { - m_OutWindowStream.ReleaseStream(); - } + bool IsFinished() const { return _remainLen == kLenIdFinished;; } + bool IsFinalBlock() const { return m_FinalBlock; } HRESULT CodeReal(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress); @@ -126,31 +129,24 @@ public: } void AlignToByte() { m_InBitStream.AlignToByte(); } - Byte ReadByte() { return (Byte)m_InBitStream.ReadBits(8); } + Byte ReadAlignedByte(); + UInt32 ReadAligned_UInt16() // aligned for Byte range + { + UInt32 v = m_InBitStream.ReadAlignedByte(); + return v | ((UInt32)m_InBitStream.ReadAlignedByte() << 8); + } bool InputEofError() const { return m_InBitStream.ExtraBitsWereRead(); } + + UInt64 GetStreamSize() const { return m_InBitStream.GetStreamSize(); } UInt64 GetInputProcessedSize() const { return m_InBitStream.GetProcessedSize(); } // IGetInStreamProcessedSize STDMETHOD(GetInStreamProcessedSize)(UInt64 *value); }; -class CCOMCoder : public CCoder -{ -public: - CCOMCoder(): CCoder(false) {} -}; - -class CNsisCOMCoder : public CCoder -{ -public: - CNsisCOMCoder(): CCoder(false, true) {} -}; - -class CCOMCoder64 : public CCoder -{ -public: - CCOMCoder64(): CCoder(true) {} -}; +class CCOMCoder : public CCoder { public: CCOMCoder(): CCoder(false) {} }; +class CNsisCOMCoder : public CCoder { public: CNsisCOMCoder(): CCoder(false, true) {} }; +class CCOMCoder64 : public CCoder { public: CCOMCoder64(): CCoder(true) {} }; }}} |