1 // Base.java
2 
3 package SevenZip.Compression.LZMA;
4 
5 public class Base
6 {
7 	public static final int kNumRepDistances = 4;
8 	public static final int kNumStates = 12;
9 
StateInit()10 	public static final int StateInit()
11 	{
12 		return 0;
13 	}
14 
StateUpdateChar(int index)15 	public static final int StateUpdateChar(int index)
16 	{
17 		if (index < 4)
18 			return 0;
19 		if (index < 10)
20 			return index - 3;
21 		return index - 6;
22 	}
23 
StateUpdateMatch(int index)24 	public static final int StateUpdateMatch(int index)
25 	{
26 		return (index < 7 ? 7 : 10);
27 	}
28 
StateUpdateRep(int index)29 	public static final int StateUpdateRep(int index)
30 	{
31 		return (index < 7 ? 8 : 11);
32 	}
33 
StateUpdateShortRep(int index)34 	public static final int StateUpdateShortRep(int index)
35 	{
36 		return (index < 7 ? 9 : 11);
37 	}
38 
StateIsCharState(int index)39 	public static final boolean StateIsCharState(int index)
40 	{
41 		return index < 7;
42 	}
43 
44 	public static final int kNumPosSlotBits = 6;
45 	public static final int kDicLogSizeMin = 0;
46 	// public static final int kDicLogSizeMax = 28;
47 	// public static final int kDistTableSizeMax = kDicLogSizeMax * 2;
48 
49 	public static final int kNumLenToPosStatesBits = 2; // it's for speed optimization
50 	public static final int kNumLenToPosStates = 1 << kNumLenToPosStatesBits;
51 
52 	public static final int kMatchMinLen = 2;
53 
GetLenToPosState(int len)54 	public static final int GetLenToPosState(int len)
55 	{
56 		len -= kMatchMinLen;
57 		if (len < kNumLenToPosStates)
58 			return len;
59 		return (int)(kNumLenToPosStates - 1);
60 	}
61 
62 	public static final int kNumAlignBits = 4;
63 	public static final int kAlignTableSize = 1 << kNumAlignBits;
64 	public static final int kAlignMask = (kAlignTableSize - 1);
65 
66 	public static final int kStartPosModelIndex = 4;
67 	public static final int kEndPosModelIndex = 14;
68 	public static final int kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;
69 
70 	public static final  int kNumFullDistances = 1 << (kEndPosModelIndex / 2);
71 
72 	public static final  int kNumLitPosStatesBitsEncodingMax = 4;
73 	public static final  int kNumLitContextBitsMax = 8;
74 
75 	public static final  int kNumPosStatesBitsMax = 4;
76 	public static final  int kNumPosStatesMax = (1 << kNumPosStatesBitsMax);
77 	public static final  int kNumPosStatesBitsEncodingMax = 4;
78 	public static final  int kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);
79 
80 	public static final  int kNumLowLenBits = 3;
81 	public static final  int kNumMidLenBits = 3;
82 	public static final  int kNumHighLenBits = 8;
83 	public static final  int kNumLowLenSymbols = 1 << kNumLowLenBits;
84 	public static final  int kNumMidLenSymbols = 1 << kNumMidLenBits;
85 	public static final  int kNumLenSymbols = kNumLowLenSymbols + kNumMidLenSymbols +
86 			(1 << kNumHighLenBits);
87 	public static final  int kMatchMaxLen = kMatchMinLen + kNumLenSymbols - 1;
88 }
89