• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Bcj2Coder.h
2 
3 #ifndef __COMPRESS_BCJ2_CODER_H
4 #define __COMPRESS_BCJ2_CODER_H
5 
6 #include "../../../C/Bcj2.h"
7 
8 #include "../../Common/MyCom.h"
9 
10 #include "../ICoder.h"
11 
12 namespace NCompress {
13 namespace NBcj2 {
14 
15 class CBaseCoder
16 {
17 protected:
18   Byte *_bufs[BCJ2_NUM_STREAMS + 1];
19   UInt32 _bufsCurSizes[BCJ2_NUM_STREAMS + 1];
20   UInt32 _bufsNewSizes[BCJ2_NUM_STREAMS + 1];
21 
22   HRESULT Alloc(bool allocForOrig = true);
23 public:
24   CBaseCoder();
25   ~CBaseCoder();
26 };
27 
28 
29 #ifndef EXTRACT_ONLY
30 
31 class CEncoder:
32   public ICompressCoder2,
33   public ICompressSetCoderProperties,
34   public ICompressSetBufSize,
35   public CMyUnknownImp,
36   public CBaseCoder
37 {
38   UInt32 _relatLim;
39 
40   HRESULT CodeReal(ISequentialInStream * const *inStreams, const UInt64 * const *inSizes, UInt32 numInStreams,
41       ISequentialOutStream * const *outStreams, const UInt64 * const *outSizes, UInt32 numOutStreams,
42       ICompressProgressInfo *progress);
43 
44 public:
45   MY_UNKNOWN_IMP3(ICompressCoder2, ICompressSetCoderProperties, ICompressSetBufSize)
46 
47   STDMETHOD(Code)(ISequentialInStream * const *inStreams, const UInt64 * const *inSizes, UInt32 numInStreams,
48       ISequentialOutStream * const *outStreams, const UInt64 * const *outSizes, UInt32 numOutStreams,
49       ICompressProgressInfo *progress);
50 
51   STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
52 
53   STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
54   STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
55 
56   CEncoder();
57   ~CEncoder();
58 };
59 
60 #endif
61 
62 class CDecoder:
63   public ICompressCoder2,
64   public ICompressSetFinishMode,
65   public ICompressGetInStreamProcessedSize2,
66   public ICompressSetInStream2,
67   public ISequentialInStream,
68   public ICompressSetOutStreamSize,
69   public ICompressSetBufSize,
70   public CMyUnknownImp,
71   public CBaseCoder
72 {
73   unsigned _extraReadSizes[BCJ2_NUM_STREAMS];
74   UInt64 _inStreamsProcessed[BCJ2_NUM_STREAMS];
75   HRESULT _readRes[BCJ2_NUM_STREAMS];
76   CMyComPtr<ISequentialInStream> _inStreams[BCJ2_NUM_STREAMS];
77 
78   bool _finishMode;
79   bool _outSizeDefined;
80   UInt64 _outSize;
81   UInt64 _outSize_Processed;
82   CBcj2Dec dec;
83 
84   void InitCommon();
85   // HRESULT ReadSpec();
86 
87 public:
88   MY_UNKNOWN_IMP7(
89     ICompressCoder2,
90     ICompressSetFinishMode,
91     ICompressGetInStreamProcessedSize2,
92     ICompressSetInStream2,
93     ISequentialInStream,
94     ICompressSetOutStreamSize,
95     ICompressSetBufSize
96     );
97 
98   STDMETHOD(Code)(ISequentialInStream * const *inStreams, const UInt64 * const *inSizes, UInt32 numInStreams,
99       ISequentialOutStream * const *outStreams, const UInt64 * const *outSizes, UInt32 numOutStreams,
100       ICompressProgressInfo *progress);
101 
102   STDMETHOD(SetFinishMode)(UInt32 finishMode);
103   STDMETHOD(GetInStreamProcessedSize2)(UInt32 streamIndex, UInt64 *value);
104 
105   STDMETHOD(SetInStream2)(UInt32 streamIndex, ISequentialInStream *inStream);
106   STDMETHOD(ReleaseInStream2)(UInt32 streamIndex);
107 
108   STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
109 
110   STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
111 
112   STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
113   STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
114 
115   CDecoder();
116 };
117 
118 }}
119 
120 #endif
121