zstd-ruby 1.5.1.1 → 1.5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +78 -5
- data/Rakefile +8 -2
- data/ext/zstdruby/common.h +15 -0
- data/ext/zstdruby/extconf.rb +1 -1
- data/ext/zstdruby/libzstd/common/allocations.h +55 -0
- data/ext/zstdruby/libzstd/common/bits.h +200 -0
- data/ext/zstdruby/libzstd/common/bitstream.h +19 -60
- data/ext/zstdruby/libzstd/common/compiler.h +26 -3
- data/ext/zstdruby/libzstd/common/cpu.h +1 -1
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +1 -1
- data/ext/zstdruby/libzstd/common/entropy_common.c +12 -40
- data/ext/zstdruby/libzstd/common/error_private.c +9 -2
- data/ext/zstdruby/libzstd/common/error_private.h +1 -1
- data/ext/zstdruby/libzstd/common/fse.h +5 -83
- data/ext/zstdruby/libzstd/common/fse_decompress.c +7 -99
- data/ext/zstdruby/libzstd/common/huf.h +65 -156
- data/ext/zstdruby/libzstd/common/mem.h +39 -46
- data/ext/zstdruby/libzstd/common/pool.c +37 -16
- data/ext/zstdruby/libzstd/common/pool.h +9 -3
- data/ext/zstdruby/libzstd/common/portability_macros.h +28 -3
- data/ext/zstdruby/libzstd/common/threading.c +68 -14
- data/ext/zstdruby/libzstd/common/threading.h +5 -10
- data/ext/zstdruby/libzstd/common/xxhash.c +2 -2
- data/ext/zstdruby/libzstd/common/xxhash.h +8 -8
- data/ext/zstdruby/libzstd/common/zstd_common.c +1 -36
- data/ext/zstdruby/libzstd/common/zstd_deps.h +1 -1
- data/ext/zstdruby/libzstd/common/zstd_internal.h +20 -122
- data/ext/zstdruby/libzstd/common/zstd_trace.h +3 -3
- data/ext/zstdruby/libzstd/compress/clevels.h +1 -1
- data/ext/zstdruby/libzstd/compress/fse_compress.c +7 -124
- data/ext/zstdruby/libzstd/compress/hist.c +1 -1
- data/ext/zstdruby/libzstd/compress/hist.h +1 -1
- data/ext/zstdruby/libzstd/compress/huf_compress.c +234 -169
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +1317 -594
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +272 -165
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +115 -39
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -8
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +13 -13
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -21
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +162 -82
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +95 -33
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +434 -149
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +405 -348
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +4 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +9 -7
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +149 -100
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +32 -16
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +5 -2
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +434 -441
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +42 -37
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +4 -4
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +205 -80
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +201 -81
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +6 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +4 -2
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +19 -15
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +2 -2
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +13 -91
- data/ext/zstdruby/libzstd/zdict.h +53 -31
- data/ext/zstdruby/libzstd/zstd.h +580 -135
- data/ext/zstdruby/libzstd/zstd_errors.h +27 -8
- data/ext/zstdruby/main.c +20 -0
- data/ext/zstdruby/skippable_frame.c +63 -0
- data/ext/zstdruby/streaming_compress.c +177 -0
- data/ext/zstdruby/streaming_compress.h +5 -0
- data/ext/zstdruby/streaming_decompress.c +123 -0
- data/ext/zstdruby/zstdruby.c +113 -31
- data/lib/zstd-ruby/version.rb +1 -1
- data/lib/zstd-ruby.rb +0 -1
- data/zstd-ruby.gemspec +1 -1
- metadata +11 -37
- data/.github/dependabot.yml +0 -8
- data/.github/workflows/ruby.yml +0 -35
- data/ext/zstdruby/libzstd/.gitignore +0 -3
- data/ext/zstdruby/libzstd/BUCK +0 -232
- data/ext/zstdruby/libzstd/Makefile +0 -357
- data/ext/zstdruby/libzstd/README.md +0 -217
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +0 -214
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +0 -26
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +0 -167
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +0 -75
- data/ext/zstdruby/libzstd/dll/example/Makefile +0 -48
- data/ext/zstdruby/libzstd/dll/example/README.md +0 -63
- data/ext/zstdruby/libzstd/dll/example/build_package.bat +0 -20
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +0 -25
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +0 -181
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +0 -415
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +0 -2158
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3518
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3160
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3647
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4050
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4154
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4541
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +0 -187
- data/ext/zstdruby/libzstd/libzstd.mk +0 -185
- data/ext/zstdruby/libzstd/libzstd.pc.in +0 -16
- data/ext/zstdruby/libzstd/modulemap/module.modulemap +0 -4
- data/ext/zstdruby/zstdruby.h +0 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
@@ -23,6 +23,7 @@
|
|
23
23
|
#ifdef ZSTD_MULTITHREAD
|
24
24
|
# include "zstdmt_compress.h"
|
25
25
|
#endif
|
26
|
+
#include "../common/bits.h" /* ZSTD_highbit32, ZSTD_NbCommonBytes */
|
26
27
|
|
27
28
|
#if defined (__cplusplus)
|
28
29
|
extern "C" {
|
@@ -117,19 +118,20 @@ typedef struct {
|
|
117
118
|
/** ZSTD_buildBlockEntropyStats() :
|
118
119
|
* Builds entropy for the block.
|
119
120
|
* @return : 0 on success or error code */
|
120
|
-
size_t ZSTD_buildBlockEntropyStats(
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
size_t ZSTD_buildBlockEntropyStats(
|
122
|
+
const seqStore_t* seqStorePtr,
|
123
|
+
const ZSTD_entropyCTables_t* prevEntropy,
|
124
|
+
ZSTD_entropyCTables_t* nextEntropy,
|
125
|
+
const ZSTD_CCtx_params* cctxParams,
|
126
|
+
ZSTD_entropyCTablesMetadata_t* entropyMetadata,
|
127
|
+
void* workspace, size_t wkspSize);
|
126
128
|
|
127
129
|
/*********************************
|
128
130
|
* Compression internals structs *
|
129
131
|
*********************************/
|
130
132
|
|
131
133
|
typedef struct {
|
132
|
-
U32 off; /* Offset code
|
134
|
+
U32 off; /* Offset sumtype code for the match, using ZSTD_storeSeq() format */
|
133
135
|
U32 len; /* Raw length of match */
|
134
136
|
} ZSTD_match_t;
|
135
137
|
|
@@ -148,6 +150,12 @@ typedef struct {
|
|
148
150
|
size_t capacity; /* The capacity starting from `seq` pointer */
|
149
151
|
} rawSeqStore_t;
|
150
152
|
|
153
|
+
typedef struct {
|
154
|
+
U32 idx; /* Index in array of ZSTD_Sequence */
|
155
|
+
U32 posInSequence; /* Position within sequence at idx */
|
156
|
+
size_t posInSrc; /* Number of bytes given by sequences provided so far */
|
157
|
+
} ZSTD_sequencePosition;
|
158
|
+
|
151
159
|
UNUSED_ATTR static const rawSeqStore_t kNullRawSeqStore = {NULL, 0, 0, 0, 0};
|
152
160
|
|
153
161
|
typedef struct {
|
@@ -218,8 +226,10 @@ struct ZSTD_matchState_t {
|
|
218
226
|
U32 hashLog3; /* dispatch table for matches of len==3 : larger == faster, more memory */
|
219
227
|
|
220
228
|
U32 rowHashLog; /* For row-based matchfinder: Hashlog based on nb of rows in the hashTable.*/
|
221
|
-
|
229
|
+
BYTE* tagTable; /* For row-based matchFinder: A row-based table containing the hashes and head index. */
|
222
230
|
U32 hashCache[ZSTD_ROW_HASH_CACHE_SIZE]; /* For row-based matchFinder: a cache of hashes to improve speed */
|
231
|
+
U64 hashSalt; /* For row-based matchFinder: salts the hash for re-use of tag table */
|
232
|
+
U32 hashSaltEntropy; /* For row-based matchFinder: collects entropy for salt generation */
|
223
233
|
|
224
234
|
U32* hashTable;
|
225
235
|
U32* hashTable3;
|
@@ -234,6 +244,18 @@ struct ZSTD_matchState_t {
|
|
234
244
|
const ZSTD_matchState_t* dictMatchState;
|
235
245
|
ZSTD_compressionParameters cParams;
|
236
246
|
const rawSeqStore_t* ldmSeqStore;
|
247
|
+
|
248
|
+
/* Controls prefetching in some dictMatchState matchfinders.
|
249
|
+
* This behavior is controlled from the cctx ms.
|
250
|
+
* This parameter has no effect in the cdict ms. */
|
251
|
+
int prefetchCDictTables;
|
252
|
+
|
253
|
+
/* When == 0, lazy match finders insert every position.
|
254
|
+
* When != 0, lazy match finders only insert positions they search.
|
255
|
+
* This allows them to skip much faster over incompressible data,
|
256
|
+
* at a small cost to compression ratio.
|
257
|
+
*/
|
258
|
+
int lazySkipping;
|
237
259
|
};
|
238
260
|
|
239
261
|
typedef struct {
|
@@ -330,6 +352,24 @@ struct ZSTD_CCtx_params_s {
|
|
330
352
|
|
331
353
|
/* Internal use, for createCCtxParams() and freeCCtxParams() only */
|
332
354
|
ZSTD_customMem customMem;
|
355
|
+
|
356
|
+
/* Controls prefetching in some dictMatchState matchfinders */
|
357
|
+
ZSTD_paramSwitch_e prefetchCDictTables;
|
358
|
+
|
359
|
+
/* Controls whether zstd will fall back to an internal matchfinder
|
360
|
+
* if the external matchfinder returns an error code. */
|
361
|
+
int enableMatchFinderFallback;
|
362
|
+
|
363
|
+
/* Indicates whether an external matchfinder has been referenced.
|
364
|
+
* Users can't set this externally.
|
365
|
+
* It is set internally in ZSTD_registerSequenceProducer(). */
|
366
|
+
int useSequenceProducer;
|
367
|
+
|
368
|
+
/* Adjust the max block size*/
|
369
|
+
size_t maxBlockSize;
|
370
|
+
|
371
|
+
/* Controls repcode search in external sequence parsing */
|
372
|
+
ZSTD_paramSwitch_e searchForExternalRepcodes;
|
333
373
|
}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
|
334
374
|
|
335
375
|
#define COMPRESS_SEQUENCES_WORKSPACE_SIZE (sizeof(unsigned) * (MaxSeq + 2))
|
@@ -361,6 +401,14 @@ typedef struct {
|
|
361
401
|
ZSTD_entropyCTablesMetadata_t entropyMetadata;
|
362
402
|
} ZSTD_blockSplitCtx;
|
363
403
|
|
404
|
+
/* Context for block-level external matchfinder API */
|
405
|
+
typedef struct {
|
406
|
+
void* mState;
|
407
|
+
ZSTD_sequenceProducer_F* mFinder;
|
408
|
+
ZSTD_Sequence* seqBuffer;
|
409
|
+
size_t seqBufferCapacity;
|
410
|
+
} ZSTD_externalMatchCtx;
|
411
|
+
|
364
412
|
struct ZSTD_CCtx_s {
|
365
413
|
ZSTD_compressionStage_e stage;
|
366
414
|
int cParamsChanged; /* == 1 if cParams(except wlog) or compression level are changed in requestedParams. Triggers transmission of new params to ZSTDMT (if available) then reset to 0. */
|
@@ -410,6 +458,7 @@ struct ZSTD_CCtx_s {
|
|
410
458
|
|
411
459
|
/* Stable in/out buffer verification */
|
412
460
|
ZSTD_inBuffer expectedInBuffer;
|
461
|
+
size_t stableIn_notConsumed; /* nb bytes within stable input buffer that are said to be consumed but are not */
|
413
462
|
size_t expectedOutBufferSize;
|
414
463
|
|
415
464
|
/* Dictionary */
|
@@ -429,9 +478,13 @@ struct ZSTD_CCtx_s {
|
|
429
478
|
|
430
479
|
/* Workspace for block splitter */
|
431
480
|
ZSTD_blockSplitCtx blockSplitCtx;
|
481
|
+
|
482
|
+
/* Workspace for external matchfinder */
|
483
|
+
ZSTD_externalMatchCtx externalMatchCtx;
|
432
484
|
};
|
433
485
|
|
434
486
|
typedef enum { ZSTD_dtlm_fast, ZSTD_dtlm_full } ZSTD_dictTableLoadMethod_e;
|
487
|
+
typedef enum { ZSTD_tfp_forCCtx, ZSTD_tfp_forCDict } ZSTD_tableFillPurpose_e;
|
435
488
|
|
436
489
|
typedef enum {
|
437
490
|
ZSTD_noDict = 0,
|
@@ -453,7 +506,7 @@ typedef enum {
|
|
453
506
|
* In this mode we take both the source size and the dictionary size
|
454
507
|
* into account when selecting and adjusting the parameters.
|
455
508
|
*/
|
456
|
-
ZSTD_cpm_unknown = 3
|
509
|
+
ZSTD_cpm_unknown = 3 /* ZSTD_getCParams, ZSTD_getParams, ZSTD_adjustParams.
|
457
510
|
* We don't know what these parameters are for. We default to the legacy
|
458
511
|
* behavior of taking both the source size and the dict size into account
|
459
512
|
* when selecting and adjusting parameters.
|
@@ -497,31 +550,6 @@ MEM_STATIC U32 ZSTD_MLcode(U32 mlBase)
|
|
497
550
|
return (mlBase > 127) ? ZSTD_highbit32(mlBase) + ML_deltaCode : ML_Code[mlBase];
|
498
551
|
}
|
499
552
|
|
500
|
-
typedef struct repcodes_s {
|
501
|
-
U32 rep[3];
|
502
|
-
} repcodes_t;
|
503
|
-
|
504
|
-
MEM_STATIC repcodes_t ZSTD_updateRep(U32 const rep[3], U32 const offset, U32 const ll0)
|
505
|
-
{
|
506
|
-
repcodes_t newReps;
|
507
|
-
if (offset >= ZSTD_REP_NUM) { /* full offset */
|
508
|
-
newReps.rep[2] = rep[1];
|
509
|
-
newReps.rep[1] = rep[0];
|
510
|
-
newReps.rep[0] = offset - ZSTD_REP_MOVE;
|
511
|
-
} else { /* repcode */
|
512
|
-
U32 const repCode = offset + ll0;
|
513
|
-
if (repCode > 0) { /* note : if repCode==0, no change */
|
514
|
-
U32 const currentOffset = (repCode==ZSTD_REP_NUM) ? (rep[0] - 1) : rep[repCode];
|
515
|
-
newReps.rep[2] = (repCode >= 2) ? rep[1] : rep[2];
|
516
|
-
newReps.rep[1] = rep[0];
|
517
|
-
newReps.rep[0] = currentOffset;
|
518
|
-
} else { /* repCode == 0 */
|
519
|
-
ZSTD_memcpy(&newReps, rep, sizeof(newReps));
|
520
|
-
}
|
521
|
-
}
|
522
|
-
return newReps;
|
523
|
-
}
|
524
|
-
|
525
553
|
/* ZSTD_cParam_withinBounds:
|
526
554
|
* @return 1 if value is within cParam bounds,
|
527
555
|
* 0 otherwise */
|
@@ -537,9 +565,11 @@ MEM_STATIC int ZSTD_cParam_withinBounds(ZSTD_cParameter cParam, int value)
|
|
537
565
|
/* ZSTD_noCompressBlock() :
|
538
566
|
* Writes uncompressed block to dst buffer from given src.
|
539
567
|
* Returns the size of the block */
|
540
|
-
MEM_STATIC size_t
|
568
|
+
MEM_STATIC size_t
|
569
|
+
ZSTD_noCompressBlock(void* dst, size_t dstCapacity, const void* src, size_t srcSize, U32 lastBlock)
|
541
570
|
{
|
542
571
|
U32 const cBlockHeader24 = lastBlock + (((U32)bt_raw)<<1) + (U32)(srcSize << 3);
|
572
|
+
DEBUGLOG(5, "ZSTD_noCompressBlock (srcSize=%zu, dstCapacity=%zu)", srcSize, dstCapacity);
|
543
573
|
RETURN_ERROR_IF(srcSize + ZSTD_blockHeaderSize > dstCapacity,
|
544
574
|
dstSize_tooSmall, "dst buf too small for uncompressed block");
|
545
575
|
MEM_writeLE24(dst, cBlockHeader24);
|
@@ -547,7 +577,8 @@ MEM_STATIC size_t ZSTD_noCompressBlock (void* dst, size_t dstCapacity, const voi
|
|
547
577
|
return ZSTD_blockHeaderSize + srcSize;
|
548
578
|
}
|
549
579
|
|
550
|
-
MEM_STATIC size_t
|
580
|
+
MEM_STATIC size_t
|
581
|
+
ZSTD_rleCompressBlock(void* dst, size_t dstCapacity, BYTE src, size_t srcSize, U32 lastBlock)
|
551
582
|
{
|
552
583
|
BYTE* const op = (BYTE*)dst;
|
553
584
|
U32 const cBlockHeader = lastBlock + (((U32)bt_rle)<<1) + (U32)(srcSize << 3);
|
@@ -566,7 +597,7 @@ MEM_STATIC size_t ZSTD_minGain(size_t srcSize, ZSTD_strategy strat)
|
|
566
597
|
{
|
567
598
|
U32 const minlog = (strat>=ZSTD_btultra) ? (U32)(strat) - 1 : 6;
|
568
599
|
ZSTD_STATIC_ASSERT(ZSTD_btultra == 8);
|
569
|
-
assert(ZSTD_cParam_withinBounds(ZSTD_c_strategy, strat));
|
600
|
+
assert(ZSTD_cParam_withinBounds(ZSTD_c_strategy, (int)strat));
|
570
601
|
return (srcSize >> minlog) + 2;
|
571
602
|
}
|
572
603
|
|
@@ -590,7 +621,9 @@ MEM_STATIC int ZSTD_literalsCompressionIsDisabled(const ZSTD_CCtx_params* cctxPa
|
|
590
621
|
* Only called when the sequence ends past ilimit_w, so it only needs to be optimized for single
|
591
622
|
* large copies.
|
592
623
|
*/
|
593
|
-
static void
|
624
|
+
static void
|
625
|
+
ZSTD_safecopyLiterals(BYTE* op, BYTE const* ip, BYTE const* const iend, BYTE const* ilimit_w)
|
626
|
+
{
|
594
627
|
assert(iend > ilimit_w);
|
595
628
|
if (ip <= ilimit_w) {
|
596
629
|
ZSTD_wildcopy(op, ip, ilimit_w - ip, ZSTD_no_overlap);
|
@@ -600,14 +633,28 @@ static void ZSTD_safecopyLiterals(BYTE* op, BYTE const* ip, BYTE const* const ie
|
|
600
633
|
while (ip < iend) *op++ = *ip++;
|
601
634
|
}
|
602
635
|
|
636
|
+
|
637
|
+
#define REPCODE1_TO_OFFBASE REPCODE_TO_OFFBASE(1)
|
638
|
+
#define REPCODE2_TO_OFFBASE REPCODE_TO_OFFBASE(2)
|
639
|
+
#define REPCODE3_TO_OFFBASE REPCODE_TO_OFFBASE(3)
|
640
|
+
#define REPCODE_TO_OFFBASE(r) (assert((r)>=1), assert((r)<=ZSTD_REP_NUM), (r)) /* accepts IDs 1,2,3 */
|
641
|
+
#define OFFSET_TO_OFFBASE(o) (assert((o)>0), o + ZSTD_REP_NUM)
|
642
|
+
#define OFFBASE_IS_OFFSET(o) ((o) > ZSTD_REP_NUM)
|
643
|
+
#define OFFBASE_IS_REPCODE(o) ( 1 <= (o) && (o) <= ZSTD_REP_NUM)
|
644
|
+
#define OFFBASE_TO_OFFSET(o) (assert(OFFBASE_IS_OFFSET(o)), (o) - ZSTD_REP_NUM)
|
645
|
+
#define OFFBASE_TO_REPCODE(o) (assert(OFFBASE_IS_REPCODE(o)), (o)) /* returns ID 1,2,3 */
|
646
|
+
|
603
647
|
/*! ZSTD_storeSeq() :
|
604
|
-
* Store a sequence (litlen, litPtr,
|
605
|
-
*
|
606
|
-
*
|
607
|
-
* Allowed to
|
648
|
+
* Store a sequence (litlen, litPtr, offBase and matchLength) into seqStore_t.
|
649
|
+
* @offBase : Users should employ macros REPCODE_TO_OFFBASE() and OFFSET_TO_OFFBASE().
|
650
|
+
* @matchLength : must be >= MINMATCH
|
651
|
+
* Allowed to over-read literals up to litLimit.
|
608
652
|
*/
|
609
|
-
HINT_INLINE UNUSED_ATTR
|
610
|
-
|
653
|
+
HINT_INLINE UNUSED_ATTR void
|
654
|
+
ZSTD_storeSeq(seqStore_t* seqStorePtr,
|
655
|
+
size_t litLength, const BYTE* literals, const BYTE* litLimit,
|
656
|
+
U32 offBase,
|
657
|
+
size_t matchLength)
|
611
658
|
{
|
612
659
|
BYTE const* const litLimit_w = litLimit - WILDCOPY_OVERLENGTH;
|
613
660
|
BYTE const* const litEnd = literals + litLength;
|
@@ -615,8 +662,8 @@ void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const BYTE* litera
|
|
615
662
|
static const BYTE* g_start = NULL;
|
616
663
|
if (g_start==NULL) g_start = (const BYTE*)literals; /* note : index only works for compression within a single segment */
|
617
664
|
{ U32 const pos = (U32)((const BYTE*)literals - g_start);
|
618
|
-
DEBUGLOG(6, "Cpos%7u :%3u literals, match%4u bytes at
|
619
|
-
pos, (U32)litLength, (U32)
|
665
|
+
DEBUGLOG(6, "Cpos%7u :%3u literals, match%4u bytes at offBase%7u",
|
666
|
+
pos, (U32)litLength, (U32)matchLength, (U32)offBase);
|
620
667
|
}
|
621
668
|
#endif
|
622
669
|
assert((size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq);
|
@@ -626,9 +673,9 @@ void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const BYTE* litera
|
|
626
673
|
assert(literals + litLength <= litLimit);
|
627
674
|
if (litEnd <= litLimit_w) {
|
628
675
|
/* Common case we can use wildcopy.
|
629
|
-
|
630
|
-
|
631
|
-
|
676
|
+
* First copy 16 bytes, because literals are likely short.
|
677
|
+
*/
|
678
|
+
ZSTD_STATIC_ASSERT(WILDCOPY_OVERLENGTH >= 16);
|
632
679
|
ZSTD_copy16(seqStorePtr->lit, literals);
|
633
680
|
if (litLength > 16) {
|
634
681
|
ZSTD_wildcopy(seqStorePtr->lit+16, literals+16, (ptrdiff_t)litLength-16, ZSTD_no_overlap);
|
@@ -647,120 +694,63 @@ void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const BYTE* litera
|
|
647
694
|
seqStorePtr->sequences[0].litLength = (U16)litLength;
|
648
695
|
|
649
696
|
/* match offset */
|
650
|
-
seqStorePtr->sequences[0].
|
697
|
+
seqStorePtr->sequences[0].offBase = offBase;
|
651
698
|
|
652
699
|
/* match Length */
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
700
|
+
assert(matchLength >= MINMATCH);
|
701
|
+
{ size_t const mlBase = matchLength - MINMATCH;
|
702
|
+
if (mlBase>0xFFFF) {
|
703
|
+
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
704
|
+
seqStorePtr->longLengthType = ZSTD_llt_matchLength;
|
705
|
+
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
706
|
+
}
|
707
|
+
seqStorePtr->sequences[0].mlBase = (U16)mlBase;
|
657
708
|
}
|
658
|
-
seqStorePtr->sequences[0].matchLength = (U16)mlBase;
|
659
709
|
|
660
710
|
seqStorePtr->sequences++;
|
661
711
|
}
|
662
712
|
|
663
|
-
|
664
|
-
|
665
|
-
*
|
666
|
-
|
667
|
-
|
713
|
+
/* ZSTD_updateRep() :
|
714
|
+
* updates in-place @rep (array of repeat offsets)
|
715
|
+
* @offBase : sum-type, using numeric representation of ZSTD_storeSeq()
|
716
|
+
*/
|
717
|
+
MEM_STATIC void
|
718
|
+
ZSTD_updateRep(U32 rep[ZSTD_REP_NUM], U32 const offBase, U32 const ll0)
|
668
719
|
{
|
669
|
-
if (
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
}
|
683
|
-
# endif
|
684
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
685
|
-
return (__builtin_ctzll((U64)val) >> 3);
|
686
|
-
# else
|
687
|
-
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
|
688
|
-
0, 3, 1, 3, 1, 4, 2, 7,
|
689
|
-
0, 2, 3, 6, 1, 5, 3, 5,
|
690
|
-
1, 3, 4, 4, 2, 5, 6, 7,
|
691
|
-
7, 0, 1, 2, 3, 3, 4, 6,
|
692
|
-
2, 6, 5, 5, 3, 4, 5, 6,
|
693
|
-
7, 1, 2, 4, 6, 4, 4, 5,
|
694
|
-
7, 2, 6, 5, 7, 6, 7, 7 };
|
695
|
-
return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
|
696
|
-
# endif
|
697
|
-
} else { /* 32 bits */
|
698
|
-
# if defined(_MSC_VER)
|
699
|
-
if (val != 0) {
|
700
|
-
unsigned long r;
|
701
|
-
_BitScanForward(&r, (U32)val);
|
702
|
-
return (unsigned)(r >> 3);
|
703
|
-
} else {
|
704
|
-
/* Should not reach this code path */
|
705
|
-
__assume(0);
|
706
|
-
}
|
707
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
708
|
-
return (__builtin_ctz((U32)val) >> 3);
|
709
|
-
# else
|
710
|
-
static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0,
|
711
|
-
3, 2, 2, 1, 3, 2, 0, 1,
|
712
|
-
3, 3, 1, 2, 2, 2, 2, 0,
|
713
|
-
3, 1, 2, 0, 1, 0, 1, 1 };
|
714
|
-
return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
|
715
|
-
# endif
|
720
|
+
if (OFFBASE_IS_OFFSET(offBase)) { /* full offset */
|
721
|
+
rep[2] = rep[1];
|
722
|
+
rep[1] = rep[0];
|
723
|
+
rep[0] = OFFBASE_TO_OFFSET(offBase);
|
724
|
+
} else { /* repcode */
|
725
|
+
U32 const repCode = OFFBASE_TO_REPCODE(offBase) - 1 + ll0;
|
726
|
+
if (repCode > 0) { /* note : if repCode==0, no change */
|
727
|
+
U32 const currentOffset = (repCode==ZSTD_REP_NUM) ? (rep[0] - 1) : rep[repCode];
|
728
|
+
rep[2] = (repCode >= 2) ? rep[1] : rep[2];
|
729
|
+
rep[1] = rep[0];
|
730
|
+
rep[0] = currentOffset;
|
731
|
+
} else { /* repCode == 0 */
|
732
|
+
/* nothing to do */
|
716
733
|
}
|
717
|
-
}
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
# endif
|
732
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
733
|
-
return (__builtin_clzll(val) >> 3);
|
734
|
-
# else
|
735
|
-
unsigned r;
|
736
|
-
const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
|
737
|
-
if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
|
738
|
-
if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
|
739
|
-
r += (!val);
|
740
|
-
return r;
|
741
|
-
# endif
|
742
|
-
} else { /* 32 bits */
|
743
|
-
# if defined(_MSC_VER)
|
744
|
-
if (val != 0) {
|
745
|
-
unsigned long r;
|
746
|
-
_BitScanReverse(&r, (unsigned long)val);
|
747
|
-
return (unsigned)(r >> 3);
|
748
|
-
} else {
|
749
|
-
/* Should not reach this code path */
|
750
|
-
__assume(0);
|
751
|
-
}
|
752
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
753
|
-
return (__builtin_clz((U32)val) >> 3);
|
754
|
-
# else
|
755
|
-
unsigned r;
|
756
|
-
if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
|
757
|
-
r += (!val);
|
758
|
-
return r;
|
759
|
-
# endif
|
760
|
-
} }
|
734
|
+
}
|
735
|
+
}
|
736
|
+
|
737
|
+
typedef struct repcodes_s {
|
738
|
+
U32 rep[3];
|
739
|
+
} repcodes_t;
|
740
|
+
|
741
|
+
MEM_STATIC repcodes_t
|
742
|
+
ZSTD_newRep(U32 const rep[ZSTD_REP_NUM], U32 const offBase, U32 const ll0)
|
743
|
+
{
|
744
|
+
repcodes_t newReps;
|
745
|
+
ZSTD_memcpy(&newReps, rep, sizeof(newReps));
|
746
|
+
ZSTD_updateRep(newReps.rep, offBase, ll0);
|
747
|
+
return newReps;
|
761
748
|
}
|
762
749
|
|
763
750
|
|
751
|
+
/*-*************************************
|
752
|
+
* Match length counter
|
753
|
+
***************************************/
|
764
754
|
MEM_STATIC size_t ZSTD_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* const pInLimit)
|
765
755
|
{
|
766
756
|
const BYTE* const pStart = pIn;
|
@@ -806,32 +796,43 @@ ZSTD_count_2segments(const BYTE* ip, const BYTE* match,
|
|
806
796
|
* Hashes
|
807
797
|
***************************************/
|
808
798
|
static const U32 prime3bytes = 506832829U;
|
809
|
-
static U32 ZSTD_hash3(U32 u, U32 h) { return ((u << (32-24)) * prime3bytes) >> (32-h) ; }
|
810
|
-
MEM_STATIC size_t ZSTD_hash3Ptr(const void* ptr, U32 h) { return ZSTD_hash3(MEM_readLE32(ptr), h); } /* only in zstd_opt.h */
|
799
|
+
static U32 ZSTD_hash3(U32 u, U32 h, U32 s) { assert(h <= 32); return (((u << (32-24)) * prime3bytes) ^ s) >> (32-h) ; }
|
800
|
+
MEM_STATIC size_t ZSTD_hash3Ptr(const void* ptr, U32 h) { return ZSTD_hash3(MEM_readLE32(ptr), h, 0); } /* only in zstd_opt.h */
|
801
|
+
MEM_STATIC size_t ZSTD_hash3PtrS(const void* ptr, U32 h, U32 s) { return ZSTD_hash3(MEM_readLE32(ptr), h, s); }
|
811
802
|
|
812
803
|
static const U32 prime4bytes = 2654435761U;
|
813
|
-
static U32 ZSTD_hash4(U32 u, U32 h) { return (u * prime4bytes) >> (32-h) ; }
|
814
|
-
static size_t ZSTD_hash4Ptr(const void* ptr, U32 h) { return ZSTD_hash4(
|
804
|
+
static U32 ZSTD_hash4(U32 u, U32 h, U32 s) { assert(h <= 32); return ((u * prime4bytes) ^ s) >> (32-h) ; }
|
805
|
+
static size_t ZSTD_hash4Ptr(const void* ptr, U32 h) { return ZSTD_hash4(MEM_readLE32(ptr), h, 0); }
|
806
|
+
static size_t ZSTD_hash4PtrS(const void* ptr, U32 h, U32 s) { return ZSTD_hash4(MEM_readLE32(ptr), h, s); }
|
815
807
|
|
816
808
|
static const U64 prime5bytes = 889523592379ULL;
|
817
|
-
static size_t ZSTD_hash5(U64 u, U32 h) { return (size_t)(((u << (64-40)) * prime5bytes) >> (64-h)) ; }
|
818
|
-
static size_t ZSTD_hash5Ptr(const void* p, U32 h) { return ZSTD_hash5(MEM_readLE64(p), h); }
|
809
|
+
static size_t ZSTD_hash5(U64 u, U32 h, U64 s) { assert(h <= 64); return (size_t)((((u << (64-40)) * prime5bytes) ^ s) >> (64-h)) ; }
|
810
|
+
static size_t ZSTD_hash5Ptr(const void* p, U32 h) { return ZSTD_hash5(MEM_readLE64(p), h, 0); }
|
811
|
+
static size_t ZSTD_hash5PtrS(const void* p, U32 h, U64 s) { return ZSTD_hash5(MEM_readLE64(p), h, s); }
|
819
812
|
|
820
813
|
static const U64 prime6bytes = 227718039650203ULL;
|
821
|
-
static size_t ZSTD_hash6(U64 u, U32 h) { return (size_t)(((u << (64-48)) * prime6bytes) >> (64-h)) ; }
|
822
|
-
static size_t ZSTD_hash6Ptr(const void* p, U32 h) { return ZSTD_hash6(MEM_readLE64(p), h); }
|
814
|
+
static size_t ZSTD_hash6(U64 u, U32 h, U64 s) { assert(h <= 64); return (size_t)((((u << (64-48)) * prime6bytes) ^ s) >> (64-h)) ; }
|
815
|
+
static size_t ZSTD_hash6Ptr(const void* p, U32 h) { return ZSTD_hash6(MEM_readLE64(p), h, 0); }
|
816
|
+
static size_t ZSTD_hash6PtrS(const void* p, U32 h, U64 s) { return ZSTD_hash6(MEM_readLE64(p), h, s); }
|
823
817
|
|
824
818
|
static const U64 prime7bytes = 58295818150454627ULL;
|
825
|
-
static size_t ZSTD_hash7(U64 u, U32 h) { return (size_t)(((u << (64-56)) * prime7bytes) >> (64-h)) ; }
|
826
|
-
static size_t ZSTD_hash7Ptr(const void* p, U32 h) { return ZSTD_hash7(MEM_readLE64(p), h); }
|
819
|
+
static size_t ZSTD_hash7(U64 u, U32 h, U64 s) { assert(h <= 64); return (size_t)((((u << (64-56)) * prime7bytes) ^ s) >> (64-h)) ; }
|
820
|
+
static size_t ZSTD_hash7Ptr(const void* p, U32 h) { return ZSTD_hash7(MEM_readLE64(p), h, 0); }
|
821
|
+
static size_t ZSTD_hash7PtrS(const void* p, U32 h, U64 s) { return ZSTD_hash7(MEM_readLE64(p), h, s); }
|
827
822
|
|
828
823
|
static const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL;
|
829
|
-
static size_t ZSTD_hash8(U64 u, U32 h) { return (size_t)(((u) * prime8bytes) >> (64-h)) ; }
|
830
|
-
static size_t ZSTD_hash8Ptr(const void* p, U32 h) { return ZSTD_hash8(MEM_readLE64(p), h); }
|
824
|
+
static size_t ZSTD_hash8(U64 u, U32 h, U64 s) { assert(h <= 64); return (size_t)((((u) * prime8bytes) ^ s) >> (64-h)) ; }
|
825
|
+
static size_t ZSTD_hash8Ptr(const void* p, U32 h) { return ZSTD_hash8(MEM_readLE64(p), h, 0); }
|
826
|
+
static size_t ZSTD_hash8PtrS(const void* p, U32 h, U64 s) { return ZSTD_hash8(MEM_readLE64(p), h, s); }
|
827
|
+
|
831
828
|
|
832
829
|
MEM_STATIC FORCE_INLINE_ATTR
|
833
830
|
size_t ZSTD_hashPtr(const void* p, U32 hBits, U32 mls)
|
834
831
|
{
|
832
|
+
/* Although some of these hashes do support hBits up to 64, some do not.
|
833
|
+
* To be on the safe side, always avoid hBits > 32. */
|
834
|
+
assert(hBits <= 32);
|
835
|
+
|
835
836
|
switch(mls)
|
836
837
|
{
|
837
838
|
default:
|
@@ -843,6 +844,24 @@ size_t ZSTD_hashPtr(const void* p, U32 hBits, U32 mls)
|
|
843
844
|
}
|
844
845
|
}
|
845
846
|
|
847
|
+
MEM_STATIC FORCE_INLINE_ATTR
|
848
|
+
size_t ZSTD_hashPtrSalted(const void* p, U32 hBits, U32 mls, const U64 hashSalt) {
|
849
|
+
/* Although some of these hashes do support hBits up to 64, some do not.
|
850
|
+
* To be on the safe side, always avoid hBits > 32. */
|
851
|
+
assert(hBits <= 32);
|
852
|
+
|
853
|
+
switch(mls)
|
854
|
+
{
|
855
|
+
default:
|
856
|
+
case 4: return ZSTD_hash4PtrS(p, hBits, (U32)hashSalt);
|
857
|
+
case 5: return ZSTD_hash5PtrS(p, hBits, hashSalt);
|
858
|
+
case 6: return ZSTD_hash6PtrS(p, hBits, hashSalt);
|
859
|
+
case 7: return ZSTD_hash7PtrS(p, hBits, hashSalt);
|
860
|
+
case 8: return ZSTD_hash8PtrS(p, hBits, hashSalt);
|
861
|
+
}
|
862
|
+
}
|
863
|
+
|
864
|
+
|
846
865
|
/** ZSTD_ipow() :
|
847
866
|
* Return base^exponent.
|
848
867
|
*/
|
@@ -1190,10 +1209,15 @@ ZSTD_checkDictValidity(const ZSTD_window_t* window,
|
|
1190
1209
|
(unsigned)blockEndIdx, (unsigned)maxDist, (unsigned)loadedDictEnd);
|
1191
1210
|
assert(blockEndIdx >= loadedDictEnd);
|
1192
1211
|
|
1193
|
-
if (blockEndIdx > loadedDictEnd + maxDist) {
|
1212
|
+
if (blockEndIdx > loadedDictEnd + maxDist || loadedDictEnd != window->dictLimit) {
|
1194
1213
|
/* On reaching window size, dictionaries are invalidated.
|
1195
1214
|
* For simplification, if window size is reached anywhere within next block,
|
1196
1215
|
* the dictionary is invalidated for the full block.
|
1216
|
+
*
|
1217
|
+
* We also have to invalidate the dictionary if ZSTD_window_update() has detected
|
1218
|
+
* non-contiguous segments, which means that loadedDictEnd != window->dictLimit.
|
1219
|
+
* loadedDictEnd may be 0, if forceWindow is true, but in that case we never use
|
1220
|
+
* dictMatchState, so setting it to NULL is not a problem.
|
1197
1221
|
*/
|
1198
1222
|
DEBUGLOG(6, "invalidating dictionary for current block (distance > windowSize)");
|
1199
1223
|
*loadedDictEndPtr = 0;
|
@@ -1325,6 +1349,42 @@ MEM_STATIC void ZSTD_debugTable(const U32* table, U32 max)
|
|
1325
1349
|
|
1326
1350
|
#endif
|
1327
1351
|
|
1352
|
+
/* Short Cache */
|
1353
|
+
|
1354
|
+
/* Normally, zstd matchfinders follow this flow:
|
1355
|
+
* 1. Compute hash at ip
|
1356
|
+
* 2. Load index from hashTable[hash]
|
1357
|
+
* 3. Check if *ip == *(base + index)
|
1358
|
+
* In dictionary compression, loading *(base + index) is often an L2 or even L3 miss.
|
1359
|
+
*
|
1360
|
+
* Short cache is an optimization which allows us to avoid step 3 most of the time
|
1361
|
+
* when the data doesn't actually match. With short cache, the flow becomes:
|
1362
|
+
* 1. Compute (hash, currentTag) at ip. currentTag is an 8-bit independent hash at ip.
|
1363
|
+
* 2. Load (index, matchTag) from hashTable[hash]. See ZSTD_writeTaggedIndex to understand how this works.
|
1364
|
+
* 3. Only if currentTag == matchTag, check *ip == *(base + index). Otherwise, continue.
|
1365
|
+
*
|
1366
|
+
* Currently, short cache is only implemented in CDict hashtables. Thus, its use is limited to
|
1367
|
+
* dictMatchState matchfinders.
|
1368
|
+
*/
|
1369
|
+
#define ZSTD_SHORT_CACHE_TAG_BITS 8
|
1370
|
+
#define ZSTD_SHORT_CACHE_TAG_MASK ((1u << ZSTD_SHORT_CACHE_TAG_BITS) - 1)
|
1371
|
+
|
1372
|
+
/* Helper function for ZSTD_fillHashTable and ZSTD_fillDoubleHashTable.
|
1373
|
+
* Unpacks hashAndTag into (hash, tag), then packs (index, tag) into hashTable[hash]. */
|
1374
|
+
MEM_STATIC void ZSTD_writeTaggedIndex(U32* const hashTable, size_t hashAndTag, U32 index) {
|
1375
|
+
size_t const hash = hashAndTag >> ZSTD_SHORT_CACHE_TAG_BITS;
|
1376
|
+
U32 const tag = (U32)(hashAndTag & ZSTD_SHORT_CACHE_TAG_MASK);
|
1377
|
+
assert(index >> (32 - ZSTD_SHORT_CACHE_TAG_BITS) == 0);
|
1378
|
+
hashTable[hash] = (index << ZSTD_SHORT_CACHE_TAG_BITS) | tag;
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
/* Helper function for short cache matchfinders.
|
1382
|
+
* Unpacks tag1 and tag2 from lower bits of packedTag1 and packedTag2, then checks if the tags match. */
|
1383
|
+
MEM_STATIC int ZSTD_comparePackedTags(size_t packedTag1, size_t packedTag2) {
|
1384
|
+
U32 const tag1 = packedTag1 & ZSTD_SHORT_CACHE_TAG_MASK;
|
1385
|
+
U32 const tag2 = packedTag2 & ZSTD_SHORT_CACHE_TAG_MASK;
|
1386
|
+
return tag1 == tag2;
|
1387
|
+
}
|
1328
1388
|
|
1329
1389
|
#if defined (__cplusplus)
|
1330
1390
|
}
|
@@ -1422,4 +1482,51 @@ U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat);
|
|
1422
1482
|
*/
|
1423
1483
|
void ZSTD_CCtx_trace(ZSTD_CCtx* cctx, size_t extraCSize);
|
1424
1484
|
|
1485
|
+
/* Returns 0 on success, and a ZSTD_error otherwise. This function scans through an array of
|
1486
|
+
* ZSTD_Sequence, storing the sequences it finds, until it reaches a block delimiter.
|
1487
|
+
* Note that the block delimiter must include the last literals of the block.
|
1488
|
+
*/
|
1489
|
+
size_t
|
1490
|
+
ZSTD_copySequencesToSeqStoreExplicitBlockDelim(ZSTD_CCtx* cctx,
|
1491
|
+
ZSTD_sequencePosition* seqPos,
|
1492
|
+
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
|
1493
|
+
const void* src, size_t blockSize, ZSTD_paramSwitch_e externalRepSearch);
|
1494
|
+
|
1495
|
+
/* Returns the number of bytes to move the current read position back by.
|
1496
|
+
* Only non-zero if we ended up splitting a sequence.
|
1497
|
+
* Otherwise, it may return a ZSTD error if something went wrong.
|
1498
|
+
*
|
1499
|
+
* This function will attempt to scan through blockSize bytes
|
1500
|
+
* represented by the sequences in @inSeqs,
|
1501
|
+
* storing any (partial) sequences.
|
1502
|
+
*
|
1503
|
+
* Occasionally, we may want to change the actual number of bytes we consumed from inSeqs to
|
1504
|
+
* avoid splitting a match, or to avoid splitting a match such that it would produce a match
|
1505
|
+
* smaller than MINMATCH. In this case, we return the number of bytes that we didn't read from this block.
|
1506
|
+
*/
|
1507
|
+
size_t
|
1508
|
+
ZSTD_copySequencesToSeqStoreNoBlockDelim(ZSTD_CCtx* cctx, ZSTD_sequencePosition* seqPos,
|
1509
|
+
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
|
1510
|
+
const void* src, size_t blockSize, ZSTD_paramSwitch_e externalRepSearch);
|
1511
|
+
|
1512
|
+
|
1513
|
+
/* ===============================================================
|
1514
|
+
* Deprecated definitions that are still used internally to avoid
|
1515
|
+
* deprecation warnings. These functions are exactly equivalent to
|
1516
|
+
* their public variants, but avoid the deprecation warnings.
|
1517
|
+
* =============================================================== */
|
1518
|
+
|
1519
|
+
size_t ZSTD_compressBegin_usingCDict_deprecated(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
|
1520
|
+
|
1521
|
+
size_t ZSTD_compressContinue_public(ZSTD_CCtx* cctx,
|
1522
|
+
void* dst, size_t dstCapacity,
|
1523
|
+
const void* src, size_t srcSize);
|
1524
|
+
|
1525
|
+
size_t ZSTD_compressEnd_public(ZSTD_CCtx* cctx,
|
1526
|
+
void* dst, size_t dstCapacity,
|
1527
|
+
const void* src, size_t srcSize);
|
1528
|
+
|
1529
|
+
size_t ZSTD_compressBlock_deprecated(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
1530
|
+
|
1531
|
+
|
1425
1532
|
#endif /* ZSTD_COMPRESS_H */
|