#[non_exhaustive]pub enum ColorSpace {
Bt709,
Bt470bg,
Smpte170m,
Bt2020Ncl,
Bt2020Cl,
Rgb,
Fcc,
Smpte240m,
Ycgco,
Unknown,
}Expand description
Color space (matrix coefficients) for YUV to RGB conversion.
The color space defines how YUV values are converted to RGB and vice versa. Different standards use different matrix coefficients for this conversion.
§Common Usage
- BT.709: HD content (720p, 1080p)
- BT.470BG / SMPTE-170M: SD content (576i PAL / 480i NTSC)
- BT.2020 NCL / CL: UHD/HDR content (4K, 8K)
- RGB: Identity matrix for RGB/GBR content
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bt709
ITU-R BT.709 — HD television matrix (most common for HD video)
Bt470bg
ITU-R BT.470BG — BT.601 625-line (PAL/SECAM SD) matrix
Smpte170m
SMPTE 170M — BT.601 525-line (NTSC SD) matrix
Bt2020Ncl
ITU-R BT.2020 non-constant luminance — UHD/HDR matrix
Bt2020Cl
ITU-R BT.2020 constant luminance — UHD/HDR matrix
Rgb
Identity / RGB (GBR planar) — no YUV matrix
Fcc
FCC — legacy NTSC 1953 matrix
Smpte240m
SMPTE 240M — legacy HD matrix
Ycgco
YCgCo — reversible YCgCo matrix
Unknown
Color space matrix is not specified or unknown
Implementations§
Source§impl ColorSpace
impl ColorSpace
Sourcepub const fn name(&self) -> &'static str
pub const fn name(&self) -> &'static str
Returns the name of the color space as a human-readable string.
§Examples
use ff_format::color::ColorSpace;
assert_eq!(ColorSpace::Bt709.name(), "bt709");
assert_eq!(ColorSpace::Bt2020Ncl.name(), "bt2020ncl");Sourcepub const fn is_hd(&self) -> bool
pub const fn is_hd(&self) -> bool
Returns true if this is the HD matrix (BT.709).
§Examples
use ff_format::color::ColorSpace;
assert!(ColorSpace::Bt709.is_hd());
assert!(!ColorSpace::Smpte170m.is_hd());Sourcepub const fn is_sd(&self) -> bool
pub const fn is_sd(&self) -> bool
Returns true if this is an SD matrix (BT.601: BT.470BG or SMPTE-170M).
§Examples
use ff_format::color::ColorSpace;
assert!(ColorSpace::Smpte170m.is_sd());
assert!(!ColorSpace::Bt709.is_sd());Sourcepub const fn is_uhd(&self) -> bool
pub const fn is_uhd(&self) -> bool
Returns true if this is a UHD/HDR matrix (BT.2020 NCL or CL).
§Examples
use ff_format::color::ColorSpace;
assert!(ColorSpace::Bt2020Ncl.is_uhd());
assert!(!ColorSpace::Bt709.is_uhd());Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns true if the color space is unknown.
§Examples
use ff_format::color::ColorSpace;
assert!(ColorSpace::Unknown.is_unknown());
assert!(!ColorSpace::Bt709.is_unknown());Trait Implementations§
Source§impl Clone for ColorSpace
impl Clone for ColorSpace
Source§fn clone(&self) -> ColorSpace
fn clone(&self) -> ColorSpace
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ColorSpace
Source§impl Debug for ColorSpace
impl Debug for ColorSpace
Source§impl Default for ColorSpace
impl Default for ColorSpace
Source§fn default() -> ColorSpace
fn default() -> ColorSpace
Source§impl Display for ColorSpace
impl Display for ColorSpace
impl Eq for ColorSpace
Source§impl Hash for ColorSpace
impl Hash for ColorSpace
Source§impl PartialEq for ColorSpace
impl PartialEq for ColorSpace
Source§fn eq(&self, other: &ColorSpace) -> bool
fn eq(&self, other: &ColorSpace) -> bool
self and other values to be equal, and is used by ==.