]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Flesh out required args for ldm_handleLdm()
authorsenhuang42 <senhuang96@fb.com>
Sat, 26 Sep 2020 15:59:07 +0000 (11:59 -0400)
committersenhuang42 <senhuang96@fb.com>
Wed, 7 Oct 2020 17:56:24 +0000 (13:56 -0400)
lib/compress/zstd_opt.c

index 3c3f223133c7ae8ef02a0c7248f291ff0408074c..0680e831ba1bb78b49724cadd54c7e7c21435ee2 100644 (file)
@@ -768,12 +768,14 @@ FORCE_INLINE_TEMPLATE U32 ZSTD_BtGetAllMatches (
 *  LDM util functions
 *********************************/
 
-static int ldm_splitSequence() {
+// The only function that can update pos (i think, for now)
+static int ldm_splitSequence(rawSeqStore_t* ldmSeqStore, U32 remainingBytes) {
+    rawSeq currSeq = ldmSeqStore->seq[ldmSeqStore->pos];
 
 }
 
 /* Returns 1 if the rest of the block is just LDM literals */
-static int ldm_getNextMatch() {
+static int ldm_getNextMatch(U32* matchStartPosInBlock, U32* matchEndPosInBlock, U32 remainingBytes) {
     int ret = ldm_splitSequence();
 }
 
@@ -788,8 +790,13 @@ static void ldm_maybeUpdateSeqStoreReadPos() {
 }
 
 /* Wrapper function to call ldm functions as needed */
-static void ldm_handleLdm(int* nbMatches) {
-    int noMoreLdms = getNextMatch();
+static void ldm_handleLdm(ZSTD_match_t* matches, int* nbMatches,
+                          U32* matchStartPosInBlock, U32* matchEndPosInBlock,
+                          U32 currPosInBlock, U32 remainingBytes) {
+    if (currPosInBlock >= matchEndPosInBlock) {
+        int noMoreLdms = ldm_getNextMatch(matchStartPosInBlock, matchEndPosInBlock, remainingBytes);
+    }
+    ldm_maybeAddLdm(matches, currPosInBlock, matchStartPosInBlock, matchEndPosInBlock);
 }
 
 
@@ -846,6 +853,10 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
     ZSTD_match_t* const matches = optStatePtr->matchTable;
     ZSTD_optimal_t lastSequence;
 
+    U32 matchStartPosInBlock = 0;
+    U32 matchEndPosInBlock = 0;
+    ldm_getNextMatch(matchStartPosInBlock, matchEndPosInBlock, (U32)(iend - ip));
+
     /* init */
     DEBUGLOG(5, "ZSTD_compressBlock_opt_generic: current=%u, prefix=%u, nextToUpdate=%u",
                 (U32)(ip - base), ms->window.dictLimit, ms->nextToUpdate);
@@ -976,7 +987,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
                 U32 const basePrice = previousPrice + ZSTD_litLengthPrice(0, optStatePtr, optLevel);
                 U32 const nbMatches = ZSTD_BtGetAllMatches(matches, ms, &nextToUpdate3, inr, iend, dictMode, opt[cur].rep, ll0, minMatch);
                 U32 matchNb;
-                
+
                 ldm_handleLdm(&nbMatches);
                 if (!nbMatches) {
                     DEBUGLOG(7, "rPos:%u : no match found", cur);