Skip to main content

rusty_h264_common/
lib.rs

1//! Shared primitives for the `rusty_h264` pure-Rust H.264 codec.
2//!
3//! This crate is the foundation both the encoder and decoder sit on. It is
4//! `#![forbid(unsafe_code)]`: the bit-twiddling core of an H.264 codec is
5//! exactly where memory-safety bugs hide in the C implementations, so we keep
6//! it provably safe.
7//!
8//! Modules mirror the concerns shared across `codec/common` in Cisco's
9//! openh264:
10//! - [`bit_writer`] / [`bit_reader`] — MSB-first bit packing + Exp-Golomb.
11//! - [`nal`] — NAL units, Annex-B framing, RBSP emulation prevention.
12//! - [`types`] — shared enums and the raw YUV frame container.
13//!
14//! The shipped build is `#![forbid(unsafe_code)]`. The `profile` feature (a
15//! measurement-only dev build, never shipped) relaxes this to unlock the `rdtsc`
16//! timer in [`prof`]; that is the *only* unsafe in the crate and only under `profile`.
17#![cfg_attr(not(feature = "profile"), forbid(unsafe_code))]
18
19pub mod aligned;
20pub mod bit_reader;
21pub mod bit_writer;
22pub mod cabac_tables;
23pub mod cavlc;
24pub mod deblock;
25
26/// Whether the vendored SIMD kernels are compiled in (`asm` feature on x86-64).
27/// Exposed so benchmarks can state which path they measured — a harness that
28/// silently falls back to the scalar twin reports numbers that look like a
29/// regression in the fast path.
30pub const ACCEL: bool = cfg!(accel);
31pub mod inter;
32pub mod nal;
33pub mod predict;
34pub mod prof;
35pub mod transform;
36pub mod types;
37
38pub use bit_reader::BitReader;
39pub use bit_writer::BitWriter;
40pub use nal::{NalUnit, NalUnitType};
41pub use types::{ChromaFormat, Profile, YuvFrame};