offset_2 = offset_1;
offset_1 = offset;
- ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset + ZSTD_REP_NUM - 1, mlCode);
+ ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mlCode);
}
/* match found */
offset = current - matchIndex;
offset_2 = offset_1;
offset_1 = offset;
- ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset + ZSTD_REP_NUM - 1, mlCode);
+ ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mlCode);
} }
/* found a match : store it */
searchMax_f searchMax = searchMethod ? ZSTD_BtFindBestMatch_selectMLS : ZSTD_HcFindBestMatch_selectMLS;
/* init */
- U32 rep[ZSTD_REP_NUM+1];
- for (int i=0; i<ZSTD_REP_NUM+1; i++)
+ U32 rep[ZSTD_REP_INIT];
+ for (int i=0; i<ZSTD_REP_INIT; i++)
rep[i]=REPCODE_STARTVALUE;
ZSTD_resetSeqStore(seqStorePtr);
size_t offsetFound = 99999999;
size_t ml2 = searchMax(ctx, ip, iend, &offsetFound, maxSearches, mls);
if (ml2 > matchLength)
- matchLength = ml2, start = ip, offset=offsetFound + (ZSTD_REP_NUM - 1);
+ matchLength = ml2, start = ip, offset=offsetFound + ZSTD_REP_MOVE;
}
if (matchLength < MINMATCH) {
int gain2 = (int)(ml2*4 - ZSTD_highbit((U32)offset2+1)); /* raw approx */
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 4);
if ((ml2 >= MINMATCH) && (gain2 > gain1)) {
- matchLength = ml2, offset = offset2 + (ZSTD_REP_NUM - 1), start = ip;
+ matchLength = ml2, offset = offset2 + ZSTD_REP_MOVE, start = ip;
continue; /* search a better one */
} }
int gain2 = (int)(ml2*4 - ZSTD_highbit((U32)offset2+1)); /* raw approx */
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 7);
if ((ml2 >= MINMATCH) && (gain2 > gain1)) {
- matchLength = ml2, offset = offset2 + (ZSTD_REP_NUM - 1), start = ip;
+ matchLength = ml2, offset = offset2 + ZSTD_REP_MOVE, start = ip;
continue;
} } }
break; /* nothing found : store previous solution */
/* catch up */
if (offset >= ZSTD_REP_NUM) {
- while ((start>anchor) && (start>base+offset-(ZSTD_REP_NUM-1)) && (start[-1] == start[-1-offset+(ZSTD_REP_NUM-1)])) /* only search for offset within prefix */
+ while ((start>anchor) && (start>base+offset-ZSTD_REP_MOVE) && (start[-1] == start[-1-offset+ZSTD_REP_MOVE])) /* only search for offset within prefix */
{ start--; matchLength++; }
}
rep[3] = rep[2];
rep[2] = rep[1];
rep[1] = rep[0];
- rep[0] = offset - (ZSTD_REP_NUM - 1);
+ rep[0] = offset - ZSTD_REP_MOVE;
#else
if (kSlotNew < 3)
rep[3] = rep[2];
rep[2] = rep[1];
if (kSlotNew < 1)
rep[1] = rep[0];
- rep[kSlotNew] = offset - (ZSTD_REP_NUM - 1);
+ rep[kSlotNew] = offset - ZSTD_REP_MOVE;
#endif
} else {
if (offset != 0) {
}
#else
if (offset >= ZSTD_REP_NUM) {
- rep[1] = rep[0]; rep[0] = offset - (ZSTD_REP_NUM - 1);
+ rep[1] = rep[0]; rep[0] = offset - ZSTD_REP_MOVE;
}
#endif
size_t litLength = start - anchor;
printf("ZSTD_compressBlock_lazy_extDict_generic reps not implemented!\n"); exit(1);
/* init */
- U32 rep[ZSTD_REP_NUM];
- for (int i=0; i<ZSTD_REP_NUM; i++)
+ U32 rep[ZSTD_REP_INIT];
+ for (int i=0; i<ZSTD_REP_INIT; i++)
rep[i]=REPCODE_STARTVALUE;
ZSTD_resetSeqStore(seqStorePtr);
if ((ip - prefixStart) < REPCODE_STARTVALUE) ip += REPCODE_STARTVALUE;
size_t offsetFound = 99999999;
size_t ml2 = searchMax(ctx, ip, iend, &offsetFound, maxSearches, mls);
if (ml2 > matchLength)
- matchLength = ml2, start = ip, offset=offsetFound + (ZSTD_REP_NUM - 1);
+ matchLength = ml2, start = ip, offset=offsetFound + ZSTD_REP_MOVE;
}
if (matchLength < MINMATCH) {
int gain2 = (int)(ml2*4 - ZSTD_highbit((U32)offset2+1)); /* raw approx */
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 4);
if ((ml2 >= MINMATCH) && (gain2 > gain1)) {
- matchLength = ml2, offset = offset2 + (ZSTD_REP_NUM - 1), start = ip;
+ matchLength = ml2, offset = offset2 + ZSTD_REP_MOVE, start = ip;
continue; /* search a better one */
} }
int gain2 = (int)(ml2*4 - ZSTD_highbit((U32)offset2+1)); /* raw approx */
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 7);
if ((ml2 >= MINMATCH) && (gain2 > gain1)) {
- matchLength = ml2, offset = offset2 + (ZSTD_REP_NUM - 1), start = ip;
+ matchLength = ml2, offset = offset2 + ZSTD_REP_MOVE, start = ip;
continue;
} } }
break; /* nothing found : store previous solution */
/* catch up */
if (offset >= ZSTD_REP_NUM) {
- U32 matchIndex = (U32)((start-base) - (offset - (ZSTD_REP_NUM - 1)));
+ U32 matchIndex = (U32)((start-base) - (offset - ZSTD_REP_MOVE));
const BYTE* match = (matchIndex < dictLimit) ? dictBase + matchIndex : base + matchIndex;
const BYTE* const mStart = (matchIndex < dictLimit) ? dictStart : prefixStart;
while ((start>anchor) && (match>mStart) && (start[-1] == match[-1])) { start--; match--; matchLength++; } /* catch up */
- rep[1] = rep[0]; rep[0] = offset - (ZSTD_REP_NUM - 1);
+ rep[1] = rep[0]; rep[0] = offset - ZSTD_REP_MOVE;
}
/* store sequence */
FSE_DState_t stateLL;
FSE_DState_t stateOffb;
FSE_DState_t stateML;
- size_t prevOffset[ZSTD_REP_NUM];
+ size_t prevOffset[ZSTD_REP_INIT];
const BYTE* dumps;
const BYTE* dumpsEnd;
} seqState_t;
else
offset = seqState->prevOffset[0];
} else {
- offset -= ZSTD_REP_NUM - 1;
-#if 0
+ offset -= ZSTD_REP_MOVE;
+ #if 0
seqState->prevOffset[3] = seqState->prevOffset[2];
seqState->prevOffset[2] = seqState->prevOffset[1];
seqState->prevOffset[1] = seqState->prevOffset[0];
seqState->prevOffset[0] = offset;
-#else
+ #else
if (kSlotNew < 3)
seqState->prevOffset[3] = seqState->prevOffset[2];
if (kSlotNew < 2)
if (kSlotNew < 1)
seqState->prevOffset[1] = seqState->prevOffset[0];
seqState->prevOffset[kSlotNew] = offset;
-#endif
+ #endif
}
-#else
+#else // ZSTD_REP_NUM == 1
+ #if 0
if (offsetCode==0) offset = litLength ? seq->offset : seqState->prevOffset[0]; /* repcode, cmove */
+ else offset -= ZSTD_REP_MOVE;
if (offsetCode | !litLength) seqState->prevOffset[0] = seq->offset; /* cmove */
+ #else
+ if (offsetCode==0) {
+ if (!litLength) {
+ offset = seqState->prevOffset[0]; /* repcode, cmove */
+ seqState->prevOffset[0] = seq->offset; /* cmove */
+ } else
+ offset = seq->offset; /* repcode, cmove */
+ } else {
+ seqState->prevOffset[0] = seq->offset; /* cmove */
+ offset -= ZSTD_REP_MOVE;
+ }
+ #endif
#endif
FSE_decodeSymbol(&(seqState->stateOffb), &(seqState->DStream)); /* update */
// printf("offsetCode=%d nbBits=%d offset=%d\n", offsetCode, nbBits, (int)offset); fflush(stdout);
sequence.offset = REPCODE_STARTVALUE;
seqState.dumps = dumps;
seqState.dumpsEnd = dumps + dumpsLength;
- for (int i=0; i<ZSTD_REP_NUM; i++)
+ for (int i=0; i<ZSTD_REP_INIT; i++)
seqState.prevOffset[i] = REPCODE_STARTVALUE;
errorCode = BIT_initDStream(&(seqState.DStream), ip, iend-ip);
if (ERR_isError(errorCode)) return ERROR(corruption_detected);
U32 cur, match_num, last_pos, litlen, price;
/* init */
- U32 rep[ZSTD_REP_NUM+1];
- for (int i=0; i<ZSTD_REP_NUM+1; i++)
+ U32 rep[ZSTD_REP_INIT];
+ for (int i=0; i<ZSTD_REP_INIT; i++)
rep[i]=REPCODE_STARTVALUE;
ctx->nextToUpdate3 = ctx->nextToUpdate;
#endif
ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen-minMatch);
- ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset ? offset + ZSTD_REP_NUM - 1 : 0, mlen-minMatch);
+ ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset ? offset + ZSTD_REP_MOVE : 0, mlen-minMatch);
anchor = ip = ip + mlen;
} /* for (cur=0; cur < last_pos; ) */
U32 cur, match_num, last_pos, litlen, price;
/* init */
- U32 rep[ZSTD_REP_NUM+1];
- for (int i=0; i<ZSTD_REP_NUM+1; i++)
+ U32 rep[ZSTD_REP_INIT];
+ for (int i=0; i<ZSTD_REP_INIT; i++)
rep[i]=REPCODE_STARTVALUE;
ctx->nextToUpdate3 = ctx->nextToUpdate;
#endif
ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen-minMatch);
- ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset ? offset + ZSTD_REP_NUM - 1 : 0, mlen-minMatch);
+ ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset ? offset + ZSTD_REP_MOVE : 0, mlen-minMatch);
anchor = ip = ip + mlen;
}