pub struct Color {
pub matrix: Matrix,
pub range: Range,
pub primaries: Primaries,
pub transfer: Transfer,
}Expand description
Which color space a frame’s samples are in: the YUV matrix and range that decode them to RGB, and the primaries and transfer curve that RGB means.
Video carries luma and chroma, not RGB, and the matrix that converts between them differs by generation (BT.601 for standard definition, BT.709 for high definition, BT.2020 for UHD) as does the numeric range (limited/studio swing pins luma to 16..235, full swing uses 0..255). Pairing samples with the wrong matrix is the classic tinted-video bug: it leaves grays untouched and skews saturated colors, so it survives a casual look at the picture. The primaries and transfer travel separately because sources mix them: a BT.601 matrix over BT.709 primaries is common, and HDR changes only the transfer.
Surface::color reports it where the crate knows:
when the crate did the conversion itself, when a decoder read the stream’s
VUI, or when the surface carries the answer. It is None for pixels that
merely passed through with nothing naming their space, a camera’s raw YUYV
among them. Color::infer is the fallback then.
Build one from BT601 or BT709 and change
the fields that differ:
use moq_video::Color;
use moq_video::color::{Primaries, Range};
let jpeg = Color { range: Range::Full, ..Color::BT601 };
let webcam = Color { primaries: Primaries::Bt709, ..Color::BT601 };Fields§
§matrix: MatrixThe matrix between RGB and Y’CbCr.
range: RangeThe numeric range of the samples.
primaries: PrimariesThe chromaticities of the RGB primaries.
transfer: TransferThe curve between linear light and the RGB values.
Implementations§
Trait Implementations§
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.