scuffle_h264/lib.rs
1//! A pure Rust implementation of the H.264 (header only) builder and parser.
2//!
3//! This crate is designed to provide a simple and safe interface to build and parse H.264 headers.
4#![cfg_attr(feature = "docs", doc = "\n\nSee the [changelog][changelog] for a full release history.")]
5#![cfg_attr(feature = "docs", doc = "## Feature flags")]
6#![cfg_attr(feature = "docs", doc = document_features::document_features!())]
7//! ## Examples
8//!
9//! ### Parsing
10//!
11//! ```rust
12//! use std::io;
13//!
14//! use bytes::Bytes;
15//!
16//! use scuffle_h264::{AVCDecoderConfigurationRecord, Sps};
17//!
18//! // A sample h264 bytestream to parse
19//! # let bytes = Bytes::from(b"\x01d\0\x1f\xff\xe1\0\x17\x67\x64\x00\x1F\xAC\xD9\x41\xE0\x6D\xF9\xE6\xA0\x20\x20\x28\x00\x00\x00\x08\x00\x00\x01\xE0\x01\0\x06h\xeb\xe3\xcb\"\xc0\xfd\xf8\xf8\0".to_vec());
20//!
21//! // Parsing
22//! let result = AVCDecoderConfigurationRecord::parse(&mut io::Cursor::new(bytes)).unwrap();
23//!
24//! // Do something with it!
25//!
26//! // You can also parse an Sps from the Sps struct:
27//! let sps = Sps::parse_with_emulation_prevention(io::Cursor::new(&result.sps[0]));
28//! ```
29//!
30//! For more examples, check out the tests in the source code for the parse function.
31//!
32//! ### Building
33//!
34//! ```rust
35//! use bytes::Bytes;
36//!
37//! use scuffle_h264::{AVCDecoderConfigurationRecord, AvccExtendedConfig, Sps, SpsExtended};
38//!
39//! let extended_config = AvccExtendedConfig {
40//! chroma_format_idc: 1,
41//! bit_depth_luma_minus8: 0,
42//! bit_depth_chroma_minus8: 0,
43//! sequence_parameter_set_ext: vec![SpsExtended {
44//! chroma_format_idc: 1,
45//! separate_color_plane_flag: false,
46//! bit_depth_luma_minus8: 2,
47//! bit_depth_chroma_minus8: 3,
48//! qpprime_y_zero_transform_bypass_flag: false,
49//! scaling_matrix: vec![],
50//! }],
51//! };
52//! let config = AVCDecoderConfigurationRecord {
53//! configuration_version: 1,
54//! profile_indication: 100,
55//! profile_compatibility: 0,
56//! level_indication: 31,
57//! length_size_minus_one: 3,
58//! sps: vec![
59//! Bytes::from_static(b"spsdata"),
60//! ],
61//! pps: vec![Bytes::from_static(b"ppsdata")],
62//! extended_config: Some(extended_config),
63//! };
64//!
65//! // Creating a buffer to store the built bytestream
66//! let mut built = Vec::new();
67//!
68//! // Building
69//! config.build(&mut built).unwrap();
70//!
71//! // Do something with it!
72//! ```
73//!
74//! For more examples, check out the tests in the source code for the build function.
75//!
76//! ## License
77//!
78//! This project is licensed under the MIT or Apache-2.0 license.
79//! You can choose between one of them if you use this work.
80//!
81//! `SPDX-License-Identifier: MIT OR Apache-2.0`
82#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))]
83#![cfg_attr(docsrs, feature(doc_auto_cfg))]
84#![deny(missing_docs)]
85#![deny(unsafe_code)]
86#![deny(unreachable_pub)]
87
88mod config;
89mod enums;
90mod sps;
91
92pub use enums::*;
93pub use sps::*;
94
95pub use self::config::{AVCDecoderConfigurationRecord, AvccExtendedConfig};
96
97/// Changelogs generated by [scuffle_changelog]
98#[cfg(feature = "docs")]
99#[scuffle_changelog::changelog]
100pub mod changelog {}