| Crates.io | zimtohrli-sys |
| lib.rs | zimtohrli-sys |
| version | 0.2.0 |
| created_at | 2025-12-14 15:36:28.435606+00 |
| updated_at | 2025-12-26 06:14:26.391394+00 |
| description | Rust FFI bindings to the Zimtohrli psychoacoustic audio metric |
| homepage | https://github.com/xnorpx/rust-zimtohrli |
| repository | https://github.com/xnorpx/rust-zimtohrli |
| max_upload_size | |
| id | 1984632 |
| size | 74,330 |
Low-level Rust FFI bindings to the Zimtohrli psychoacoustic perceptual audio metric library.
Zimtohrli is a psychoacoustic perceptual metric that quantifies the human-observable difference between two audio signals. It's particularly focused on just-noticeable-differences for high-quality audio compression evaluation. For more details, see the paper.
Add to your Cargo.toml:
[dependencies]
zimtohrli-sys = "0.2"
use zimtohrli_sys::ffi;
fn main() {
// Create a new Zimtohrli analyzer
let zimtohrli = ffi::new_zimtohrli();
// Audio samples must be:
// - f32 values in range [-1.0, 1.0]
// - 48kHz sample rate
// - Mono
let samples_a: Vec<f32> = load_audio_a(); // your audio loading code
let samples_b: Vec<f32> = load_audio_b();
// Analyze both signals to get spectrograms
let mut spec_a = zimtohrli.analyze(&samples_a);
let mut spec_b = zimtohrli.analyze(&samples_b);
// Compute perceptual distance
// Returns value in [0, 1] where:
// - 0 = identical
// - 1 = maximally different
let distance = zimtohrli.distance(spec_a.pin_mut(), spec_b.pin_mut());
println!("Perceptual distance: {}", distance);
}
By default this crate enables compiler fast-math flags for the C++ bridge, which may change numerical results.
-fassociative-math -freciprocal-math -fno-signed-zeros -fno-math-errno/fp:fastTo disable it:
[dependencies]
zimtohrli-sys = { version = "0.1", default-features = false }
This crate vendors the zimtohrli.h header from the upstream repository. See vendor/ZIMTOHRLI_VERSION for the exact version information.
This crate is licensed under the Apache License 2.0, matching the upstream Zimtohrli library.