2 // According to unRAR license, this code may not be used to develop
\r
3 // a program that creates RAR archives
\r
5 #ifndef __COMPRESS_RAR1_DECODER_H
\r
6 #define __COMPRESS_RAR1_DECODER_H
\r
8 #include "../../Common/MyCom.h"
\r
10 #include "../ICoder.h"
\r
12 #include "../Common/InBuffer.h"
\r
14 #include "BitmDecoder.h"
\r
15 #include "HuffmanDecoder.h"
\r
16 #include "LzOutWindow.h"
\r
18 namespace NCompress {
\r
21 const UInt32 kNumRepDists = 4;
\r
23 typedef NBitm::CDecoder<CInBuffer> CBitDecoder;
\r
26 public ICompressCoder,
\r
27 public ICompressSetDecoderProperties2,
\r
28 public CMyUnknownImp
\r
31 CLzOutWindow m_OutWindowStream;
\r
32 CBitDecoder m_InBitStream;
\r
34 UInt32 m_RepDists[kNumRepDists];
\r
35 UInt32 m_RepDistPtr;
\r
43 UInt32 ReadBits(int numBits);
\r
44 HRESULT CopyBlock(UInt32 distance, UInt32 len);
\r
46 UInt32 DecodeNum(const UInt32 *posTab);
\r
49 HRESULT HuffDecode();
\r
53 void CorrHuff(UInt32 *CharSet, UInt32 *NumToPlace);
\r
54 void OldUnpWriteBuf();
\r
56 UInt32 ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
\r
57 UInt32 Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
\r
58 UInt32 NToPl[256],NToPlB[256],NToPlC[256];
\r
59 UInt32 FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
\r
60 int Buf60,NumHuf,StMode,LCount,FlagsCnt;
\r
61 UInt32 Nhfb,Nlzb,MaxDist3;
\r
63 void InitStructures();
\r
65 HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
\r
66 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
\r
71 MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
\r
73 void ReleaseStreams()
\r
75 m_OutWindowStream.ReleaseStream();
\r
76 m_InBitStream.ReleaseStream();
\r
79 STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
\r
80 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
\r
82 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
\r