1 // PpmdDecoder.h
2 // 2009-03-11 : Igor Pavlov : Public domain
3 
4 #ifndef __COMPRESS_PPMD_DECODER_H
5 #define __COMPRESS_PPMD_DECODER_H
6 
7 #include "../../../C/Ppmd7.h"
8 
9 #include "../../Common/MyCom.h"
10 
11 #include "../Common/CWrappers.h"
12 
13 #include "../ICoder.h"
14 
15 namespace NCompress {
16 namespace NPpmd {
17 
18 class CDecoder :
19   public ICompressCoder,
20   public ICompressSetDecoderProperties2,
21   #ifndef NO_READ_FROM_CODER
22   public ICompressSetInStream,
23   public ICompressSetOutStreamSize,
24   public ISequentialInStream,
25   #endif
26   public CMyUnknownImp
27 {
28   Byte *_outBuf;
29   CPpmd7z_RangeDec _rangeDec;
30   CByteInBufWrap _inStream;
31   CPpmd7 _ppmd;
32 
33   Byte _order;
34   bool _outSizeDefined;
35   int _status;
36   UInt64 _outSize;
37   UInt64 _processedSize;
38 
39   HRESULT CodeSpec(Byte *memStream, UInt32 size);
40 
41 public:
42 
43   #ifndef NO_READ_FROM_CODER
44   CMyComPtr<ISequentialInStream> InSeqStream;
45   MY_UNKNOWN_IMP4(
46       ICompressSetDecoderProperties2,
47       ICompressSetInStream,
48       ICompressSetOutStreamSize,
49       ISequentialInStream)
50   #else
51   MY_UNKNOWN_IMP1(
52       ICompressSetDecoderProperties2)
53   #endif
54 
55   STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
56       const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
57   STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
58   STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
59 
60   #ifndef NO_READ_FROM_CODER
61   STDMETHOD(SetInStream)(ISequentialInStream *inStream);
62   STDMETHOD(ReleaseInStream)();
63   STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
64   #endif
65 
CDecoder()66   CDecoder(): _outBuf(NULL), _outSizeDefined(false)
67   {
68     Ppmd7z_RangeDec_CreateVTable(&_rangeDec);
69     _rangeDec.Stream = &_inStream.p;
70     Ppmd7_Construct(&_ppmd);
71   }
72 
73   ~CDecoder();
74 };
75 
76 }}
77 
78 #endif
79