1 /* LzFind.h -- Match finder for LZ algorithms
2 2009-04-22 : Igor Pavlov : Public domain */
9 typedef uint32_t CLzRef
;
19 uint32_t cyclicBufferPos
;
20 uint32_t cyclicBufferSize
; /* it must be = (historySize + 1) */
29 struct ISeqInStream
*stream
;
30 int streamEndWasReached
;
33 uint32_t keepSizeBefore
;
34 uint32_t keepSizeAfter
;
36 uint32_t numHashBytes
;
38 size_t directInputRem
;
42 uint32_t fixedHashSize
;
49 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
50 #define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(int32_t)(index)])
52 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
54 int MatchFinder_NeedMove(struct CMatchFinder
*p
);
55 uint8_t *MatchFinder_GetPointerToCurrentPos(struct CMatchFinder
*p
);
56 void MatchFinder_MoveBlock(struct CMatchFinder
*p
);
57 void MatchFinder_ReadIfRequired(struct CMatchFinder
*p
);
59 void MatchFinder_Construct(struct CMatchFinder
*p
);
63 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
65 int MatchFinder_Create(struct CMatchFinder
*p
, uint32_t historySize
,
66 uint32_t keepAddBufferBefore
, uint32_t matchMaxLen
, uint32_t keepAddBufferAfter
,
67 struct ISzAlloc
*alloc
);
68 void MatchFinder_Free(struct CMatchFinder
*p
, struct ISzAlloc
*alloc
);
69 void MatchFinder_Normalize3(uint32_t subValue
, CLzRef
*items
, uint32_t numItems
);
70 void MatchFinder_ReduceOffsets(struct CMatchFinder
*p
, uint32_t subValue
);
72 uint32_t * GetMatchesSpec1(uint32_t lenLimit
, uint32_t curMatch
, uint32_t pos
, const uint8_t *buffer
, CLzRef
*son
,
73 uint32_t _cyclicBufferPos
, uint32_t _cyclicBufferSize
, uint32_t _cutValue
,
74 uint32_t *distances
, uint32_t 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 uint8_t (*Mf_GetIndexByte_Func
)(void *object
, int32_t index
);
84 typedef uint32_t (*Mf_GetNumAvailableBytes_Func
)(void *object
);
85 typedef const uint8_t * (*Mf_GetPointerToCurrentPos_Func
)(void *object
);
86 typedef uint32_t (*Mf_GetMatches_Func
)(void *object
, uint32_t *distances
);
87 typedef void (*Mf_Skip_Func
)(void *object
, uint32_t);
92 Mf_GetIndexByte_Func GetIndexByte
;
93 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes
;
94 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos
;
95 Mf_GetMatches_Func GetMatches
;
99 void MatchFinder_CreateVTable(struct CMatchFinder
*p
, struct IMatchFinder
*vTable
);
101 void MatchFinder_Init(struct CMatchFinder
*p
);
102 uint32_t Bt3Zip_MatchFinder_GetMatches(struct CMatchFinder
*p
, uint32_t *distances
);
103 uint32_t Hc3Zip_MatchFinder_GetMatches(struct CMatchFinder
*p
, uint32_t *distances
);
104 void Bt3Zip_MatchFinder_Skip(struct CMatchFinder
*p
, uint32_t num
);
105 void Hc3Zip_MatchFinder_Skip(struct CMatchFinder
*p
, uint32_t num
);