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