#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum YuvMatrix {
#[default]
Bt709,
Bt601,
Bt2020,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct YuvColors {
pub matrix: YuvMatrix,
pub full_range: bool,
}
impl YuvColors {
pub const BT709: Self = Self {
matrix: YuvMatrix::Bt709,
full_range: false,
};
pub fn new(matrix: YuvMatrix) -> Self {
Self {
matrix,
full_range: false,
}
}
pub fn full_range(mut self) -> Self {
self.full_range = true;
self
}
#[cfg(all(windows, feature = "raster", any(feature = "wgpu", feature = "dx12")))]
pub(crate) fn shader(self) -> [f32; 2] {
let matrix = match self.matrix {
YuvMatrix::Bt709 => 0.0,
YuvMatrix::Bt601 => 1.0,
YuvMatrix::Bt2020 => 2.0,
};
[matrix, if self.full_range { 1.0 } else { 0.0 }]
}
}