aboutsummaryrefslogtreecommitdiff
path: root/tools/apultra/src/matchfinder.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-10-12 19:21:36 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-10-12 19:21:36 +0100
commit2b93e381676bcd96e98a1141dccc7340af05f7c0 (patch)
treeed6dce4fabbb0e667d04b0e83be985e1144a8b76 /tools/apultra/src/matchfinder.c
parent57e87d6280e2e40b0d363bc08d9d15eeec52a113 (diff)
downloadubox-msx-lib-2b93e381676bcd96e98a1141dccc7340af05f7c0.tar.gz
ubox-msx-lib-2b93e381676bcd96e98a1141dccc7340af05f7c0.zip
Updated apultra to version 1.4.8
Diffstat (limited to 'tools/apultra/src/matchfinder.c')
-rw-r--r--tools/apultra/src/matchfinder.c65
1 files changed, 27 insertions, 38 deletions
diff --git a/tools/apultra/src/matchfinder.c b/tools/apultra/src/matchfinder.c
index c3a30f3..b331d61 100644
--- a/tools/apultra/src/matchfinder.c
+++ b/tools/apultra/src/matchfinder.c
@@ -247,14 +247,12 @@ static int apultra_find_matches_at(apultra_compressor *pCompressor, const int nO
const int nMatchLen = (const int)(ref >> (LCP_SHIFT + TAG_BITS));
if (nMatchOffset <= nMaxOffset) {
- nCurDepth = 0;
-
- cur_depth = depthptr;
matchptr->length = nMatchLen;
matchptr->offset = nMatchOffset;
- *depthptr = 0;
matchptr++;
- depthptr++;
+
+ *depthptr = nCurDepth = 0;
+ cur_depth = depthptr++;
nPrevLen = nMatchLen;
nPrevOffset = nMatchOffset;
@@ -272,20 +270,18 @@ static int apultra_find_matches_at(apultra_compressor *pCompressor, const int nO
if ((matchptr - pMatches) < nMaxMatches) {
const int nMatchLen = (const int)(ref >> (LCP_SHIFT + TAG_BITS));
- if (nMatchOffset <= nMaxOffset && abs(nMatchOffset - nPrevOffset) >= 128) {
+ if (nMatchOffset <= nMaxOffset && (nPrevOffset - nMatchOffset) >= 128) {
if (nPrevOffset && nPrevLen > 2 && nMatchOffset == (nPrevOffset - 1) && nMatchLen == (nPrevLen - 1) && cur_depth && nCurDepth < LCP_MAX) {
- nCurDepth++;
- *cur_depth = nCurDepth | 0x8000;
+ *cur_depth = (++nCurDepth) | 0x8000;
}
else {
- nCurDepth = 0;
-
- cur_depth = depthptr;
matchptr->length = nMatchLen;
matchptr->offset = nMatchOffset;
- *depthptr = 0x8000;
matchptr++;
- depthptr++;
+
+ nCurDepth = 0;
+ *depthptr = 0x8000;
+ cur_depth = depthptr++;
}
nPrevLen = nMatchLen;
@@ -298,26 +294,24 @@ static int apultra_find_matches_at(apultra_compressor *pCompressor, const int nO
while ((super_ref = pos_data[match_pos]) > ref) {
match_pos = intervals[super_ref & POS_MASK] & EXCL_VISITED_MASK;
- if (nOffset > match_pos && nIsSelfContainedBlock) {
+ if (nOffset >= match_pos && nIsSelfContainedBlock) {
const int nMatchOffset = (const int)(nOffset - match_pos);
if ((matchptr - pMatches) < nMaxMatches) {
const int nMatchLen = (const int)(ref >> (LCP_SHIFT + TAG_BITS));
- if (nMatchOffset <= nMaxOffset && (nMatchLen >= 3 || (nMatchLen >= 2 && (matchptr - pMatches) < (nMaxMatches - 1))) && nMatchLen < 1280 && abs(nMatchOffset - nPrevOffset) >= 128) {
+ if (nMatchOffset <= nMaxOffset && (nMatchLen >= 3 || (nMatchLen >= 2 && (matchptr - pMatches) < (nMaxMatches - 1))) && nMatchLen < 1280 && (nPrevOffset - nMatchOffset) >= 128) {
if (nPrevOffset && nPrevLen > 2 && nMatchOffset == (nPrevOffset - 1) && nMatchLen == (nPrevLen - 1) && cur_depth && nCurDepth < LCP_MAX) {
- nCurDepth++;
- *cur_depth = nCurDepth | 0x8000;
+ *cur_depth = (++nCurDepth) | 0x8000;
}
else {
- nCurDepth = 0;
-
- cur_depth = depthptr;
matchptr->length = nMatchLen;
matchptr->offset = nMatchOffset;
- *depthptr = 0x8000;
matchptr++;
- depthptr++;
+
+ nCurDepth = 0;
+ *depthptr = 0x8000;
+ cur_depth = depthptr++;
}
nPrevLen = nMatchLen;
@@ -336,18 +330,15 @@ static int apultra_find_matches_at(apultra_compressor *pCompressor, const int nO
if ((matchptr - pMatches) < nMaxMatches) {
if (nMainMatchOffset <= nMaxOffset && nMainMatchOffset != nPrevOffset) {
if (nPrevOffset && nPrevLen > 2 && nMainMatchOffset == (nPrevOffset - 1) && nMainMatchLen == (nPrevLen - 1) && cur_depth && nCurDepth < LCP_MAX) {
- nCurDepth++;
- *cur_depth = nCurDepth;
+ *cur_depth = ++nCurDepth;
}
else {
- nCurDepth = 0;
-
- cur_depth = depthptr;
matchptr->length = nMainMatchLen;
matchptr->offset = nMainMatchOffset;
- *depthptr = 0;
matchptr++;
- depthptr++;
+
+ *depthptr = nCurDepth = 0;
+ cur_depth = depthptr++;
}
nPrevLen = nMainMatchLen;
@@ -363,26 +354,24 @@ static int apultra_find_matches_at(apultra_compressor *pCompressor, const int nO
ref = super_ref;
match_pos = intervals[ref & POS_MASK] & EXCL_VISITED_MASK;
- if (nOffset > match_pos && nIsSelfContainedBlock) {
+ if (nOffset >= match_pos && nIsSelfContainedBlock) {
const int nMatchOffset = (const int)(nOffset - match_pos);
if ((matchptr - pMatches) < nMaxMatches) {
const int nMatchLen = (const int)(ref >> (LCP_SHIFT + TAG_BITS));
- if (nMatchOffset <= nMaxOffset && nMatchLen >= 2 && abs(nMatchOffset - nPrevOffset) >= 128) {
+ if (nMatchOffset <= nMaxOffset && nMatchLen >= 2 && (nPrevOffset - nMatchOffset) >= 128) {
if (nPrevOffset && nPrevLen > 2 && nMatchOffset == (nPrevOffset - 1) && nMatchLen == (nPrevLen - 1) && cur_depth && nCurDepth < LCP_MAX) {
- nCurDepth++;
- *cur_depth = nCurDepth | 0x8000;
+ *cur_depth = (++nCurDepth) | 0x8000;
}
else {
- nCurDepth = 0;
-
- cur_depth = depthptr;
matchptr->length = nMatchLen;
matchptr->offset = nMatchOffset;
- *depthptr = 0x8000;
matchptr++;
- depthptr++;
+
+ nCurDepth = 0;
+ *depthptr = 0x8000;
+ cur_depth = depthptr++;
}
nPrevLen = nMatchLen;