]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/zstd/lib/compress/zstd_ldm.h
Merge llvm trunk r321017 to contrib/llvm.
[FreeBSD/FreeBSD.git] / sys / contrib / zstd / lib / compress / zstd_ldm.h
1 /*
2  * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3  * All rights reserved.
4  *
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).
8  */
9
10 #ifndef ZSTD_LDM_H
11 #define ZSTD_LDM_H
12
13 #include "zstd_compress.h"
14
15 #if defined (__cplusplus)
16 extern "C" {
17 #endif
18
19 /*-*************************************
20 *  Long distance matching
21 ***************************************/
22
23 #define ZSTD_LDM_DEFAULT_WINDOW_LOG ZSTD_WINDOWLOG_DEFAULTMAX
24 #define ZSTD_LDM_HASHEVERYLOG_NOTSET 9999
25
26 /** ZSTD_compressBlock_ldm_generic() :
27  *
28  *  This is a block compressor intended for long distance matching.
29  *
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.
33  *
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);
42
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);
46
47 /** ZSTD_ldm_getTableSize() :
48  *  Estimate the space needed for long distance matching tables. */
49 size_t ZSTD_ldm_getTableSize(U32 hashLog, U32 bucketSizeLog);
50
51 /** ZSTD_ldm_getTableSize() :
52  *  Return prime8bytes^(minMatchLength-1) */
53 U64 ZSTD_ldm_getHashPower(U32 minMatchLength);
54
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.
58  *
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);
62
63 #if defined (__cplusplus)
64 }
65 #endif
66
67 #endif /* ZSTD_FAST_H */