scuffle_h265/sps/
conformance_window.rs

1use std::io;
2
3use scuffle_bytes_util::BitReader;
4use scuffle_expgolomb::BitReaderExpGolombExt;
5
6/// Specifies the samples of the pictures in the CVS that are output from the decoding process, in terms of a rectangular
7/// region specified in picture coordinates for output.
8///
9/// Directly part of [SPS RBSP](crate::SpsRbsp).
10#[derive(Debug, Clone, PartialEq, Default)]
11pub struct ConformanceWindow {
12    /// The the left crop offset which is used to compute the [`croppedWidth`](crate::SpsRbsp::cropped_width).
13    pub conf_win_left_offset: u64,
14    /// The the right crop offset which is used to compute the [`croppedWidth`](crate::SpsRbsp::cropped_width).
15    pub conf_win_right_offset: u64,
16    /// The top crop offset which is used to compute the [`croppedHeight`](crate::SpsRbsp::cropped_height).
17    pub conf_win_top_offset: u64,
18    /// The bottom crop offset which is used to compute the [`croppedHeight`](crate::SpsRbsp::cropped_height).
19    pub conf_win_bottom_offset: u64,
20}
21
22impl ConformanceWindow {
23    pub(crate) fn parse<R: io::Read>(reader: &mut BitReader<R>) -> io::Result<Self> {
24        let conf_win_left_offset = reader.read_exp_golomb()?;
25        let conf_win_right_offset = reader.read_exp_golomb()?;
26        let conf_win_top_offset = reader.read_exp_golomb()?;
27        let conf_win_bottom_offset = reader.read_exp_golomb()?;
28
29        Ok(ConformanceWindow {
30            conf_win_left_offset,
31            conf_win_right_offset,
32            conf_win_top_offset,
33            conf_win_bottom_offset,
34        })
35    }
36}