1 // LZMA.h |
|
2 |
|
3 #ifndef __LZMA_H |
|
4 #define __LZMA_H |
|
5 |
|
6 namespace NCompress { |
|
7 namespace NLZMA { |
|
8 |
|
9 const UInt32 kNumRepDistances = 4; |
|
10 |
|
11 const int kNumStates = 12; |
|
12 |
|
13 const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; |
|
14 const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; |
|
15 const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; |
|
16 const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; |
|
17 |
|
18 class CState |
|
19 { |
|
20 public: |
|
21 Byte Index; |
|
22 void Init() { Index = 0; } |
|
23 void UpdateChar() { Index = kLiteralNextStates[Index]; } |
|
24 void UpdateMatch() { Index = kMatchNextStates[Index]; } |
|
25 void UpdateRep() { Index = kRepNextStates[Index]; } |
|
26 void UpdateShortRep() { Index = kShortRepNextStates[Index]; } |
|
27 bool IsCharState() const { return Index < 7; } |
|
28 }; |
|
29 |
|
30 const int kNumPosSlotBits = 6; |
|
31 const int kDicLogSizeMin = 0; |
|
32 const int kDicLogSizeMax = 32; |
|
33 const int kDistTableSizeMax = kDicLogSizeMax * 2; |
|
34 |
|
35 const UInt32 kNumLenToPosStates = 4; |
|
36 |
|
37 inline UInt32 GetLenToPosState(UInt32 len) |
|
38 { |
|
39 len -= 2; |
|
40 if (len < kNumLenToPosStates) |
|
41 return len; |
|
42 return kNumLenToPosStates - 1; |
|
43 } |
|
44 |
|
45 namespace NLength { |
|
46 |
|
47 const int kNumPosStatesBitsMax = 4; |
|
48 const UInt32 kNumPosStatesMax = (1 << kNumPosStatesBitsMax); |
|
49 |
|
50 const int kNumPosStatesBitsEncodingMax = 4; |
|
51 const UInt32 kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax); |
|
52 |
|
53 const int kNumLowBits = 3; |
|
54 const int kNumMidBits = 3; |
|
55 const int kNumHighBits = 8; |
|
56 const UInt32 kNumLowSymbols = 1 << kNumLowBits; |
|
57 const UInt32 kNumMidSymbols = 1 << kNumMidBits; |
|
58 const UInt32 kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits); |
|
59 |
|
60 } |
|
61 |
|
62 const UInt32 kMatchMinLen = 2; |
|
63 const UInt32 kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1; |
|
64 |
|
65 const int kNumAlignBits = 4; |
|
66 const UInt32 kAlignTableSize = 1 << kNumAlignBits; |
|
67 const UInt32 kAlignMask = (kAlignTableSize - 1); |
|
68 |
|
69 const UInt32 kStartPosModelIndex = 4; |
|
70 const UInt32 kEndPosModelIndex = 14; |
|
71 const UInt32 kNumPosModels = kEndPosModelIndex - kStartPosModelIndex; |
|
72 |
|
73 const UInt32 kNumFullDistances = 1 << (kEndPosModelIndex / 2); |
|
74 |
|
75 const int kNumLitPosStatesBitsEncodingMax = 4; |
|
76 const int kNumLitContextBitsMax = 8; |
|
77 |
|
78 const int kNumMoveBits = 5; |
|
79 |
|
80 }} |
|
81 |
|
82 #endif |
|