Split non-rep from repmatch candidates

This commit is contained in:
Emmanuel Marty 2019-11-26 11:58:34 +01:00 committed by GitHub
parent a38e8b126c
commit 0b5e915d83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -334,13 +334,17 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
int nRepOffset = arrival[(i << MATCHES_PER_ARRIVAL_SHIFT) + j].rep_offset;
int nCurMaxRepLen = 0;
if (nMatchOffset != nRepOffset &&
nRepOffset &&
i > nRepOffset &&
if (nRepOffset) {
if (nMatchOffset == nRepOffset)
nCurMaxRepLen = nMatchLen;
else {
if (i > nRepOffset &&
(i - nRepOffset + nMatchLen) <= (nEndOffset - LAST_LITERALS)) {
while (nCurMaxRepLen < nMatchLen && pInWindow[i - nRepOffset + nCurMaxRepLen] == pInWindow[i - nMatchOffset + nCurMaxRepLen])
nCurMaxRepLen++;
}
}
}
nMaxRepLen[j] = nCurMaxRepLen;
}
@ -365,15 +369,16 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
if (nRepCodingChoiceCost <= pDestSlots[nMatchesPerArrival - 1].cost) {
int nRepOffset = arrival[(i << MATCHES_PER_ARRIVAL_SHIFT) + j].rep_offset;
int nMatchOffsetCost = (nMatchOffset == nRepOffset) ? 0 : nNoRepmatchOffsetCost;
int nCodingChoiceCost = nRepCodingChoiceCost + nMatchOffsetCost;
if (nMatchOffset != nRepOffset) {
int nCodingChoiceCost = nRepCodingChoiceCost + nNoRepmatchOffsetCost;
if (!nFavorRatio && !arrival[(i << MATCHES_PER_ARRIVAL_SHIFT) + j].num_literals)
nCodingChoiceCost += MODESWITCH_PENALTY;
if (nCodingChoiceCost <= pDestSlots[nMatchesPerArrival - 1].cost) {
int exists = 0;
int nScore = arrival[(i << MATCHES_PER_ARRIVAL_SHIFT) + j].score + ((nMatchOffset == nRepOffset) ? 2 : 3);
int nScore = arrival[(i << MATCHES_PER_ARRIVAL_SHIFT) + j].score + 3;
for (n = 0;
n < nMatchesPerArrival && pDestSlots[n].cost <= nCodingChoiceCost;
@ -413,6 +418,7 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
}
}
}
}
/* If this coding choice doesn't rep-match, see if we still get a match by using the current repmatch offset for this arrival. This can occur (and not have the
* matchfinder offer the offset in the first place, or have too many choices with the same cost to retain the repmatchable offset) when compressing regions