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++) {
|
||||
const int nRepOffset = arrival[j].rep_offset;
|
||||
|
||||
if (nMatchOffset != nRepOffset && nRepOffset && arrival[j].rep_len >= MIN_MATCH_SIZE_V2) {
|
||||
const int nRepPos = arrival[j].rep_pos;
|
||||
if (nMatchOffset != nRepOffset && nRepOffset) {
|
||||
const int nRepLen = arrival[j].rep_len;
|
||||
|
||||
if (nRepLen >= MIN_MATCH_SIZE_V2) {
|
||||
const int nRepPos = arrival[j].rep_pos;
|
||||
|
||||
if (nRepPos > nMatchOffset &&
|
||||
(nRepPos + nRepLen) <= nEndOffset) {
|
||||
|
||||
@ -255,6 +257,7 @@ static void lzsa_insert_forward_match_v2(lzsa_compressor *pCompressor, const uns
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -525,16 +528,26 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
||||
if (n < nArrivalsPerPosition - 1) {
|
||||
int nn;
|
||||
|
||||
if (!nInsertForwardReps || pDestSlots[nArrivalsPerPosition - 1].from_slot) {
|
||||
for (nn = n;
|
||||
nn < nArrivalsPerPosition && pDestSlots[nn].cost == nCodingChoiceCost;
|
||||
nn++) {
|
||||
if (pDestSlots[nn].rep_offset == nMatchOffset &&
|
||||
(!nInsertForwardReps || pDestSlots[nn].rep_pos >= i ||
|
||||
pDestSlots[nArrivalsPerPosition - 1].from_slot)) {
|
||||
if (pDestSlots[nn].rep_offset == nMatchOffset) {
|
||||
exists = 1;
|
||||
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) {
|
||||
int z;
|
||||
@ -561,7 +574,7 @@ static void lzsa_optimize_forward_v2(lzsa_compressor *pCompressor, const unsigne
|
||||
pDestArrival->rep_offset = nMatchOffset;
|
||||
pDestArrival->rep_pos = i;
|
||||
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);
|
||||
|
||||
for (nCurRepMatchArrival = 0; (j = nRepMatchArrivalIdxAndLen[nCurRepMatchArrival]) >= 0; nCurRepMatchArrival += 2) {
|
||||
if (nRepMatchArrivalIdxAndLen[nCurRepMatchArrival + 1] >= k) {
|
||||
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;
|
||||
int nRepCodingChoiceCost = nPrevCost /* the actual cost of the literals themselves accumulates up the chain */ + nMatchLenCost;
|
||||
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_pos = i;
|
||||
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)
|
||||
nMinOverallRepLen = k;
|
||||
|
Loading…
Reference in New Issue
Block a user