1 // ImplodeDecoder.h 2 3 #ifndef ZIP7_INC_COMPRESS_IMPLODE_DECODER_H 4 #define ZIP7_INC_COMPRESS_IMPLODE_DECODER_H 5 6 #include "../../Common/MyCom.h" 7 8 #include "../ICoder.h" 9 10 #include "../Common/InBuffer.h" 11 12 #include "BitlDecoder.h" 13 #include "LzOutWindow.h" 14 15 namespace NCompress { 16 namespace NImplode { 17 namespace NDecoder { 18 19 typedef NBitl::CDecoder<CInBuffer> CInBit; 20 21 const unsigned kNumHuffmanBits = 16; 22 const unsigned kMaxHuffTableSize = 1 << 8; 23 24 class CHuffmanDecoder 25 { 26 UInt32 _limits[kNumHuffmanBits + 1]; 27 UInt32 _poses[kNumHuffmanBits + 1]; 28 Byte _symbols[kMaxHuffTableSize]; 29 public: 30 bool Build(const Byte *lens, unsigned numSymbols) throw(); 31 unsigned Decode(CInBit *inStream) const throw(); 32 }; 33 34 35 Z7_CLASS_IMP_NOQIB_4( 36 CCoder 37 , ICompressCoder 38 , ICompressSetDecoderProperties2 39 , ICompressSetFinishMode 40 , ICompressGetInStreamProcessedSize 41 ) 42 Byte _flags; 43 bool _fullStreamMode; 44 45 CLzOutWindow _outWindowStream; 46 CInBit _inBitStream; 47 48 CHuffmanDecoder _litDecoder; 49 CHuffmanDecoder _lenDecoder; 50 CHuffmanDecoder _distDecoder; 51 52 bool BuildHuff(CHuffmanDecoder &table, unsigned numSymbols); 53 HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, 54 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 55 public: 56 CCoder(); 57 }; 58 59 }}} 60 61 #endif 62