]>
Commit | Line | Data |
---|---|---|
11ff2c71 LG |
1 | /* LzFind.h -- Match finder for LZ algorithms\r |
2 | 2008-10-04 : Igor Pavlov : Public domain */\r | |
3 | \r | |
4 | #ifndef __LZFIND_H\r | |
5 | #define __LZFIND_H\r | |
6 | \r | |
7 | #include "Types.h"\r | |
8 | \r | |
9 | typedef UInt32 CLzRef;\r | |
10 | \r | |
11 | typedef struct _CMatchFinder\r | |
12 | {\r | |
13 | Byte *buffer;\r | |
14 | UInt32 pos;\r | |
15 | UInt32 posLimit;\r | |
16 | UInt32 streamPos;\r | |
17 | UInt32 lenLimit;\r | |
18 | \r | |
19 | UInt32 cyclicBufferPos;\r | |
20 | UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */\r | |
21 | \r | |
22 | UInt32 matchMaxLen;\r | |
23 | CLzRef *hash;\r | |
24 | CLzRef *son;\r | |
25 | UInt32 hashMask;\r | |
26 | UInt32 cutValue;\r | |
27 | \r | |
28 | Byte *bufferBase;\r | |
29 | ISeqInStream *stream;\r | |
30 | int streamEndWasReached;\r | |
31 | \r | |
32 | UInt32 blockSize;\r | |
33 | UInt32 keepSizeBefore;\r | |
34 | UInt32 keepSizeAfter;\r | |
35 | \r | |
36 | UInt32 numHashBytes;\r | |
37 | int directInput;\r | |
38 | int btMode;\r | |
39 | /* int skipModeBits; */\r | |
40 | int bigHash;\r | |
41 | UInt32 historySize;\r | |
42 | UInt32 fixedHashSize;\r | |
43 | UInt32 hashSizeSum;\r | |
44 | UInt32 numSons;\r | |
45 | SRes result;\r | |
46 | UInt32 crc[256];\r | |
47 | } CMatchFinder;\r | |
48 | \r | |
49 | #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)\r | |
50 | #define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])\r | |
51 | \r | |
52 | #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)\r | |
53 | \r | |
54 | int MatchFinder_NeedMove(CMatchFinder *p);\r | |
55 | Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);\r | |
56 | void MatchFinder_MoveBlock(CMatchFinder *p);\r | |
57 | void MatchFinder_ReadIfRequired(CMatchFinder *p);\r | |
58 | \r | |
59 | void MatchFinder_Construct(CMatchFinder *p);\r | |
60 | \r | |
61 | /* Conditions:\r | |
62 | historySize <= 3 GB\r | |
63 | keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB\r | |
64 | */\r | |
65 | int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,\r | |
66 | UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,\r | |
67 | ISzAlloc *alloc);\r | |
68 | void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);\r | |
69 | void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);\r | |
70 | void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);\r | |
71 | \r | |
72 | UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,\r | |
73 | UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r | |
74 | UInt32 *distances, UInt32 maxLen);\r | |
75 | \r | |
76 | /*\r | |
77 | Conditions:\r | |
78 | Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.\r | |
79 | Mf_GetPointerToCurrentPos_Func's result must be used only before any other function\r | |
80 | */\r | |
81 | \r | |
82 | typedef void (*Mf_Init_Func)(void *object);\r | |
83 | typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);\r | |
84 | typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);\r | |
85 | typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);\r | |
86 | typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);\r | |
87 | typedef void (*Mf_Skip_Func)(void *object, UInt32);\r | |
88 | \r | |
89 | typedef struct _IMatchFinder\r | |
90 | {\r | |
91 | Mf_Init_Func Init;\r | |
92 | Mf_GetIndexByte_Func GetIndexByte;\r | |
93 | Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;\r | |
94 | Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;\r | |
95 | Mf_GetMatches_Func GetMatches;\r | |
96 | Mf_Skip_Func Skip;\r | |
97 | } IMatchFinder;\r | |
98 | \r | |
99 | void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);\r | |
100 | \r | |
101 | void MatchFinder_Init(CMatchFinder *p);\r | |
102 | UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r | |
103 | UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r | |
104 | void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r | |
105 | void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r | |
106 | \r | |
107 | #endif\r |