#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MatrixCoefficients {
Identity = 0,
Bt709 = 1,
Unspecified = 2,
Bt601 = 6,
Bt2020Ncl = 9,
YCgCo = 8,
}
impl MatrixCoefficients {
#[must_use]
pub fn code_point(self) -> u16 {
self as u16
}
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ColourPrimaries {
Bt709 = 1,
Unspecified = 2,
Bt601Pal = 5,
Smpte170m = 6,
Bt2020 = 9,
DisplayP3 = 12,
}
impl ColourPrimaries {
#[must_use]
pub fn code_point(self) -> u16 {
self as u16
}
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum TransferCharacteristics {
Bt709 = 1,
Unspecified = 2,
Srgb = 13,
Bt2020_10 = 14,
Pq = 16,
Hlg = 18,
}
impl TransferCharacteristics {
#[must_use]
pub fn code_point(self) -> u16 {
self as u16
}
}
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ColorRange {
Limited = 0,
Full = 1,
}
impl ColorRange {
#[must_use]
pub fn flag(self) -> u8 {
self as u8
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn code_points_match_spec() {
assert_eq!(MatrixCoefficients::Identity.code_point(), 0);
assert_eq!(MatrixCoefficients::Bt709.code_point(), 1);
assert_eq!(ColourPrimaries::Bt709.code_point(), 1);
assert_eq!(TransferCharacteristics::Srgb.code_point(), 13);
assert_eq!(TransferCharacteristics::Pq.code_point(), 16);
assert_eq!(ColorRange::Full.flag(), 1);
assert_eq!(ColorRange::Limited.flag(), 0);
}
}