]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h
BaseTools Lzma: Update LZMA SDK version to 18.05
[mirror_edk2.git] / BaseTools / Source / C / LzmaCompress / Sdk / C / LzFindMt.h
CommitLineData
30fdf114 1/* LzFindMt.h -- multithreaded Match finder for LZ algorithms\r
5ec5a236 22017-04-03 : Igor Pavlov : Public domain */\r
30fdf114 3\r
c4ab09ef
LG
4#ifndef __LZ_FIND_MT_H\r
5#define __LZ_FIND_MT_H\r
30fdf114 6\r
30fdf114 7#include "LzFind.h"\r
c4ab09ef
LG
8#include "Threads.h"\r
9\r
10EXTERN_C_BEGIN\r
30fdf114
LG
11\r
12#define kMtHashBlockSize (1 << 13)\r
13#define kMtHashNumBlocks (1 << 3)\r
14#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)\r
15\r
16#define kMtBtBlockSize (1 << 14)\r
17#define kMtBtNumBlocks (1 << 6)\r
18#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)\r
19\r
20typedef struct _CMtSync\r
21{\r
22 Bool wasCreated;\r
23 Bool needStart;\r
24 Bool exit;\r
25 Bool stopWriting;\r
26\r
27 CThread thread;\r
28 CAutoResetEvent canStart;\r
29 CAutoResetEvent wasStarted;\r
30 CAutoResetEvent wasStopped;\r
31 CSemaphore freeSemaphore;\r
32 CSemaphore filledSemaphore;\r
33 Bool csWasInitialized;\r
34 Bool csWasEntered;\r
35 CCriticalSection cs;\r
36 UInt32 numProcessedBlocks;\r
37} CMtSync;\r
38\r
39typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);\r
40\r
41/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */\r
42#define kMtCacheLineDummy 128\r
43\r
44typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,\r
45 UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);\r
46\r
47typedef struct _CMatchFinderMt\r
48{\r
49 /* LZ */\r
50 const Byte *pointerToCurPos;\r
51 UInt32 *btBuf;\r
52 UInt32 btBufPos;\r
53 UInt32 btBufPosLimit;\r
54 UInt32 lzPos;\r
55 UInt32 btNumAvailBytes;\r
56\r
57 UInt32 *hash;\r
58 UInt32 fixedHashSize;\r
59 UInt32 historySize;\r
60 const UInt32 *crc;\r
61\r
62 Mf_Mix_Matches MixMatchesFunc;\r
63 \r
64 /* LZ + BT */\r
65 CMtSync btSync;\r
66 Byte btDummy[kMtCacheLineDummy];\r
67\r
68 /* BT */\r
69 UInt32 *hashBuf;\r
70 UInt32 hashBufPos;\r
71 UInt32 hashBufPosLimit;\r
72 UInt32 hashNumAvail;\r
73\r
74 CLzRef *son;\r
75 UInt32 matchMaxLen;\r
76 UInt32 numHashBytes;\r
77 UInt32 pos;\r
c4ab09ef 78 const Byte *buffer;\r
30fdf114
LG
79 UInt32 cyclicBufferPos;\r
80 UInt32 cyclicBufferSize; /* it must be historySize + 1 */\r
81 UInt32 cutValue;\r
82\r
83 /* BT + Hash */\r
84 CMtSync hashSync;\r
85 /* Byte hashDummy[kMtCacheLineDummy]; */\r
86 \r
87 /* Hash */\r
88 Mf_GetHeads GetHeadsFunc;\r
89 CMatchFinder *MatchFinder;\r
90} CMatchFinderMt;\r
91\r
92void MatchFinderMt_Construct(CMatchFinderMt *p);\r
5ec5a236 93void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc);\r
30fdf114 94SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,\r
5ec5a236 95 UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc);\r
30fdf114
LG
96void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);\r
97void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);\r
98\r
c4ab09ef
LG
99EXTERN_C_END\r
100\r
30fdf114 101#endif\r