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