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