3
#ifndef __COMPRESS_LZH_DECODER_H
4
#define __COMPRESS_LZH_DECODER_H
6
#include "../../Common/MyCom.h"
10
#include "../Common/InBuffer.h"
12
#include "BitmDecoder.h"
13
#include "HuffmanDecoder.h"
14
#include "LzOutWindow.h"
20
const int kMaxHuffmanLen = 16; // Check it
22
const int kNumSpecLevelSymbols = 3;
23
const int kNumLevelSymbols = kNumSpecLevelSymbols + kMaxHuffmanLen;
25
const int kDictBitsMax = 16;
26
const int kNumDistanceSymbols = kDictBitsMax + 1;
28
const int kMaxMatch = 256;
29
const int kMinMatch = 3;
30
const int kNumCSymbols = 256 + kMaxMatch + 2 - kMinMatch;
32
template <UInt32 m_NumSymbols>
33
class CHuffmanDecoder:public NCompress::NHuffman::CDecoder<kMaxHuffmanLen, m_NumSymbols>
37
template <class TBitDecoder>
38
UInt32 Decode(TBitDecoder *bitStream)
41
return (UInt32)Symbol;
42
return DecodeSymbol(bitStream);
47
public ICompressCoder,
50
CLzOutWindow m_OutWindowStream;
51
NBitm::CDecoder<CInBuffer> m_InBitStream;
55
CHuffmanDecoder<kNumLevelSymbols> m_LevelHuffman;
56
CHuffmanDecoder<kNumDistanceSymbols> m_PHuffmanDecoder;
57
CHuffmanDecoder<kNumCSymbols> m_CHuffmanDecoder;
61
m_OutWindowStream.ReleaseStream();
62
m_InBitStream.ReleaseStream();
70
CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
74
m_Coder->m_OutWindowStream.Flush();
75
m_Coder->ReleaseStreams();
78
friend class CCoderReleaser;
80
void MakeTable(int nchar, Byte *bitlen, int tablebits,
81
UInt32 *table, int tablesize);
83
UInt32 ReadBits(int numBits);
84
HRESULT ReadLevelTable();
85
HRESULT ReadPTable(int numBits);
92
STDMETHOD(CodeReal)(ISequentialInStream *inStream,
93
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
94
ICompressProgressInfo *progress);
96
STDMETHOD(Code)(ISequentialInStream *inStream,
97
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
98
ICompressProgressInfo *progress);
100
void SetDictionary(int numDictBits) { m_NumDictBits = numDictBits; }
101
CCoder(): m_NumDictBits(0) {}