From: inikep Date: Thu, 17 Mar 2016 10:21:00 +0000 (+0100) Subject: support for ZSTD_REP_NUM == 1 and ZSTD_REP_NUM == 4 X-Git-Tag: v0.6.0^2~17^2~16^2~8^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d1742825b9f443fcacd9926c84c615ebfff52cf;p=thirdparty%2Fzstd.git support for ZSTD_REP_NUM == 1 and ZSTD_REP_NUM == 4 --- diff --git a/lib/zstd_compress.c b/lib/zstd_compress.c index 967ecc065..f9022cc86 100644 --- a/lib/zstd_compress.c +++ b/lib/zstd_compress.c @@ -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 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; diff --git a/lib/zstd_decompress.c b/lib/zstd_decompress.c index 4f7ba6d76..305f9b90f 100644 --- a/lib/zstd_decompress.c +++ b/lib/zstd_decompress.c @@ -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); } diff --git a/lib/zstd_opt.h b/lib/zstd_opt.h index 0648a2aeb..692af92c9 100644 --- a/lib/zstd_opt.h +++ b/lib/zstd_opt.h @@ -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; inextToUpdate3 = 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; inextToUpdate3 = ctx->nextToUpdate; diff --git a/programs/bench.c b/programs/bench.c index fd4f9b547..0499cc3c9 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -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);