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