Code Monkey home page Code Monkey logo

lzw's Introduction

Docs Crates.io Crates.io

salzweg

Salzweg is a LZW encoder and decoder. It supports the GIF flavored, TIFF flavored and fixed code flavors of LZW.

LZW is a universal lossless data compression algorithm.

The aim of this library is to be memory efficient, and fast.

  • The decoder lives only on the stack, and will be friendly with machines with low memory.
  • The encoder builds on the heap though, as it creates a growing tree of possible encoded words as the compression progresses.

Speed

First, a few formulas

  • Compressing speed = uncompressed bytes/seconds to compress.
  • Decompressing speed = uncompressed bytes/seconds to decompress.

Results

Using criterion on a AMD Ryzen 7 2700X Eight-Core Processor 3.70 GHz CPU , I observed the following throughput when processing data:

Variable encoder Fix 12 bit size
Compressing image data 70 MiB/s 120 MiB/s
Decompressing image data 200 MiB/s 210 MiB/s
Compressing lorem ipsum text 70 MiB/s 85 MiB/s
Decompressing lorem ipsum text 200 MiB/s 220 MiB/s

These timings are rounded, indicative more than 100% accurate. But they are consistently faster than the LZW and Weezl crate for encoding, and consistently faster than the Weezl crate for decoding (I did not try to decode with LZW, as the comparison is difficult due to API design).

Sources

License

Code is licensed under MIT.

lzw's People

Contributors

redwarp avatar

Stargazers

 avatar

Watchers

 avatar

lzw's Issues

TiffStyle decoder panics on some malformed input

Input as base64: H0A6AAAARAAARABgVA==

With cargo fuzz setup:

#![no_main]
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
    let ref mut output = vec![];
    let _ = salzweg::decoder::TiffStyleDecoder::decode(data, output);
});
thread '<unnamed>' panicked at 'attempt to subtract with overflow', /salzweg/lzw/src/decoder.rs:257:25

An lzw-like compress/decompress

Hi,

Firstly, thank you for sharing your excellent work!

There's an compression format called terse, and IBM has published a decompresser for it -
https://github.com/openmainframeproject/tersedecompress

If/when you have time, would you be able to look at this to add support for it to this crate.
Or maybe advise on what I'd need to change.
It also works with 12 bits of input at a time.
There are 2 variants - PACK and SPACK. I'm only interested in the PACK variant.

I can share a Rust "port" of the above Java impl privately, if that'll help.

Thanks in advance for any guidance you can give.
PS: I'm pretty novice w.r.t programming; so it'd take ages for me to fully understand your work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.