zstd-ruby 1.3.5.0 → 1.3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/README.md +2 -1
- data/ext/zstdruby/libzstd/BUCK +1 -0
- data/ext/zstdruby/libzstd/Makefile +25 -13
- data/ext/zstdruby/libzstd/README.md +11 -10
- data/ext/zstdruby/libzstd/common/bitstream.h +8 -11
- data/ext/zstdruby/libzstd/common/compiler.h +30 -8
- data/ext/zstdruby/libzstd/common/cpu.h +1 -1
- data/ext/zstdruby/libzstd/common/mem.h +20 -2
- data/ext/zstdruby/libzstd/common/xxhash.c +1 -0
- data/ext/zstdruby/libzstd/common/zstd_internal.h +3 -2
- data/ext/zstdruby/libzstd/compress/fse_compress.c +55 -48
- data/ext/zstdruby/libzstd/compress/hist.h +1 -1
- data/ext/zstdruby/libzstd/compress/huf_compress.c +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +290 -147
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +5 -2
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +63 -51
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -4
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +44 -33
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -4
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +125 -116
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +13 -15
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +9 -11
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +0 -1
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +42 -36
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +8 -9
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +96 -51
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +16 -6
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +3 -3
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +169 -101
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +111 -87
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +83 -0
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +3 -3
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +728 -0
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +34 -31
- data/ext/zstdruby/libzstd/dictBuilder/zdict.h +60 -5
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +9 -3
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +6 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +6 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +1 -5
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +12 -9
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +10 -10
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +20 -18
- data/ext/zstdruby/libzstd/zstd.h +109 -50
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +4 -2
@@ -19,17 +19,16 @@ extern "C" {
|
|
19
19
|
#include "zstd_compress_internal.h"
|
20
20
|
|
21
21
|
void ZSTD_fillHashTable(ZSTD_matchState_t* ms,
|
22
|
-
ZSTD_compressionParameters const* cParams,
|
23
22
|
void const* end, ZSTD_dictTableLoadMethod_e dtlm);
|
24
23
|
size_t ZSTD_compressBlock_fast(
|
25
24
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
26
|
-
|
25
|
+
void const* src, size_t srcSize);
|
27
26
|
size_t ZSTD_compressBlock_fast_dictMatchState(
|
28
27
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
29
|
-
|
28
|
+
void const* src, size_t srcSize);
|
30
29
|
size_t ZSTD_compressBlock_fast_extDict(
|
31
30
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
32
|
-
|
31
|
+
void const* src, size_t srcSize);
|
33
32
|
|
34
33
|
#if defined (__cplusplus)
|
35
34
|
}
|
@@ -16,11 +16,12 @@
|
|
16
16
|
* Binary Tree search
|
17
17
|
***************************************/
|
18
18
|
|
19
|
-
void
|
20
|
-
|
19
|
+
static void
|
20
|
+
ZSTD_updateDUBT(ZSTD_matchState_t* ms,
|
21
21
|
const BYTE* ip, const BYTE* iend,
|
22
22
|
U32 mls)
|
23
23
|
{
|
24
|
+
const ZSTD_compressionParameters* const cParams = &ms->cParams;
|
24
25
|
U32* const hashTable = ms->hashTable;
|
25
26
|
U32 const hashLog = cParams->hashLog;
|
26
27
|
|
@@ -59,11 +60,12 @@ void ZSTD_updateDUBT(
|
|
59
60
|
* sort one already inserted but unsorted position
|
60
61
|
* assumption : current >= btlow == (current - btmask)
|
61
62
|
* doesn't fail */
|
62
|
-
static void
|
63
|
-
|
63
|
+
static void
|
64
|
+
ZSTD_insertDUBT1(ZSTD_matchState_t* ms,
|
64
65
|
U32 current, const BYTE* inputEnd,
|
65
66
|
U32 nbCompares, U32 btLow, const ZSTD_dictMode_e dictMode)
|
66
67
|
{
|
68
|
+
const ZSTD_compressionParameters* const cParams = &ms->cParams;
|
67
69
|
U32* const bt = ms->chainTable;
|
68
70
|
U32 const btLog = cParams->chainLog - 1;
|
69
71
|
U32 const btMask = (1 << btLog) - 1;
|
@@ -140,17 +142,20 @@ static void ZSTD_insertDUBT1(
|
|
140
142
|
}
|
141
143
|
|
142
144
|
|
143
|
-
static size_t
|
144
|
-
|
145
|
+
static size_t
|
146
|
+
ZSTD_DUBT_findBetterDictMatch (
|
147
|
+
ZSTD_matchState_t* ms,
|
145
148
|
const BYTE* const ip, const BYTE* const iend,
|
146
149
|
size_t* offsetPtr,
|
147
150
|
size_t bestLength,
|
148
151
|
U32 nbCompares,
|
149
152
|
U32 const mls,
|
150
|
-
const ZSTD_dictMode_e dictMode)
|
153
|
+
const ZSTD_dictMode_e dictMode)
|
154
|
+
{
|
151
155
|
const ZSTD_matchState_t * const dms = ms->dictMatchState;
|
156
|
+
const ZSTD_compressionParameters* const dmsCParams = &dms->cParams;
|
152
157
|
const U32 * const dictHashTable = dms->hashTable;
|
153
|
-
U32 const hashLog =
|
158
|
+
U32 const hashLog = dmsCParams->hashLog;
|
154
159
|
size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
|
155
160
|
U32 dictMatchIndex = dictHashTable[h];
|
156
161
|
|
@@ -164,12 +169,11 @@ static size_t ZSTD_DUBT_findBetterDictMatch (
|
|
164
169
|
U32 const dictIndexDelta = ms->window.lowLimit - dictHighLimit;
|
165
170
|
|
166
171
|
U32* const dictBt = dms->chainTable;
|
167
|
-
U32 const btLog =
|
172
|
+
U32 const btLog = dmsCParams->chainLog - 1;
|
168
173
|
U32 const btMask = (1 << btLog) - 1;
|
169
174
|
U32 const btLow = (btMask >= dictHighLimit - dictLowLimit) ? dictLowLimit : dictHighLimit - btMask;
|
170
175
|
|
171
176
|
size_t commonLengthSmaller=0, commonLengthLarger=0;
|
172
|
-
U32 matchEndIdx = current+8+1;
|
173
177
|
|
174
178
|
(void)dictMode;
|
175
179
|
assert(dictMode == ZSTD_dictMatchState);
|
@@ -184,14 +188,12 @@ static size_t ZSTD_DUBT_findBetterDictMatch (
|
|
184
188
|
|
185
189
|
if (matchLength > bestLength) {
|
186
190
|
U32 matchIndex = dictMatchIndex + dictIndexDelta;
|
187
|
-
if (matchLength > matchEndIdx - matchIndex)
|
188
|
-
matchEndIdx = matchIndex + (U32)matchLength;
|
189
191
|
if ( (4*(int)(matchLength-bestLength)) > (int)(ZSTD_highbit32(current-matchIndex+1) - ZSTD_highbit32((U32)offsetPtr[0]+1)) ) {
|
190
|
-
DEBUGLOG(9, "
|
192
|
+
DEBUGLOG(9, "ZSTD_DUBT_findBetterDictMatch(%u) : found better match length %u -> %u and offsetCode %u -> %u (dictMatchIndex %u, matchIndex %u)",
|
191
193
|
current, (U32)bestLength, (U32)matchLength, (U32)*offsetPtr, ZSTD_REP_MOVE + current - matchIndex, dictMatchIndex, matchIndex);
|
192
194
|
bestLength = matchLength, *offsetPtr = ZSTD_REP_MOVE + current - matchIndex;
|
193
195
|
}
|
194
|
-
if (ip+matchLength == iend) { /*
|
196
|
+
if (ip+matchLength == iend) { /* reached end of input : ip[matchLength] is not valid, no way to know if it's larger or smaller than match */
|
195
197
|
break; /* drop, to guarantee consistency (miss a little bit of compression) */
|
196
198
|
}
|
197
199
|
}
|
@@ -210,7 +212,7 @@ static size_t ZSTD_DUBT_findBetterDictMatch (
|
|
210
212
|
|
211
213
|
if (bestLength >= MINMATCH) {
|
212
214
|
U32 const mIndex = current - ((U32)*offsetPtr - ZSTD_REP_MOVE); (void)mIndex;
|
213
|
-
DEBUGLOG(8, "
|
215
|
+
DEBUGLOG(8, "ZSTD_DUBT_findBetterDictMatch(%u) : found match of length %u and offsetCode %u (pos %u)",
|
214
216
|
current, (U32)bestLength, (U32)*offsetPtr, mIndex);
|
215
217
|
}
|
216
218
|
return bestLength;
|
@@ -218,13 +220,14 @@ static size_t ZSTD_DUBT_findBetterDictMatch (
|
|
218
220
|
}
|
219
221
|
|
220
222
|
|
221
|
-
static size_t
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
223
|
+
static size_t
|
224
|
+
ZSTD_DUBT_findBestMatch(ZSTD_matchState_t* ms,
|
225
|
+
const BYTE* const ip, const BYTE* const iend,
|
226
|
+
size_t* offsetPtr,
|
227
|
+
U32 const mls,
|
228
|
+
const ZSTD_dictMode_e dictMode)
|
227
229
|
{
|
230
|
+
const ZSTD_compressionParameters* const cParams = &ms->cParams;
|
228
231
|
U32* const hashTable = ms->hashTable;
|
229
232
|
U32 const hashLog = cParams->hashLog;
|
230
233
|
size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
|
@@ -275,7 +278,7 @@ static size_t ZSTD_DUBT_findBestMatch (
|
|
275
278
|
while (matchIndex) { /* will end on matchIndex == 0 */
|
276
279
|
U32* const nextCandidateIdxPtr = bt + 2*(matchIndex&btMask) + 1;
|
277
280
|
U32 const nextCandidateIdx = *nextCandidateIdxPtr;
|
278
|
-
ZSTD_insertDUBT1(ms,
|
281
|
+
ZSTD_insertDUBT1(ms, matchIndex, iend,
|
279
282
|
nbCandidates, unsortLimit, dictMode);
|
280
283
|
matchIndex = nextCandidateIdx;
|
281
284
|
nbCandidates++;
|
@@ -317,6 +320,11 @@ static size_t ZSTD_DUBT_findBestMatch (
|
|
317
320
|
if ( (4*(int)(matchLength-bestLength)) > (int)(ZSTD_highbit32(current-matchIndex+1) - ZSTD_highbit32((U32)offsetPtr[0]+1)) )
|
318
321
|
bestLength = matchLength, *offsetPtr = ZSTD_REP_MOVE + current - matchIndex;
|
319
322
|
if (ip+matchLength == iend) { /* equal : no way to know if inf or sup */
|
323
|
+
if (dictMode == ZSTD_dictMatchState) {
|
324
|
+
nbCompares = 0; /* in addition to avoiding checking any
|
325
|
+
* further in this loop, make sure we
|
326
|
+
* skip checking in the dictionary. */
|
327
|
+
}
|
320
328
|
break; /* drop, to guarantee consistency (miss a little bit of compression) */
|
321
329
|
}
|
322
330
|
}
|
@@ -340,7 +348,10 @@ static size_t ZSTD_DUBT_findBestMatch (
|
|
340
348
|
*smallerPtr = *largerPtr = 0;
|
341
349
|
|
342
350
|
if (dictMode == ZSTD_dictMatchState && nbCompares) {
|
343
|
-
bestLength = ZSTD_DUBT_findBetterDictMatch(
|
351
|
+
bestLength = ZSTD_DUBT_findBetterDictMatch(
|
352
|
+
ms, ip, iend,
|
353
|
+
offsetPtr, bestLength, nbCompares,
|
354
|
+
mls, dictMode);
|
344
355
|
}
|
345
356
|
|
346
357
|
assert(matchEndIdx > current+8); /* ensure nextToUpdate is increased */
|
@@ -356,64 +367,64 @@ static size_t ZSTD_DUBT_findBestMatch (
|
|
356
367
|
|
357
368
|
|
358
369
|
/** ZSTD_BtFindBestMatch() : Tree updater, providing best match */
|
359
|
-
FORCE_INLINE_TEMPLATE size_t
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
370
|
+
FORCE_INLINE_TEMPLATE size_t
|
371
|
+
ZSTD_BtFindBestMatch( ZSTD_matchState_t* ms,
|
372
|
+
const BYTE* const ip, const BYTE* const iLimit,
|
373
|
+
size_t* offsetPtr,
|
374
|
+
const U32 mls /* template */,
|
375
|
+
const ZSTD_dictMode_e dictMode)
|
365
376
|
{
|
366
377
|
DEBUGLOG(7, "ZSTD_BtFindBestMatch");
|
367
378
|
if (ip < ms->window.base + ms->nextToUpdate) return 0; /* skipped area */
|
368
|
-
ZSTD_updateDUBT(ms,
|
369
|
-
return ZSTD_DUBT_findBestMatch(ms,
|
379
|
+
ZSTD_updateDUBT(ms, ip, iLimit, mls);
|
380
|
+
return ZSTD_DUBT_findBestMatch(ms, ip, iLimit, offsetPtr, mls, dictMode);
|
370
381
|
}
|
371
382
|
|
372
383
|
|
373
|
-
static size_t
|
374
|
-
|
375
|
-
|
376
|
-
|
384
|
+
static size_t
|
385
|
+
ZSTD_BtFindBestMatch_selectMLS ( ZSTD_matchState_t* ms,
|
386
|
+
const BYTE* ip, const BYTE* const iLimit,
|
387
|
+
size_t* offsetPtr)
|
377
388
|
{
|
378
|
-
switch(cParams
|
389
|
+
switch(ms->cParams.searchLength)
|
379
390
|
{
|
380
391
|
default : /* includes case 3 */
|
381
|
-
case 4 : return ZSTD_BtFindBestMatch(ms,
|
382
|
-
case 5 : return ZSTD_BtFindBestMatch(ms,
|
392
|
+
case 4 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict);
|
393
|
+
case 5 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict);
|
383
394
|
case 7 :
|
384
|
-
case 6 : return ZSTD_BtFindBestMatch(ms,
|
395
|
+
case 6 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict);
|
385
396
|
}
|
386
397
|
}
|
387
398
|
|
388
399
|
|
389
400
|
static size_t ZSTD_BtFindBestMatch_dictMatchState_selectMLS (
|
390
|
-
ZSTD_matchState_t* ms,
|
401
|
+
ZSTD_matchState_t* ms,
|
391
402
|
const BYTE* ip, const BYTE* const iLimit,
|
392
403
|
size_t* offsetPtr)
|
393
404
|
{
|
394
|
-
switch(cParams
|
405
|
+
switch(ms->cParams.searchLength)
|
395
406
|
{
|
396
407
|
default : /* includes case 3 */
|
397
|
-
case 4 : return ZSTD_BtFindBestMatch(ms,
|
398
|
-
case 5 : return ZSTD_BtFindBestMatch(ms,
|
408
|
+
case 4 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState);
|
409
|
+
case 5 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState);
|
399
410
|
case 7 :
|
400
|
-
case 6 : return ZSTD_BtFindBestMatch(ms,
|
411
|
+
case 6 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState);
|
401
412
|
}
|
402
413
|
}
|
403
414
|
|
404
415
|
|
405
416
|
static size_t ZSTD_BtFindBestMatch_extDict_selectMLS (
|
406
|
-
ZSTD_matchState_t* ms,
|
417
|
+
ZSTD_matchState_t* ms,
|
407
418
|
const BYTE* ip, const BYTE* const iLimit,
|
408
419
|
size_t* offsetPtr)
|
409
420
|
{
|
410
|
-
switch(cParams
|
421
|
+
switch(ms->cParams.searchLength)
|
411
422
|
{
|
412
423
|
default : /* includes case 3 */
|
413
|
-
case 4 : return ZSTD_BtFindBestMatch(ms,
|
414
|
-
case 5 : return ZSTD_BtFindBestMatch(ms,
|
424
|
+
case 4 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict);
|
425
|
+
case 5 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict);
|
415
426
|
case 7 :
|
416
|
-
case 6 : return ZSTD_BtFindBestMatch(ms,
|
427
|
+
case 6 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict);
|
417
428
|
}
|
418
429
|
}
|
419
430
|
|
@@ -427,7 +438,8 @@ static size_t ZSTD_BtFindBestMatch_extDict_selectMLS (
|
|
427
438
|
/* Update chains up to ip (excluded)
|
428
439
|
Assumption : always within prefix (i.e. not within extDict) */
|
429
440
|
static U32 ZSTD_insertAndFindFirstIndex_internal(
|
430
|
-
ZSTD_matchState_t* ms,
|
441
|
+
ZSTD_matchState_t* ms,
|
442
|
+
const ZSTD_compressionParameters* const cParams,
|
431
443
|
const BYTE* ip, U32 const mls)
|
432
444
|
{
|
433
445
|
U32* const hashTable = ms->hashTable;
|
@@ -449,22 +461,21 @@ static U32 ZSTD_insertAndFindFirstIndex_internal(
|
|
449
461
|
return hashTable[ZSTD_hashPtr(ip, hashLog, mls)];
|
450
462
|
}
|
451
463
|
|
452
|
-
U32 ZSTD_insertAndFindFirstIndex(
|
453
|
-
|
454
|
-
|
455
|
-
{
|
456
|
-
return ZSTD_insertAndFindFirstIndex_internal(ms, cParams, ip, cParams->searchLength);
|
464
|
+
U32 ZSTD_insertAndFindFirstIndex(ZSTD_matchState_t* ms, const BYTE* ip) {
|
465
|
+
const ZSTD_compressionParameters* const cParams = &ms->cParams;
|
466
|
+
return ZSTD_insertAndFindFirstIndex_internal(ms, cParams, ip, ms->cParams.searchLength);
|
457
467
|
}
|
458
468
|
|
459
469
|
|
460
470
|
/* inlining is important to hardwire a hot branch (template emulation) */
|
461
471
|
FORCE_INLINE_TEMPLATE
|
462
472
|
size_t ZSTD_HcFindBestMatch_generic (
|
463
|
-
ZSTD_matchState_t* ms,
|
473
|
+
ZSTD_matchState_t* ms,
|
464
474
|
const BYTE* const ip, const BYTE* const iLimit,
|
465
475
|
size_t* offsetPtr,
|
466
476
|
const U32 mls, const ZSTD_dictMode_e dictMode)
|
467
477
|
{
|
478
|
+
const ZSTD_compressionParameters* const cParams = &ms->cParams;
|
468
479
|
U32* const chainTable = ms->chainTable;
|
469
480
|
const U32 chainSize = (1 << cParams->chainLog);
|
470
481
|
const U32 chainMask = chainSize-1;
|
@@ -509,14 +520,16 @@ size_t ZSTD_HcFindBestMatch_generic (
|
|
509
520
|
if (dictMode == ZSTD_dictMatchState) {
|
510
521
|
const ZSTD_matchState_t* const dms = ms->dictMatchState;
|
511
522
|
const U32* const dmsChainTable = dms->chainTable;
|
523
|
+
const U32 dmsChainSize = (1 << dms->cParams.chainLog);
|
524
|
+
const U32 dmsChainMask = dmsChainSize - 1;
|
512
525
|
const U32 dmsLowestIndex = dms->window.dictLimit;
|
513
526
|
const BYTE* const dmsBase = dms->window.base;
|
514
527
|
const BYTE* const dmsEnd = dms->window.nextSrc;
|
515
528
|
const U32 dmsSize = (U32)(dmsEnd - dmsBase);
|
516
529
|
const U32 dmsIndexDelta = dictLimit - dmsSize;
|
517
|
-
const U32 dmsMinChain = dmsSize >
|
530
|
+
const U32 dmsMinChain = dmsSize > dmsChainSize ? dmsSize - dmsChainSize : 0;
|
518
531
|
|
519
|
-
matchIndex = dms->hashTable[ZSTD_hashPtr(ip, cParams
|
532
|
+
matchIndex = dms->hashTable[ZSTD_hashPtr(ip, dms->cParams.hashLog, mls)];
|
520
533
|
|
521
534
|
for ( ; (matchIndex>dmsLowestIndex) & (nbAttempts>0) ; nbAttempts--) {
|
522
535
|
size_t currentMl=0;
|
@@ -533,7 +546,7 @@ size_t ZSTD_HcFindBestMatch_generic (
|
|
533
546
|
}
|
534
547
|
|
535
548
|
if (matchIndex <= dmsMinChain) break;
|
536
|
-
matchIndex = dmsChainTable[matchIndex &
|
549
|
+
matchIndex = dmsChainTable[matchIndex & dmsChainMask];
|
537
550
|
}
|
538
551
|
}
|
539
552
|
|
@@ -542,49 +555,49 @@ size_t ZSTD_HcFindBestMatch_generic (
|
|
542
555
|
|
543
556
|
|
544
557
|
FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_selectMLS (
|
545
|
-
ZSTD_matchState_t* ms,
|
558
|
+
ZSTD_matchState_t* ms,
|
546
559
|
const BYTE* ip, const BYTE* const iLimit,
|
547
560
|
size_t* offsetPtr)
|
548
561
|
{
|
549
|
-
switch(cParams
|
562
|
+
switch(ms->cParams.searchLength)
|
550
563
|
{
|
551
564
|
default : /* includes case 3 */
|
552
|
-
case 4 : return ZSTD_HcFindBestMatch_generic(ms,
|
553
|
-
case 5 : return ZSTD_HcFindBestMatch_generic(ms,
|
565
|
+
case 4 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict);
|
566
|
+
case 5 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict);
|
554
567
|
case 7 :
|
555
|
-
case 6 : return ZSTD_HcFindBestMatch_generic(ms,
|
568
|
+
case 6 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict);
|
556
569
|
}
|
557
570
|
}
|
558
571
|
|
559
572
|
|
560
573
|
static size_t ZSTD_HcFindBestMatch_dictMatchState_selectMLS (
|
561
|
-
ZSTD_matchState_t* ms,
|
574
|
+
ZSTD_matchState_t* ms,
|
562
575
|
const BYTE* ip, const BYTE* const iLimit,
|
563
576
|
size_t* offsetPtr)
|
564
577
|
{
|
565
|
-
switch(cParams
|
578
|
+
switch(ms->cParams.searchLength)
|
566
579
|
{
|
567
580
|
default : /* includes case 3 */
|
568
|
-
case 4 : return ZSTD_HcFindBestMatch_generic(ms,
|
569
|
-
case 5 : return ZSTD_HcFindBestMatch_generic(ms,
|
581
|
+
case 4 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState);
|
582
|
+
case 5 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState);
|
570
583
|
case 7 :
|
571
|
-
case 6 : return ZSTD_HcFindBestMatch_generic(ms,
|
584
|
+
case 6 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState);
|
572
585
|
}
|
573
586
|
}
|
574
587
|
|
575
588
|
|
576
589
|
FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_extDict_selectMLS (
|
577
|
-
ZSTD_matchState_t* ms,
|
590
|
+
ZSTD_matchState_t* ms,
|
578
591
|
const BYTE* ip, const BYTE* const iLimit,
|
579
592
|
size_t* offsetPtr)
|
580
593
|
{
|
581
|
-
switch(cParams
|
594
|
+
switch(ms->cParams.searchLength)
|
582
595
|
{
|
583
596
|
default : /* includes case 3 */
|
584
|
-
case 4 : return ZSTD_HcFindBestMatch_generic(ms,
|
585
|
-
case 5 : return ZSTD_HcFindBestMatch_generic(ms,
|
597
|
+
case 4 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict);
|
598
|
+
case 5 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict);
|
586
599
|
case 7 :
|
587
|
-
case 6 : return ZSTD_HcFindBestMatch_generic(ms,
|
600
|
+
case 6 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict);
|
588
601
|
}
|
589
602
|
}
|
590
603
|
|
@@ -596,7 +609,6 @@ FORCE_INLINE_TEMPLATE
|
|
596
609
|
size_t ZSTD_compressBlock_lazy_generic(
|
597
610
|
ZSTD_matchState_t* ms, seqStore_t* seqStore,
|
598
611
|
U32 rep[ZSTD_REP_NUM],
|
599
|
-
ZSTD_compressionParameters const* cParams,
|
600
612
|
const void* src, size_t srcSize,
|
601
613
|
const U32 searchMethod, const U32 depth,
|
602
614
|
ZSTD_dictMode_e const dictMode)
|
@@ -611,7 +623,7 @@ size_t ZSTD_compressBlock_lazy_generic(
|
|
611
623
|
const BYTE* const prefixLowest = base + prefixLowestIndex;
|
612
624
|
|
613
625
|
typedef size_t (*searchMax_f)(
|
614
|
-
ZSTD_matchState_t* ms,
|
626
|
+
ZSTD_matchState_t* ms,
|
615
627
|
const BYTE* ip, const BYTE* iLimit, size_t* offsetPtr);
|
616
628
|
searchMax_f const searchMax = dictMode == ZSTD_dictMatchState ?
|
617
629
|
(searchMethod ? ZSTD_BtFindBestMatch_dictMatchState_selectMLS : ZSTD_HcFindBestMatch_dictMatchState_selectMLS) :
|
@@ -632,8 +644,6 @@ size_t ZSTD_compressBlock_lazy_generic(
|
|
632
644
|
0;
|
633
645
|
const U32 dictAndPrefixLength = (U32)(ip - prefixLowest + dictEnd - dictLowest);
|
634
646
|
|
635
|
-
(void)dictMode;
|
636
|
-
|
637
647
|
/* init */
|
638
648
|
ip += (dictAndPrefixLength == 0);
|
639
649
|
ms->nextToUpdate3 = ms->nextToUpdate;
|
@@ -676,8 +686,8 @@ size_t ZSTD_compressBlock_lazy_generic(
|
|
676
686
|
}
|
677
687
|
|
678
688
|
/* first search (depth 0) */
|
679
|
-
{ size_t offsetFound =
|
680
|
-
size_t const ml2 = searchMax(ms,
|
689
|
+
{ size_t offsetFound = 999999999;
|
690
|
+
size_t const ml2 = searchMax(ms, ip, iend, &offsetFound);
|
681
691
|
if (ml2 > matchLength)
|
682
692
|
matchLength = ml2, start = ip, offset=offsetFound;
|
683
693
|
}
|
@@ -714,8 +724,8 @@ size_t ZSTD_compressBlock_lazy_generic(
|
|
714
724
|
matchLength = mlRep, offset = 0, start = ip;
|
715
725
|
}
|
716
726
|
}
|
717
|
-
{ size_t offset2=
|
718
|
-
size_t const ml2 = searchMax(ms,
|
727
|
+
{ size_t offset2=999999999;
|
728
|
+
size_t const ml2 = searchMax(ms, ip, iend, &offset2);
|
719
729
|
int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
|
720
730
|
int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 4);
|
721
731
|
if ((ml2 >= 4) && (gain2 > gain1)) {
|
@@ -749,8 +759,8 @@ size_t ZSTD_compressBlock_lazy_generic(
|
|
749
759
|
matchLength = mlRep, offset = 0, start = ip;
|
750
760
|
}
|
751
761
|
}
|
752
|
-
{ size_t offset2=
|
753
|
-
size_t const ml2 = searchMax(ms,
|
762
|
+
{ size_t offset2=999999999;
|
763
|
+
size_t const ml2 = searchMax(ms, ip, iend, &offset2);
|
754
764
|
int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
|
755
765
|
int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 7);
|
756
766
|
if ((ml2 >= 4) && (gain2 > gain1)) {
|
@@ -833,58 +843,58 @@ _storeSequence:
|
|
833
843
|
|
834
844
|
size_t ZSTD_compressBlock_btlazy2(
|
835
845
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
836
|
-
|
846
|
+
void const* src, size_t srcSize)
|
837
847
|
{
|
838
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
848
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 1, 2, ZSTD_noDict);
|
839
849
|
}
|
840
850
|
|
841
851
|
size_t ZSTD_compressBlock_lazy2(
|
842
852
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
843
|
-
|
853
|
+
void const* src, size_t srcSize)
|
844
854
|
{
|
845
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
855
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 2, ZSTD_noDict);
|
846
856
|
}
|
847
857
|
|
848
858
|
size_t ZSTD_compressBlock_lazy(
|
849
859
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
850
|
-
|
860
|
+
void const* src, size_t srcSize)
|
851
861
|
{
|
852
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
862
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 1, ZSTD_noDict);
|
853
863
|
}
|
854
864
|
|
855
865
|
size_t ZSTD_compressBlock_greedy(
|
856
866
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
857
|
-
|
867
|
+
void const* src, size_t srcSize)
|
858
868
|
{
|
859
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
869
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 0, ZSTD_noDict);
|
860
870
|
}
|
861
871
|
|
862
872
|
size_t ZSTD_compressBlock_btlazy2_dictMatchState(
|
863
873
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
864
|
-
|
874
|
+
void const* src, size_t srcSize)
|
865
875
|
{
|
866
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
876
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 1, 2, ZSTD_dictMatchState);
|
867
877
|
}
|
868
878
|
|
869
879
|
size_t ZSTD_compressBlock_lazy2_dictMatchState(
|
870
880
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
871
|
-
|
881
|
+
void const* src, size_t srcSize)
|
872
882
|
{
|
873
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
883
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 2, ZSTD_dictMatchState);
|
874
884
|
}
|
875
885
|
|
876
886
|
size_t ZSTD_compressBlock_lazy_dictMatchState(
|
877
887
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
878
|
-
|
888
|
+
void const* src, size_t srcSize)
|
879
889
|
{
|
880
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
890
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 1, ZSTD_dictMatchState);
|
881
891
|
}
|
882
892
|
|
883
893
|
size_t ZSTD_compressBlock_greedy_dictMatchState(
|
884
894
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
885
|
-
|
895
|
+
void const* src, size_t srcSize)
|
886
896
|
{
|
887
|
-
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep,
|
897
|
+
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 0, ZSTD_dictMatchState);
|
888
898
|
}
|
889
899
|
|
890
900
|
|
@@ -892,7 +902,6 @@ FORCE_INLINE_TEMPLATE
|
|
892
902
|
size_t ZSTD_compressBlock_lazy_extDict_generic(
|
893
903
|
ZSTD_matchState_t* ms, seqStore_t* seqStore,
|
894
904
|
U32 rep[ZSTD_REP_NUM],
|
895
|
-
ZSTD_compressionParameters const* cParams,
|
896
905
|
const void* src, size_t srcSize,
|
897
906
|
const U32 searchMethod, const U32 depth)
|
898
907
|
{
|
@@ -910,7 +919,7 @@ size_t ZSTD_compressBlock_lazy_extDict_generic(
|
|
910
919
|
const BYTE* const dictStart = dictBase + lowestIndex;
|
911
920
|
|
912
921
|
typedef size_t (*searchMax_f)(
|
913
|
-
ZSTD_matchState_t* ms,
|
922
|
+
ZSTD_matchState_t* ms,
|
914
923
|
const BYTE* ip, const BYTE* iLimit, size_t* offsetPtr);
|
915
924
|
searchMax_f searchMax = searchMethod ? ZSTD_BtFindBestMatch_extDict_selectMLS : ZSTD_HcFindBestMatch_extDict_selectMLS;
|
916
925
|
|
@@ -940,8 +949,8 @@ size_t ZSTD_compressBlock_lazy_extDict_generic(
|
|
940
949
|
} }
|
941
950
|
|
942
951
|
/* first search (depth 0) */
|
943
|
-
{ size_t offsetFound =
|
944
|
-
size_t const ml2 = searchMax(ms,
|
952
|
+
{ size_t offsetFound = 999999999;
|
953
|
+
size_t const ml2 = searchMax(ms, ip, iend, &offsetFound);
|
945
954
|
if (ml2 > matchLength)
|
946
955
|
matchLength = ml2, start = ip, offset=offsetFound;
|
947
956
|
}
|
@@ -973,8 +982,8 @@ size_t ZSTD_compressBlock_lazy_extDict_generic(
|
|
973
982
|
} }
|
974
983
|
|
975
984
|
/* search match, depth 1 */
|
976
|
-
{ size_t offset2=
|
977
|
-
size_t const ml2 = searchMax(ms,
|
985
|
+
{ size_t offset2=999999999;
|
986
|
+
size_t const ml2 = searchMax(ms, ip, iend, &offset2);
|
978
987
|
int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
|
979
988
|
int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 4);
|
980
989
|
if ((ml2 >= 4) && (gain2 > gain1)) {
|
@@ -1003,8 +1012,8 @@ size_t ZSTD_compressBlock_lazy_extDict_generic(
|
|
1003
1012
|
} }
|
1004
1013
|
|
1005
1014
|
/* search match, depth 2 */
|
1006
|
-
{ size_t offset2=
|
1007
|
-
size_t const ml2 = searchMax(ms,
|
1015
|
+
{ size_t offset2=999999999;
|
1016
|
+
size_t const ml2 = searchMax(ms, ip, iend, &offset2);
|
1008
1017
|
int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
|
1009
1018
|
int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 7);
|
1010
1019
|
if ((ml2 >= 4) && (gain2 > gain1)) {
|
@@ -1060,31 +1069,31 @@ _storeSequence:
|
|
1060
1069
|
|
1061
1070
|
size_t ZSTD_compressBlock_greedy_extDict(
|
1062
1071
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
1063
|
-
|
1072
|
+
void const* src, size_t srcSize)
|
1064
1073
|
{
|
1065
|
-
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep,
|
1074
|
+
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 0, 0);
|
1066
1075
|
}
|
1067
1076
|
|
1068
1077
|
size_t ZSTD_compressBlock_lazy_extDict(
|
1069
1078
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
1070
|
-
|
1079
|
+
void const* src, size_t srcSize)
|
1071
1080
|
|
1072
1081
|
{
|
1073
|
-
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep,
|
1082
|
+
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 0, 1);
|
1074
1083
|
}
|
1075
1084
|
|
1076
1085
|
size_t ZSTD_compressBlock_lazy2_extDict(
|
1077
1086
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
1078
|
-
|
1087
|
+
void const* src, size_t srcSize)
|
1079
1088
|
|
1080
1089
|
{
|
1081
|
-
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep,
|
1090
|
+
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 0, 2);
|
1082
1091
|
}
|
1083
1092
|
|
1084
1093
|
size_t ZSTD_compressBlock_btlazy2_extDict(
|
1085
1094
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
1086
|
-
|
1095
|
+
void const* src, size_t srcSize)
|
1087
1096
|
|
1088
1097
|
{
|
1089
|
-
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep,
|
1098
|
+
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 1, 2);
|
1090
1099
|
}
|