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 A planes, the input of Picture::from_yuva.

Strides count elements of the slices’ type, which are 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 samples. a_stride is ignored when a is None.

§Examples

use webp::api::encode::{Picture, YuvaPlanes};

// 3 by 3: chroma planes of 2 by 2, alpha omitted.
let (mut y, mut u, mut v) = (vec![128_u8; 9], vec![128_u8; 4], vec![128_u8; 4]);
let planes = YuvaPlanes {
    y: &mut y, y_stride: 3,
    u: &mut u, v: &mut v, uv_stride: 2,
    a: None, a_stride: 0,
};
let picture = Picture::from_yuva(3, 3, planes)?;
assert_eq!(picture.owned_sample_bytes(), 0);

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, or None for an opaque picture.

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