Expand description
Shared primitives for the rusty_h264 pure-Rust H.264 codec.
This crate is the foundation both the encoder and decoder sit on. It is
#![forbid(unsafe_code)]: the bit-twiddling core of an H.264 codec is
exactly where memory-safety bugs hide in the C implementations, so we keep
it provably safe.
Modules mirror the concerns shared across codec/common in Cisco’s
openh264:
bit_writer/bit_reader— MSB-first bit packing + Exp-Golomb.nal— NAL units, Annex-B framing, RBSP emulation prevention.types— shared enums and the raw YUV frame container.
The shipped build is #![forbid(unsafe_code)]. The profile feature (a
measurement-only dev build, never shipped) relaxes this to unlock the rdtsc
timer in prof; that is the only unsafe in the crate and only under profile.
Re-exports§
pub use bit_reader::BitReader;pub use bit_writer::BitWriter;pub use nal::NalUnit;pub use nal::NalUnitType;pub use types::ChromaFormat;pub use types::Profile;pub use types::YuvFrame;
Modules§
- aligned
- A 16-byte-aligned heap byte buffer for the openh264 spatial asm kernels.
- bit_
reader - MSB-first bit reader with H.264 Exp-Golomb decoding.
- bit_
writer - MSB-first bit writer with H.264 Exp-Golomb coding.
- cabac_
tables - CABAC tables ported verbatim from openh264
common_tables.cpp(spec Tables 9-44/9-45 and 9-12..9-33). 460 contexts, 4 init models [I,idc0,idc1,idc2].CTX_NAsentinels (I-slice-unused contexts) are 0 as in openh264. - cavlc
- CAVLC — Context-Adaptive Variable-Length Coding of residual blocks.
- deblock
- In-loop deblocking filter (spec §8.7), all-intra case.
- inter
- Inter prediction primitives: motion compensation and motion-vector prediction. Shared by the encoder (reconstruction) and decoder so the two agree bit-for-bit. Motion vectors are in quarter-pel units; phase 4b uses the integer part only (full-pel), with the 6-tap/bilinear sub-pel filters arriving in 4c.
- nal
- NAL units, Annex-B framing, and RBSP emulation-prevention.
- predict
- Intra prediction + shared block reconstruction for I_16x16 macroblocks.
- prof
- Feature-gated decode/encode stage profiler — the instrument for perf work.
- transform
- H.264 4×4 residual transform and quantization (spec §8.5 / §8.6).
- types
- Shared codec types: profiles, chroma format, and the raw YUV frame container.
Constants§
- ACCEL
- Whether the vendored SIMD kernels are compiled in (
asmfeature on x86-64). Exposed so benchmarks can state which path they measured — a harness that silently falls back to the scalar twin reports numbers that look like a regression in the fast path.