Skip to main content

display_types/cea861/
video_capability.rs

1bitflags::bitflags! {
2    /// Flags from the Video Capability Data Block (extended tag `0x00`).
3    ///
4    /// Describes over-/underscan behaviour and quantization range support.
5    ///
6    /// | Bit | Mask   | Meaning                                          |
7    /// |-----|--------|--------------------------------------------------|
8    /// | 7   | `0x80` | QY: quantization range selectable (YCC)          |
9    /// | 6   | `0x40` | QS: quantization range selectable (RGB)          |
10    /// | 5–4 | `0x30` | PT: preferred PT behavior (2-bit field)          |
11    /// | 3–2 | `0x0C` | IT: IT content behavior (2-bit field)            |
12    /// | 1–0 | `0x03` | CE: CE content behavior (2-bit field)            |
13    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
15    pub struct VideoCapabilityFlags: u8 {
16        /// YCC quantization range is selectable (QY).
17        const QY = 0x80;
18        /// RGB quantization range is selectable (QS).
19        const QS = 0x40;
20    }
21}
22
23/// Decoded Video Capability Data Block (extended tag `0x00`).
24#[non_exhaustive]
25#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub struct VideoCapability {
28    /// Quantization range and overscan flags.
29    pub flags: VideoCapabilityFlags,
30    /// Preferred timing overscan/underscan behaviour (bits 5–4, 2-bit field).
31    pub pt_behaviour: u8,
32    /// IT content overscan/underscan behaviour (bits 3–2, 2-bit field).
33    pub it_behaviour: u8,
34    /// CE content overscan/underscan behaviour (bits 1–0, 2-bit field).
35    pub ce_behaviour: u8,
36}
37
38impl VideoCapability {
39    /// Constructs a `VideoCapability`.
40    pub fn new(
41        flags: VideoCapabilityFlags,
42        pt_behaviour: u8,
43        it_behaviour: u8,
44        ce_behaviour: u8,
45    ) -> Self {
46        Self {
47            flags,
48            pt_behaviour,
49            it_behaviour,
50            ce_behaviour,
51        }
52    }
53}