#[non_exhaustive]pub enum Color {
Bt601Limited,
Bt601Full,
Bt709Limited,
Bt709Full,
}Expand description
Which YUV color space a frame’s samples are in.
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) as does the numeric range (limited/studio swing pins luma to 16..235, full/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.
Surface::color reports it where the crate knows:
when the crate did the conversion itself, or when the surface carries the
answer (a macOS pixel buffer names its matrix, which VideoToolbox copies out
of the stream’s VUI). 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.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bt601Limited
BT.601 (standard definition), limited range.
Bt601Full
BT.601 (standard definition), full range.
Bt709Limited
BT.709 (high definition), limited range.
Bt709Full
BT.709 (high definition), full range.
Implementations§
Source§impl Color
impl Color
Sourcepub fn infer(size: Size) -> Self
pub fn infer(size: Size) -> Self
The conventional guess for a frame of this size: BT.601 up to standard definition (576 lines), BT.709 above it, both limited range.
What a player does when the bitstream carries no VUI color description,
which is most of the time. A guess, so prefer a known Color whenever
one is available.