use ec_core::color::Tags; use ec_h264_syntax::Sps; use crate::error::Result; /// An SPS's VUI `colour_description` and range flag, as [`Tags`] for /// [`ec_core::color::ColorDescription::resolve`]. [`Tags::default()`] when the VUI has no /// `video_signal_type` at all. pub(crate) fn vui_colour_tags(sps: &Sps) -> Tags { let Some(vui) = &sps.vui else { return Tags::default(); }; if vui.video_format.is_none() { return Tags::default(); } let (_primaries, transfer, matrix) = vui.colour_description.unwrap_or((0, 0, 0)); Tags::from_codes( u64::from(matrix), u64::from(transfer), if vui.video_full_range { 2 } else { 1 }, ) } /// The `pic_parameter_set_id` of a slice header, which is the second syntax /// element and needs no parameter set to read. pub(crate) fn peek_pps_id(rbsp: &[u8]) -> Result { let mut r = ec_core::BitReader::new(rbsp); r.read_ue()?; // first_mb_in_slice r.read_ue()?; // slice_type Ok(r.read_ue()?) }