#compression-level #lz77 #fastlz #no-alloc

no-std bin+lib fastlz-rs

Pure-Rust reimplementation of FastLZ

3 releases

0.0.3 Sep 21, 2024
0.0.2 Sep 21, 2024
0.0.1 Jul 19, 2024

#180 in Compression

Download history 11/week @ 2024-09-14 353/week @ 2024-09-21 100/week @ 2024-09-28 189/week @ 2024-10-05 58/week @ 2024-10-12 44/week @ 2024-10-19 103/week @ 2024-10-26 78/week @ 2024-11-02 112/week @ 2024-11-09 82/week @ 2024-11-16 100/week @ 2024-11-23 94/week @ 2024-11-30

398 downloads per month

0BSD license

48KB
1K SLoC

Pure-Rust reimplementation of FastLZ.

docs.rs


lib.rs:

This crate is a pure-Rust reimplementation of FastLZ.

This crate uses the same fundamental algorithm as the original C code, namely using a hash table keyed off of the next three bytes to try to find backreferences. Just like FastLZ (and unlike "traditional" implementations of DEFLATE such as gzip), no chaining is used in the hashtable, only a single entry per hash key.

This crate does not generate bit-identical output, but output should be fully compatible with other decoders, at least for compression level 1.

Compression level 2 is not formally documented, but this crate implements it as follows:

  • If opc[7:5] == 0b000, copy opc[4:0] + 1 of the following literals
  • Else it is a backreference. Set the initial len to opc[7:5] + 2 and the initial disp[12:8] to opc[4:0]
    • If opc[7:5] == 0b111 then there is an extended length. len += all bytes until and including the first non-0xff byte
    • Set the initial disp[7:0] to the next byte
    • If the initial disp is all 1 bits, disp += the next two bytes as a big-endian integer
  • A file is, for some reason, not permitted to end on a backreference requiring extended displacement bytes

Like the original code, this crate does not support "streaming" compression. It only operates on full input.

No runtime deps