]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add support for repcodes
authorsenhuang42 <senhuang96@fb.com>
Tue, 27 Oct 2020 15:02:58 +0000 (11:02 -0400)
committersenhuang42 <senhuang96@fb.com>
Mon, 16 Nov 2020 15:49:16 +0000 (10:49 -0500)
lib/compress/zstd_compress.c
lib/compress/zstd_compress_internal.h

index cdfc39c203627cd5ba7cb11acf5e4562ffc8b27d..cb227bea56ebe037ad4d9cc2cd7cb2a78f2f1c6e 100644 (file)
@@ -4505,7 +4505,11 @@ static size_t ZSTD_copySequencesToSeqStore(ZSTD_CCtx* zc,
         U32 offCode = inSeqs[idx].offset + ZSTD_REP_MOVE;
         RETURN_ERROR_IF(matchLength < MINMATCH, corruption_detected, "Matchlength too small!");
         DEBUGLOG(7, "Seqstore idx: %zu, seq: (ll: %u, ml: %u, of: %u)", idx, litLength, matchLength, offCode);
-        ZSTD_storeSeq(&zc->seqStore, litLength, ip, iend, offCode, matchLength - MINMATCH);
+        if (inSeqs[idx].rep) {
+            ZSTD_storeSeq(&zc->seqStore, litLength, ip, iend, inSeqs[idx].rep - 1, matchLength - MINMATCH);
+        } else {
+            ZSTD_storeSeq(&zc->seqStore, litLength, ip, iend, offCode, matchLength - MINMATCH);
+        }
         ip += matchLength + litLength;
     }
 
index 3ff318d5348ef8f9e6512aa26418f26b61ba9bd2..6b6d101f8d25f9024ccc948f81e78f5d4643ef33 100644 (file)
@@ -497,6 +497,9 @@ static void ZSTD_safecopyLiterals(BYTE* op, BYTE const* ip, BYTE const* const ie
 HINT_INLINE UNUSED_ATTR
 void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const BYTE* literals, const BYTE* litLimit, U32 offCode, size_t mlBase)
 {
+    if (offCode <= 3) {
+        printf("of: %u ml: %u ll: %u\n", offCode, mlBase, litLength);
+    }
     BYTE const* const litLimit_w = litLimit - WILDCOPY_OVERLENGTH;
     BYTE const* const litEnd = literals + litLength;
 #if defined(DEBUGLEVEL) && (DEBUGLEVEL >= 6)