1 // ZlibEncoder.h 2 3 #ifndef __ZLIB_ENCODER_H 4 #define __ZLIB_ENCODER_H 5 6 #include "DeflateEncoder.h" 7 8 namespace NCompress { 9 namespace NZlib { 10 11 class CInStreamWithAdler: 12 public ISequentialInStream, 13 public CMyUnknownImp 14 { 15 CMyComPtr<ISequentialInStream> _stream; 16 UInt32 _adler; 17 UInt64 _size; 18 public: 19 MY_UNKNOWN_IMP 20 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); SetStream(ISequentialInStream * stream)21 void SetStream(ISequentialInStream *stream) { _stream = stream; } ReleaseStream()22 void ReleaseStream() { _stream.Release(); } Init()23 void Init() { _adler = 1; _size = 0; } // ADLER_INIT_VAL GetAdler()24 UInt32 GetAdler() const { return _adler; } GetSize()25 UInt64 GetSize() const { return _size; } 26 }; 27 28 class CEncoder: 29 public ICompressCoder, 30 public CMyUnknownImp 31 { 32 CInStreamWithAdler *AdlerSpec; 33 CMyComPtr<ISequentialInStream> AdlerStream; 34 CMyComPtr<ICompressCoder> DeflateEncoder; 35 public: 36 NCompress::NDeflate::NEncoder::CCOMCoder *DeflateEncoderSpec; 37 38 void Create(); 39 STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 40 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); GetInputProcessedSize()41 UInt64 GetInputProcessedSize() const { return AdlerSpec->GetSize(); } 42 43 MY_UNKNOWN_IMP 44 }; 45 46 }} 47 48 #endif 49