General purpose utility methods for creating lossless transforms for various file formats.
This crate provides tools to estimate data compressibility:
- Histogram: Count byte frequencies in data
- Entropy: Calculate ideal bits-per-byte (how compressible by entropy coders)
- Match Estimator: Estimate LZ match count (how compressible by LZ-based compressors)
Use these to compare different data transformations and determine which yields better compression.
Add to your Cargo.toml:
[dependencies]
lossless-transform-utils = "0.1.3"use lossless_transform_utils::histogram::{histogram32_from_bytes, Histogram32};
use lossless_transform_utils::entropy::code_length_of_histogram32;
use lossless_transform_utils::match_estimator::estimate_num_lz_matches_fast;
// Calculate byte histogram
let data = [1, 2, 3, 1, 2, 1];
let mut histogram = Histogram32::default();
histogram32_from_bytes(&data, &mut histogram);
// Calculate entropy (bits per byte)
let entropy = code_length_of_histogram32(&histogram, data.len() as u64);
// Estimate LZ matches
let num_matches = estimate_num_lz_matches_fast(&data);See the lossless-transform-utils crate documentation for detailed usage, feature flags, performance numbers, and comprehensive examples.
- lossless-transform-utils: Core library with histogram, entropy, and LZ match estimation utilities
For step-by-step development guidance, see the Developer Manual.
We welcome contributions! See the Contributing Guide for details.
Licensed under MIT.