A Rust no-std (de)compressor based on PAQ

Overview

MASHI まし

A 100% no-std compatible Rust implementation of a PAQ style arithmetic coding, context mixing compressor. Its intended use case is compressing 64k demos, but whatever works for you!

Quick start

The main crate is mashi-core but I've provided a very bare-bones mashi-cli so you can test the compressor.

To build and use the CLI:

  • cargo build --release
  • target/release/mashi-cli compress tests/test.wasm
  • target/release/mashi-cli decompress tests/test.wasm.mashi

Cargo features

  • Use the encoder feature if you want to include the encoder
  • Use the std feature to enable std support (e.g. for running the unit tests)

Unscientific benchmarks

Compressing tests/test.wasm with various compressors:

Compressor % Size Command-line
mashi 34.4% 12083 mashi-cli compress
zpaq 37.0% 13004 zpaq a -m5
xz 38.5% 13522 xz --format=raw --lzma2=preset=9e
zstd 41.3% 14536 zstd --ultra -22
gzip 44.5% 15629 gzip --9
original 100% 35151

License

Since the original PAQ compressors are GPL licensed be aware that Mashi is also GPL licensed.

Credits

  • The compression model is based on the PAQ work by Matt Mahoney et al.
  • The arithmetic coder is a port of the one in Crinkler, done by Mentor and Blueberry.
  • Wrapping my head around all of this was aided by the videos of Jeff Miller and the compression seminar by Ferris at Revision 2020.
  • Some of my porting efforts were eased by the work done by aufdj.
You might also like...
Rust-based toolset and library for Halo: Combat Evolved

Ringhopper Ringhopper is a pure-Rust library used for creating and manipulating tag data for Halo: Combat Evolved. It also contains the Invader toolse

The non-opinionated Rust-based commit message linter.
The non-opinionated Rust-based commit message linter.

Documentation | Website git-sumi The non-opinionated Rust-based commit message linter Transform your commit practices with flexible linting for consis

Rust implementations of finite-field arithmetic based on big integers with configurable limb sizes

multiprecision TODO: rewrite readme implement CIOS for 16-bit limbs All operations are in little-endian form (where the digit in memory at the smalles

TodoX is a sophisticated Rust-based application designed to facilitate seamless todo management.

Rust Todo List App is a command-line tool written in Rust that allows users to manage their tasks efficiently. Whether you need to add, mark as done, edit, or clear tasks from your todo list, this app provides essential functionalities to streamline your task management process. Additionally, I have integrated sqlite3 using the rusqlite crate. The database stores the data and will persist indefinitely until you manually delete it.

Rust-based linux reverse shell listener.
Rust-based linux reverse shell listener.

Catch Rust-based linux reverse shell listener. Installation TODO: fix this installation guide, but this kinda works: mkdir /opt/catch/ cd /opt/catch/

An MVP stack based bytecode VM

TinyVM An MVP stack-based bytecode VM This VM runs a simplistic, Turing complete instruction set. In ~250 LOC with extensive comments, it's meant to b

An expression based data notation, aimed at transpiling itself to any cascaded data notation.

Lala An expression oriented data notation, aimed at transpiling itself to any cascaded data notation. Lala is separated into three components: Nana, L

A stack based interpreted programming language.

Nightmare Nightmare is a dynamically-typed, procedural programming language that aims to be fast & simple. let user = input() as Int; print("You were

a frontier based evm compatible chain template

Substrate Frontier Node Template A FRAME-based Substrate node with the Ethereum RPC support, ready for hacking 🚀 Generation & Upstream This template

Comments
  • Stream support

    Stream support

    Would be very nice to be able to pipe data through this. Could you add this feature to your CLI? Also, it would be nice if you enhanced the CLI a bit, so it is usable in non-rust projects. Thanks!

    opened by L3P3 0
Owner
all code is data / all data is code / unless properly curated all data is trash
null
An extension to Rust std for beginner exercises

note: this is for practicing rust only, do not use this in actual production programs! really, don't. [dependencies] simple-std = "0.1.1" simple-std i

nils 2 Jan 2, 2022
Additional Rust collections not found in std::collections

More collections Rust crate with additional collections not found in std::collections. Multimaps Completion Name Behaves like ?? ?? ?? ⬜️ ⬜️ HashSetMu

Rinde van Lon 4 Dec 21, 2022
A tiny Rust std-lib for Linux x86_64 and aarch64

Tiny std Like a bad, probably buggy, tiny standard library for Linux. When it's appropriate If you are actually trying to do something solid, checkout

null 4 Dec 17, 2022
A no-std esp32 Wifi Lamp

Nostd-wifi-lamp A Wi-Fi controllable lamp written in Rust for the ESP32 using esp-hal. This was created for a blog post you can read here. Usage Sadly

null 9 Apr 30, 2023
Zero-copy, no-std proquint encoding and decoding

proqnt A pronounceable quintuplet, or proquint, is a pronounceable 5-letter string encoding a unique 16-bit integer. Proquints may be used to encode b

Jad Ghalayini 11 May 9, 2023
A stack based, virtual machine language written in Rust

Stackyy A stack based, virtual machine language written in Rust Description: Stackyy is a stack based, virtual machine language inspired by Forth and

FlawlessCode 2 May 2, 2022
Tools to feature more lenient Polonius-based borrow-checker patterns in stable Rust

Though this be madness, yet there is method in 't. More context Hamlet: For yourself, sir, shall grow old as I am – if, like a crab, you could go back

Daniel Henry-Mantilla 52 Dec 26, 2022
Rust crate implementing short & stable ids based on timestamps

Lexicoid Short & stable IDs based on timestamps. Heavily inspired by Short, friendly base32 slugs from timestamps by @brandur. Install Install with ca

Luciano Mammino 6 Jan 29, 2023
A rust-based benchmark for BlueField SmartNICs.

Smartbench Smart-bench is a rust-based benchmarking tool for BlueField-series SmartNICs. The purpose is to enable easy testing of BlueField-series Sma

null 4 Jun 15, 2023
Rust based magic-string with source map chains support

enhanced-magic-string Rust implementation of https://www.npmjs.com/package/magic-string with original sourcemap chain support. license. This project i

Farm 3 Nov 5, 2023