mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-06-14 14:29:30 +00:00
Optimal LZSA1 compression
This commit is contained in:
parent
6b08bc3990
commit
35ec6d73da
|
@ -203,6 +203,7 @@ static int lzsa_find_matches_at(lzsa_compressor *pCompressor, const int nOffset,
|
||||||
unsigned int match_pos;
|
unsigned int match_pos;
|
||||||
lzsa_match *matchptr;
|
lzsa_match *matchptr;
|
||||||
unsigned int nPrevOffset = 0;
|
unsigned int nPrevOffset = 0;
|
||||||
|
unsigned char nV1OffsetFound[2] = { 0, 0 };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find matches using intervals
|
* Find matches using intervals
|
||||||
|
@ -281,14 +282,25 @@ static int lzsa_find_matches_at(lzsa_compressor *pCompressor, const int nOffset,
|
||||||
if (nMatchOffset <= MAX_OFFSET && nMatchOffset != nPrevOffset) {
|
if (nMatchOffset <= MAX_OFFSET && nMatchOffset != nPrevOffset) {
|
||||||
if (pCompressor->format_version >= 2) {
|
if (pCompressor->format_version >= 2) {
|
||||||
matchptr->length = (const unsigned short)(ref >> (LCP_SHIFT + TAG_BITS));
|
matchptr->length = (const unsigned short)(ref >> (LCP_SHIFT + TAG_BITS));
|
||||||
|
matchptr->offset = (const unsigned short)nMatchOffset;
|
||||||
|
matchptr++;
|
||||||
|
|
||||||
|
nPrevOffset = nMatchOffset;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
matchptr->length = (const unsigned short)(ref >> LCP_SHIFT);
|
unsigned int nV1OffsetType = (nMatchOffset <= 256) ? 0 : 1;
|
||||||
}
|
|
||||||
matchptr->offset = (const unsigned short)nMatchOffset;
|
|
||||||
matchptr++;
|
|
||||||
|
|
||||||
nPrevOffset = nMatchOffset;
|
if (!nV1OffsetFound[nV1OffsetType]) {
|
||||||
|
matchptr->length = (const unsigned short)(ref >> LCP_SHIFT);
|
||||||
|
matchptr->offset = (const unsigned short)nMatchOffset;
|
||||||
|
|
||||||
|
if (matchptr->length < 256)
|
||||||
|
nV1OffsetFound[nV1OffsetType] = 1;
|
||||||
|
matchptr++;
|
||||||
|
|
||||||
|
nPrevOffset = nMatchOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user