TianoCore EDK2 master
Loading...
Searching...
No Matches
LzFind.h
1/* LzFind.h -- Match finder for LZ algorithms
22017-06-10 : Igor Pavlov : Public domain */
3
4#ifndef __LZ_FIND_H
5#define __LZ_FIND_H
6
7#include "7zTypes.h"
8
9EXTERN_C_BEGIN
10
11typedef UInt32 CLzRef;
12
13typedef 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;
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
62int
63MatchFinder_NeedMove (
65 );
66
67Byte *
68MatchFinder_GetPointerToCurrentPos (
70 );
71
72void
73MatchFinder_MoveBlock (
75 );
76
77void
78MatchFinder_ReadIfRequired (
80 );
81
82void
83MatchFinder_Construct (
85 );
86
87/* Conditions:
88 historySize <= 3 GB
89 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
90*/
91int
92MatchFinder_Create (
93 CMatchFinder *p,
94 UInt32 historySize,
95 UInt32 keepAddBufferBefore,
96 UInt32 matchMaxLen,
97 UInt32 keepAddBufferAfter,
98 ISzAllocPtr alloc
99 );
100
101void
102MatchFinder_Free (
103 CMatchFinder *p,
104 ISzAllocPtr alloc
105 );
106
107void
108MatchFinder_Normalize3 (
109 UInt32 subValue,
110 CLzRef *items,
111 size_t numItems
112 );
113
114void
115MatchFinder_ReduceOffsets (
116 CMatchFinder *p,
117 UInt32 subValue
118 );
119
120UInt32 *
121GetMatchesSpec1 (
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/*
135Conditions:
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
140typedef void (*Mf_Init_Func)(
141 void *object
142 );
143typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(
144 void *object
145 );
146typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(
147 void *object
148 );
149typedef UInt32 (*Mf_GetMatches_Func)(
150 void *object,
151 UInt32 *distances
152 );
153typedef void (*Mf_Skip_Func)(
154 void *object,
155 UInt32
156 );
157
158typedef 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;
165
166void
167MatchFinder_CreateVTable (
168 CMatchFinder *p,
169 IMatchFinder *vTable
170 );
171
172void
173MatchFinder_Init_LowHash (
174 CMatchFinder *p
175 );
176
177void
178MatchFinder_Init_HighHash (
179 CMatchFinder *p
180 );
181
182void
183MatchFinder_Init_3 (
184 CMatchFinder *p,
185 int readData
186 );
187
188void
189MatchFinder_Init (
190 CMatchFinder *p
191 );
192
193UInt32
194Bt3Zip_MatchFinder_GetMatches (
195 CMatchFinder *p,
196 UInt32 *distances
197 );
198
199UInt32
200Hc3Zip_MatchFinder_GetMatches (
201 CMatchFinder *p,
202 UInt32 *distances
203 );
204
205void
206Bt3Zip_MatchFinder_Skip (
207 CMatchFinder *p,
208 UInt32 num
209 );
210
211void
212Hc3Zip_MatchFinder_Skip (
213 CMatchFinder *p,
214 UInt32 num
215 );
216
217EXTERN_C_END
218
219#endif