Skip to main content

colr_types/model/
ycbcr.rs

1//! YCbCr color model.
2
3use core::marker::PhantomData;
4
5use crate::BackingStore;
6use crate::layout::{Ycbcr, YCbCrLayout};
7use crate::primaries::Primaries;
8use crate::transfer::TransferFunction;
9
10/// YCbCr derived from an RGB space with primaries P and transfer function TF.
11///
12/// Y' is luma, Cb is scaled blue chroma difference, Cr is scaled red chroma
13/// difference. The conversion matrix is derived from the primaries' luma
14/// weights. Used in JPEG, H.264, H.265, and broadcast video. Layout defaults
15/// to `Ycbcr`.
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
17pub struct YCbCr<P: Primaries, TF: TransferFunction, L: YCbCrLayout = Ycbcr>(
18    PhantomData<(P, TF, L)>,
19);
20
21impl<P: Primaries, TF: TransferFunction, L: YCbCrLayout + BackingStore<[f32; 3]>>
22    BackingStore<[f32; 3]> for YCbCr<P, TF, L>
23{
24}
25impl<P: Primaries, TF: TransferFunction, L: YCbCrLayout + BackingStore<[f32; 4]>>
26    BackingStore<[f32; 4]> for YCbCr<P, TF, L>
27{
28}