/* ZSTD_selectBlockCompressor() :
* Not static, but internal use only (used by long distance matcher)
* assumption : strat is a valid strategy */
-ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, int extDict, ZSTD_hasDictMatchState_e hdms)
+ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_dictMode_e dictMode)
{
static const ZSTD_blockCompressor blockCompressor[3][(unsigned)ZSTD_btultra+1] = {
{ ZSTD_compressBlock_fast /* default for 0 */,
ZSTD_compressBlock_fast_extDict, ZSTD_compressBlock_doubleFast_extDict, ZSTD_compressBlock_greedy_extDict,
ZSTD_compressBlock_lazy_extDict,ZSTD_compressBlock_lazy2_extDict, ZSTD_compressBlock_btlazy2_extDict,
ZSTD_compressBlock_btopt_extDict, ZSTD_compressBlock_btultra_extDict },
- { ZSTD_compressBlock_fast_extDictMatchState /* default for 0 */,
- ZSTD_compressBlock_fast_extDictMatchState,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL }
+ { ZSTD_compressBlock_fast_dictMatchState /* default for 0 */,
+ ZSTD_compressBlock_fast_dictMatchState,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL /* unimplemented as of yet */ }
};
ZSTD_STATIC_ASSERT((unsigned)ZSTD_fast == 1);
assert((U32)strat >= (U32)ZSTD_fast);
assert((U32)strat <= (U32)ZSTD_btultra);
- return blockCompressor[hdms == ZSTD_hasDictMatchState ? 2 : (extDict!=0)][(U32)strat];
+ return blockCompressor[(int)dictMode][(U32)strat];
}
static void ZSTD_storeLastLiterals(seqStore_t* seqStorePtr,
}
/* select and store sequences */
- { U32 const extDict = ZSTD_window_hasExtDict(ms->window);
- ZSTD_hasDictMatchState_e const hdms =
- ZSTD_matchState_hasDictMatchState(ms);
+ { ZSTD_dictMode_e const dictMode = ZSTD_matchState_dictMode(ms);
size_t lastLLSize;
{ int i;
for (i = 0; i < ZSTD_REP_NUM; ++i)
ms, &zc->seqStore,
zc->blockState.nextCBlock->rep,
&zc->appliedParams.cParams,
- src, srcSize, extDict);
+ src, srcSize);
assert(zc->externSeqStore.pos <= zc->externSeqStore.size);
} else if (zc->appliedParams.ldmParams.enableLdm) {
rawSeqStore_t ldmSeqStore = {NULL, 0, 0, 0};
ms, &zc->seqStore,
zc->blockState.nextCBlock->rep,
&zc->appliedParams.cParams,
- src, srcSize, extDict);
+ src, srcSize);
assert(ldmSeqStore.pos == ldmSeqStore.size);
} else { /* not long range mode */
- ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->appliedParams.cParams.strategy, extDict, hdms);
+ ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->appliedParams.cParams.strategy, dictMode);
lastLLSize = blockCompressor(ms, &zc->seqStore, zc->blockState.nextCBlock->rep, &zc->appliedParams.cParams, src, srcSize);
}
{ const BYTE* const lastLiterals = (const BYTE*)src + srcSize - lastLLSize;
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
void const* src, size_t srcSize,
U32 const hlog, U32 const stepSize, U32 const mls,
- ZSTD_hasDictMatchState_e const hasDict)
+ ZSTD_dictMode_e const hasDict)
{
U32* const hashTable = ms->hashTable;
const BYTE* const base = ms->window.base;
*/
const ZSTD_matchState_t* const dms = ms->dictMatchState;
- const U32* const dictHashTable = hasDict == ZSTD_hasDictMatchState ?
+ const U32* const dictHashTable = hasDict == ZSTD_dictMatchState ?
dms->hashTable : NULL;
- const U32 lowestDictIndex = hasDict == ZSTD_hasDictMatchState ?
+ const U32 lowestDictIndex = hasDict == ZSTD_dictMatchState ?
dms->window.dictLimit : 0;
- const BYTE* const dictBase = hasDict == ZSTD_hasDictMatchState ?
+ const BYTE* const dictBase = hasDict == ZSTD_dictMatchState ?
dms->window.base : NULL;
- const BYTE* const dictLowest = hasDict == ZSTD_hasDictMatchState ?
+ const BYTE* const dictLowest = hasDict == ZSTD_dictMatchState ?
dictBase + lowestDictIndex : NULL;
- const BYTE* const dictEnd = hasDict == ZSTD_hasDictMatchState ?
+ const BYTE* const dictEnd = hasDict == ZSTD_dictMatchState ?
dms->window.nextSrc : NULL;
- const U32 dictIndexDelta = hasDict == ZSTD_hasDictMatchState ?
+ const U32 dictIndexDelta = hasDict == ZSTD_dictMatchState ?
lowestIndex - (dictEnd - dictBase) :
0;
- ptrdiff_t dictLowestIndex = hasDict == ZSTD_hasDictMatchState ?
+ ptrdiff_t dictLowestIndex = hasDict == ZSTD_dictMatchState ?
lowestDictIndex + dictIndexDelta :
lowestIndex;
+ assert(hasDict == ZSTD_noDict || hasDict == ZSTD_dictMatchState);
+
/* init */
ip += (ip==lowest);
{ U32 const maxRep = (U32)(ip-lowest);
U32 const matchIndex = hashTable[h];
const BYTE* match = base + matchIndex;
const ptrdiff_t repIndex = current + 1 - offset_1;
- const BYTE* repBase = hasDict == ZSTD_hasDictMatchState && repIndex < (ptrdiff_t)lowestIndex ? dictBase - dictIndexDelta : base;
+ const BYTE* repBase = hasDict == ZSTD_dictMatchState && repIndex < (ptrdiff_t)lowestIndex ? dictBase - dictIndexDelta : base;
const BYTE* repMatch = repBase + repIndex;
hashTable[h] = current; /* update hash table */
- if (hasDict == ZSTD_hasDictMatchState
+ if (hasDict == ZSTD_dictMatchState
&& (((U32)((lowestIndex-1) - repIndex) >= 3) & (repIndex > dictLowestIndex) /* intentional underflow */)
&& (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
const BYTE* repMatchEnd = repIndex < (ptrdiff_t)lowestIndex ? dictEnd : iend;
mLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, istart) + 4;
ip++;
ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
- } else if (hasDict == ZSTD_noDictMatchState
+ } else if (hasDict == ZSTD_noDict
&& (offset_1 > 0) & (MEM_read32(repMatch) == MEM_read32(ip+1))) {
mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
ip++;
} else {
if ( (matchIndex <= lowestIndex)
|| (MEM_read32(match) != MEM_read32(ip)) ) {
- if (hasDict == ZSTD_hasDictMatchState) {
+ if (hasDict == ZSTD_dictMatchState) {
U32 const dictMatchIndex = dictHashTable[h];
const BYTE* dictMatch = dictBase + dictMatchIndex;
if (dictMatchIndex <= lowestDictIndex ||
hashTable[ZSTD_hashPtr(ip-2, hlog, mls)] = (U32)(ip-2-base);
/* check immediate repcode */
- if (hasDict == ZSTD_hasDictMatchState) {
+ if (hasDict == ZSTD_dictMatchState) {
while (ip <= ilimit) {
U32 const current2 = (U32)(ip-base);
ptrdiff_t const repIndex2 = current2 - offset_2;
- const BYTE* repMatch2 = hasDict == ZSTD_hasDictMatchState
+ const BYTE* repMatch2 = hasDict == ZSTD_dictMatchState
&& repIndex2 < (ptrdiff_t)lowestIndex ?
dictBase - dictIndexDelta + repIndex2 :
base + repIndex2;
}
}
- if (hasDict == ZSTD_noDictMatchState) {
+ if (hasDict == ZSTD_noDict) {
while ( (ip <= ilimit)
- && (hasDict != ZSTD_hasDictMatchState || ip - offset_2 >= istart)
+ && (hasDict != ZSTD_dictMatchState || ip - offset_2 >= istart)
&& ( (offset_2>0)
& (MEM_read32(ip) == MEM_read32(ip - offset_2)) )) {
/* store sequence */
{
default: /* includes case 3 */
case 4 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 4, ZSTD_noDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 4, ZSTD_noDict);
case 5 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 5, ZSTD_noDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 5, ZSTD_noDict);
case 6 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 6, ZSTD_noDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 6, ZSTD_noDict);
case 7 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 7, ZSTD_noDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 7, ZSTD_noDict);
}
}
-size_t ZSTD_compressBlock_fast_extDictMatchState(
+size_t ZSTD_compressBlock_fast_dictMatchState(
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
ZSTD_compressionParameters const* cParams, void const* src, size_t srcSize)
{
{
default: /* includes case 3 */
case 4 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 4, ZSTD_hasDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 4, ZSTD_dictMatchState);
case 5 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 5, ZSTD_hasDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 5, ZSTD_dictMatchState);
case 6 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 6, ZSTD_hasDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 6, ZSTD_dictMatchState);
case 7 :
- return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 7, ZSTD_hasDictMatchState);
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, hlog, stepSize, 7, ZSTD_dictMatchState);
}
}