@@ -1467,6 +1467,48 @@ ZSTD_adjustCParams_internal(ZSTD_compressionParameters cPar,
1467
1467
const U64 maxWindowResize = 1ULL << (ZSTD_WINDOWLOG_MAX - 1 );
1468
1468
assert (ZSTD_checkCParams (cPar )== 0 );
1469
1469
1470
+ /* Cascade the selected strategy down to the next-highest one built into
1471
+ * this binary. */
1472
+ #ifdef ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR
1473
+ if (cPar .strategy == ZSTD_btultra2 ) {
1474
+ cPar .strategy = ZSTD_btultra ;
1475
+ }
1476
+ if (cPar .strategy == ZSTD_btultra ) {
1477
+ cPar .strategy = ZSTD_btopt ;
1478
+ }
1479
+ #endif
1480
+ #ifdef ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR
1481
+ if (cPar .strategy == ZSTD_btopt ) {
1482
+ cPar .strategy = ZSTD_btlazy2 ;
1483
+ }
1484
+ #endif
1485
+ #ifdef ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR
1486
+ if (cPar .strategy == ZSTD_btlazy2 ) {
1487
+ cPar .strategy = ZSTD_lazy2 ;
1488
+ }
1489
+ #endif
1490
+ #ifdef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
1491
+ if (cPar .strategy == ZSTD_lazy2 ) {
1492
+ cPar .strategy = ZSTD_lazy ;
1493
+ }
1494
+ #endif
1495
+ #ifdef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
1496
+ if (cPar .strategy == ZSTD_lazy ) {
1497
+ cPar .strategy = ZSTD_greedy ;
1498
+ }
1499
+ #endif
1500
+ #ifdef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
1501
+ if (cPar .strategy == ZSTD_greedy ) {
1502
+ cPar .strategy = ZSTD_dfast ;
1503
+ }
1504
+ #endif
1505
+ #ifdef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR
1506
+ if (cPar .strategy == ZSTD_dfast ) {
1507
+ cPar .strategy = ZSTD_fast ;
1508
+ cPar .targetLength = 0 ;
1509
+ }
1510
+ #endif
1511
+
1470
1512
switch (mode ) {
1471
1513
case ZSTD_cpm_unknown :
1472
1514
case ZSTD_cpm_noAttachDict :
@@ -2992,40 +3034,43 @@ ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_paramS
2992
3034
static const ZSTD_blockCompressor blockCompressor [4 ][ZSTD_STRATEGY_MAX + 1 ] = {
2993
3035
{ ZSTD_compressBlock_fast /* default for 0 */ ,
2994
3036
ZSTD_compressBlock_fast ,
2995
- ZSTD_compressBlock_doubleFast ,
2996
- ZSTD_compressBlock_greedy ,
2997
- ZSTD_compressBlock_lazy ,
2998
- ZSTD_compressBlock_lazy2 ,
2999
- ZSTD_compressBlock_btlazy2 ,
3000
- ZSTD_compressBlock_btopt ,
3001
- ZSTD_compressBlock_btultra ,
3002
- ZSTD_compressBlock_btultra2 },
3037
+ ZSTD_COMPRESSBLOCK_DOUBLEFAST ,
3038
+ ZSTD_COMPRESSBLOCK_GREEDY ,
3039
+ ZSTD_COMPRESSBLOCK_LAZY ,
3040
+ ZSTD_COMPRESSBLOCK_LAZY2 ,
3041
+ ZSTD_COMPRESSBLOCK_BTLAZY2 ,
3042
+ ZSTD_COMPRESSBLOCK_BTOPT ,
3043
+ ZSTD_COMPRESSBLOCK_BTULTRA ,
3044
+ ZSTD_COMPRESSBLOCK_BTULTRA2
3045
+ },
3003
3046
{ ZSTD_compressBlock_fast_extDict /* default for 0 */ ,
3004
3047
ZSTD_compressBlock_fast_extDict ,
3005
- ZSTD_compressBlock_doubleFast_extDict ,
3006
- ZSTD_compressBlock_greedy_extDict ,
3007
- ZSTD_compressBlock_lazy_extDict ,
3008
- ZSTD_compressBlock_lazy2_extDict ,
3009
- ZSTD_compressBlock_btlazy2_extDict ,
3010
- ZSTD_compressBlock_btopt_extDict ,
3011
- ZSTD_compressBlock_btultra_extDict ,
3012
- ZSTD_compressBlock_btultra_extDict },
3048
+ ZSTD_COMPRESSBLOCK_DOUBLEFAST_EXTDICT ,
3049
+ ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT ,
3050
+ ZSTD_COMPRESSBLOCK_LAZY_EXTDICT ,
3051
+ ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT ,
3052
+ ZSTD_COMPRESSBLOCK_BTLAZY2_EXTDICT ,
3053
+ ZSTD_COMPRESSBLOCK_BTOPT_EXTDICT ,
3054
+ ZSTD_COMPRESSBLOCK_BTULTRA_EXTDICT ,
3055
+ ZSTD_COMPRESSBLOCK_BTULTRA_EXTDICT
3056
+ },
3013
3057
{ ZSTD_compressBlock_fast_dictMatchState /* default for 0 */ ,
3014
3058
ZSTD_compressBlock_fast_dictMatchState ,
3015
- ZSTD_compressBlock_doubleFast_dictMatchState ,
3016
- ZSTD_compressBlock_greedy_dictMatchState ,
3017
- ZSTD_compressBlock_lazy_dictMatchState ,
3018
- ZSTD_compressBlock_lazy2_dictMatchState ,
3019
- ZSTD_compressBlock_btlazy2_dictMatchState ,
3020
- ZSTD_compressBlock_btopt_dictMatchState ,
3021
- ZSTD_compressBlock_btultra_dictMatchState ,
3022
- ZSTD_compressBlock_btultra_dictMatchState },
3059
+ ZSTD_COMPRESSBLOCK_DOUBLEFAST_DICTMATCHSTATE ,
3060
+ ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE ,
3061
+ ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE ,
3062
+ ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE ,
3063
+ ZSTD_COMPRESSBLOCK_BTLAZY2_DICTMATCHSTATE ,
3064
+ ZSTD_COMPRESSBLOCK_BTOPT_DICTMATCHSTATE ,
3065
+ ZSTD_COMPRESSBLOCK_BTULTRA_DICTMATCHSTATE ,
3066
+ ZSTD_COMPRESSBLOCK_BTULTRA_DICTMATCHSTATE
3067
+ },
3023
3068
{ NULL /* default for 0 */ ,
3024
3069
NULL ,
3025
3070
NULL ,
3026
- ZSTD_compressBlock_greedy_dedicatedDictSearch ,
3027
- ZSTD_compressBlock_lazy_dedicatedDictSearch ,
3028
- ZSTD_compressBlock_lazy2_dedicatedDictSearch ,
3071
+ ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH ,
3072
+ ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH ,
3073
+ ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH ,
3029
3074
NULL ,
3030
3075
NULL ,
3031
3076
NULL ,
@@ -3038,18 +3083,26 @@ ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_paramS
3038
3083
DEBUGLOG (4 , "Selected block compressor: dictMode=%d strat=%d rowMatchfinder=%d" , (int )dictMode , (int )strat , (int )useRowMatchFinder );
3039
3084
if (ZSTD_rowMatchFinderUsed (strat , useRowMatchFinder )) {
3040
3085
static const ZSTD_blockCompressor rowBasedBlockCompressors [4 ][3 ] = {
3041
- { ZSTD_compressBlock_greedy_row ,
3042
- ZSTD_compressBlock_lazy_row ,
3043
- ZSTD_compressBlock_lazy2_row },
3044
- { ZSTD_compressBlock_greedy_extDict_row ,
3045
- ZSTD_compressBlock_lazy_extDict_row ,
3046
- ZSTD_compressBlock_lazy2_extDict_row },
3047
- { ZSTD_compressBlock_greedy_dictMatchState_row ,
3048
- ZSTD_compressBlock_lazy_dictMatchState_row ,
3049
- ZSTD_compressBlock_lazy2_dictMatchState_row },
3050
- { ZSTD_compressBlock_greedy_dedicatedDictSearch_row ,
3051
- ZSTD_compressBlock_lazy_dedicatedDictSearch_row ,
3052
- ZSTD_compressBlock_lazy2_dedicatedDictSearch_row }
3086
+ {
3087
+ ZSTD_COMPRESSBLOCK_GREEDY_ROW ,
3088
+ ZSTD_COMPRESSBLOCK_LAZY_ROW ,
3089
+ ZSTD_COMPRESSBLOCK_LAZY2_ROW
3090
+ },
3091
+ {
3092
+ ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT_ROW ,
3093
+ ZSTD_COMPRESSBLOCK_LAZY_EXTDICT_ROW ,
3094
+ ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT_ROW
3095
+ },
3096
+ {
3097
+ ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE_ROW ,
3098
+ ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE_ROW ,
3099
+ ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE_ROW
3100
+ },
3101
+ {
3102
+ ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH_ROW ,
3103
+ ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH_ROW ,
3104
+ ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH_ROW
3105
+ }
3053
3106
};
3054
3107
DEBUGLOG (4 , "Selecting a row-based matchfinder" );
3055
3108
assert (useRowMatchFinder != ZSTD_ps_auto );
@@ -3280,9 +3333,11 @@ static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize)
3280
3333
}
3281
3334
3282
3335
/* Fallback to software matchfinder */
3283
- { ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor (zc -> appliedParams .cParams .strategy ,
3284
- zc -> appliedParams .useRowMatchFinder ,
3285
- dictMode );
3336
+ { ZSTD_blockCompressor const blockCompressor =
3337
+ ZSTD_selectBlockCompressor (
3338
+ zc -> appliedParams .cParams .strategy ,
3339
+ zc -> appliedParams .useRowMatchFinder ,
3340
+ dictMode );
3286
3341
ms -> ldmSeqStore = NULL ;
3287
3342
DEBUGLOG (
3288
3343
5 ,
@@ -3292,9 +3347,10 @@ static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize)
3292
3347
lastLLSize = blockCompressor (ms , & zc -> seqStore , zc -> blockState .nextCBlock -> rep , src , srcSize );
3293
3348
} }
3294
3349
} else { /* not long range mode and no external matchfinder */
3295
- ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor (zc -> appliedParams .cParams .strategy ,
3296
- zc -> appliedParams .useRowMatchFinder ,
3297
- dictMode );
3350
+ ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor (
3351
+ zc -> appliedParams .cParams .strategy ,
3352
+ zc -> appliedParams .useRowMatchFinder ,
3353
+ dictMode );
3298
3354
ms -> ldmSeqStore = NULL ;
3299
3355
lastLLSize = blockCompressor (ms , & zc -> seqStore , zc -> blockState .nextCBlock -> rep , src , srcSize );
3300
3356
}
@@ -4760,12 +4816,19 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_matchState_t* ms,
4760
4816
ZSTD_fillHashTable (ms , iend , dtlm , tfp );
4761
4817
break ;
4762
4818
case ZSTD_dfast :
4819
+ #ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR
4763
4820
ZSTD_fillDoubleHashTable (ms , iend , dtlm , tfp );
4821
+ #else
4822
+ assert (0 ); /* shouldn't be called: cparams should've been adjusted. */
4823
+ #endif
4764
4824
break ;
4765
4825
4766
4826
case ZSTD_greedy :
4767
4827
case ZSTD_lazy :
4768
4828
case ZSTD_lazy2 :
4829
+ #if !defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR ) \
4830
+ || !defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR ) \
4831
+ || !defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR )
4769
4832
assert (srcSize >= HASH_READ_SIZE );
4770
4833
if (ms -> dedicatedDictSearch ) {
4771
4834
assert (ms -> chainTable != NULL );
@@ -4782,14 +4845,23 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_matchState_t* ms,
4782
4845
DEBUGLOG (4 , "Using chain-based hash table for lazy dict" );
4783
4846
}
4784
4847
}
4848
+ #else
4849
+ assert (0 ); /* shouldn't be called: cparams should've been adjusted. */
4850
+ #endif
4785
4851
break ;
4786
4852
4787
4853
case ZSTD_btlazy2 : /* we want the dictionary table fully sorted */
4788
4854
case ZSTD_btopt :
4789
4855
case ZSTD_btultra :
4790
4856
case ZSTD_btultra2 :
4857
+ #if !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR ) \
4858
+ || !defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR ) \
4859
+ || !defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR )
4791
4860
assert (srcSize >= HASH_READ_SIZE );
4792
4861
ZSTD_updateTree (ms , iend - HASH_READ_SIZE , iend );
4862
+ #else
4863
+ assert (0 ); /* shouldn't be called: cparams should've been adjusted. */
4864
+ #endif
4793
4865
break ;
4794
4866
4795
4867
default :
0 commit comments