3 #ifndef __MATCHFINDER_H
4 #define __MATCHFINDER_H
6 #include "../../IStream.h"
10 typedef struct _CMatchFinder
18 UInt32 cyclicBufferPos;
19 UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
29 int streamEndWasReached;
32 UInt32 keepSizeBefore;
38 /* int skipModeBits; */
48 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
49 #define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
51 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
53 int MatchFinder_NeedMove(CMatchFinder *p);
54 Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
55 void MatchFinder_MoveBlock(CMatchFinder *p);
56 void MatchFinder_ReadIfRequired(CMatchFinder *p);
58 void MatchFinder_Construct(CMatchFinder *p);
62 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
64 int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
65 UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
67 void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
68 void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
69 void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
71 UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
72 UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
73 UInt32 *distances, UInt32 maxLen);
77 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
78 Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
81 typedef void (*Mf_Init_Func)(void *object);
82 typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
83 typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
84 typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
85 typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
86 typedef void (*Mf_Skip_Func)(void *object, UInt32);
88 typedef struct _IMatchFinder
91 Mf_GetIndexByte_Func GetIndexByte;
92 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
93 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
94 Mf_GetMatches_Func GetMatches;
98 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
100 void MatchFinder_Init(CMatchFinder *p);
101 UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
102 UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
103 void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
104 void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);