From 2ec2698ef98ee73f265722c341f253da5ca3551b Mon Sep 17 00:00:00 2001 From: inikep Date: Tue, 5 Apr 2016 09:34:13 +0200 Subject: [PATCH] working 4 reps --- lib/zstd_decompress.c | 64 +++++++++++++++++++++++++++---------------- lib/zstd_internal.h | 2 +- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/lib/zstd_decompress.c b/lib/zstd_decompress.c index 5fd22ffc..85ef9faf 100644 --- a/lib/zstd_decompress.c +++ b/lib/zstd_decompress.c @@ -656,17 +656,47 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls) 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, /*fake*/ 1, 1, 1, 1, 1 }; /* sequence */ - { size_t const offset = ofCode ? OF_base[ofCode] + BIT_readBits(&(seqState->DStream), ofBits) : /* <= 26 bits */ +#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; + 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 (ofCode) { + offset = OF_base[ofCode] + BIT_readBits(&(seqState->DStream), ofBits); /* <= 26 bits */ + if (MEM_32bits()) BIT_reloadDStream(&(seqState->DStream)); + + } else { + offset = 0; + } -#if ZSTD_REP_NUM == 4 - if (ofCode==0) offset = 0; - if (offset < ZSTD_REP_NUM) { - if (litLength == 0 && offset <= 1) offset = 1-offset; + if (llCode == 0 && offset <= 1) offset = 1-offset; if (offset != 0) { size_t temp = seqState->prevOffset[offset]; @@ -695,25 +725,13 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls) seqState->prevOffset[kSlotNew] = offset; #endif } -#else // ZSTD_REP_NUM == 1 - #if 1 -/* if (ofCode==0) offset = litLength ? seq->offset : seqState->prevOffset[0]; - else offset -= ZSTD_REP_MOVE; - if (ofCode | !litLength) seqState->prevOffset[0] = seq->offset; */ - #else - if (ofCode==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 + + seq->offset = offset; } + + + +#endif 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)); diff --git a/lib/zstd_internal.h b/lib/zstd_internal.h index 55c40da6..1a527d51 100644 --- a/lib/zstd_internal.h +++ b/lib/zstd_internal.h @@ -64,7 +64,7 @@ #define ZSTD_OPT_NUM (1<<12) #define ZSTD_DICT_MAGIC 0xEC30A435 -#if 0 +#if 1 #define ZSTD_REP_NUM 4 #define ZSTD_REP_INIT 4 #define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)