1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Shared primitives for the `rusty_h264` pure-Rust H.264 codec.
//!
//! # Global allocator
//!
//! The optional `global-alloc` feature installs [`rusty_alloc`] as the process-wide
//! allocator. It is **off by default**, because an allocator belongs in a deliverable
//! and this is a published library:
//!
//! 1. `#[global_allocator]` is PROCESS-WIDE and there may be exactly one. A downstream
//! consumer that declares its own (jemalloc, mimalloc, a custom arena) would get a
//! hard compile error from a default-on allocator here.
//! 2. Cargo features are ADDITIVE and unify across the whole graph, so a single
//! transitive dependency enabling it would turn the allocator on for a consumer's
//! entire program with no way to switch it off locally.
//!
//! The binaries that ship — `rusty_h264-cli` and the `bench` harness — enable it
//! explicitly, so every measured and shipped route still runs on `rusty_alloc`.
//! Library consumers who want it can opt in with
//! `features = ["rusty_h264-common/global-alloc"]`.
//!
//! 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`.
/// Process-wide allocator (see the crate docs for the two hazards this carries).
static ALLOC: RustyAlloc = RustyAlloc;
/// Whether the vendored SIMD kernels are compiled in (`asm` feature 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.
pub const ACCEL: bool = cfg!;
pub use BitReader;
pub use BitWriter;
pub use ;
pub use ;