1 /* LzFind.h -- Match finder for LZ algorithms
2 2008-10-04 : Igor Pavlov : Public domain */
11 typedef struct _CMatchFinder
19 UInt32 cyclicBufferPos
;
20 UInt32 cyclicBufferSize
; /* it must be = (historySize + 1) */
30 int streamEndWasReached
;
33 UInt32 keepSizeBefore
;
39 /* int skipModeBits; */
49 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
50 #define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
52 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
54 int MatchFinder_NeedMove(CMatchFinder
*p
);
55 Byte
*MatchFinder_GetPointerToCurrentPos(CMatchFinder
*p
);
56 void MatchFinder_MoveBlock(CMatchFinder
*p
);
57 void MatchFinder_ReadIfRequired(CMatchFinder
*p
);
59 void MatchFinder_Construct(CMatchFinder
*p
);
63 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
65 int MatchFinder_Create(CMatchFinder
*p
, UInt32 historySize
,
66 UInt32 keepAddBufferBefore
, UInt32 matchMaxLen
, UInt32 keepAddBufferAfter
,
68 void MatchFinder_Free(CMatchFinder
*p
, ISzAlloc
*alloc
);
69 void MatchFinder_Normalize3(UInt32 subValue
, CLzRef
*items
, UInt32 numItems
);
70 void MatchFinder_ReduceOffsets(CMatchFinder
*p
, UInt32 subValue
);
72 UInt32
* GetMatchesSpec1(UInt32 lenLimit
, UInt32 curMatch
, UInt32 pos
, const Byte
*buffer
, CLzRef
*son
,
73 UInt32 _cyclicBufferPos
, UInt32 _cyclicBufferSize
, UInt32 _cutValue
,
74 UInt32
*distances
, UInt32 maxLen
);
78 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
79 Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
82 typedef void (*Mf_Init_Func
)(void *object
);
83 typedef Byte (*Mf_GetIndexByte_Func
)(void *object
, Int32 index
);
84 typedef UInt32 (*Mf_GetNumAvailableBytes_Func
)(void *object
);
85 typedef const Byte
* (*Mf_GetPointerToCurrentPos_Func
)(void *object
);
86 typedef UInt32 (*Mf_GetMatches_Func
)(void *object
, UInt32
*distances
);
87 typedef void (*Mf_Skip_Func
)(void *object
, UInt32
);
89 typedef struct _IMatchFinder
92 Mf_GetIndexByte_Func GetIndexByte
;
93 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes
;
94 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos
;
95 Mf_GetMatches_Func GetMatches
;
99 void MatchFinder_CreateVTable(CMatchFinder
*p
, IMatchFinder
*vTable
);
101 void MatchFinder_Init(CMatchFinder
*p
);
102 UInt32
Bt3Zip_MatchFinder_GetMatches(CMatchFinder
*p
, UInt32
*distances
);
103 UInt32
Hc3Zip_MatchFinder_GetMatches(CMatchFinder
*p
, UInt32
*distances
);
104 void Bt3Zip_MatchFinder_Skip(CMatchFinder
*p
, UInt32 num
);
105 void Hc3Zip_MatchFinder_Skip(CMatchFinder
*p
, UInt32 num
);