Small LZSA2 improvement

This commit is contained in:
Emmanuel Marty 2022-04-20 14:06:19 +02:00 committed by GitHub
parent a5f3691d4f
commit 38bfea7ecf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -328,19 +328,25 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
const int nNumLiterals = cur_arrival[j].num_literals + 1;
const int nRepOffset = cur_arrival[j].rep_offset;
if (nNumLiterals == 1) {
switch (nNumLiterals) {
case 1:
nCodingChoiceCost += nModeSwitchPenalty;
}
else if (nNumLiterals == LITERALS_RUN_LEN_V2) {
break;
case LITERALS_RUN_LEN_V2:
nCodingChoiceCost += 4;
}
else if (nNumLiterals >= (LITERALS_RUN_LEN_V2 + 15)) {
if (nNumLiterals == (LITERALS_RUN_LEN_V2 + 15)) {
break;
case LITERALS_RUN_LEN_V2 + 15:
nCodingChoiceCost += 8;
}
else if (nNumLiterals == 256) {
break;
case 256:
nCodingChoiceCost += 16;
}
break;
default:
break;
}
if (nCodingChoiceCost < pDestLiteralSlots[nArrivalsPerPosition - 1].cost ||