Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement of literal run length & match length encoding #2

Closed
da0ka opened this issue Jun 22, 2019 · 2 comments
Closed

improvement of literal run length & match length encoding #2

da0ka opened this issue Jun 22, 2019 · 2 comments

Comments

@da0ka
Copy link

da0ka commented Jun 22, 2019

`low=LITERALS_RUN_LEN_V1 or MATCH_RUN_LEN_V1

if(len >= low)
if((len-=low)<254)
output len
else if((len-=254)<256)
output 254,len
else ouput 255,len&255,len>>8

EOD marker:
ouput 0,255,255,255(because it is greater than BLOCK_SIZE)`

@specke
Copy link
Collaborator

specke commented Jun 22, 2019

Hi da0ka, yes, this is a small inefficiency in the format, which was introduced to save on an extra operation in the decompressor. I.e. it is a performance optimization. Since the compressor itself is nearly optimal, it very well compensates for this inefficiency, literally losing 2 or 3 bytes per file usually.

@specke
Copy link
Collaborator

specke commented Dec 24, 2019

In fact, there is another way to improve the format, which will be almost compatible with the existing format. The pseudo-code would look as follows:
if (len == low) {
len += byte1;
if (len <= 255)
// same as before, +1 byte for lengths low..255
else if (len == 256)
// same as before, +3 bytes for lengths up to 65535
else
// we used +2 bytes for lengths 256..511
// however, we can use (len-256)*256 + byte2 which will make use of all currently unused values.
}

In fact Z80 decompressors are already compatible with this format change. However, current decompressors for 8088 and 6502 are not compatible. Our current plan is to modify decompressors for this change and introduce the change at the compressor level together with the next minor version update. Or the one after. We do not want to rush it, esp. since the change in the compression ratio is basically negligible.

emmanuel-marty pushed a commit that referenced this issue Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants