2 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
13 #include "zstd_compress.h"
15 #if defined (__cplusplus)
19 /*-*************************************
20 * Long distance matching
21 ***************************************/
23 #define ZSTD_LDM_DEFAULT_WINDOW_LOG ZSTD_WINDOWLOG_DEFAULTMAX
24 #define ZSTD_LDM_HASHEVERYLOG_NOTSET 9999
26 /** ZSTD_compressBlock_ldm_generic() :
28 * This is a block compressor intended for long distance matching.
30 * The function searches for matches of length at least
31 * ldmParams.minMatchLength using a hash table in cctx->ldmState.
32 * Matches can be at a distance of up to cParams.windowLog.
34 * Upon finding a match, the unmatched literals are compressed using a
35 * ZSTD_blockCompressor (depending on the strategy in the compression
36 * parameters), which stores the matched sequences. The "long distance"
37 * match is then stored with the remaining literals from the
38 * ZSTD_blockCompressor. */
39 size_t ZSTD_compressBlock_ldm(ZSTD_CCtx* cctx, const void* src, size_t srcSize);
40 size_t ZSTD_compressBlock_ldm_extDict(ZSTD_CCtx* ctx,
41 const void* src, size_t srcSize);
43 /** ZSTD_ldm_initializeParameters() :
44 * Initialize the long distance matching parameters to their default values. */
45 size_t ZSTD_ldm_initializeParameters(ldmParams_t* params, U32 enableLdm);
47 /** ZSTD_ldm_getTableSize() :
48 * Estimate the space needed for long distance matching tables. */
49 size_t ZSTD_ldm_getTableSize(U32 hashLog, U32 bucketSizeLog);
51 /** ZSTD_ldm_getTableSize() :
52 * Return prime8bytes^(minMatchLength-1) */
53 U64 ZSTD_ldm_getHashPower(U32 minMatchLength);
55 /** ZSTD_ldm_adjustParameters() :
56 * If the params->hashEveryLog is not set, set it to its default value based on
57 * windowLog and params->hashLog.
59 * Ensures that params->bucketSizeLog is <= params->hashLog (setting it to
60 * params->hashLog if it is not). */
61 void ZSTD_ldm_adjustParameters(ldmParams_t* params, U32 windowLog);
63 #if defined (__cplusplus)
67 #endif /* ZSTD_FAST_H */