Skip to main content

YuvaPlanes

Struct YuvaPlanes 

Source
pub struct YuvaPlanes<'a> {
    pub y: &'a mut [u8],
    pub y_stride: usize,
    pub u: &'a mut [u8],
    pub v: &'a mut [u8],
    pub uv_stride: usize,
    pub a: Option<&'a mut [u8]>,
    pub a_stride: usize,
}
Expand description

The caller’s Y, U, V and optional alpha planes, an Output for ColorMode::Yuv and ColorMode::Yuva.

Every stride counts bytes. The Y and A planes have height rows of width samples, the U and V planes (height + 1) / 2 rows of (width + 1) / 2 samples; each stride is at least its row length and at most i32::MAX, and each plane holds at least (rows - 1) * stride + row length bytes. a is given exactly for ColorMode::Yuva; a_stride is ignored without it.

§Examples

use webp::api::decode::{decode_into, ColorMode, Config, Output, YuvaPlanes};

// A 5 by 3 image: chroma planes of 3 by 2, rows padded to 8 bytes.
let (mut y, mut u, mut v) = (vec![0_u8; 8 * 3], vec![0_u8; 8 * 2], vec![0_u8; 8 * 2]);
let planes = YuvaPlanes {
    y: &mut y, y_stride: 8,
    u: &mut u, v: &mut v, uv_stride: 8,
    a: None, a_stride: 0,
};
decode_into(&file, &Config::new(ColorMode::Yuv), Output::Planes(planes))?;
assert!(y[..5].iter().all(|&luma| (16..=235).contains(&luma)));

Fields§

§y: &'a mut [u8]

The luma plane.

§y_stride: usize

The distance between luma rows, in bytes.

§u: &'a mut [u8]

The U (Cb) chroma plane.

§v: &'a mut [u8]

The V (Cr) chroma plane.

§uv_stride: usize

The distance between rows of both chroma planes, in bytes.

§a: Option<&'a mut [u8]>

The alpha plane, straight alpha, for ColorMode::Yuva.

§a_stride: usize

The distance between alpha rows, in bytes.

Trait Implementations§

Source§

impl Debug for YuvaPlanes<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for YuvaPlanes<'a>

§

impl<'a> Forget for YuvaPlanes<'a>

§

impl<'a> Freeze for YuvaPlanes<'a>

§

impl<'a> Move for YuvaPlanes<'a>

§

impl<'a> RefUnwindSafe for YuvaPlanes<'a>

§

impl<'a> Send for YuvaPlanes<'a>

§

impl<'a> Sync for YuvaPlanes<'a>

§

impl<'a> Unpin for YuvaPlanes<'a>

§

impl<'a> UnsafeUnpin for YuvaPlanes<'a>

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