support for ZSTD_REP_NUM=3
This commit is contained in:
+5
-6
@@ -1736,16 +1736,19 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
|
|||||||
/* store sequence */
|
/* store sequence */
|
||||||
_storeSequence:
|
_storeSequence:
|
||||||
{
|
{
|
||||||
#if ZSTD_REP_NUM == 4
|
|
||||||
if (offset >= ZSTD_REP_NUM) {
|
if (offset >= ZSTD_REP_NUM) {
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
rep[3] = rep[2];
|
rep[3] = rep[2];
|
||||||
|
#endif
|
||||||
rep[2] = rep[1];
|
rep[2] = rep[1];
|
||||||
rep[1] = rep[0];
|
rep[1] = rep[0];
|
||||||
rep[0] = offset - ZSTD_REP_MOVE;
|
rep[0] = offset - ZSTD_REP_MOVE;
|
||||||
} else {
|
} else {
|
||||||
if (offset != 0) {
|
if (offset != 0) {
|
||||||
size_t temp = rep[offset];
|
size_t temp = rep[offset];
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
if (offset > 2) rep[3] = rep[2];
|
if (offset > 2) rep[3] = rep[2];
|
||||||
|
#endif
|
||||||
if (offset > 1) rep[2] = rep[1];
|
if (offset > 1) rep[2] = rep[1];
|
||||||
if (offset > 0) rep[1] = rep[0];
|
if (offset > 0) rep[1] = rep[0];
|
||||||
rep[0] = temp;
|
rep[0] = temp;
|
||||||
@@ -1753,11 +1756,7 @@ _storeSequence:
|
|||||||
|
|
||||||
if (offset<=1 && start==anchor) offset = 1-offset;
|
if (offset<=1 && start==anchor) offset = 1-offset;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (offset >= ZSTD_REP_NUM) {
|
|
||||||
rep[1] = rep[0]; rep[0] = offset - ZSTD_REP_MOVE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
size_t const litLength = start - anchor;
|
size_t const litLength = start - anchor;
|
||||||
|
|
||||||
ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, matchLength-MINMATCH);
|
ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, matchLength-MINMATCH);
|
||||||
|
|||||||
+21
-68
@@ -656,51 +656,7 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
|
|||||||
0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, /*fake*/ 1, 1, 1, 1, 1 };
|
0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, /*fake*/ 1, 1, 1, 1, 1 };
|
||||||
|
|
||||||
/* sequence */
|
/* sequence */
|
||||||
#if ZSTD_REP_NUM == 1
|
|
||||||
#if 1
|
|
||||||
{ size_t const offset = ofCode ? OF_base[ofCode] + BIT_readBits(&(seqState->DStream), ofBits) - ZSTD_REP_MOVE : /* <= 26 bits */
|
|
||||||
llCode ? seq->offset : seqState->prevOffset[0];
|
|
||||||
if (MEM_32bits()) BIT_reloadDStream(&(seqState->DStream));
|
|
||||||
if (ofCode | !llCode) seqState->prevOffset[0] = seq->offset; /* cmove */
|
|
||||||
seq->offset = offset;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
{ size_t offset;
|
{ size_t offset;
|
||||||
if (ofCode) {
|
|
||||||
offset = OF_base[ofCode] + BIT_readBits(&(seqState->DStream), ofBits) - ZSTD_REP_MOVE; /* <= 26 bits */
|
|
||||||
if (MEM_32bits()) BIT_reloadDStream(&(seqState->DStream));
|
|
||||||
seqState->prevOffset[0] = seq->offset; /* cmove */
|
|
||||||
} else {
|
|
||||||
if (llCode) {
|
|
||||||
offset = seq->offset;
|
|
||||||
} else {
|
|
||||||
offset = seqState->prevOffset[0];
|
|
||||||
seqState->prevOffset[0] = seq->offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
seq->offset = offset;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#else // ZSTD_REP_NUM == 1
|
|
||||||
|
|
||||||
|
|
||||||
{ size_t offset;
|
|
||||||
#if 0
|
|
||||||
if (!ofCode) {
|
|
||||||
if (!llCode) {
|
|
||||||
offset = seqState->prevOffset[1];
|
|
||||||
seqState->prevOffset[1] = seqState->prevOffset[0];
|
|
||||||
seqState->prevOffset[0] = offset;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
offset = seqState->prevOffset[0];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
offset = OF_base[ofCode] + BIT_readBits(&(seqState->DStream), ofBits); /* <= 26 bits */
|
|
||||||
if (MEM_32bits()) BIT_reloadDStream(&(seqState->DStream));
|
|
||||||
#else
|
|
||||||
if (!ofCode)
|
if (!ofCode)
|
||||||
offset = 0;
|
offset = 0;
|
||||||
else {
|
else {
|
||||||
@@ -708,37 +664,34 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
|
|||||||
if (MEM_32bits()) BIT_reloadDStream(&(seqState->DStream));
|
if (MEM_32bits()) BIT_reloadDStream(&(seqState->DStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (offset < ZSTD_REP_NUM) {
|
||||||
|
if (llCode == 0 && offset <= 1) offset = 1-offset;
|
||||||
|
|
||||||
|
if (offset != 0) {
|
||||||
|
size_t temp = seqState->prevOffset[offset];
|
||||||
|
if (offset != 1) {
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
|
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
||||||
#endif
|
#endif
|
||||||
if (offset < ZSTD_REP_NUM) {
|
seqState->prevOffset[2] = seqState->prevOffset[1];
|
||||||
if (llCode == 0 && offset <= 1) offset = 1-offset;
|
|
||||||
|
|
||||||
if (offset != 0) {
|
|
||||||
size_t temp = seqState->prevOffset[offset];
|
|
||||||
if (offset != 1) {
|
|
||||||
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
|
||||||
seqState->prevOffset[2] = seqState->prevOffset[1];
|
|
||||||
}
|
|
||||||
seqState->prevOffset[1] = seqState->prevOffset[0];
|
|
||||||
seqState->prevOffset[0] = offset = temp;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
offset = seqState->prevOffset[0];
|
|
||||||
}
|
}
|
||||||
|
seqState->prevOffset[1] = seqState->prevOffset[0];
|
||||||
|
seqState->prevOffset[0] = offset = temp;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
offset -= ZSTD_REP_MOVE;
|
offset = seqState->prevOffset[0];
|
||||||
seqState->prevOffset[3] = seqState->prevOffset[2];
|
|
||||||
seqState->prevOffset[2] = seqState->prevOffset[1];
|
|
||||||
seqState->prevOffset[1] = seqState->prevOffset[0];
|
|
||||||
seqState->prevOffset[0] = offset;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
offset -= ZSTD_REP_MOVE;
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
|
seqState->prevOffset[3] = seqState->prevOffset[2];
|
||||||
|
#endif
|
||||||
|
seqState->prevOffset[2] = seqState->prevOffset[1];
|
||||||
|
seqState->prevOffset[1] = seqState->prevOffset[0];
|
||||||
|
seqState->prevOffset[0] = offset;
|
||||||
}
|
}
|
||||||
seq->offset = offset;
|
seq->offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
seq->matchLength = ML_base[mlCode] + mls + ((mlCode>31) ? BIT_readBits(&(seqState->DStream), mlBits) : 0); /* <= 16 bits */
|
seq->matchLength = ML_base[mlCode] + mls + ((mlCode>31) ? BIT_readBits(&(seqState->DStream), mlBits) : 0); /* <= 16 bits */
|
||||||
if (MEM_32bits() && (mlBits+llBits>24)) BIT_reloadDStream(&(seqState->DStream));
|
if (MEM_32bits() && (mlBits+llBits>24)) BIT_reloadDStream(&(seqState->DStream));
|
||||||
|
|||||||
+4
-9
@@ -64,15 +64,10 @@
|
|||||||
|
|
||||||
#define ZSTD_OPT_NUM (1<<12)
|
#define ZSTD_OPT_NUM (1<<12)
|
||||||
#define ZSTD_DICT_MAGIC 0xEC30A435
|
#define ZSTD_DICT_MAGIC 0xEC30A435
|
||||||
#if 1
|
|
||||||
#define ZSTD_REP_NUM 4
|
#define ZSTD_REP_NUM 3
|
||||||
#define ZSTD_REP_INIT 4
|
#define ZSTD_REP_INIT ZSTD_REP_NUM
|
||||||
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
||||||
#else
|
|
||||||
#define ZSTD_REP_NUM 1
|
|
||||||
#define ZSTD_REP_INIT 2
|
|
||||||
#define ZSTD_REP_MOVE 0 //(ZSTD_REP_NUM-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define KB *(1 <<10)
|
#define KB *(1 <<10)
|
||||||
#define MB *(1 <<20)
|
#define MB *(1 <<20)
|
||||||
|
|||||||
@@ -551,13 +551,17 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
|
|||||||
mlen = opt[cur].mlen;
|
mlen = opt[cur].mlen;
|
||||||
|
|
||||||
if (opt[cur].off >= ZSTD_REP_NUM) {
|
if (opt[cur].off >= ZSTD_REP_NUM) {
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
opt[cur].rep[3] = opt[cur-mlen].rep[2];
|
opt[cur].rep[3] = opt[cur-mlen].rep[2];
|
||||||
|
#endif
|
||||||
opt[cur].rep[2] = opt[cur-mlen].rep[1];
|
opt[cur].rep[2] = opt[cur-mlen].rep[1];
|
||||||
opt[cur].rep[1] = opt[cur-mlen].rep[0];
|
opt[cur].rep[1] = opt[cur-mlen].rep[0];
|
||||||
opt[cur].rep[0] = opt[cur].off - ZSTD_REP_MOVE;
|
opt[cur].rep[0] = opt[cur].off - ZSTD_REP_MOVE;
|
||||||
ZSTD_LOG_ENCODE("%d: COPYREP_OFF cur=%d mlen=%d rep=%d rep[1]=%d\n", (int)(inr-base), cur, mlen, opt[cur].rep[0], opt[cur].rep[1]);
|
ZSTD_LOG_ENCODE("%d: COPYREP_OFF cur=%d mlen=%d rep=%d rep[1]=%d\n", (int)(inr-base), cur, mlen, opt[cur].rep[0], opt[cur].rep[1]);
|
||||||
} else {
|
} else {
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
opt[cur].rep[3] = (opt[cur].off > 2) ? opt[cur-mlen].rep[2] : opt[cur-mlen].rep[3];
|
opt[cur].rep[3] = (opt[cur].off > 2) ? opt[cur-mlen].rep[2] : opt[cur-mlen].rep[3];
|
||||||
|
#endif
|
||||||
opt[cur].rep[2] = (opt[cur].off > 1) ? opt[cur-mlen].rep[1] : opt[cur-mlen].rep[2];
|
opt[cur].rep[2] = (opt[cur].off > 1) ? opt[cur-mlen].rep[1] : opt[cur-mlen].rep[2];
|
||||||
opt[cur].rep[1] = (opt[cur].off > 0) ? opt[cur-mlen].rep[0] : opt[cur-mlen].rep[1];
|
opt[cur].rep[1] = (opt[cur].off > 0) ? opt[cur-mlen].rep[0] : opt[cur-mlen].rep[1];
|
||||||
opt[cur].rep[0] = opt[cur-mlen].rep[opt[cur].off];
|
opt[cur].rep[0] = opt[cur-mlen].rep[opt[cur].off];
|
||||||
@@ -684,7 +688,9 @@ _storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */
|
|||||||
ZSTD_LOG_ENCODE("%d/%d: ENCODE literals=%d mlen=%d off=%d rep1=%d rep[1]=%d\n", (int)(ip-base), (int)(iend-base), (int)(litLength), (int)mlen, (int)(offset), (int)rep[0], (int)rep[1]);
|
ZSTD_LOG_ENCODE("%d/%d: ENCODE literals=%d mlen=%d off=%d rep1=%d rep[1]=%d\n", (int)(ip-base), (int)(iend-base), (int)(litLength), (int)mlen, (int)(offset), (int)rep[0], (int)rep[1]);
|
||||||
|
|
||||||
if (offset >= ZSTD_REP_NUM) {
|
if (offset >= ZSTD_REP_NUM) {
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
rep[3] = rep[2];
|
rep[3] = rep[2];
|
||||||
|
#endif
|
||||||
rep[2] = rep[1];
|
rep[2] = rep[1];
|
||||||
rep[1] = rep[0];
|
rep[1] = rep[0];
|
||||||
rep[0] = offset - ZSTD_REP_MOVE;
|
rep[0] = offset - ZSTD_REP_MOVE;
|
||||||
@@ -692,7 +698,9 @@ _storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */
|
|||||||
if (offset != 0) {
|
if (offset != 0) {
|
||||||
size_t temp = rep[offset];
|
size_t temp = rep[offset];
|
||||||
if (offset != 1) {
|
if (offset != 1) {
|
||||||
|
#if ZSTD_REP_NUM > 3
|
||||||
if (offset == 3) rep[3] = rep[2];
|
if (offset == 3) rep[3] = rep[2];
|
||||||
|
#endif
|
||||||
rep[2] = rep[1];
|
rep[2] = rep[1];
|
||||||
}
|
}
|
||||||
rep[1] = rep[0];
|
rep[1] = rep[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user