#[non_exhaustive]pub enum ColorMatrix {
Show 19 variants
Unknown(u32),
Rgb,
Bt601,
Bt709,
Unspecified,
Fcc,
Bt470Bg,
Smpte170M,
Smpte240m,
YCgCo,
Bt2020Ncl,
Bt2020Cl,
Smpte2085,
ChromaDerivedNcl,
ChromaDerivedCl,
Ictcp,
IptC2,
YCgCoRe,
YCgCoRo,
}Expand description
Color matrix coefficients per ITU-T H.273 MatrixCoefficients (Table 4) / ISO/IEC 23001-8.
Read from AVFrame.colorspace / VideoColorSpace.matrix /
kCVImageBufferYCbCrMatrixKey.
This type’s stored Default is Self::Unspecified (FFmpeg
AVCOL_SPC_UNSPECIFIED, code 2). For AVCOL_SPC_UNSPECIFIED,
FFmpeg’s convention picks BT.709 for sources with height >= 720
and BT.601 otherwise — that is a consumer-side resolution of
Unspecified applied at read time, not a stored value (the
Bt601 reference there denotes the Self::Bt601 domain
variant below).
Self::to_u32 / Self::from_u32 use the FFmpeg
AVColorSpace code points (ITU-T H.273 MatrixCoefficients);
FFmpeg is the source of truth (the downstream consumer reads these
via a buffa extern_path). Self::Bt601 is a
mediaframe-domain id (no H.273 code; see DOMAIN_EXT_BASE).
Self::Unknown carries any unrecognised code through unchanged
so the round-trip is lossless.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unknown(u32)
Unknown / unrecognised AVColorSpace code. The wrapped u32
is the original value passed to Self::from_u32 — preserved
so round-tripping unknown codes is lossless.
Rgb
GBR (sRGB / ST 428-1); FFmpeg AVCOL_SPC_RGB (code 0).
Bt601
mediaframe-domain unified ITU-R BT.601 YCbCr matrix
(Kr=0.299, Kb=0.114). H.273 has no single BT.601 code: it
splits into Self::Bt470Bg (625-line) and Self::Smpte170M
(525-line), which carry the identical coefficients. The FFmpeg
ingest path therefore yields those two, never Bt601;
RAW / SDK backends and explicit domain tagging use Bt601. Its
id is in the domain-extension band (see DOMAIN_EXT_BASE),
never an FFmpeg code.
Bt709
ITU-R BT.709 (HDTV).
Unspecified
Unspecified — caller infers (FFmpeg’s height >= 720 →
BT.709, else BT.601 rule is applied downstream).
Fcc
FCC CFR 47 §73.682 (legacy NTSC, very close to BT.601 numerically).
Bt470Bg
ITU-R BT.470 System BG / BT.601 625 (SDTV; identical coefficients to SMPTE170M).
Smpte170M
SMPTE 170M / BT.601 525 (SDTV).
Smpte240m
SMPTE 240M (legacy 1990s HDTV).
YCgCo
YCgCo per ITU-T H.273 MatrixCoefficients = 8.
Bt2020Ncl
ITU-R BT.2020 non-constant-luminance (UHDTV / HDR10).
Bt2020Cl
ITU-R BT.2020 constant-luminance.
Smpte2085
SMPTE 2085 (Y’D’zD’x).
ChromaDerivedNcl
Chromaticity-derived non-constant luminance.
ChromaDerivedCl
Chromaticity-derived constant luminance.
Ictcp
ITU-R BT.2100-0 ICtCp.
IptC2
SMPTE ST 2128 IPT-C2.
YCgCoRe
YCgCo-R, even bit addition.
YCgCoRo
YCgCo-R, odd bit addition.
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns true if this value is of type Unknown. Returns false otherwise
Sourcepub const fn is_rgb(&self) -> bool
pub const fn is_rgb(&self) -> bool
Returns true if this value is of type Rgb. Returns false otherwise
Sourcepub const fn is_bt_601(&self) -> bool
pub const fn is_bt_601(&self) -> bool
Returns true if this value is of type Bt601. Returns false otherwise
Sourcepub const fn is_bt_709(&self) -> bool
pub const fn is_bt_709(&self) -> bool
Returns true if this value is of type Bt709. Returns false otherwise
Sourcepub const fn is_unspecified(&self) -> bool
pub const fn is_unspecified(&self) -> bool
Returns true if this value is of type Unspecified. Returns false otherwise
Sourcepub const fn is_fcc(&self) -> bool
pub const fn is_fcc(&self) -> bool
Returns true if this value is of type Fcc. Returns false otherwise
Sourcepub const fn is_bt_470_bg(&self) -> bool
pub const fn is_bt_470_bg(&self) -> bool
Returns true if this value is of type Bt470Bg. Returns false otherwise
Sourcepub const fn is_smpte_170_m(&self) -> bool
pub const fn is_smpte_170_m(&self) -> bool
Returns true if this value is of type Smpte170M. Returns false otherwise
Sourcepub const fn is_smpte_240_m(&self) -> bool
pub const fn is_smpte_240_m(&self) -> bool
Returns true if this value is of type Smpte240m. Returns false otherwise
Sourcepub const fn is_y_cg_co(&self) -> bool
pub const fn is_y_cg_co(&self) -> bool
Returns true if this value is of type YCgCo. Returns false otherwise
Sourcepub const fn is_bt_2020_ncl(&self) -> bool
pub const fn is_bt_2020_ncl(&self) -> bool
Returns true if this value is of type Bt2020Ncl. Returns false otherwise
Sourcepub const fn is_bt_2020_cl(&self) -> bool
pub const fn is_bt_2020_cl(&self) -> bool
Returns true if this value is of type Bt2020Cl. Returns false otherwise
Sourcepub const fn is_smpte_2085(&self) -> bool
pub const fn is_smpte_2085(&self) -> bool
Returns true if this value is of type Smpte2085. Returns false otherwise
Sourcepub const fn is_chroma_derived_ncl(&self) -> bool
pub const fn is_chroma_derived_ncl(&self) -> bool
Returns true if this value is of type ChromaDerivedNcl. Returns false otherwise
Sourcepub const fn is_chroma_derived_cl(&self) -> bool
pub const fn is_chroma_derived_cl(&self) -> bool
Returns true if this value is of type ChromaDerivedCl. Returns false otherwise
Sourcepub const fn is_ictcp(&self) -> bool
pub const fn is_ictcp(&self) -> bool
Returns true if this value is of type Ictcp. Returns false otherwise
Sourcepub const fn is_ipt_c_2(&self) -> bool
pub const fn is_ipt_c_2(&self) -> bool
Returns true if this value is of type IptC2. Returns false otherwise
Sourcepub const fn is_y_cg_co_re(&self) -> bool
pub const fn is_y_cg_co_re(&self) -> bool
Returns true if this value is of type YCgCoRe. Returns false otherwise
Sourcepub const fn is_y_cg_co_ro(&self) -> bool
pub const fn is_y_cg_co_ro(&self) -> bool
Returns true if this value is of type YCgCoRo. Returns false otherwise
Source§impl Matrix
impl Matrix
Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Lowercase FFmpeg-style identifier for this variant
(AVCOL_SPC_* slug).
Sourcepub const fn to_u32(&self) -> u32
pub const fn to_u32(&self) -> u32
Stable wire id — the FFmpeg AVColorSpace code point
(ITU-T H.273 MatrixCoefficients) for the H.273 variants, or a
mediaframe-domain id >= DOMAIN_EXT_BASE for concepts
H.273 does not enumerate (Self::Bt601 is the first, at
offset 0). Self::Unknown carries its original u32
through unchanged so from_u32(to_u32(x)) == x for every x.
Note Rgb is code 0 (non-default, so the buffa codec
encodes it explicitly).
Sourcepub const fn from_u32(v: u32) -> Matrix
pub const fn from_u32(v: u32) -> Matrix
Decodes from the code produced by Self::to_u32. FFmpeg
AVColorSpace codes map to their H.273 variant — in particular
5/6 decode to Self::Bt470Bg/Self::Smpte170M,
never Self::Bt601 (the FFmpeg ingest path never yields a
domain variant). DOMAIN_EXT_BASE (offset 0) decodes to the
mediaframe-domain Self::Bt601. Any other unrecognised code
(including reserved code 3, or an unassigned >= DOMAIN_EXT_BASE id) maps to Self::Unknown carrying the
original value, so the round-trip is lossless.