]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
final repcodes for ZSTD_btopt
authorinikep <inikep@gmail.com>
Mon, 21 Mar 2016 19:14:03 +0000 (20:14 +0100)
committerinikep <inikep@gmail.com>
Mon, 21 Mar 2016 19:14:03 +0000 (20:14 +0100)
lib/zstd_decompress.c
lib/zstd_opt.h

index 500157ef3b4c4b893fe758fe5d46a0addcc7c1a1..f0475bf25a7aafeffbcb69ab7460b688ef8d155d 100644 (file)
@@ -683,14 +683,8 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
         if (offsetCode==0) offset = 0;
         
         if (offset < ZSTD_REP_NUM) {
-            if (litLength == 0) {
-                if (offset <= 1) offset = 1-offset;
-                offset = seqState->prevOffset[offset];
-                size_t temp = seqState->prevOffset[1];
-                seqState->prevOffset[1] = seqState->prevOffset[0];
-                seqState->prevOffset[0] = temp;
-            }
-            else
+            if (litLength == 0 && offset <= 1) offset = 1-offset;
+
             if (offset != 0) {
                 size_t temp = seqState->prevOffset[offset];
                 if (offset != 1) {
index cd1ef18780fd90ce8b8116d2cbde5a5646b24c25..c41c8c88d9cc679c1636025a348ea32bf0ef0208 100644 (file)
@@ -532,33 +532,11 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
                 opt[cur].rep[kSlotNew] = 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 1
-                if (opt[cur].litlen == 0) {
-                    opt[cur].rep[0] = opt[cur-mlen].rep[1];
-                    opt[cur].rep[1] = opt[cur-mlen].rep[0];
-                    opt[cur].rep[2] = opt[cur-mlen].rep[2];
-                    opt[cur].rep[3] = opt[cur-mlen].rep[3];
-                } else {
-                    opt[cur].rep[3] = (opt[cur].off > 2) ? opt[cur-mlen].rep[2] : opt[cur-mlen].rep[3];
-                    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];
-                }
-#else
-                if (cur!=mlen && opt[cur].litlen == 0) {
-                    opt[cur].rep[3] = (opt[cur].off > 2) ? opt[cur-mlen].rep[2] : opt[cur-mlen].rep[3];
-                    opt[cur].rep[2] = (opt[cur].off > 1) ? opt[cur-mlen].rep[1] : opt[cur-mlen].rep[2];
-                    opt[cur].rep[0] = (opt[cur].off > 0) ? opt[cur-mlen].rep[0] : opt[cur-mlen].rep[1];
-                    opt[cur].rep[1] = opt[cur-mlen].rep[opt[cur].off];
-                    ZSTD_LOG_ENCODE("%d: COPYREP_SWI cur=%d mlen=%d rep=%d rep[1]=%d\n", (int)(inr-base), cur, mlen, opt[cur].rep[0], opt[cur].rep[1]);
-                } else {
-                    opt[cur].rep[3] = (opt[cur].off > 2) ? opt[cur-mlen].rep[2] : opt[cur-mlen].rep[3];
-                    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];
-                    ZSTD_LOG_ENCODE("%d: COPYREP_NOR cur=%d mlen=%d rep=%d rep[1]=%d\n", (int)(inr-base), cur, mlen, opt[cur].rep[0], opt[cur].rep[1]);
-                }
-#endif
+                opt[cur].rep[3] = (opt[cur].off > 2) ? opt[cur-mlen].rep[2] : opt[cur-mlen].rep[3];
+                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];
+                ZSTD_LOG_ENCODE("%d: COPYREP_NOR 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_PARSER("%d: CURRENT_NoExt price[%d/%d]=%d off=%d mlen=%d litlen=%d rep=%d rep[1]=%d\n", (int)(inr-base), cur, last_pos, opt[cur].price, opt[cur].off, opt[cur].mlen, opt[cur].litlen, opt[cur].rep[0], opt[cur].rep[1]);
@@ -686,22 +664,17 @@ _storeSequence:   /* cur, last_pos, best_mlen, best_off have to be set */
                 if (kSlotNew < 1) rep[1] = rep[0];               
                 rep[kSlotNew] = offset - ZSTD_REP_MOVE;               
             } else {
-                if (litLength == 0) {
-                    U32 temp = rep[0];
-                    rep[0] = rep[1];
-                    rep[1] = temp;
-                    if (offset<=1) offset = 1-offset;
-                 }  else {
-                    if (offset != 0) {
-                        size_t temp = rep[offset];
-                        if (offset != 1) {
-                            if (offset == 3) rep[3] = rep[2];
-                            rep[2] = rep[1];
-                        }
-                        rep[1] = rep[0];
-                        rep[0] = temp;
+                if (offset != 0) {
+                    size_t temp = rep[offset];
+                    if (offset != 1) {
+                        if (offset == 3) rep[3] = rep[2];
+                        rep[2] = rep[1];
                     }
+                    rep[1] = rep[0];
+                    rep[0] = temp;
                 }
+                
+                if (litLength == 0 && offset<=1) offset = 1-offset;
            }
 
            // ZSTD_LOG_ENCODE("%d/%d: ENCODE2 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[1], (int)rep_2);