support for ZSTD_REP_NUM=3

This commit is contained in:
inikep
2016-04-05 10:30:05 +02:00
parent 74e3a7ba4c
commit ba73d1bb6b
4 changed files with 38 additions and 83 deletions
+8
View File
@@ -551,13 +551,17 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
mlen = opt[cur].mlen;
if (opt[cur].off >= ZSTD_REP_NUM) {
#if ZSTD_REP_NUM > 3
opt[cur].rep[3] = opt[cur-mlen].rep[2];
#endif
opt[cur].rep[2] = opt[cur-mlen].rep[1];
opt[cur].rep[1] = opt[cur-mlen].rep[0];
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]);
} else {
#if ZSTD_REP_NUM > 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[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];
@@ -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]);
if (offset >= ZSTD_REP_NUM) {
#if ZSTD_REP_NUM > 3
rep[3] = rep[2];
#endif
rep[2] = rep[1];
rep[1] = rep[0];
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) {
size_t temp = rep[offset];
if (offset != 1) {
#if ZSTD_REP_NUM > 3
if (offset == 3) rep[3] = rep[2];
#endif
rep[2] = rep[1];
}
rep[1] = rep[0];