diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
tree | fe5e17420300b715021a76328444088d32047963 /C/LzFind.h | |
parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
download | 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.tar.gz 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.tar.bz2 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.zip |
23.0123.01
Diffstat (limited to 'C/LzFind.h')
-rw-r--r-- | C/LzFind.h | 53 |
1 files changed, 38 insertions, 15 deletions
@@ -1,8 +1,8 @@ | |||
1 | /* LzFind.h -- Match finder for LZ algorithms | 1 | /* LzFind.h -- Match finder for LZ algorithms |
2 | 2021-07-13 : Igor Pavlov : Public domain */ | 2 | 2023-03-04 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #ifndef __LZ_FIND_H | 4 | #ifndef ZIP7_INC_LZ_FIND_H |
5 | #define __LZ_FIND_H | 5 | #define ZIP7_INC_LZ_FIND_H |
6 | 6 | ||
7 | #include "7zTypes.h" | 7 | #include "7zTypes.h" |
8 | 8 | ||
@@ -10,9 +10,9 @@ EXTERN_C_BEGIN | |||
10 | 10 | ||
11 | typedef UInt32 CLzRef; | 11 | typedef UInt32 CLzRef; |
12 | 12 | ||
13 | typedef struct _CMatchFinder | 13 | typedef struct |
14 | { | 14 | { |
15 | Byte *buffer; | 15 | const Byte *buffer; |
16 | UInt32 pos; | 16 | UInt32 pos; |
17 | UInt32 posLimit; | 17 | UInt32 posLimit; |
18 | UInt32 streamPos; /* wrap over Zero is allowed (streamPos < pos). Use (UInt32)(streamPos - pos) */ | 18 | UInt32 streamPos; /* wrap over Zero is allowed (streamPos < pos). Use (UInt32)(streamPos - pos) */ |
@@ -32,8 +32,8 @@ typedef struct _CMatchFinder | |||
32 | UInt32 hashMask; | 32 | UInt32 hashMask; |
33 | UInt32 cutValue; | 33 | UInt32 cutValue; |
34 | 34 | ||
35 | Byte *bufferBase; | 35 | Byte *bufBase; |
36 | ISeqInStream *stream; | 36 | ISeqInStreamPtr stream; |
37 | 37 | ||
38 | UInt32 blockSize; | 38 | UInt32 blockSize; |
39 | UInt32 keepSizeBefore; | 39 | UInt32 keepSizeBefore; |
@@ -43,7 +43,9 @@ typedef struct _CMatchFinder | |||
43 | size_t directInputRem; | 43 | size_t directInputRem; |
44 | UInt32 historySize; | 44 | UInt32 historySize; |
45 | UInt32 fixedHashSize; | 45 | UInt32 fixedHashSize; |
46 | UInt32 hashSizeSum; | 46 | Byte numHashBytes_Min; |
47 | Byte numHashOutBits; | ||
48 | Byte _pad2_[2]; | ||
47 | SRes result; | 49 | SRes result; |
48 | UInt32 crc[256]; | 50 | UInt32 crc[256]; |
49 | size_t numRefs; | 51 | size_t numRefs; |
@@ -69,24 +71,45 @@ void MatchFinder_ReadIfRequired(CMatchFinder *p); | |||
69 | 71 | ||
70 | void MatchFinder_Construct(CMatchFinder *p); | 72 | void MatchFinder_Construct(CMatchFinder *p); |
71 | 73 | ||
72 | /* Conditions: | 74 | /* (directInput = 0) is default value. |
73 | historySize <= 3 GB | 75 | It's required to provide correct (directInput) value |
74 | keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB | 76 | before calling MatchFinder_Create(). |
77 | You can set (directInput) by any of the following calls: | ||
78 | - MatchFinder_SET_DIRECT_INPUT_BUF() | ||
79 | - MatchFinder_SET_STREAM() | ||
80 | - MatchFinder_SET_STREAM_MODE() | ||
75 | */ | 81 | */ |
82 | |||
83 | #define MatchFinder_SET_DIRECT_INPUT_BUF(p, _src_, _srcLen_) { \ | ||
84 | (p)->stream = NULL; \ | ||
85 | (p)->directInput = 1; \ | ||
86 | (p)->buffer = (_src_); \ | ||
87 | (p)->directInputRem = (_srcLen_); } | ||
88 | |||
89 | /* | ||
90 | #define MatchFinder_SET_STREAM_MODE(p) { \ | ||
91 | (p)->directInput = 0; } | ||
92 | */ | ||
93 | |||
94 | #define MatchFinder_SET_STREAM(p, _stream_) { \ | ||
95 | (p)->stream = _stream_; \ | ||
96 | (p)->directInput = 0; } | ||
97 | |||
98 | |||
76 | int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, | 99 | int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, |
77 | UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, | 100 | UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, |
78 | ISzAllocPtr alloc); | 101 | ISzAllocPtr alloc); |
79 | void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc); | 102 | void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc); |
80 | void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); | 103 | void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); |
81 | // void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); | ||
82 | 104 | ||
83 | /* | 105 | /* |
84 | #define Inline_MatchFinder_InitPos(p, val) \ | 106 | #define MatchFinder_INIT_POS(p, val) \ |
85 | (p)->pos = (val); \ | 107 | (p)->pos = (val); \ |
86 | (p)->streamPos = (val); | 108 | (p)->streamPos = (val); |
87 | */ | 109 | */ |
88 | 110 | ||
89 | #define Inline_MatchFinder_ReduceOffsets(p, subValue) \ | 111 | // void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); |
112 | #define MatchFinder_REDUCE_OFFSETS(p, subValue) \ | ||
90 | (p)->pos -= (subValue); \ | 113 | (p)->pos -= (subValue); \ |
91 | (p)->streamPos -= (subValue); | 114 | (p)->streamPos -= (subValue); |
92 | 115 | ||
@@ -107,7 +130,7 @@ typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); | |||
107 | typedef UInt32 * (*Mf_GetMatches_Func)(void *object, UInt32 *distances); | 130 | typedef UInt32 * (*Mf_GetMatches_Func)(void *object, UInt32 *distances); |
108 | typedef void (*Mf_Skip_Func)(void *object, UInt32); | 131 | typedef void (*Mf_Skip_Func)(void *object, UInt32); |
109 | 132 | ||
110 | typedef struct _IMatchFinder | 133 | typedef struct |
111 | { | 134 | { |
112 | Mf_Init_Func Init; | 135 | Mf_Init_Func Init; |
113 | Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; | 136 | Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; |