1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Archive/Cab/MSZipDecoder.h
#ifndef __ARCHIVE_CAB_DECODER_H
#define __ARCHIVE_CAB_DECODER_H
#include "Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/LSBFDecoder.h"
#include "../../Compress/Huffman/HuffmanDecoder.h"
#include "../../Compress/LZ/LZOutWindow.h"
#include "CabInBuffer.h"
#include "MSZipExtConst.h"
#include "MSZipConst.h"
namespace NArchive {
namespace NCab {
namespace NMSZip {
class CDecoderException
{
public:
enum ECauseType
{
kData
} m_Cause;
CDecoderException(ECauseType aCause): m_Cause(aCause) {}
};
class CMSZipBitDecoder: public NStream::NLSBF::CDecoder<NCab::CInBuffer>
{
public:
void InitMain(Byte reservedSize, UInt32 aNumBlocks)
{
m_Stream.Init(reservedSize, aNumBlocks);
Init();
}
HRESULT ReadBlock(UInt32 &uncompressedSize, bool &dataAreCorrect)
{
return m_Stream.ReadBlock(uncompressedSize, dataAreCorrect);
}
};
class CDecoder :
public ICompressCoder,
public CMyUnknownImp
{
CLZOutWindow m_OutWindowStream;
CMSZipBitDecoder m_InBitStream;
NCompress::NHuffman::CDecoder<kNumHuffmanBits, kStaticMainTableSize> m_MainDecoder;
NCompress::NHuffman::CDecoder<kNumHuffmanBits, kStaticDistTableSize> m_DistDecoder;
NCompress::NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
bool m_FinalBlock;
bool m_StoredMode;
UInt32 m_StoredBlockSize;
Byte m_ReservedSize;
UInt32 m_NumInDataBlocks;
void DeCodeLevelTable(Byte *newLevels, int numLevels);
void ReadTables();
public:
CDecoder();
MY_UNKNOWN_IMP
HRESULT Flush();
void ReleaseStreams();
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
void SetParams(Byte reservedSize, UInt32 numInDataBlocks)
{
m_ReservedSize = reservedSize;
m_NumInDataBlocks = numInDataBlocks;
}
};
}}}
#endif
|