view 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
line wrap: on
line source
1 // Rar1Decoder.h
2 // According to unRAR license, this code may not be used to develop
3 // a program that creates RAR archives
5 #ifndef __COMPRESS_RAR1_DECODER_H
6 #define __COMPRESS_RAR1_DECODER_H
8 #include "../../Common/MyCom.h"
10 #include "../ICoder.h"
12 #include "../Common/InBuffer.h"
14 #include "BitmDecoder.h"
15 #include "HuffmanDecoder.h"
16 #include "LzOutWindow.h"
18 namespace NCompress {
19 namespace NRar1 {
21 const UInt32 kNumRepDists = 4;
23 typedef NBitm::CDecoder<CInBuffer> CBitDecoder;
25 class CDecoder :
26 public ICompressCoder,
27 public ICompressSetDecoderProperties2,
28 public CMyUnknownImp
29 {
30 public:
31 CLzOutWindow m_OutWindowStream;
32 CBitDecoder m_InBitStream;
34 UInt32 m_RepDists[kNumRepDists];
35 UInt32 m_RepDistPtr;
37 UInt32 LastDist;
38 UInt32 LastLength;
40 Int64 m_UnpackSize;
41 bool m_IsSolid;
43 UInt32 ReadBits(int numBits);
44 HRESULT CopyBlock(UInt32 distance, UInt32 len);
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();
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;
63 void InitStructures();
65 HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
66 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
68 public:
69 CDecoder();
71 MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
73 void ReleaseStreams()
74 {
75 m_OutWindowStream.ReleaseStream();
76 m_InBitStream.ReleaseStream();
77 }
79 STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
80 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
82 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
84 };
86 }}
88 #endif