All Projects → niklasf → rust-huffman-compress

niklasf / rust-huffman-compress

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
A Rust library for Huffman compression given a propability distribution over arbitrary symbols

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to rust-huffman-compress

Huffman-Coding
A C++ compression program based on Huffman's lossless compression algorithm and decoder.
Stars: ✭ 81 (+350%)
Mutual labels:  compression, huffman-coding
huffman-coding
A C++ compression and decompression program based on Huffman Coding.
Stars: ✭ 31 (+72.22%)
Mutual labels:  compression, huffman-coding
JPQ
CIKM'21: JPQ substantially improves the efficiency of Dense Retrieval with 30x compression ratio, 10x CPU speedup and 2x GPU speedup.
Stars: ✭ 39 (+116.67%)
Mutual labels:  compression
upx
Node.js cross-platform wrapper for UPX - the ultimate packer for eXecutables.
Stars: ✭ 27 (+50%)
Mutual labels:  compression
Perfect-Zip
Perfect Zip compression utility.
Stars: ✭ 20 (+11.11%)
Mutual labels:  compression
LZ77-Compressor
A simplified implementation of the LZ77 compression algorithm
Stars: ✭ 70 (+288.89%)
Mutual labels:  compression
clp
Compressed Log Processor (CLP) is a free tool capable of compressing text logs and searching the compressed logs without decompression.
Stars: ✭ 49 (+172.22%)
Mutual labels:  compression
minibsdiff
A miniature, portable version of bsdiff.
Stars: ✭ 115 (+538.89%)
Mutual labels:  compression
box
Box - Open Standard Archive Format, a zip killer.
Stars: ✭ 38 (+111.11%)
Mutual labels:  compression
zpacker
very simple LZ77-based compression
Stars: ✭ 15 (-16.67%)
Mutual labels:  compression
LittleBit
LittleBit is a pure Huffman coding compression algorithm with the option of random access reading while offering competitive compression ratios.
Stars: ✭ 13 (-27.78%)
Mutual labels:  compression
raisin
A simple lightweight set of implementations and bindings for compression algorithms written in Go.
Stars: ✭ 17 (-5.56%)
Mutual labels:  compression
AppThinning
Make app thinner. Help you find large files and compress png, gif, jpg, svg files. 应用程序瘦身工具,帮助你找到大文件,压缩png、gif、jpg、svg等文件。
Stars: ✭ 22 (+22.22%)
Mutual labels:  compression
tiny
compress data for better performance
Stars: ✭ 21 (+16.67%)
Mutual labels:  compression
DSIN
Deep Image Compression using Decoder Side Information (ECCV 2020)
Stars: ✭ 39 (+116.67%)
Mutual labels:  compression
x-compressor
x – minimalist data compressor
Stars: ✭ 42 (+133.33%)
Mutual labels:  compression
pcc geo cnn
Learning Convolutional Transforms for Point Cloud Geometry Compression
Stars: ✭ 44 (+144.44%)
Mutual labels:  compression
unzip
Tiny unzip helper class for .NET 3.5 Client Profile and Mono 2.10, written in pure C#.
Stars: ✭ 25 (+38.89%)
Mutual labels:  compression
srcset.sh
A command line script that generates multiple responsive versions of an image at width breakpoints -- 320,480,640,768,960,1024,1280,1440 pixels wide -- that match common Mobile and widescreen desktop/laptop viewports using Imagemagick's convert utility and outputs the needed <img/> tag
Stars: ✭ 20 (+11.11%)
Mutual labels:  compression
deflate-rs
An implementation of a DEFLATE encoder in rust
Stars: ✭ 47 (+161.11%)
Mutual labels:  compression

huffman-compress

Huffman compression given a probability distribution over arbitrary symbols.

Build Status crates.io docs.rs No Maintenance Intended

Examples

use std::iter::FromIterator;
use std::collections::HashMap;
use bit_vec::BitVec;
use huffman_compress::{CodeBuilder, Book, Tree};

let mut weights = HashMap::new();
weights.insert("CG", 293);
weights.insert("AG", 34);
weights.insert("AT", 4);
weights.insert("CT", 4);
weights.insert("TG", 1);

// Construct a Huffman code based on the weights (e.g. counts or relative
// frequencies).
let (book, tree) = CodeBuilder::from_iter(weights).finish();

// More frequent symbols will be encoded with fewer bits.
assert!(book.get("CG").map_or(0, |cg| cg.len()) <
        book.get("AG").map_or(0, |ag| ag.len()));

// Encode some symbols using the book.
let mut buffer = BitVec::new();
let example = vec!["AT", "CG", "AT", "TG", "AG", "CT", "CT", "AG", "CG"];
for symbol in &example {
    book.encode(&mut buffer, symbol);
}

// Decode the symbols using the tree.
let decoded: Vec<&str> = tree.decoder(&buffer).collect();
assert_eq!(decoded, example);

Documentation

Read the documentation

Changelog

  • 0.6.1
    • Fix deprecation warning and remove #[deny(warnings)] (a future compatibility hazard in libraries).
  • 0.6.0
    • Update to bit-vec 0.6.
  • 0.5.0
    • Update to bit-vec 0.5.
  • 0.4.0
    • Renamed Tree::decoder() to Tree::unbounded_decoder() to avoid surprises. A new Tree::decoder() takes the maximum number of symbols to decode.
    • No longer reexporting Saturating from num-traits.
  • 0.3.2
    • Preallocate arena space for Huffman tree.
  • 0.3.1
    • Update num-traits to 0.2 (semver compatible).
  • 0.3.0
    • Introduce CodeBuilder.
    • Changes tie breaking order.
  • 0.2.0
    • Allow initialization from iterators without creating a HashMap. Thanks @mernen.
    • Require K: Ord instead of K: Hash + Eq for symbols and switch Book internals from HashMap to BTreeMap.
    • Specify stability guarantees.
  • 0.1.1
    • Expose more methods on Book.
  • 0.1.0
    • Initial release.

License

huffman-compress is dual licensed under the Apache 2.0 and MIT license, at your option.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].