]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Library / LzmaCustomDecompressLib / Sdk / C / LzFind.h
CommitLineData
11ff2c71 1/* LzFind.h -- Match finder for LZ algorithms\r
f0737de8 22017-06-10 : Igor Pavlov : Public domain */\r
11ff2c71 3\r
1e230224
LG
4#ifndef __LZ_FIND_H\r
5#define __LZ_FIND_H\r
11ff2c71 6\r
1e230224
LG
7#include "7zTypes.h"\r
8\r
9EXTERN_C_BEGIN\r
11ff2c71
LG
10\r
11typedef UInt32 CLzRef;\r
12\r
1436aea4
MK
13typedef struct _CMatchFinder {\r
14 Byte *buffer;\r
15 UInt32 pos;\r
16 UInt32 posLimit;\r
17 UInt32 streamPos;\r
18 UInt32 lenLimit;\r
19\r
20 UInt32 cyclicBufferPos;\r
21 UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */\r
22\r
23 Byte streamEndWasReached;\r
24 Byte btMode;\r
25 Byte bigHash;\r
26 Byte directInput;\r
27\r
28 UInt32 matchMaxLen;\r
29 CLzRef *hash;\r
30 CLzRef *son;\r
31 UInt32 hashMask;\r
32 UInt32 cutValue;\r
33\r
34 Byte *bufferBase;\r
35 ISeqInStream *stream;\r
36\r
37 UInt32 blockSize;\r
38 UInt32 keepSizeBefore;\r
39 UInt32 keepSizeAfter;\r
40\r
41 UInt32 numHashBytes;\r
42 size_t directInputRem;\r
43 UInt32 historySize;\r
44 UInt32 fixedHashSize;\r
45 UInt32 hashSizeSum;\r
46 SRes result;\r
47 UInt32 crc[256];\r
48 size_t numRefs;\r
49\r
50 UInt64 expectedDataSize;\r
11ff2c71
LG
51} CMatchFinder;\r
52\r
1436aea4 53#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)\r
11ff2c71 54\r
1436aea4 55#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)\r
11ff2c71 56\r
1e230224
LG
57#define Inline_MatchFinder_IsFinishedOK(p) \\r
58 ((p)->streamEndWasReached \\r
59 && (p)->streamPos == (p)->pos \\r
60 && (!(p)->directInput || (p)->directInputRem == 0))\r
ba39402f 61\r
1436aea4
MK
62int\r
63MatchFinder_NeedMove (\r
64 CMatchFinder *p\r
65 );\r
11ff2c71 66\r
1436aea4
MK
67Byte *\r
68MatchFinder_GetPointerToCurrentPos (\r
69 CMatchFinder *p\r
70 );\r
71\r
72void\r
73MatchFinder_MoveBlock (\r
74 CMatchFinder *p\r
75 );\r
76\r
77void\r
78MatchFinder_ReadIfRequired (\r
79 CMatchFinder *p\r
80 );\r
81\r
82void\r
83MatchFinder_Construct (\r
84 CMatchFinder *p\r
85 );\r
11ff2c71
LG
86\r
87/* Conditions:\r
88 historySize <= 3 GB\r
89 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB\r
90*/\r
1436aea4
MK
91int\r
92MatchFinder_Create (\r
93 CMatchFinder *p,\r
94 UInt32 historySize,\r
95 UInt32 keepAddBufferBefore,\r
96 UInt32 matchMaxLen,\r
97 UInt32 keepAddBufferAfter,\r
98 ISzAllocPtr alloc\r
99 );\r
100\r
101void\r
102MatchFinder_Free (\r
103 CMatchFinder *p,\r
104 ISzAllocPtr alloc\r
105 );\r
106\r
107void\r
108MatchFinder_Normalize3 (\r
109 UInt32 subValue,\r
110 CLzRef *items,\r
111 size_t numItems\r
112 );\r
113\r
114void\r
115MatchFinder_ReduceOffsets (\r
116 CMatchFinder *p,\r
117 UInt32 subValue\r
118 );\r
119\r
120UInt32 *\r
121GetMatchesSpec1 (\r
122 UInt32 lenLimit,\r
123 UInt32 curMatch,\r
124 UInt32 pos,\r
125 const Byte *buffer,\r
126 CLzRef *son,\r
127 UInt32 _cyclicBufferPos,\r
128 UInt32 _cyclicBufferSize,\r
129 UInt32 _cutValue,\r
130 UInt32 *distances,\r
131 UInt32 maxLen\r
132 );\r
11ff2c71
LG
133\r
134/*\r
135Conditions:\r
136 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.\r
137 Mf_GetPointerToCurrentPos_Func's result must be used only before any other function\r
138*/\r
139\r
1436aea4
MK
140typedef void (*Mf_Init_Func)(\r
141 void *object\r
142 );\r
143typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(\r
144 void *object\r
145 );\r
146typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(\r
147 void *object\r
148 );\r
149typedef UInt32 (*Mf_GetMatches_Func)(\r
150 void *object,\r
151 UInt32 *distances\r
152 );\r
153typedef void (*Mf_Skip_Func)(\r
154 void *object,\r
155 UInt32\r
156 );\r
157\r
158typedef struct _IMatchFinder {\r
159 Mf_Init_Func Init;\r
160 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;\r
161 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;\r
162 Mf_GetMatches_Func GetMatches;\r
163 Mf_Skip_Func Skip;\r
11ff2c71
LG
164} IMatchFinder;\r
165\r
1436aea4
MK
166void\r
167MatchFinder_CreateVTable (\r
168 CMatchFinder *p,\r
169 IMatchFinder *vTable\r
170 );\r
171\r
172void\r
173MatchFinder_Init_LowHash (\r
174 CMatchFinder *p\r
175 );\r
176\r
177void\r
178MatchFinder_Init_HighHash (\r
179 CMatchFinder *p\r
180 );\r
181\r
182void\r
183MatchFinder_Init_3 (\r
184 CMatchFinder *p,\r
185 int readData\r
186 );\r
187\r
188void\r
189MatchFinder_Init (\r
190 CMatchFinder *p\r
191 );\r
192\r
193UInt32\r
194Bt3Zip_MatchFinder_GetMatches (\r
195 CMatchFinder *p,\r
196 UInt32 *distances\r
197 );\r
198\r
199UInt32\r
200Hc3Zip_MatchFinder_GetMatches (\r
201 CMatchFinder *p,\r
202 UInt32 *distances\r
203 );\r
204\r
205void\r
206Bt3Zip_MatchFinder_Skip (\r
207 CMatchFinder *p,\r
208 UInt32 num\r
209 );\r
210\r
211void\r
212Hc3Zip_MatchFinder_Skip (\r
213 CMatchFinder *p,\r
214 UInt32 num\r
215 );\r
11ff2c71 216\r
1e230224
LG
217EXTERN_C_END\r
218\r
11ff2c71 219#endif\r