]>
Commit | Line | Data |
---|---|---|
30fdf114 | 1 | /* LzFind.h -- Match finder for LZ algorithms\r |
c4ab09ef | 2 | 2015-10-15 : Igor Pavlov : Public domain */\r |
30fdf114 | 3 | \r |
c4ab09ef LG |
4 | #ifndef __LZ_FIND_H\r |
5 | #define __LZ_FIND_H\r | |
30fdf114 | 6 | \r |
c4ab09ef LG |
7 | #include "7zTypes.h"\r |
8 | \r | |
9 | EXTERN_C_BEGIN\r | |
30fdf114 LG |
10 | \r |
11 | typedef UInt32 CLzRef;\r | |
12 | \r | |
13 | typedef struct _CMatchFinder\r | |
14 | {\r | |
15 | Byte *buffer;\r | |
16 | UInt32 pos;\r | |
17 | UInt32 posLimit;\r | |
18 | UInt32 streamPos;\r | |
19 | UInt32 lenLimit;\r | |
20 | \r | |
21 | UInt32 cyclicBufferPos;\r | |
22 | UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */\r | |
23 | \r | |
c4ab09ef LG |
24 | Byte streamEndWasReached;\r |
25 | Byte btMode;\r | |
26 | Byte bigHash;\r | |
27 | Byte directInput;\r | |
28 | \r | |
30fdf114 LG |
29 | UInt32 matchMaxLen;\r |
30 | CLzRef *hash;\r | |
31 | CLzRef *son;\r | |
32 | UInt32 hashMask;\r | |
33 | UInt32 cutValue;\r | |
34 | \r | |
35 | Byte *bufferBase;\r | |
36 | ISeqInStream *stream;\r | |
c4ab09ef | 37 | \r |
30fdf114 LG |
38 | UInt32 blockSize;\r |
39 | UInt32 keepSizeBefore;\r | |
40 | UInt32 keepSizeAfter;\r | |
41 | \r | |
42 | UInt32 numHashBytes;\r | |
c4ab09ef | 43 | size_t directInputRem;\r |
30fdf114 LG |
44 | UInt32 historySize;\r |
45 | UInt32 fixedHashSize;\r | |
46 | UInt32 hashSizeSum;\r | |
30fdf114 LG |
47 | SRes result;\r |
48 | UInt32 crc[256];\r | |
c4ab09ef | 49 | size_t numRefs;\r |
30fdf114 LG |
50 | } CMatchFinder;\r |
51 | \r | |
52 | #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)\r | |
30fdf114 LG |
53 | \r |
54 | #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)\r | |
55 | \r | |
c4ab09ef LG |
56 | #define Inline_MatchFinder_IsFinishedOK(p) \\r |
57 | ((p)->streamEndWasReached \\r | |
58 | && (p)->streamPos == (p)->pos \\r | |
59 | && (!(p)->directInput || (p)->directInputRem == 0))\r | |
60 | \r | |
30fdf114 LG |
61 | int MatchFinder_NeedMove(CMatchFinder *p);\r |
62 | Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);\r | |
63 | void MatchFinder_MoveBlock(CMatchFinder *p);\r | |
64 | void MatchFinder_ReadIfRequired(CMatchFinder *p);\r | |
65 | \r | |
66 | void MatchFinder_Construct(CMatchFinder *p);\r | |
67 | \r | |
68 | /* Conditions:\r | |
69 | historySize <= 3 GB\r | |
70 | keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB\r | |
71 | */\r | |
72 | int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,\r | |
73 | UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,\r | |
74 | ISzAlloc *alloc);\r | |
75 | void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);\r | |
c4ab09ef | 76 | void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);\r |
30fdf114 LG |
77 | void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);\r |
78 | \r | |
79 | UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,\r | |
80 | UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r | |
81 | UInt32 *distances, UInt32 maxLen);\r | |
82 | \r | |
83 | /*\r | |
84 | Conditions:\r | |
85 | Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.\r | |
86 | Mf_GetPointerToCurrentPos_Func's result must be used only before any other function\r | |
87 | */\r | |
88 | \r | |
89 | typedef void (*Mf_Init_Func)(void *object);\r | |
30fdf114 LG |
90 | typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);\r |
91 | typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);\r | |
92 | typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);\r | |
93 | typedef void (*Mf_Skip_Func)(void *object, UInt32);\r | |
94 | \r | |
95 | typedef struct _IMatchFinder\r | |
96 | {\r | |
97 | Mf_Init_Func Init;\r | |
30fdf114 LG |
98 | Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;\r |
99 | Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;\r | |
100 | Mf_GetMatches_Func GetMatches;\r | |
101 | Mf_Skip_Func Skip;\r | |
102 | } IMatchFinder;\r | |
103 | \r | |
104 | void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);\r | |
105 | \r | |
c4ab09ef | 106 | void MatchFinder_Init_2(CMatchFinder *p, int readData);\r |
30fdf114 | 107 | void MatchFinder_Init(CMatchFinder *p);\r |
c4ab09ef | 108 | \r |
30fdf114 LG |
109 | UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r |
110 | UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r | |
c4ab09ef | 111 | \r |
30fdf114 LG |
112 | void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r |
113 | void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r | |
114 | \r | |
c4ab09ef LG |
115 | EXTERN_C_END\r |
116 | \r | |
30fdf114 | 117 | #endif\r |