mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-11-29 05:49:20 +00:00
Clarify optimizer
This commit is contained in:
parent
d70830b525
commit
3caa72c722
@ -36,6 +36,8 @@
|
|||||||
#define MIN_OFFSET 1
|
#define MIN_OFFSET 1
|
||||||
#define MAX_OFFSET 0xffff
|
#define MAX_OFFSET 0xffff
|
||||||
|
|
||||||
|
#define MAX_VARLEN 0xffff
|
||||||
|
|
||||||
#define MIN_MATCH_SIZE_V1 3
|
#define MIN_MATCH_SIZE_V1 3
|
||||||
#define LITERALS_RUN_LEN_V1 7
|
#define LITERALS_RUN_LEN_V1 7
|
||||||
#define MATCH_RUN_LEN_V1 15
|
#define MATCH_RUN_LEN_V1 15
|
||||||
|
@ -314,7 +314,7 @@ static int lzsa_optimize_command_count_v1(lsza_compressor *pCompressor, const in
|
|||||||
else {
|
else {
|
||||||
if ((i + nMatchLen) < nEndOffset && nMatchLen >= LCP_MAX &&
|
if ((i + nMatchLen) < nEndOffset && nMatchLen >= LCP_MAX &&
|
||||||
pMatch->offset && pMatch->offset <= 32 && pCompressor->match[(i + nMatchLen) << MATCHES_PER_OFFSET_SHIFT].offset == pMatch->offset && (nMatchLen % pMatch->offset) == 0 &&
|
pMatch->offset && pMatch->offset <= 32 && pCompressor->match[(i + nMatchLen) << MATCHES_PER_OFFSET_SHIFT].offset == pMatch->offset && (nMatchLen % pMatch->offset) == 0 &&
|
||||||
(nMatchLen + pCompressor->match[(i + nMatchLen) << MATCHES_PER_OFFSET_SHIFT].length) <= MAX_OFFSET) {
|
(nMatchLen + pCompressor->match[(i + nMatchLen) << MATCHES_PER_OFFSET_SHIFT].length) <= MAX_VARLEN) {
|
||||||
/* Join */
|
/* Join */
|
||||||
|
|
||||||
pMatch->length += pCompressor->match[(i + nMatchLen) << MATCHES_PER_OFFSET_SHIFT].length;
|
pMatch->length += pCompressor->match[(i + nMatchLen) << MATCHES_PER_OFFSET_SHIFT].length;
|
||||||
|
@ -208,19 +208,16 @@ static void lzsa_optimize_matches_v2(lsza_compressor *pCompressor, const int nSt
|
|||||||
|
|
||||||
int nLiteralsLen = nLastLiteralsOffset - i;
|
int nLiteralsLen = nLastLiteralsOffset - i;
|
||||||
nLiteralsCost = 8 + cost[i + 1];
|
nLiteralsCost = 8 + cost[i + 1];
|
||||||
|
|
||||||
|
/* Add to the cost of encoding literals as their number crosses a variable length encoding boundary.
|
||||||
|
* The cost automatically accumulates down the chain. */
|
||||||
if (nLiteralsLen == LITERALS_RUN_LEN_V2) {
|
if (nLiteralsLen == LITERALS_RUN_LEN_V2) {
|
||||||
/* Add to the cost of encoding literals as their number crosses a variable length encoding boundary.
|
|
||||||
* The cost automatically accumulates down the chain. */
|
|
||||||
nLiteralsCost += 4;
|
nLiteralsCost += 4;
|
||||||
}
|
}
|
||||||
else if (nLiteralsLen == (LITERALS_RUN_LEN_V2 + 15)) {
|
else if (nLiteralsLen == (LITERALS_RUN_LEN_V2 + 15)) {
|
||||||
/* Add to the cost of encoding literals as their number crosses a variable length encoding boundary.
|
|
||||||
* The cost automatically accumulates down the chain. */
|
|
||||||
nLiteralsCost += 8;
|
nLiteralsCost += 8;
|
||||||
}
|
}
|
||||||
else if (nLiteralsLen == 256) {
|
else if (nLiteralsLen == 256) {
|
||||||
/* Add to the cost of encoding literals as their number crosses a variable length encoding boundary.
|
|
||||||
* The cost automatically accumulates down the chain. */
|
|
||||||
nLiteralsCost += 16;
|
nLiteralsCost += 16;
|
||||||
}
|
}
|
||||||
if (pCompressor->best_match[i + 1].length >= MIN_MATCH_SIZE_V2)
|
if (pCompressor->best_match[i + 1].length >= MIN_MATCH_SIZE_V2)
|
||||||
@ -527,7 +524,7 @@ static int lzsa_optimize_command_count_v2(lsza_compressor *pCompressor, const in
|
|||||||
else {
|
else {
|
||||||
if ((i + nMatchLen) < nEndOffset && nMatchLen >= LCP_MAX &&
|
if ((i + nMatchLen) < nEndOffset && nMatchLen >= LCP_MAX &&
|
||||||
pMatch->offset && pMatch->offset <= 32 && pCompressor->best_match[i + nMatchLen].offset == pMatch->offset && (nMatchLen % pMatch->offset) == 0 &&
|
pMatch->offset && pMatch->offset <= 32 && pCompressor->best_match[i + nMatchLen].offset == pMatch->offset && (nMatchLen % pMatch->offset) == 0 &&
|
||||||
(nMatchLen + pCompressor->best_match[i + nMatchLen].length) <= MAX_OFFSET) {
|
(nMatchLen + pCompressor->best_match[i + nMatchLen].length) <= MAX_VARLEN) {
|
||||||
/* Join */
|
/* Join */
|
||||||
|
|
||||||
pMatch->length += pCompressor->best_match[i + nMatchLen].length;
|
pMatch->length += pCompressor->best_match[i + nMatchLen].length;
|
||||||
|
Loading…
Reference in New Issue
Block a user