rlm@1
|
1 // Rar1Decoder.h
|
rlm@1
|
2 // According to unRAR license, this code may not be used to develop
|
rlm@1
|
3 // a program that creates RAR archives
|
rlm@1
|
4
|
rlm@1
|
5 #ifndef __COMPRESS_RAR1_DECODER_H
|
rlm@1
|
6 #define __COMPRESS_RAR1_DECODER_H
|
rlm@1
|
7
|
rlm@1
|
8 #include "../../Common/MyCom.h"
|
rlm@1
|
9
|
rlm@1
|
10 #include "../ICoder.h"
|
rlm@1
|
11
|
rlm@1
|
12 #include "../Common/InBuffer.h"
|
rlm@1
|
13
|
rlm@1
|
14 #include "BitmDecoder.h"
|
rlm@1
|
15 #include "HuffmanDecoder.h"
|
rlm@1
|
16 #include "LzOutWindow.h"
|
rlm@1
|
17
|
rlm@1
|
18 namespace NCompress {
|
rlm@1
|
19 namespace NRar1 {
|
rlm@1
|
20
|
rlm@1
|
21 const UInt32 kNumRepDists = 4;
|
rlm@1
|
22
|
rlm@1
|
23 typedef NBitm::CDecoder<CInBuffer> CBitDecoder;
|
rlm@1
|
24
|
rlm@1
|
25 class CDecoder :
|
rlm@1
|
26 public ICompressCoder,
|
rlm@1
|
27 public ICompressSetDecoderProperties2,
|
rlm@1
|
28 public CMyUnknownImp
|
rlm@1
|
29 {
|
rlm@1
|
30 public:
|
rlm@1
|
31 CLzOutWindow m_OutWindowStream;
|
rlm@1
|
32 CBitDecoder m_InBitStream;
|
rlm@1
|
33
|
rlm@1
|
34 UInt32 m_RepDists[kNumRepDists];
|
rlm@1
|
35 UInt32 m_RepDistPtr;
|
rlm@1
|
36
|
rlm@1
|
37 UInt32 LastDist;
|
rlm@1
|
38 UInt32 LastLength;
|
rlm@1
|
39
|
rlm@1
|
40 Int64 m_UnpackSize;
|
rlm@1
|
41 bool m_IsSolid;
|
rlm@1
|
42
|
rlm@1
|
43 UInt32 ReadBits(int numBits);
|
rlm@1
|
44 HRESULT CopyBlock(UInt32 distance, UInt32 len);
|
rlm@1
|
45
|
rlm@1
|
46 UInt32 DecodeNum(const UInt32 *posTab);
|
rlm@1
|
47 HRESULT ShortLZ();
|
rlm@1
|
48 HRESULT LongLZ();
|
rlm@1
|
49 HRESULT HuffDecode();
|
rlm@1
|
50 void GetFlagsBuf();
|
rlm@1
|
51 void InitData();
|
rlm@1
|
52 void InitHuff();
|
rlm@1
|
53 void CorrHuff(UInt32 *CharSet, UInt32 *NumToPlace);
|
rlm@1
|
54 void OldUnpWriteBuf();
|
rlm@1
|
55
|
rlm@1
|
56 UInt32 ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
|
rlm@1
|
57 UInt32 Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
|
rlm@1
|
58 UInt32 NToPl[256],NToPlB[256],NToPlC[256];
|
rlm@1
|
59 UInt32 FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
|
rlm@1
|
60 int Buf60,NumHuf,StMode,LCount,FlagsCnt;
|
rlm@1
|
61 UInt32 Nhfb,Nlzb,MaxDist3;
|
rlm@1
|
62
|
rlm@1
|
63 void InitStructures();
|
rlm@1
|
64
|
rlm@1
|
65 HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
rlm@1
|
66 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
rlm@1
|
67
|
rlm@1
|
68 public:
|
rlm@1
|
69 CDecoder();
|
rlm@1
|
70
|
rlm@1
|
71 MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
|
rlm@1
|
72
|
rlm@1
|
73 void ReleaseStreams()
|
rlm@1
|
74 {
|
rlm@1
|
75 m_OutWindowStream.ReleaseStream();
|
rlm@1
|
76 m_InBitStream.ReleaseStream();
|
rlm@1
|
77 }
|
rlm@1
|
78
|
rlm@1
|
79 STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
rlm@1
|
80 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
rlm@1
|
81
|
rlm@1
|
82 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
|
rlm@1
|
83
|
rlm@1
|
84 };
|
rlm@1
|
85
|
rlm@1
|
86 }}
|
rlm@1
|
87
|
rlm@1
|
88 #endif
|