xref: /netbsd-src/external/bsd/zstd/dist/lib/compress/zstd_lazy.h (revision 3117ece4fc4a4ca4489ba793710b60b0d26bab6c)
1*3117ece4Schristos /*
2*3117ece4Schristos  * Copyright (c) Meta Platforms, Inc. and affiliates.
3*3117ece4Schristos  * All rights reserved.
4*3117ece4Schristos  *
5*3117ece4Schristos  * This source code is licensed under both the BSD-style license (found in the
6*3117ece4Schristos  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7*3117ece4Schristos  * in the COPYING file in the root directory of this source tree).
8*3117ece4Schristos  * You may select, at your option, one of the above-listed licenses.
9*3117ece4Schristos  */
10*3117ece4Schristos 
11*3117ece4Schristos #ifndef ZSTD_LAZY_H
12*3117ece4Schristos #define ZSTD_LAZY_H
13*3117ece4Schristos 
14*3117ece4Schristos #if defined (__cplusplus)
15*3117ece4Schristos extern "C" {
16*3117ece4Schristos #endif
17*3117ece4Schristos 
18*3117ece4Schristos #include "zstd_compress_internal.h"
19*3117ece4Schristos 
20*3117ece4Schristos /**
21*3117ece4Schristos  * Dedicated Dictionary Search Structure bucket log. In the
22*3117ece4Schristos  * ZSTD_dedicatedDictSearch mode, the hashTable has
23*3117ece4Schristos  * 2 ** ZSTD_LAZY_DDSS_BUCKET_LOG entries in each bucket, rather than just
24*3117ece4Schristos  * one.
25*3117ece4Schristos  */
26*3117ece4Schristos #define ZSTD_LAZY_DDSS_BUCKET_LOG 2
27*3117ece4Schristos 
28*3117ece4Schristos #define ZSTD_ROW_HASH_TAG_BITS 8        /* nb bits to use for the tag */
29*3117ece4Schristos 
30*3117ece4Schristos #if !defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
31*3117ece4Schristos  || !defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
32*3117ece4Schristos  || !defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR) \
33*3117ece4Schristos  || !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR)
34*3117ece4Schristos U32 ZSTD_insertAndFindFirstIndex(ZSTD_matchState_t* ms, const BYTE* ip);
35*3117ece4Schristos void ZSTD_row_update(ZSTD_matchState_t* const ms, const BYTE* ip);
36*3117ece4Schristos 
37*3117ece4Schristos void ZSTD_dedicatedDictSearch_lazy_loadDictionary(ZSTD_matchState_t* ms, const BYTE* const ip);
38*3117ece4Schristos 
39*3117ece4Schristos void ZSTD_preserveUnsortedMark (U32* const table, U32 const size, U32 const reducerValue);  /*! used in ZSTD_reduceIndex(). preemptively increase value of ZSTD_DUBT_UNSORTED_MARK */
40*3117ece4Schristos #endif
41*3117ece4Schristos 
42*3117ece4Schristos #ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
43*3117ece4Schristos size_t ZSTD_compressBlock_greedy(
44*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
45*3117ece4Schristos         void const* src, size_t srcSize);
46*3117ece4Schristos size_t ZSTD_compressBlock_greedy_row(
47*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
48*3117ece4Schristos         void const* src, size_t srcSize);
49*3117ece4Schristos size_t ZSTD_compressBlock_greedy_dictMatchState(
50*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
51*3117ece4Schristos         void const* src, size_t srcSize);
52*3117ece4Schristos size_t ZSTD_compressBlock_greedy_dictMatchState_row(
53*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
54*3117ece4Schristos         void const* src, size_t srcSize);
55*3117ece4Schristos size_t ZSTD_compressBlock_greedy_dedicatedDictSearch(
56*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
57*3117ece4Schristos         void const* src, size_t srcSize);
58*3117ece4Schristos size_t ZSTD_compressBlock_greedy_dedicatedDictSearch_row(
59*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
60*3117ece4Schristos         void const* src, size_t srcSize);
61*3117ece4Schristos size_t ZSTD_compressBlock_greedy_extDict(
62*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
63*3117ece4Schristos         void const* src, size_t srcSize);
64*3117ece4Schristos size_t ZSTD_compressBlock_greedy_extDict_row(
65*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
66*3117ece4Schristos         void const* src, size_t srcSize);
67*3117ece4Schristos 
68*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY ZSTD_compressBlock_greedy
69*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_ROW ZSTD_compressBlock_greedy_row
70*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE ZSTD_compressBlock_greedy_dictMatchState
71*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE_ROW ZSTD_compressBlock_greedy_dictMatchState_row
72*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH ZSTD_compressBlock_greedy_dedicatedDictSearch
73*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH_ROW ZSTD_compressBlock_greedy_dedicatedDictSearch_row
74*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT ZSTD_compressBlock_greedy_extDict
75*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT_ROW ZSTD_compressBlock_greedy_extDict_row
76*3117ece4Schristos #else
77*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY NULL
78*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_ROW NULL
79*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE NULL
80*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE_ROW NULL
81*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH NULL
82*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH_ROW NULL
83*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT NULL
84*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT_ROW NULL
85*3117ece4Schristos #endif
86*3117ece4Schristos 
87*3117ece4Schristos #ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
88*3117ece4Schristos size_t ZSTD_compressBlock_lazy(
89*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
90*3117ece4Schristos         void const* src, size_t srcSize);
91*3117ece4Schristos size_t ZSTD_compressBlock_lazy_row(
92*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
93*3117ece4Schristos         void const* src, size_t srcSize);
94*3117ece4Schristos size_t ZSTD_compressBlock_lazy_dictMatchState(
95*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
96*3117ece4Schristos         void const* src, size_t srcSize);
97*3117ece4Schristos size_t ZSTD_compressBlock_lazy_dictMatchState_row(
98*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
99*3117ece4Schristos         void const* src, size_t srcSize);
100*3117ece4Schristos size_t ZSTD_compressBlock_lazy_dedicatedDictSearch(
101*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
102*3117ece4Schristos         void const* src, size_t srcSize);
103*3117ece4Schristos size_t ZSTD_compressBlock_lazy_dedicatedDictSearch_row(
104*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
105*3117ece4Schristos         void const* src, size_t srcSize);
106*3117ece4Schristos size_t ZSTD_compressBlock_lazy_extDict(
107*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
108*3117ece4Schristos         void const* src, size_t srcSize);
109*3117ece4Schristos size_t ZSTD_compressBlock_lazy_extDict_row(
110*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
111*3117ece4Schristos         void const* src, size_t srcSize);
112*3117ece4Schristos 
113*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY ZSTD_compressBlock_lazy
114*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_ROW ZSTD_compressBlock_lazy_row
115*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE ZSTD_compressBlock_lazy_dictMatchState
116*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE_ROW ZSTD_compressBlock_lazy_dictMatchState_row
117*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH ZSTD_compressBlock_lazy_dedicatedDictSearch
118*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH_ROW ZSTD_compressBlock_lazy_dedicatedDictSearch_row
119*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT ZSTD_compressBlock_lazy_extDict
120*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT_ROW ZSTD_compressBlock_lazy_extDict_row
121*3117ece4Schristos #else
122*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY NULL
123*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_ROW NULL
124*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE NULL
125*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE_ROW NULL
126*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH NULL
127*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH_ROW NULL
128*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT NULL
129*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT_ROW NULL
130*3117ece4Schristos #endif
131*3117ece4Schristos 
132*3117ece4Schristos #ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
133*3117ece4Schristos size_t ZSTD_compressBlock_lazy2(
134*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
135*3117ece4Schristos         void const* src, size_t srcSize);
136*3117ece4Schristos size_t ZSTD_compressBlock_lazy2_row(
137*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
138*3117ece4Schristos         void const* src, size_t srcSize);
139*3117ece4Schristos size_t ZSTD_compressBlock_lazy2_dictMatchState(
140*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
141*3117ece4Schristos         void const* src, size_t srcSize);
142*3117ece4Schristos size_t ZSTD_compressBlock_lazy2_dictMatchState_row(
143*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
144*3117ece4Schristos         void const* src, size_t srcSize);
145*3117ece4Schristos size_t ZSTD_compressBlock_lazy2_dedicatedDictSearch(
146*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
147*3117ece4Schristos         void const* src, size_t srcSize);
148*3117ece4Schristos size_t ZSTD_compressBlock_lazy2_dedicatedDictSearch_row(
149*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
150*3117ece4Schristos         void const* src, size_t srcSize);
151*3117ece4Schristos size_t ZSTD_compressBlock_lazy2_extDict(
152*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
153*3117ece4Schristos         void const* src, size_t srcSize);
154*3117ece4Schristos size_t ZSTD_compressBlock_lazy2_extDict_row(
155*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
156*3117ece4Schristos         void const* src, size_t srcSize);
157*3117ece4Schristos 
158*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2 ZSTD_compressBlock_lazy2
159*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_ROW ZSTD_compressBlock_lazy2_row
160*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE ZSTD_compressBlock_lazy2_dictMatchState
161*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE_ROW ZSTD_compressBlock_lazy2_dictMatchState_row
162*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH ZSTD_compressBlock_lazy2_dedicatedDictSearch
163*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH_ROW ZSTD_compressBlock_lazy2_dedicatedDictSearch_row
164*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT ZSTD_compressBlock_lazy2_extDict
165*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT_ROW ZSTD_compressBlock_lazy2_extDict_row
166*3117ece4Schristos #else
167*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2 NULL
168*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_ROW NULL
169*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE NULL
170*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE_ROW NULL
171*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH NULL
172*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH_ROW NULL
173*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT NULL
174*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT_ROW NULL
175*3117ece4Schristos #endif
176*3117ece4Schristos 
177*3117ece4Schristos #ifndef ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR
178*3117ece4Schristos size_t ZSTD_compressBlock_btlazy2(
179*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
180*3117ece4Schristos         void const* src, size_t srcSize);
181*3117ece4Schristos size_t ZSTD_compressBlock_btlazy2_dictMatchState(
182*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
183*3117ece4Schristos         void const* src, size_t srcSize);
184*3117ece4Schristos size_t ZSTD_compressBlock_btlazy2_extDict(
185*3117ece4Schristos         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
186*3117ece4Schristos         void const* src, size_t srcSize);
187*3117ece4Schristos 
188*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_BTLAZY2 ZSTD_compressBlock_btlazy2
189*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_BTLAZY2_DICTMATCHSTATE ZSTD_compressBlock_btlazy2_dictMatchState
190*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_BTLAZY2_EXTDICT ZSTD_compressBlock_btlazy2_extDict
191*3117ece4Schristos #else
192*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_BTLAZY2 NULL
193*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_BTLAZY2_DICTMATCHSTATE NULL
194*3117ece4Schristos #define ZSTD_COMPRESSBLOCK_BTLAZY2_EXTDICT NULL
195*3117ece4Schristos #endif
196*3117ece4Schristos 
197*3117ece4Schristos 
198*3117ece4Schristos #if defined (__cplusplus)
199*3117ece4Schristos }
200*3117ece4Schristos #endif
201*3117ece4Schristos 
202*3117ece4Schristos #endif /* ZSTD_LAZY_H */
203