forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

h264_common.rs31 lines, 1017 bytesHistoryRawDownload
1use ec_core::color::Tags;
2use ec_h264_syntax::Sps;
3
4use crate::error::Result;
5
6/// An SPS's VUI `colour_description` and range flag, as [`Tags`] for
7/// [`ec_core::color::ColorDescription::resolve`]. [`Tags::default()`] when the VUI has no
8/// `video_signal_type` at all.
9pub(crate) fn vui_colour_tags(sps: &Sps) -> Tags {
10 let Some(vui) = &sps.vui else {
11 return Tags::default();
12 };
13 if vui.video_format.is_none() {
14 return Tags::default();
15 }
16 let (_primaries, transfer, matrix) = vui.colour_description.unwrap_or((0, 0, 0));
17 Tags::from_codes(
18 u64::from(matrix),
19 u64::from(transfer),
20 if vui.video_full_range { 2 } else { 1 },
21 )
22}
23
24/// The `pic_parameter_set_id` of a slice header, which is the second syntax
25/// element and needs no parameter set to read.
26pub(crate) fn peek_pps_id(rbsp: &[u8]) -> Result<u32> {
27 let mut r = ec_core::BitReader::new(rbsp);
28 r.read_ue()?; // first_mb_in_slice
29 r.read_ue()?; // slice_type
30 Ok(r.read_ue()?)
31}