mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-11-24 19:32:16 +00:00
Compress LZSA2 a bit faster again
This commit is contained in:
parent
c6a93601cf
commit
bb1b4fda14
@ -194,10 +194,12 @@ static void lzsa_insert_forward_match_v2(lzsa_compressor *pCompressor, const uns
|
|||||||
for (j = 0; j < NARRIVALS_PER_POSITION_V2_BIG && arrival[j].from_slot; j++) {
|
for (j = 0; j < NARRIVALS_PER_POSITION_V2_BIG && arrival[j].from_slot; j++) {
|
||||||
const int nRepOffset = arrival[j].rep_offset;
|
const int nRepOffset = arrival[j].rep_offset;
|
||||||
|
|
||||||
if (nMatchOffset != nRepOffset && nRepOffset && arrival[j].rep_len >= MIN_MATCH_SIZE_V2) {
|
if (nMatchOffset != nRepOffset && nRepOffset) {
|
||||||
const int nRepPos = arrival[j].rep_pos;
|
|
||||||
const int nRepLen = arrival[j].rep_len;
|
const int nRepLen = arrival[j].rep_len;
|
||||||
|
|
||||||
|
if (nRepLen >= MIN_MATCH_SIZE_V2) {
|
||||||
|
const int nRepPos = arrival[j].rep_pos;
|
||||||
|
|
||||||
if (nRepPos > nMatchOffset &&
|
if (nRepPos > nMatchOffset &&
|
||||||
(nRepPos + nRepLen) <= nEndOffset) {
|
(nRepPos + nRepLen) <= nEndOffset) {
|
||||||
|
|
||||||
@ -256,6 +258,7 @@ static void lzsa_insert_forward_match_v2(lzsa_compressor *pCompressor, const uns
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to pick optimal matches using a forward arrivals parser, so as to produce the smallest possible output that decompresses to the same input
|
* Attempt to pick optimal matches using a forward arrivals parser, so as to produce the smallest possible output that decompresses to the same input
|
||||||
@ -525,16 +528,26 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
if (n < nArrivalsPerPosition - 1) {
|
if (n < nArrivalsPerPosition - 1) {
|
||||||
int nn;
|
int nn;
|
||||||
|
|
||||||
|
if (!nInsertForwardReps || pDestSlots[nArrivalsPerPosition - 1].from_slot) {
|
||||||
for (nn = n;
|
for (nn = n;
|
||||||
nn < nArrivalsPerPosition && pDestSlots[nn].cost == nCodingChoiceCost;
|
nn < nArrivalsPerPosition && pDestSlots[nn].cost == nCodingChoiceCost;
|
||||||
nn++) {
|
nn++) {
|
||||||
if (pDestSlots[nn].rep_offset == nMatchOffset &&
|
if (pDestSlots[nn].rep_offset == nMatchOffset) {
|
||||||
(!nInsertForwardReps || pDestSlots[nn].rep_pos >= i ||
|
|
||||||
pDestSlots[nArrivalsPerPosition - 1].from_slot)) {
|
|
||||||
exists = 1;
|
exists = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (nn = n;
|
||||||
|
nn < nArrivalsPerPosition && pDestSlots[nn].cost == nCodingChoiceCost;
|
||||||
|
nn++) {
|
||||||
|
if (pDestSlots[nn].rep_offset == nMatchOffset && pDestSlots[nn].rep_pos >= i) {
|
||||||
|
exists = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
int z;
|
int z;
|
||||||
@ -561,7 +574,7 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
pDestArrival->rep_offset = nMatchOffset;
|
pDestArrival->rep_offset = nMatchOffset;
|
||||||
pDestArrival->rep_pos = i;
|
pDestArrival->rep_pos = i;
|
||||||
pDestArrival->rep_len = k;
|
pDestArrival->rep_len = k;
|
||||||
nRepLenHandledMask[k >> 3] &= ~(1 << (k & 7));
|
nRepLenHandledMask[k >> 3] &= ~((1 ^ nReduce) << (k & 7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -577,8 +590,10 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
nRepLenHandledMask[k >> 3] |= 1 << (k & 7);
|
nRepLenHandledMask[k >> 3] |= 1 << (k & 7);
|
||||||
|
|
||||||
for (nCurRepMatchArrival = 0; (j = nRepMatchArrivalIdxAndLen[nCurRepMatchArrival]) >= 0; nCurRepMatchArrival += 2) {
|
for (nCurRepMatchArrival = 0; (j = nRepMatchArrivalIdxAndLen[nCurRepMatchArrival]) >= 0; nCurRepMatchArrival += 2) {
|
||||||
|
if (nRepMatchArrivalIdxAndLen[nCurRepMatchArrival + 1] >= k) {
|
||||||
int nMaskOffset = (j << 7) + (k >> 3);
|
int nMaskOffset = (j << 7) + (k >> 3);
|
||||||
if (nRepMatchArrivalIdxAndLen[nCurRepMatchArrival + 1] >= k && (nReduce || !(nRepSlotHandledMask[nMaskOffset] & (1 << (k & 7))))) {
|
|
||||||
|
if (nReduce || !(nRepSlotHandledMask[nMaskOffset] & (1 << (k & 7)))) {
|
||||||
const int nPrevCost = cur_arrival[j].cost & 0x3fffffff;
|
const int nPrevCost = cur_arrival[j].cost & 0x3fffffff;
|
||||||
int nRepCodingChoiceCost = nPrevCost /* the actual cost of the literals themselves accumulates up the chain */ + nMatchLenCost;
|
int nRepCodingChoiceCost = nPrevCost /* the actual cost of the literals themselves accumulates up the chain */ + nMatchLenCost;
|
||||||
int nScore = cur_arrival[j].score + 2;
|
int nScore = cur_arrival[j].score + 2;
|
||||||
@ -644,7 +659,7 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
pDestArrival->rep_offset = nRepOffset;
|
pDestArrival->rep_offset = nRepOffset;
|
||||||
pDestArrival->rep_pos = i;
|
pDestArrival->rep_pos = i;
|
||||||
pDestArrival->rep_len = k;
|
pDestArrival->rep_len = k;
|
||||||
nRepLenHandledMask[k >> 3] &= ~(1 << (k & 7));
|
nRepLenHandledMask[k >> 3] &= ~((1 ^ nReduce) << (k & 7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -655,6 +670,7 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (k < nMaxRepInsertedLen)
|
if (k < nMaxRepInsertedLen)
|
||||||
nMinOverallRepLen = k;
|
nMinOverallRepLen = k;
|
||||||
|
Loading…
Reference in New Issue
Block a user