1 /* LzFind.h -- Match finder for LZ algorithms
\r
2 2021-07-13 : Igor Pavlov : Public domain */
\r
11 typedef UInt32 CLzRef;
\r
13 typedef struct _CMatchFinder
\r
18 UInt32 streamPos; /* wrap over Zero is allowed (streamPos < pos). Use (UInt32)(streamPos - pos) */
\r
21 UInt32 cyclicBufferPos;
\r
22 UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
\r
24 Byte streamEndWasReached;
\r
36 ISeqInStream *stream;
\r
39 UInt32 keepSizeBefore;
\r
40 UInt32 keepSizeAfter;
\r
42 UInt32 numHashBytes;
\r
43 size_t directInputRem;
\r
45 UInt32 fixedHashSize;
\r
51 UInt64 expectedDataSize;
\r
54 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((const Byte *)(p)->buffer)
\r
56 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((UInt32)((p)->streamPos - (p)->pos))
\r
59 #define Inline_MatchFinder_IsFinishedOK(p) \
\r
60 ((p)->streamEndWasReached \
\r
61 && (p)->streamPos == (p)->pos \
\r
62 && (!(p)->directInput || (p)->directInputRem == 0))
\r
65 int MatchFinder_NeedMove(CMatchFinder *p);
\r
66 /* Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); */
\r
67 void MatchFinder_MoveBlock(CMatchFinder *p);
\r
68 void MatchFinder_ReadIfRequired(CMatchFinder *p);
\r
70 void MatchFinder_Construct(CMatchFinder *p);
\r
74 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
\r
76 int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
\r
77 UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
\r
79 void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc);
\r
80 void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);
\r
81 // void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
\r
84 #define Inline_MatchFinder_InitPos(p, val) \
\r
86 (p)->streamPos = (val);
\r
89 #define Inline_MatchFinder_ReduceOffsets(p, subValue) \
\r
90 (p)->pos -= (subValue); \
\r
91 (p)->streamPos -= (subValue);
\r
94 UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
\r
95 size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
\r
96 UInt32 *distances, UInt32 maxLen);
\r
100 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
\r
101 Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
\r
104 typedef void (*Mf_Init_Func)(void *object);
\r
105 typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
\r
106 typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
\r
107 typedef UInt32 * (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
\r
108 typedef void (*Mf_Skip_Func)(void *object, UInt32);
\r
110 typedef struct _IMatchFinder
\r
113 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
\r
114 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
\r
115 Mf_GetMatches_Func GetMatches;
\r
119 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable);
\r
121 void MatchFinder_Init_LowHash(CMatchFinder *p);
\r
122 void MatchFinder_Init_HighHash(CMatchFinder *p);
\r
123 void MatchFinder_Init_4(CMatchFinder *p);
\r
124 void MatchFinder_Init(CMatchFinder *p);
\r
126 UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
\r
127 UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
\r
129 void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
\r
130 void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
\r
132 void LzFindPrepare(void);
\r