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