comparison src/win32/7zip/7z/CPP/7zip/Compress/Rar1Decoder.h @ 1:f9f4f1b99eed

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