support for ZSTD_REP_NUM == 1 and ZSTD_REP_NUM == 4

This commit is contained in:
inikep
2016-03-17 11:21:00 +01:00
parent 5945308983
commit 7d1742825b
4 changed files with 30 additions and 11 deletions
+11 -5
View File
@@ -1092,7 +1092,7 @@ static void ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx,
const BYTE* repMatchEnd = repIndex < dictLimit ? dictEnd : iend;
mlCode = ZSTD_count_2segments(ip+1+MINMATCH, repMatch+MINMATCH, iend, repMatchEnd, lowPrefixPtr);
ip++;
ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset, mlCode);
ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, 0, mlCode);
} else {
if ( (matchIndex < lowLimit) ||
(MEM_read32(match) != MEM_read32(ip)) )
@@ -1563,8 +1563,8 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
searchMax_f searchMax = searchMethod ? ZSTD_BtFindBestMatch_selectMLS : ZSTD_HcFindBestMatch_selectMLS;
/* init */
U32 rep[ZSTD_REP_NUM];
for (int i=0; i<ZSTD_REP_NUM; i++)
U32 rep[ZSTD_REP_NUM+1];
for (int i=0; i<ZSTD_REP_NUM+1; i++)
rep[i]=REPCODE_STARTVALUE;
ZSTD_resetSeqStore(seqStorePtr);
@@ -1586,8 +1586,8 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
if (depth==0) goto _storeSequence;
} else {
size_t mlRep = ZSTD_count(ip+1+MINMATCH, ip+1+MINMATCH-rep[i], iend) + MINMATCH;
int gain2 = (int)(mlRep * 3 - (i+1));
int gain1 = (int)(matchLength*3 - (offset+1) + 1);
int gain2 = (int)(mlRep * 3 /*- ZSTD_highbit((U32)i+1)*/);
int gain1 = (int)(matchLength*3 - /*ZSTD_highbit((U32)offset+1)*/ + 1);
if (gain2 > gain1)
matchLength = mlRep, offset = i;
}
@@ -1660,6 +1660,7 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
/* store sequence */
_storeSequence:
{
#if ZSTD_REP_NUM == 4
if (offset >= ZSTD_REP_NUM) {
rep[3] = rep[2];
rep[2] = rep[1];
@@ -1676,6 +1677,11 @@ _storeSequence:
rep[0] = temp;
}
}
#else
if (offset >= ZSTD_REP_NUM) {
rep[1] = rep[0]; rep[0] = offset - (ZSTD_REP_NUM - 1);
}
#endif
size_t litLength = start - anchor;
ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, matchLength-MINMATCH);
anchor = ip = start + matchLength;
+14 -1
View File
@@ -632,6 +632,9 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
/* Literal length */
litLength = FSE_peakSymbol(&(seqState->stateLL));
#if 0 //ZSTD_REP_NUM == 1
size_t prevOffset = litLength ? seq->offset : seqState->prevOffset[0];
#endif
if (litLength == MaxLL) {
U32 add = *dumps++;
if (add < 255) litLength += add;
@@ -654,6 +657,7 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
if (offsetCode==0) nbBits = 0; /* cmove */
offset = offsetPrefix[offsetCode] + BIT_readBits(&(seqState->DStream), nbBits);
if (MEM_32bits()) BIT_reloadDStream(&(seqState->DStream));
#if ZSTD_REP_NUM == 4
if (offsetCode==0) {
if (!litLength) {
offset = seqState->prevOffset[1];
@@ -675,7 +679,16 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
seqState->prevOffset[2] = seqState->prevOffset[1];
seqState->prevOffset[1] = seq->offset; /* cmove */
}
}
}
#else
#if 0
if (offsetCode==0) offset = prevOffset; /* repcode, cmove */
if (offsetCode | !litLength) seqState->prevOffset[0] = seq->offset; /* cmove */
#else
if (offsetCode==0) offset = litLength ? seq->offset : seqState->prevOffset[0]; /* repcode, cmove */
if (offsetCode | !litLength) seqState->prevOffset[0] = seq->offset; /* cmove */
#endif
#endif
FSE_decodeSymbol(&(seqState->stateOffb), &(seqState->DStream)); /* update */
// printf("offsetCode=%d nbBits=%d offset=%d\n", offsetCode, nbBits, (int)offset); fflush(stdout);
}
+4 -4
View File
@@ -420,8 +420,8 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
U32 cur, match_num, last_pos, litlen, price;
/* init */
U32 rep[ZSTD_REP_NUM];
for (int i=0; i<ZSTD_REP_NUM; i++)
U32 rep[ZSTD_REP_NUM+1];
for (int i=0; i<ZSTD_REP_NUM+1; i++)
rep[i]=REPCODE_STARTVALUE;
ctx->nextToUpdate3 = ctx->nextToUpdate;
@@ -748,8 +748,8 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx,
U32 cur, match_num, last_pos, litlen, price;
/* init */
U32 rep[ZSTD_REP_NUM];
for (int i=0; i<ZSTD_REP_NUM; i++)
U32 rep[ZSTD_REP_NUM+1];
for (int i=0; i<ZSTD_REP_NUM+1; i++)
rep[i]=REPCODE_STARTVALUE;
ctx->nextToUpdate3 = ctx->nextToUpdate;
+1 -1
View File
@@ -280,7 +280,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
} } }
/* warmimg up memory */
int timeloop = additionalParam; //2500;
int timeloop = additionalParam ? additionalParam : 2500;
ZSTD_setAdditionalParam(refCtx, additionalParam);
RDG_genBuffer(compressedBuffer, maxCompressedSize, 0.10, 0.50, 1);