1 /* LzFind.h -- Match finder for LZ algorithms
2 2015-10-15 : Igor Pavlov : Public domain */
11 typedef UInt32 CLzRef
;
13 typedef struct _CMatchFinder
21 UInt32 cyclicBufferPos
;
22 UInt32 cyclicBufferSize
; /* it must be = (historySize + 1) */
24 Byte streamEndWasReached
;
39 UInt32 keepSizeBefore
;
43 size_t directInputRem
;
52 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
54 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
56 #define Inline_MatchFinder_IsFinishedOK(p) \
57 ((p)->streamEndWasReached \
58 && (p)->streamPos == (p)->pos \
59 && (!(p)->directInput || (p)->directInputRem == 0))
61 int MatchFinder_NeedMove(CMatchFinder
*p
);
62 Byte
*MatchFinder_GetPointerToCurrentPos(CMatchFinder
*p
);
63 void MatchFinder_MoveBlock(CMatchFinder
*p
);
64 void MatchFinder_ReadIfRequired(CMatchFinder
*p
);
66 void MatchFinder_Construct(CMatchFinder
*p
);
70 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
72 int MatchFinder_Create(CMatchFinder
*p
, UInt32 historySize
,
73 UInt32 keepAddBufferBefore
, UInt32 matchMaxLen
, UInt32 keepAddBufferAfter
,
75 void MatchFinder_Free(CMatchFinder
*p
, ISzAlloc
*alloc
);
76 void MatchFinder_Normalize3(UInt32 subValue
, CLzRef
*items
, size_t numItems
);
77 void MatchFinder_ReduceOffsets(CMatchFinder
*p
, UInt32 subValue
);
79 UInt32
* GetMatchesSpec1(UInt32 lenLimit
, UInt32 curMatch
, UInt32 pos
, const Byte
*buffer
, CLzRef
*son
,
80 UInt32 _cyclicBufferPos
, UInt32 _cyclicBufferSize
, UInt32 _cutValue
,
81 UInt32
*distances
, UInt32 maxLen
);
85 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
86 Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
89 typedef void (*Mf_Init_Func
)(void *object
);
90 typedef UInt32 (*Mf_GetNumAvailableBytes_Func
)(void *object
);
91 typedef const Byte
* (*Mf_GetPointerToCurrentPos_Func
)(void *object
);
92 typedef UInt32 (*Mf_GetMatches_Func
)(void *object
, UInt32
*distances
);
93 typedef void (*Mf_Skip_Func
)(void *object
, UInt32
);
95 typedef struct _IMatchFinder
98 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes
;
99 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos
;
100 Mf_GetMatches_Func GetMatches
;
104 void MatchFinder_CreateVTable(CMatchFinder
*p
, IMatchFinder
*vTable
);
106 void MatchFinder_Init_2(CMatchFinder
*p
, int readData
);
107 void MatchFinder_Init(CMatchFinder
*p
);
109 UInt32
Bt3Zip_MatchFinder_GetMatches(CMatchFinder
*p
, UInt32
*distances
);
110 UInt32
Hc3Zip_MatchFinder_GetMatches(CMatchFinder
*p
, UInt32
*distances
);
112 void Bt3Zip_MatchFinder_Skip(CMatchFinder
*p
, UInt32 num
);
113 void Hc3Zip_MatchFinder_Skip(CMatchFinder
*p
, UInt32 num
);