Skip to main content

msrtc_rans_core/
lib.rs

1// Copyright (c) Infinity Abundance.
2// Licensed under the MIT license.
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 raw;
28pub mod sink;
29pub mod source;
30pub mod variant;
31
32/// Frequency type used throughout the rANS implementation - corresponds to `rans_freq_t` (uint32_t)
33pub type Freq = u32;
34
35/// Re-export key types for convenience.
36pub use raw::{
37    Rans64DecSymbol, Rans64Decoder, Rans64EncSymbol, Rans64Encoder, RansByteDecSymbol,
38    RansByteDecoder, RansByteEncSymbol, RansByteEncoder,
39};
40pub use variant::RansVariant;