This commit is contained in:
Igor Pavlov
2017-04-30 00:00:00 +00:00
committed by Kornel
parent 603abd5528
commit 2efa10565a
442 changed files with 15479 additions and 8525 deletions

View File

@@ -15,6 +15,7 @@ class CDecoder:
public ICompressCoder,
public ICompressSetDecoderProperties2,
public ICompressSetFinishMode,
public ICompressGetInStreamProcessedSize,
public ICompressSetBufSize,
#ifndef NO_READ_FROM_CODER
public ICompressSetInStream,
@@ -23,21 +24,26 @@ class CDecoder:
#endif
public CMyUnknownImp
{
CMyComPtr<ISequentialInStream> _inStream;
Byte *_inBuf;
UInt32 _inPos;
UInt32 _inSize;
UInt32 _inLim;
CLzmaDec _state;
ELzmaStatus _lzmaStatus;
public:
bool FinishStream; // set it before decoding, if you need to decode full LZMA stream
private:
bool _propsWereSet;
bool _outSizeDefined;
UInt64 _outSize;
UInt64 _inSizeProcessed;
UInt64 _outSizeProcessed;
UInt64 _inProcessed;
UInt64 _outProcessed;
UInt32 _inBufSizeAllocated;
UInt32 _outStep;
UInt32 _inBufSize;
UInt32 _outBufSize;
SizeT _wrPos;
UInt32 _inBufSizeNew;
HRESULT CreateInputBuffer();
HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
@@ -47,6 +53,7 @@ public:
MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2)
MY_QUERYINTERFACE_ENTRY(ICompressSetFinishMode)
MY_QUERYINTERFACE_ENTRY(ICompressGetInStreamProcessedSize)
MY_QUERYINTERFACE_ENTRY(ICompressSetBufSize)
#ifndef NO_READ_FROM_CODER
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
@@ -60,11 +67,16 @@ public:
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
STDMETHOD(SetFinishMode)(UInt32 finishMode);
STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
#ifndef NO_READ_FROM_CODER
private:
CMyComPtr<ISequentialInStream> _inStream;
public:
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(ReleaseInStream)();
@@ -72,18 +84,24 @@ public:
HRESULT CodeResume(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress);
HRESULT ReadFromInputStream(void *data, UInt32 size, UInt32 *processedSize);
UInt64 GetInputProcessedSize() const { return _inSizeProcessed; }
#endif
bool FinishStream; // set it before decoding, if you need to decode full LZMA stream
bool NeedMoreInput; // it's set by decoder, if it needs more input data to decode stream
UInt64 GetInputProcessedSize() const { return _inProcessed; }
CDecoder();
virtual ~CDecoder();
UInt64 GetOutputProcessedSize() const { return _outSizeProcessed; }
UInt64 GetOutputProcessedSize() const { return _outProcessed; }
bool NeedsMoreInput() const { return _lzmaStatus == LZMA_STATUS_NEEDS_MORE_INPUT; }
bool CheckFinishStatus(bool withEndMark) const
{
return _lzmaStatus == (withEndMark ?
LZMA_STATUS_FINISHED_WITH_MARK :
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK);
}
};
}}