mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2025-02-18 00:30:44 +00:00
Speed up LZSA2 compression
This commit is contained in:
parent
44df8f3d2d
commit
03f841d04f
@ -295,13 +295,14 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
int nMatchOffsetCost = (nMatchOffset == nRepOffset) ? 0 : nNoRepmatchOffsetCost;
|
int nMatchOffsetCost = (nMatchOffset == nRepOffset) ? 0 : nNoRepmatchOffsetCost;
|
||||||
int nRepCodingChoiceCost = nPrevCost + 8 /* token */ /* the actual cost of the literals themselves accumulates up the chain */ + nMatchLenCost;
|
int nRepCodingChoiceCost = nPrevCost + 8 /* token */ /* the actual cost of the literals themselves accumulates up the chain */ + nMatchLenCost;
|
||||||
int nCodingChoiceCost = nRepCodingChoiceCost + nMatchOffsetCost;
|
int nCodingChoiceCost = nRepCodingChoiceCost + nMatchOffsetCost;
|
||||||
int exists = 0;
|
|
||||||
|
|
||||||
if (!nFavorRatio && !arrival[(i << MATCHES_PER_OFFSET_SHIFT) + j].num_literals)
|
if (!nFavorRatio && !arrival[(i << MATCHES_PER_OFFSET_SHIFT) + j].num_literals)
|
||||||
nCodingChoiceCost += MODESWITCH_PENALTY;
|
nCodingChoiceCost += MODESWITCH_PENALTY;
|
||||||
|
|
||||||
if (pDestSlots[NMATCHES_PER_OFFSET - 1].from_slot == 0 || nRepCodingChoiceCost <= pDestSlots[NMATCHES_PER_OFFSET - 1].cost) {
|
if (pDestSlots[NMATCHES_PER_OFFSET - 1].from_slot == 0 || nRepCodingChoiceCost <= pDestSlots[NMATCHES_PER_OFFSET - 1].cost) {
|
||||||
if (pDestSlots[NMATCHES_PER_OFFSET - 1].from_slot == 0 || nCodingChoiceCost <= pDestSlots[NMATCHES_PER_OFFSET - 1].cost) {
|
if (pDestSlots[NMATCHES_PER_OFFSET - 1].from_slot == 0 || nCodingChoiceCost <= pDestSlots[NMATCHES_PER_OFFSET - 1].cost) {
|
||||||
|
int exists = 0;
|
||||||
|
|
||||||
for (n = 0;
|
for (n = 0;
|
||||||
n < NMATCHES_PER_OFFSET && pDestSlots[n].from_slot && pDestSlots[n].cost <= nCodingChoiceCost;
|
n < NMATCHES_PER_OFFSET && pDestSlots[n].from_slot && pDestSlots[n].cost <= nCodingChoiceCost;
|
||||||
n++) {
|
n++) {
|
||||||
@ -311,7 +312,8 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = 0; !exists && n < NMATCHES_PER_OFFSET; n++) {
|
if (!exists) {
|
||||||
|
for (n = 0; n < NMATCHES_PER_OFFSET; n++) {
|
||||||
lzsa_arrival *pDestArrival = &pDestSlots[n];
|
lzsa_arrival *pDestArrival = &pDestSlots[n];
|
||||||
|
|
||||||
if (pDestArrival->from_slot == 0 ||
|
if (pDestArrival->from_slot == 0 ||
|
||||||
@ -334,15 +336,16 @@ 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
|
/* 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
|
* 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
|
||||||
* of identical bytes, for instance. Checking for this provides a big compression win on some files. */
|
* of identical bytes, for instance. Checking for this provides a big compression win on some files. */
|
||||||
|
|
||||||
if (nMaxRepLen[j] >= k) {
|
if (nMaxRepLen[j] >= k) {
|
||||||
/* A match is possible at the rep offset; insert the extra coding choice. */
|
int exists = 0;
|
||||||
|
|
||||||
exists = 0;
|
/* A match is possible at the rep offset; insert the extra coding choice. */
|
||||||
|
|
||||||
for (n = 0;
|
for (n = 0;
|
||||||
n < NMATCHES_PER_OFFSET && pDestSlots[n].from_slot && pDestSlots[n].cost <= nRepCodingChoiceCost;
|
n < NMATCHES_PER_OFFSET && pDestSlots[n].from_slot && pDestSlots[n].cost <= nRepCodingChoiceCost;
|
||||||
@ -353,7 +356,8 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = 0; !exists && n < NMATCHES_PER_OFFSET; n++) {
|
if (!exists) {
|
||||||
|
for (n = 0; n < NMATCHES_PER_OFFSET; n++) {
|
||||||
lzsa_arrival *pDestArrival = &pDestSlots[n];
|
lzsa_arrival *pDestArrival = &pDestSlots[n];
|
||||||
|
|
||||||
if (pDestArrival->from_slot == 0 ||
|
if (pDestArrival->from_slot == 0 ||
|
||||||
@ -381,6 +385,7 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lzsa_arrival *end_arrival = &arrival[(i << MATCHES_PER_OFFSET_SHIFT) + 0];
|
lzsa_arrival *end_arrival = &arrival[(i << MATCHES_PER_OFFSET_SHIFT) + 0];
|
||||||
pCompressor->best_match[i].length = 0;
|
pCompressor->best_match[i].length = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user