forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiBddf43e8Tahinli2 months ago3186 commits

lib.rs46 lines, 2.0 KiBHistoryRawDownload
1//! HEVC bitstream syntax: NAL framing, parameter sets, slice headers, SEI.
2//!
3//! This crate is the half of H.265 that both a software encoder and a *stateless
4//! hardware* decoder need, and it is deliberately the same code for both
5//! directions: every structure here is written and parsed, so a round trip is a
6//! test rather than an article of faith.
7//!
8//! What that buys, concretely:
9//!
10//! - The conformance window is a field on [`Sps`], not a caller's padding
11//! problem. 1920x1080 in 64x64 coding tree blocks is coded 1920x1088 and
12//! cropped by the SPS; [`Sps::display_size`] gives back what a player shows.
13//! - Every field of `VAPictureParameterBufferHEVC` and
14//! `VASliceParameterBufferHEVC` is either a field on [`Sps`], [`Pps`] or
15//! [`SliceHeader`], or a named method on one of them —
16//! [`Sps::pic_width_in_ctbs`], [`ParsePositions::slice_data_byte_offset`],
17//! [`ParsePositions::st_rps_bits`]. A hardware decode path built on this crate
18//! should never need to re-parse a header itself.
19//! - [`sei::decoded_picture_hash_rbsp`] writes the MD5 of the reconstruction, so
20//! any conformant decoder can be asked whether the encoder was right.
21//!
22//! Malformed input is an [`Error`](ec_core::Error), never a panic: truncation is
23//! `NeedMore`, a rule violation is `Corrupt`, and the two constructs the family
24//! genuinely does not implement (scaling lists, and short-term reference picture
25//! sets predicted from an SPS set that a caller did not keep) are `Unsupported`
26//! with the reason stated.
27
28#![forbid(unsafe_code)]
29#![warn(missing_docs)]
30
31mod md5;
32pub mod nal;
33pub mod ps;
34pub mod sei;
35pub mod slice;
36pub mod vui;
37
38pub use nal::{AnnexBNal, NalHeader, NalUnitType, escape_rbsp, split_annex_b, unescape_rbsp};
39pub use ps::{
40 ConformanceWindow, MAX_ST_REF_PICS, Pps, ProfileTierLevel, ShortTermRefPicSet, Sps, Vps,
41};
42pub use slice::{
43 LongTermRef, ParsePositions, PredWeightTable, SliceHeader, SliceType, WeightEntry,
44 count_emulation_prevention_bytes,
45};
46pub use vui::{ColourDescription, VideoSignalType, VuiParameters};