annotate src/win32/7zip/7z/C/LzFindMt.h @ 1:f9f4f1b99eed

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