Skip to main content

YuvFormat

Struct YuvFormat 

Source
pub struct YuvFormat {
    pub chroma_shift_x: u8,
    pub chroma_shift_y: u8,
    pub bit_depth: u8,
    pub interleaved_chroma: bool,
    pub msb_aligned: bool,
    pub alpha: bool,
}
Expand description

How a planar or semi-planar YCbCr frame stores its samples.

Luma is always the first plane. Chroma follows as separate U and V planes, or as one plane of interleaved U, V pairs. Each chroma plane covers ceil(width / 2^chroma_shift_x) by ceil(height / 2^chroma_shift_y) samples. A sample of more than eight bits is a little-endian u16. A format with alpha stores one more plane after the chroma: straight, full-range alpha at the luma’s size and depth.

Fields§

§chroma_shift_x: u8

Log2 of the horizontal chroma subsampling: 0 for 4:4:4, 1 for 4:2:x.

§chroma_shift_y: u8

Log2 of the vertical chroma subsampling: 1 for 4:2:0, 0 otherwise.

§bit_depth: u8

Significant bits per sample, 8 through 16.

§interleaved_chroma: bool

Whether U and V interleave in one plane, as NV12 and P010 do.

§msb_aligned: bool

Whether a sample of fewer than 16 bits sits in the high bits of its u16, as P010’s do, rather than the low bits, as yuv420p10le’s do.

§alpha: bool

Whether an alpha plane follows the chroma, as yuva444p16le’s does.

Implementations§

Source§

impl YuvFormat

Source

pub const I420: Self

8-bit planar 4:2:0 (yuv420p).

Source

pub const NV12: Self

8-bit 4:2:0 with interleaved chroma (nv12).

Source

pub const P010: Self

10-bit 4:2:0 with interleaved, high-aligned chroma (p010le).

Source

pub const fn planar( chroma_shift_x: u8, chroma_shift_y: u8, bit_depth: u8, ) -> Self

Planar YCbCr with low-aligned samples.

Source

pub const fn with_alpha(self) -> Self

The same format with an alpha plane after the chroma.

Source

pub const fn is_supported(self) -> bool

Whether the renderer can sample this format: 8 to 16 bits, chroma subsampled by at most four on either axis, and high alignment only where there are spare bits to align in.

Source

pub const fn bytes_per_sample(self) -> u32

Bytes each stored sample takes: one up to 8 bits, two above.

Source

pub const fn plane_count(self) -> usize

Number of stored planes: luma and chroma (three, or two with interleaved chroma), then alpha when the format has it.

Source

pub const fn color_plane_count(self) -> usize

Number of planes that hold luma and chroma: three, or two with interleaved chroma. The alpha plane, if any, is the one after them.

Source

pub const fn chroma_size(self, width: u32, height: u32) -> (u32, u32)

Chroma plane dimensions, in sample positions, for a coded frame size.

Trait Implementations§

Source§

impl Clone for YuvFormat

Source§

fn clone(&self) -> Self

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 YuvFormat

Source§

impl Debug for YuvFormat

Source§

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

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

impl Eq for YuvFormat

Source§

impl Hash for YuvFormat

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 YuvFormat

Source§

fn eq(&self, other: &Self) -> 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 YuvFormat

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.