improved 4reps in ZSTD_compressBlock_lazy_generic

kSlotNew = 0
This commit is contained in:
inikep
2016-03-22 11:56:22 +01:00
parent f2fa0e1198
commit 2b942881ac
5 changed files with 26 additions and 19 deletions
+7 -7
View File
@@ -1617,8 +1617,8 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
if (depth==0) goto _storeSequence;
} else {
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
int gain2 = (int)(mlRep * 3 /*- ZSTD_highbit((U32)i+1)*/);
int gain1 = (int)(matchLength*3 - /*ZSTD_highbit((U32)offset+1)*/ + 1);
int gain2 = (int)(mlRep * 3 /*- ZSTD_highbit((U32)i+1)*/ + (i==1));
int gain1 = (int)(matchLength*3 - /*ZSTD_highbit((U32)offset+1)*/ + 1 + (offset==1));
if (gain2 > gain1)
matchLength = mlRep, offset = i;
}
@@ -1642,10 +1642,10 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
while (ip<ilimit) {
ip ++;
for (int i=0; i<ZSTD_REP_NUM; i++)
if ((offset >= ZSTD_REP_NUM) && (MEM_read32(ip) == MEM_read32(ip - rep[i]))) {
if (MEM_read32(ip) == MEM_read32(ip - rep[i])) {
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
int gain2 = (int)(mlRep * 3);
int gain1 = (int)(matchLength*3 - ZSTD_highbit((U32)offset+1) + 1);
int gain1 = (int)(matchLength*3 - ZSTD_highbit((U32)offset+1) + 1 + (offset<ZSTD_REP_NUM));
if ((mlRep >= MINMATCH) && (gain2 > gain1))
matchLength = mlRep, offset = i, start = ip;
}
@@ -1663,10 +1663,10 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
if ((depth==2) && (ip<ilimit)) {
ip ++;
for (int i=0; i<ZSTD_REP_NUM; i++)
if ((offset >= ZSTD_REP_NUM) && (MEM_read32(ip) == MEM_read32(ip - rep[i]))) {
if (MEM_read32(ip) == MEM_read32(ip - rep[i])) {
size_t ml2 = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
int gain2 = (int)(ml2 * 4);
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 1);
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 1 + (offset<ZSTD_REP_NUM));
if ((ml2 >= MINMATCH) && (gain2 > gain1))
matchLength = ml2, offset = i, start = ip;
}
@@ -1693,7 +1693,7 @@ _storeSequence:
{
#if ZSTD_REP_NUM == 4
if (offset >= ZSTD_REP_NUM) {
#if 0
#if 1
rep[3] = rep[2];
rep[2] = rep[1];
rep[1] = rep[0];
+9 -2
View File
@@ -691,19 +691,26 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
seqState->prevOffset[2] = seqState->prevOffset[1];
}
offset = temp;
seqState->prevOffset[1] = seqState->prevOffset[0];
seqState->prevOffset[0] = offset;
seqState->prevOffset[0] = offset = temp;
} else {
offset = seqState->prevOffset[0];
}
} else {
offset -= ZSTD_REP_MOVE;
#if 1 // faster without kSlotNew
seqState->prevOffset[3] = seqState->prevOffset[2];
seqState->prevOffset[2] = seqState->prevOffset[1];
seqState->prevOffset[1] = seqState->prevOffset[0];
seqState->prevOffset[0] = offset;
#else
if (kSlotNew < 3) seqState->prevOffset[3] = seqState->prevOffset[2];
if (kSlotNew < 2) seqState->prevOffset[2] = seqState->prevOffset[1];
if (kSlotNew < 1) seqState->prevOffset[1] = seqState->prevOffset[0];
seqState->prevOffset[kSlotNew] = offset;
#endif
}
#else // ZSTD_REP_NUM == 1
#if 0
+1 -1
View File
@@ -71,7 +71,7 @@
#else
#define ZSTD_REP_NUM 1
#define ZSTD_REP_INIT 2
#define ZSTD_REP_MOVE 0//(ZSTD_REP_NUM-1)
#define ZSTD_REP_MOVE 0 //(ZSTD_REP_NUM-1)
#endif
#define KB *(1 <<10)