return sequence;
}
+static void printSeqStore(rawSeqStore_t* rawSeqStore) {
+ printf("rawSeqStore: pos: %zu, bytesDiscarded: %zu\n", rawSeqStore->pos);
+ for (int i = 0; i < rawSeqStore->size; ++i) {
+ printf("(of:%u ml:%u ll: %u)\n", rawSeqStore->seq[i].offset, rawSeqStore->seq[i].matchLength, rawSeqStore->seq[i].litLength);
+ }
+}
+
size_t ZSTD_ldm_blockCompress(rawSeqStore_t* rawSeqStore,
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
void const* src, size_t srcSize)
if (cParams->strategy >= ZSTD_btopt) {
size_t lastLLSize;
+ printSeqStore(rawSeqStore);
ms->ldmSeqStore = *rawSeqStore; /* copy current seqStore */
const BYTE* const prevBase = (BYTE const*)ms->window.base;
lastLLSize = blockCompressor(ms, seqStore, rep, src, srcSize);
}
srcSize -= seq->matchLength;
seq->matchLength = 0;
+ printf("ldm_skipSequences(): final: (of: %u, ml: %u, ll: %u)\n", seq->offset, seq->matchLength, seq->litLength);
rawSeqStore->pos++;
}
}
U32* matchStartPosInBlock, U32* matchEndPosInBlock,
U32* matchOffset, U32 currPosInBlock,
U32 remainingBytes, U32 sbi) {
+ if (ldmSeqStore->pos >= ldmSeqStore->size) {
+ // Don't use the LDM for the rest of the block (there is none)
+ printf("No ldm left in the block, pos max reached\n");
+ *matchStartPosInBlock = UINT32_MAX;
+ *matchEndPosInBlock = UINT32_MAX;
+ return 1;
+ }
rawSeq seq = ldm_splitSequence(ldmSeqStore, remainingBytes);
- if (seq.offset == 0 || ldmSeqStore->pos > ldmSeqStore->size) {
+ if (seq.offset == 0) {
// Don't use the LDM for the rest of the block (there is none)
- printf("No ldm left in the block\n");
+ printf("No ldm left in the block, offset = 0\n");
*matchStartPosInBlock = UINT32_MAX;
*matchEndPosInBlock = UINT32_MAX;
return 1;
U32 candidateOffCode = matchOffset + posDiff + ZSTD_REP_MOVE;
if ((*nbMatches == 0 || candidateMatchLength >= matches[*nbMatches-1].len) && *nbMatches < ZSTD_OPT_NUM) {
- printf("large enough, adding\n");
- /*matches[*nbMatches].len = candidateMatchLength;
- matches[*nbMatches].off = candidateOffCode;
- (*nbMatches)++;*/
-
+ printf("large enough: curr: %u currposinblock: %u (ofcode: %u, ml: %u)\n", curr, currPosInBlock, candidateOffCode, candidateMatchLength);
+
if (*nbMatches == 0) {
matches[*nbMatches].len = candidateMatchLength;
matches[*nbMatches].off = candidateOffCode;
U32 posOvershoot = currPosInBlock - *matchEndPosInBlock;
printf("Overshot position by: %u\n", posOvershoot);
ldm_skipSequences(ldmSeqStore, posOvershoot, MINMATCH);
- int noMoreLdms = ldm_getNextMatch(ldmSeqStore, matchStartPosInBlock,
- matchEndPosInBlock, matchOffset,
- currPosInBlock, remainingBytes, sbi);
- } else {
- int noMoreLdms = ldm_getNextMatch(ldmSeqStore, matchStartPosInBlock,
- matchEndPosInBlock, matchOffset,
- currPosInBlock, remainingBytes, sbi);
- }
+ }
+ int noMoreLdms = ldm_getNextMatch(ldmSeqStore, matchStartPosInBlock,
+ matchEndPosInBlock, matchOffset,
+ currPosInBlock, remainingBytes, sbi);
}
ldm_maybeAddLdm(matches, nbMatches, *matchStartPosInBlock, *matchEndPosInBlock, *matchOffset, currPosInBlock, curr, sbi);
}
U32 ldmEndPosInBlock = 0;
U32 ldmOffset = 0;
- printf("SBI for this block: %u\n", sbi);
+ printf("SBI for this block: %u, base: %u\n", sbi, base);
if (ms->ldmSeqStore.size != 0) {
ldm_getNextMatch(&ms->ldmSeqStore, &ldmStartPosInBlock,
&ldmEndPosInBlock, &ldmOffset, (U32)(ip-istart), (U32)(iend-ip), sbi);