• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   public ICompressGetInStreamProcessedSize,
22   #ifndef NO_READ_FROM_CODER
23   public ICompressSetInStream,
24   public ICompressSetOutStreamSize,
25   public ISequentialInStream,
26   #endif
27   public CMyUnknownImp
28 {
29   Byte *_outBuf;
30   CPpmd7z_RangeDec _rangeDec;
31   CByteInBufWrap _inStream;
32   CPpmd7 _ppmd;
33 
34   Byte _order;
35   bool _outSizeDefined;
36   int _status;
37   UInt64 _outSize;
38   UInt64 _processedSize;
39 
40   HRESULT CodeSpec(Byte *memStream, UInt32 size);
41 
42 public:
43 
44   #ifndef NO_READ_FROM_CODER
45   CMyComPtr<ISequentialInStream> InSeqStream;
46   #endif
47 
48   MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
49   MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2)
50   // MY_QUERYINTERFACE_ENTRY(ICompressSetFinishMode)
51   MY_QUERYINTERFACE_ENTRY(ICompressGetInStreamProcessedSize)
52   #ifndef NO_READ_FROM_CODER
53   MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
54   MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize)
55   MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
56   #endif
57   MY_QUERYINTERFACE_END
58   MY_ADDREF_RELEASE
59 
60 
61   STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
62       const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
63   STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
64   STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
65 
66   STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
67 
68   #ifndef NO_READ_FROM_CODER
69   STDMETHOD(SetInStream)(ISequentialInStream *inStream);
70   STDMETHOD(ReleaseInStream)();
71   STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
72   #endif
73 
CDecoder()74   CDecoder(): _outBuf(NULL), _outSizeDefined(false)
75   {
76     Ppmd7z_RangeDec_CreateVTable(&_rangeDec);
77     _rangeDec.Stream = &_inStream.vt;
78     Ppmd7_Construct(&_ppmd);
79   }
80 
81   ~CDecoder();
82 };
83 
84 }}
85 
86 #endif
87