Skip to main content

ColorMatrix

Enum ColorMatrix 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

pub const fn is_unknown(&self) -> bool

Returns true if this value is of type Unknown. Returns false otherwise

Source

pub const fn is_rgb(&self) -> bool

Returns true if this value is of type Rgb. Returns false otherwise

Source

pub const fn is_bt_601(&self) -> bool

Returns true if this value is of type Bt601. Returns false otherwise

Source

pub const fn is_bt_709(&self) -> bool

Returns true if this value is of type Bt709. Returns false otherwise

Source

pub const fn is_unspecified(&self) -> bool

Returns true if this value is of type Unspecified. Returns false otherwise

Source

pub const fn is_fcc(&self) -> bool

Returns true if this value is of type Fcc. Returns false otherwise

Source

pub const fn is_bt_470_bg(&self) -> bool

Returns true if this value is of type Bt470Bg. Returns false otherwise

Source

pub const fn is_smpte_170_m(&self) -> bool

Returns true if this value is of type Smpte170M. Returns false otherwise

Source

pub const fn is_smpte_240_m(&self) -> bool

Returns true if this value is of type Smpte240m. Returns false otherwise

Source

pub const fn is_y_cg_co(&self) -> bool

Returns true if this value is of type YCgCo. Returns false otherwise

Source

pub const fn is_bt_2020_ncl(&self) -> bool

Returns true if this value is of type Bt2020Ncl. Returns false otherwise

Source

pub const fn is_bt_2020_cl(&self) -> bool

Returns true if this value is of type Bt2020Cl. Returns false otherwise

Source

pub const fn is_smpte_2085(&self) -> bool

Returns true if this value is of type Smpte2085. Returns false otherwise

Source

pub const fn is_chroma_derived_ncl(&self) -> bool

Returns true if this value is of type ChromaDerivedNcl. Returns false otherwise

Source

pub const fn is_chroma_derived_cl(&self) -> bool

Returns true if this value is of type ChromaDerivedCl. Returns false otherwise

Source

pub const fn is_ictcp(&self) -> bool

Returns true if this value is of type Ictcp. Returns false otherwise

Source

pub const fn is_ipt_c_2(&self) -> bool

Returns true if this value is of type IptC2. Returns false otherwise

Source

pub const fn is_y_cg_co_re(&self) -> bool

Returns true if this value is of type YCgCoRe. Returns false otherwise

Source

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

Source

pub const fn as_str(&self) -> &'static str

Lowercase FFmpeg-style identifier for this variant (AVCOL_SPC_* slug).

Source

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).

Source

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.

Trait Implementations§

Source§

impl Clone for Matrix

Source§

fn clone(&self) -> Matrix

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Matrix

Source§

impl Debug for Matrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Matrix

Source§

fn default() -> Matrix

Returns the “default value” for a type. Read more
Source§

impl Display for Matrix

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Matrix

Source§

impl Hash for Matrix

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Matrix

Source§

fn eq(&self, other: &Matrix) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Matrix

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.