]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h
IntelFrameworkModulePkg Lzma: Update LZMA SDK version to 18.05
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / LzmaCustomDecompressLib / Sdk / C / LzFind.h
CommitLineData
306bf4e2 1/* LzFind.h -- Match finder for LZ algorithms\r
39bbbc87 22017-06-10 : Igor Pavlov : Public domain */\r
306bf4e2 3\r
00f5e119
LG
4#ifndef __LZ_FIND_H\r
5#define __LZ_FIND_H\r
306bf4e2 6\r
00f5e119
LG
7#include "7zTypes.h"\r
8\r
9EXTERN_C_BEGIN\r
306bf4e2 10\r
11typedef UInt32 CLzRef;\r
12\r
13typedef struct _CMatchFinder\r
14{\r
15 Byte *buffer;\r
16 UInt32 pos;\r
17 UInt32 posLimit;\r
18 UInt32 streamPos;\r
19 UInt32 lenLimit;\r
20\r
21 UInt32 cyclicBufferPos;\r
22 UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */\r
23\r
00f5e119
LG
24 Byte streamEndWasReached;\r
25 Byte btMode;\r
26 Byte bigHash;\r
27 Byte directInput;\r
28\r
306bf4e2 29 UInt32 matchMaxLen;\r
30 CLzRef *hash;\r
31 CLzRef *son;\r
32 UInt32 hashMask;\r
33 UInt32 cutValue;\r
34\r
35 Byte *bufferBase;\r
36 ISeqInStream *stream;\r
00f5e119 37 \r
306bf4e2 38 UInt32 blockSize;\r
39 UInt32 keepSizeBefore;\r
40 UInt32 keepSizeAfter;\r
41\r
42 UInt32 numHashBytes;\r
00f5e119 43 size_t directInputRem;\r
306bf4e2 44 UInt32 historySize;\r
45 UInt32 fixedHashSize;\r
46 UInt32 hashSizeSum;\r
306bf4e2 47 SRes result;\r
48 UInt32 crc[256];\r
00f5e119 49 size_t numRefs;\r
39bbbc87
LG
50\r
51 UInt64 expectedDataSize;\r
306bf4e2 52} CMatchFinder;\r
53\r
54#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)\r
306bf4e2 55\r
56#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)\r
57\r
00f5e119
LG
58#define Inline_MatchFinder_IsFinishedOK(p) \\r
59 ((p)->streamEndWasReached \\r
60 && (p)->streamPos == (p)->pos \\r
61 && (!(p)->directInput || (p)->directInputRem == 0))\r
62 \r
306bf4e2 63int MatchFinder_NeedMove(CMatchFinder *p);\r
64Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);\r
65void MatchFinder_MoveBlock(CMatchFinder *p);\r
66void MatchFinder_ReadIfRequired(CMatchFinder *p);\r
67\r
68void MatchFinder_Construct(CMatchFinder *p);\r
69\r
70/* Conditions:\r
71 historySize <= 3 GB\r
72 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB\r
73*/\r
74int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,\r
75 UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,\r
39bbbc87
LG
76 ISzAllocPtr alloc);\r
77void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc);\r
00f5e119 78void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);\r
306bf4e2 79void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);\r
80\r
81UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,\r
82 UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r
83 UInt32 *distances, UInt32 maxLen);\r
84\r
85/*\r
86Conditions:\r
87 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.\r
88 Mf_GetPointerToCurrentPos_Func's result must be used only before any other function\r
89*/\r
90\r
91typedef void (*Mf_Init_Func)(void *object);\r
306bf4e2 92typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);\r
93typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);\r
94typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);\r
95typedef void (*Mf_Skip_Func)(void *object, UInt32);\r
96\r
97typedef struct _IMatchFinder\r
98{\r
99 Mf_Init_Func Init;\r
306bf4e2 100 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;\r
101 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;\r
102 Mf_GetMatches_Func GetMatches;\r
103 Mf_Skip_Func Skip;\r
104} IMatchFinder;\r
105\r
106void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);\r
107\r
39bbbc87
LG
108void MatchFinder_Init_LowHash(CMatchFinder *p);\r
109void MatchFinder_Init_HighHash(CMatchFinder *p);\r
110void MatchFinder_Init_3(CMatchFinder *p, int readData);\r
306bf4e2 111void MatchFinder_Init(CMatchFinder *p);\r
00f5e119 112\r
306bf4e2 113UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r
114UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r
00f5e119 115\r
306bf4e2 116void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r
117void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r
118\r
00f5e119
LG
119EXTERN_C_END\r
120\r
306bf4e2 121#endif\r