3 namespace SevenZip
.Compression
.LZMA
5 internal abstract class Base
7 public const uint kNumRepDistances
= 4;
8 public const uint kNumStates
= 12;
10 // static byte []kLiteralNextStates = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
11 // static byte []kMatchNextStates = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
12 // static byte []kRepNextStates = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
13 // static byte []kShortRepNextStates = {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
18 public void Init() { Index = 0; }
19 public void UpdateChar()
21 if (Index
< 4) Index
= 0;
22 else if (Index
< 10) Index
-= 3;
25 public void UpdateMatch() { Index = (uint)(Index < 7 ? 7 : 10); }
26 public void UpdateRep() { Index = (uint)(Index < 7 ? 8 : 11); }
27 public void UpdateShortRep() { Index = (uint)(Index < 7 ? 9 : 11); }
28 public bool IsCharState() { return Index < 7; }
31 public const int kNumPosSlotBits
= 6;
32 public const int kDicLogSizeMin
= 0;
33 public const int kDicLogSizeMax
= 28;
34 public const uint kDistTableSizeMax
= kDicLogSizeMax
* 2;
36 public const int kNumLenToPosStatesBits
= 2; // it's for speed optimization
37 public const uint kNumLenToPosStates
= 1 << kNumLenToPosStatesBits
;
39 public const uint kMatchMinLen
= 2;
41 public static uint GetLenToPosState(uint len
)
44 if (len
< kNumLenToPosStates
)
46 return (uint)(kNumLenToPosStates
- 1);
49 public const int kNumAlignBits
= 4;
50 public const uint kAlignTableSize
= 1 << kNumAlignBits
;
51 public const uint kAlignMask
= (kAlignTableSize
- 1);
53 public const uint kStartPosModelIndex
= 4;
54 public const uint kEndPosModelIndex
= 14;
55 public const uint kNumPosModels
= kEndPosModelIndex
- kStartPosModelIndex
;
57 public const uint kNumFullDistances
= 1 << ((int)kEndPosModelIndex
/ 2);
59 public const uint kNumLitPosStatesBitsEncodingMax
= 4;
60 public const uint kNumLitContextBitsMax
= 8;
62 public const int kNumPosStatesBitsMax
= 4;
63 public const uint kNumPosStatesMax
= (1 << kNumPosStatesBitsMax
);
64 public const int kNumPosStatesBitsEncodingMax
= 4;
65 public const uint kNumPosStatesEncodingMax
= (1 << kNumPosStatesBitsEncodingMax
);
67 public const int kNumLowLenBits
= 3;
68 public const int kNumMidLenBits
= 3;
69 public const int kNumHighLenBits
= 8;
70 public const uint kNumLowLenSymbols
= 1 << kNumLowLenBits
;
71 public const uint kNumMidLenSymbols
= 1 << kNumMidLenBits
;
72 public const uint kNumLenSymbols
= kNumLowLenSymbols
+ kNumMidLenSymbols
+
73 (1 << kNumHighLenBits
);
74 public const uint kMatchMaxLen
= kMatchMinLen
+ kNumLenSymbols
- 1;