aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Compress/LzmaDecoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Compress/LzmaDecoder.h')
-rw-r--r--CPP/7zip/Compress/LzmaDecoder.h102
1 files changed, 51 insertions, 51 deletions
diff --git a/CPP/7zip/Compress/LzmaDecoder.h b/CPP/7zip/Compress/LzmaDecoder.h
index 37dec02..095e76f 100644
--- a/CPP/7zip/Compress/LzmaDecoder.h
+++ b/CPP/7zip/Compress/LzmaDecoder.h
@@ -1,7 +1,7 @@
1// LzmaDecoder.h 1// LzmaDecoder.h
2 2
3#ifndef __LZMA_DECODER_H 3#ifndef ZIP7_INC_LZMA_DECODER_H
4#define __LZMA_DECODER_H 4#define ZIP7_INC_LZMA_DECODER_H
5 5
6// #include "../../../C/Alloc.h" 6// #include "../../../C/Alloc.h"
7#include "../../../C/LzmaDec.h" 7#include "../../../C/LzmaDec.h"
@@ -12,39 +12,71 @@
12namespace NCompress { 12namespace NCompress {
13namespace NLzma { 13namespace NLzma {
14 14
15class CDecoder: 15class CDecoder Z7_final:
16 public ICompressCoder, 16 public ICompressCoder,
17 public ICompressSetDecoderProperties2, 17 public ICompressSetDecoderProperties2,
18 public ICompressSetFinishMode, 18 public ICompressSetFinishMode,
19 public ICompressGetInStreamProcessedSize, 19 public ICompressGetInStreamProcessedSize,
20 public ICompressSetBufSize, 20 public ICompressSetBufSize,
21 #ifndef NO_READ_FROM_CODER 21 #ifndef Z7_NO_READ_FROM_CODER
22 public ICompressSetInStream, 22 public ICompressSetInStream,
23 public ICompressSetOutStreamSize, 23 public ICompressSetOutStreamSize,
24 public ISequentialInStream, 24 public ISequentialInStream,
25 #endif 25 #endif
26 public CMyUnknownImp 26 public CMyUnknownImp
27{ 27{
28 Byte *_inBuf; 28 Z7_COM_QI_BEGIN2(ICompressCoder)
29 UInt32 _inPos; 29 Z7_COM_QI_ENTRY(ICompressSetDecoderProperties2)
30 UInt32 _inLim; 30 Z7_COM_QI_ENTRY(ICompressSetFinishMode)
31 31 Z7_COM_QI_ENTRY(ICompressGetInStreamProcessedSize)
32 ELzmaStatus _lzmaStatus; 32 Z7_COM_QI_ENTRY(ICompressSetBufSize)
33 #ifndef Z7_NO_READ_FROM_CODER
34 Z7_COM_QI_ENTRY(ICompressSetInStream)
35 Z7_COM_QI_ENTRY(ICompressSetOutStreamSize)
36 Z7_COM_QI_ENTRY(ISequentialInStream)
37 #endif
38 Z7_COM_QI_END
39 Z7_COM_ADDREF_RELEASE
40
41 Z7_IFACE_COM7_IMP(ICompressCoder)
42public:
43 Z7_IFACE_COM7_IMP(ICompressSetDecoderProperties2)
44private:
45 Z7_IFACE_COM7_IMP(ICompressSetFinishMode)
46 Z7_IFACE_COM7_IMP(ICompressGetInStreamProcessedSize)
47 // Z7_IFACE_COM7_IMP(ICompressSetOutStreamSize)
33 48
49 Z7_IFACE_COM7_IMP(ICompressSetBufSize)
50
51 #ifndef Z7_NO_READ_FROM_CODER
34public: 52public:
35 bool FinishStream; // set it before decoding, if you need to decode full LZMA stream 53 Z7_IFACE_COM7_IMP(ICompressSetInStream)
54private:
55 Z7_IFACE_COM7_IMP(ISequentialInStream)
56 Z7_IFACE_COM7_IMP(ICompressSetOutStreamSize)
57 #else
58 Z7_COM7F_IMF(SetOutStreamSize(const UInt64 *outSize));
59 #endif
36 60
61public:
62 bool FinishStream; // set it before decoding, if you need to decode full LZMA stream
37private: 63private:
38 bool _propsWereSet; 64 bool _propsWereSet;
39 bool _outSizeDefined; 65 bool _outSizeDefined;
40 UInt64 _outSize;
41 UInt64 _inProcessed;
42 UInt64 _outProcessed;
43 66
44 UInt32 _outStep; 67 UInt32 _outStep;
45 UInt32 _inBufSize; 68 UInt32 _inBufSize;
46 UInt32 _inBufSizeNew; 69 UInt32 _inBufSizeNew;
47 70
71 ELzmaStatus _lzmaStatus;
72 UInt32 _inPos;
73 UInt32 _inLim;
74 Byte *_inBuf;
75
76 UInt64 _outSize;
77 UInt64 _inProcessed;
78 UInt64 _outProcessed;
79
48 // CAlignOffsetAlloc _alloc; 80 // CAlignOffsetAlloc _alloc;
49 81
50 CLzmaDec _state; 82 CLzmaDec _state;
@@ -53,53 +85,21 @@ private:
53 HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress); 85 HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
54 void SetOutStreamSizeResume(const UInt64 *outSize); 86 void SetOutStreamSizeResume(const UInt64 *outSize);
55 87
56public: 88 #ifndef Z7_NO_READ_FROM_CODER
57 MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
58 MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2)
59 MY_QUERYINTERFACE_ENTRY(ICompressSetFinishMode)
60 MY_QUERYINTERFACE_ENTRY(ICompressGetInStreamProcessedSize)
61 MY_QUERYINTERFACE_ENTRY(ICompressSetBufSize)
62 #ifndef NO_READ_FROM_CODER
63 MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
64 MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize)
65 MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
66 #endif
67 MY_QUERYINTERFACE_END
68 MY_ADDREF_RELEASE
69
70 STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
71 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
72 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
73 STDMETHOD(SetFinishMode)(UInt32 finishMode);
74 STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
75 STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
76 STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
77 STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
78
79 #ifndef NO_READ_FROM_CODER
80
81private: 89private:
82 CMyComPtr<ISequentialInStream> _inStream; 90 CMyComPtr<ISequentialInStream> _inStream;
83public: 91public:
84
85 STDMETHOD(SetInStream)(ISequentialInStream *inStream);
86 STDMETHOD(ReleaseInStream)();
87 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
88
89 HRESULT CodeResume(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress); 92 HRESULT CodeResume(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress);
90 HRESULT ReadFromInputStream(void *data, UInt32 size, UInt32 *processedSize); 93 HRESULT ReadFromInputStream(void *data, UInt32 size, UInt32 *processedSize);
91 94 #endif
92 #endif
93
94 UInt64 GetInputProcessedSize() const { return _inProcessed; }
95 95
96public:
96 CDecoder(); 97 CDecoder();
97 virtual ~CDecoder(); 98 ~CDecoder();
98 99
100 UInt64 GetInputProcessedSize() const { return _inProcessed; }
99 UInt64 GetOutputProcessedSize() const { return _outProcessed; } 101 UInt64 GetOutputProcessedSize() const { return _outProcessed; }
100
101 bool NeedsMoreInput() const { return _lzmaStatus == LZMA_STATUS_NEEDS_MORE_INPUT; } 102 bool NeedsMoreInput() const { return _lzmaStatus == LZMA_STATUS_NEEDS_MORE_INPUT; }
102
103 bool CheckFinishStatus(bool withEndMark) const 103 bool CheckFinishStatus(bool withEndMark) const
104 { 104 {
105 return _lzmaStatus == (withEndMark ? 105 return _lzmaStatus == (withEndMark ?