Skip to main content

msrtc_rans_core/
lib.rs

1// Licensed under the MIT license.
2// Author: Riaan de Beer - github.com/infinityabundance - rdebeer.infinityabundance@gmail.com
3// Derived from Microsoft MLVC msrtc_rans (MIT)
4// See NOTICE file for attribution.
5
6#![no_std]
7#![forbid(unsafe_code)]
8#![allow(missing_docs)]
9#![allow(clippy::assign_op_pattern)]
10
11//! # msrtc-rans-core
12//!
13//! Deterministic, no_std-capable rANS primitives for the msrtc_rans entropy coder.
14//!
15//! This crate implements the raw rANS encoding and decoding primitives used by
16//! Microsoft MLVC's `msrtc_rans` package. The arithmetic (reciprocal preparation,
17//! Mul64Hi, fast division) is structurally faithful to the C++ implementation.
18//!
19//! **Status:** The encoder and decoder equations, constants, and symbol preparation
20//! are implemented and self-consistent. Byte-level parity against the pinned
21//! Microsoft C++ oracle has not yet been established by differential court.
22//! See the `msrtc-rans-court` crate for ongoing parity verification.
23
24extern crate alloc;
25
26pub mod arithmetic;
27pub mod error;
28pub mod raw;
29pub mod sink;
30pub mod source;
31pub mod variant;
32
33/// Frequency type used throughout the rANS implementation - corresponds to `rans_freq_t` (uint32_t)
34pub type Freq = u32;
35
36pub use error::RawRansError;
37/// Re-export key types for convenience.
38pub use raw::{
39    Rans64DecSymbol, Rans64Decoder, Rans64EncSymbol, Rans64Encoder, RansByteDecSymbol,
40    RansByteDecoder, RansByteEncSymbol, RansByteEncoder,
41};
42pub use variant::RansVariant;