comparison contrib/python-zstandard/zstd/compress/zstd_ldm.h @ 37495:b1fb341d8a61

zstandard: vendor python-zstandard 0.9.0 This was just released. It features a number of goodies. More info at https://gregoryszorc.com/blog/2018/04/09/release-of-python-zstandard-0.9/. The clang-format ignore list was updated to reflect the new source of files. The project contains a vendored copy of zstandard 1.3.4. The old version was 1.1.3. One of the changes between those versions is that zstandard is now dual licensed BSD + GPLv2 and the patent rights grant has been removed. Good riddance. The API should be backwards compatible. So no changes in core should be needed. However, there were a number of changes in the library that we'll want to adapt to. Those will be addressed in subsequent commits. Differential Revision: https://phab.mercurial-scm.org/D3198
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 09 Apr 2018 10:13:29 -0700
parents
children 73fef626dae3
comparison
equal deleted inserted replaced
37494:1ce7a55b09d1 37495:b1fb341d8a61
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 #if defined (__cplusplus)
14 extern "C" {
15 #endif
16
17 #include "zstd_compress_internal.h" /* ldmParams_t, U32 */
18 #include "zstd.h" /* ZSTD_CCtx, size_t */
19
20 /*-*************************************
21 * Long distance matching
22 ***************************************/
23
24 #define ZSTD_LDM_DEFAULT_WINDOW_LOG ZSTD_WINDOWLOG_DEFAULTMAX
25
26 /**
27 * ZSTD_ldm_generateSequences():
28 *
29 * Generates the sequences using the long distance match finder.
30 * Generates long range matching sequences in `sequences`, which parse a prefix
31 * of the source. `sequences` must be large enough to store every sequence,
32 * which can be checked with `ZSTD_ldm_getMaxNbSeq()`.
33 * @returns 0 or an error code.
34 *
35 * NOTE: The user must have called ZSTD_window_update() for all of the input
36 * they have, even if they pass it to ZSTD_ldm_generateSequences() in chunks.
37 * NOTE: This function returns an error if it runs out of space to store
38 * sequences.
39 */
40 size_t ZSTD_ldm_generateSequences(
41 ldmState_t* ldms, rawSeqStore_t* sequences,
42 ldmParams_t const* params, void const* src, size_t srcSize);
43
44 /**
45 * ZSTD_ldm_blockCompress():
46 *
47 * Compresses a block using the predefined sequences, along with a secondary
48 * block compressor. The literals section of every sequence is passed to the
49 * secondary block compressor, and those sequences are interspersed with the
50 * predefined sequences. Returns the length of the last literals.
51 * Updates `rawSeqStore.pos` to indicate how many sequences have been consumed.
52 * `rawSeqStore.seq` may also be updated to split the last sequence between two
53 * blocks.
54 * @return The length of the last literals.
55 *
56 * NOTE: The source must be at most the maximum block size, but the predefined
57 * sequences can be any size, and may be longer than the block. In the case that
58 * they are longer than the block, the last sequences may need to be split into
59 * two. We handle that case correctly, and update `rawSeqStore` appropriately.
60 * NOTE: This function does not return any errors.
61 */
62 size_t ZSTD_ldm_blockCompress(rawSeqStore_t* rawSeqStore,
63 ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
64 ZSTD_compressionParameters const* cParams,
65 void const* src, size_t srcSize,
66 int const extDict);
67
68 /**
69 * ZSTD_ldm_skipSequences():
70 *
71 * Skip past `srcSize` bytes worth of sequences in `rawSeqStore`.
72 * Avoids emitting matches less than `minMatch` bytes.
73 * Must be called for data with is not passed to ZSTD_ldm_blockCompress().
74 */
75 void ZSTD_ldm_skipSequences(rawSeqStore_t* rawSeqStore, size_t srcSize,
76 U32 const minMatch);
77
78
79 /** ZSTD_ldm_getTableSize() :
80 * Estimate the space needed for long distance matching tables or 0 if LDM is
81 * disabled.
82 */
83 size_t ZSTD_ldm_getTableSize(ldmParams_t params);
84
85 /** ZSTD_ldm_getSeqSpace() :
86 * Return an upper bound on the number of sequences that can be produced by
87 * the long distance matcher, or 0 if LDM is disabled.
88 */
89 size_t ZSTD_ldm_getMaxNbSeq(ldmParams_t params, size_t maxChunkSize);
90
91 /** ZSTD_ldm_getTableSize() :
92 * Return prime8bytes^(minMatchLength-1) */
93 U64 ZSTD_ldm_getHashPower(U32 minMatchLength);
94
95 /** ZSTD_ldm_adjustParameters() :
96 * If the params->hashEveryLog is not set, set it to its default value based on
97 * windowLog and params->hashLog.
98 *
99 * Ensures that params->bucketSizeLog is <= params->hashLog (setting it to
100 * params->hashLog if it is not).
101 *
102 * Ensures that the minMatchLength >= targetLength during optimal parsing.
103 */
104 void ZSTD_ldm_adjustParameters(ldmParams_t* params,
105 ZSTD_compressionParameters const* cParams);
106
107 #if defined (__cplusplus)
108 }
109 #endif
110
111 #endif /* ZSTD_FAST_H */