3 #ifndef __MATCHFINDERMT_H
4 #define __MATCHFINDERMT_H
6 #include "../../Threads.h"
7 #include "MatchFinder.h"
9 #define kMtHashBlockSize (1 << 13)
10 #define kMtHashNumBlocks (1 << 3)
11 #define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
13 #define kMtBtBlockSize (1 << 14)
14 #define kMtBtNumBlocks (1 << 6)
15 #define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
17 typedef struct _CMtSync
25 CAutoResetEvent canStart;
26 CAutoResetEvent wasStarted;
27 CAutoResetEvent wasStopped;
28 CSemaphore freeSemaphore;
29 CSemaphore filledSemaphore;
30 Bool csWasInitialized;
33 UInt32 numProcessedBlocks;
36 typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
38 /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
39 #define kMtCacheLineDummy 128
41 typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
42 UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads);
44 typedef struct _CMatchFinderMt
47 const Byte *pointerToCurPos;
52 UInt32 btNumAvailBytes;
58 Mf_Mix_Matches MixMatchesFunc;
62 Byte btDummy[kMtCacheLineDummy];
67 UInt32 hashBufPosLimit;
75 UInt32 cyclicBufferPos;
76 UInt32 cyclicBufferSize; /* it must be historySize + 1 */
81 /* Byte hashDummy[kMtCacheLineDummy]; */
84 Mf_GetHeads GetHeadsFunc;
85 CMatchFinder *MatchFinder;
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);