Skip to main content

YcbcrMatrix

Enum YcbcrMatrix 

Source
#[non_exhaustive]
pub enum YcbcrMatrix { Identity, Bt709, Fcc, Bt470Bg, Bt601, Smpte240M, YCgCo, Bt2020, ChromaDerivedNcl, }
Expand description

YCbCr / GBR / YCgCo luma-chroma matrix standard (ITU-T H.273 Table 4).

Every distinct H.273 Table 4 non-constant-luminance code has its own variant so from_cicp_code ↔ to_cicp_code is 100% lossless (e.g. 5 = Bt470Bg and 6 = Bt601 stay distinct on the wire while sharing coefficients via same_coefficients).

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

Identity

Identity / GBR (MC = 0: Y = G, Cb = B, Cr = R, lossless RGB in planar form).

§

Bt709

ITU-R BT.709 (MC = 1: Kr = 0.2126, Kb = 0.0722).

§

Fcc

FCC Title 47 CFR 73.682 (MC = 4: Kr = 0.30, Kb = 0.11).

§

Bt470Bg

ITU-R BT.470-6 System B, G (MC = 5: Kr = 0.299, Kb = 0.114).

§

Bt601

SMPTE 170M / ITU-R BT.601 (MC = 6: Kr = 0.299, Kb = 0.114).

§

Smpte240M

SMPTE 240M (MC = 7: Kr = 0.212, Kb = 0.087).

§

YCgCo

YCgCo (MC = 8: R = Y - Cg + Co, G = Y + Cg, B = Y - Cg - Co).

§

Bt2020

ITU-R BT.2020 NCL (MC = 9: Kr = 0.2627, Kb = 0.0593).

§

ChromaDerivedNcl

Chromaticity-derived non-constant luminance (MC = 12: Kr, Kb derived from primaries).

Implementations§

Source§

impl YcbcrMatrix

Source

pub const fn from_cicp_code(code: u8) -> Option<Self>

Losslessly map an ITU-T H.273 Table 4 matrix_coefficients code to a YcbcrMatrix.

Recognizes 0 (Identity / GBR), 1 (Bt709), 4 (Fcc), 5 (Bt470Bg), 6 (Bt601), 7 (Smpte240M), 8 (YCgCo), 9 (Bt2020), and 12 (ChromaDerivedNcl). Returns None for unspecified (2), reserved (3), or non-NCL matrix codes.

Source

pub const fn from_matrix_coefficients(mc: MatrixCoefficients) -> Option<Self>

Losslessly map a typed MatrixCoefficients wrapper to a YcbcrMatrix.

Returns None for unspecified (2), reserved (3), or non-NCL matrix codes (such as BT2020_CL or ICTCP).

Source

pub const fn to_matrix_coefficients(self) -> MatrixCoefficients

Exact typed MatrixCoefficients for this matrix.

Source

pub const fn to_cicp_code(self) -> u8

Exact ITU-T H.273 Table 4 matrix_coefficients code for this matrix.

Source

pub const fn same_coefficients(self, other: Self) -> bool

Whether self and other define identical luma-chroma reconstruction coefficients (e.g. Bt470Bg (MC = 5) and Bt601 (MC = 6) share Kr = 0.299, Kb = 0.114).

Source

pub const fn kr_kb(self) -> Option<(f32, f32)>

Fixed (Kr, Kb) weights for standard NCL matrices (None for Identity, YCgCo, or ChromaDerivedNcl).

Source

pub fn kr_kb_for(self, primaries: Option<Primaries>) -> Option<(f32, f32)>

Resolve (Kr, Kb) weights, deriving them from primaries when self is ChromaDerivedNcl.

Trait Implementations§

Source§

impl Clone for YcbcrMatrix

Source§

fn clone(&self) -> YcbcrMatrix

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 YcbcrMatrix

Source§

impl Debug for YcbcrMatrix

Source§

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

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

impl Eq for YcbcrMatrix

Source§

impl From<YcbcrMatrix> for MatrixCoefficients

Source§

fn from(matrix: YcbcrMatrix) -> Self

Converts to this type from the input type.
Source§

impl Hash for YcbcrMatrix

Source§

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

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 YcbcrMatrix

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for YcbcrMatrix

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