Skip to main content

YUVBuffer

Struct YUVBuffer 

Source
pub struct YUVBuffer { /* private fields */ }
Expand description

Converts RGB to YUV data.

Implementations§

Source§

impl YUVBuffer

Source

pub fn from_vec(yuv: Vec<u8>, width: usize, height: usize) -> Self

Creates a new YUV buffer from the given vec.

The vec’s length should be 3 * (width * height) / 2.

§Panics

May panic if the given sizes are not multiples of 2, or the yuv buffer’s size mismatches.

Source

pub fn new(width: usize, height: usize) -> Self

Allocates a new YUV buffer with the given width and height.

Both dimensions must be even.

§Panics

May panic if the given sizes are not multiples of 2.

Source

pub fn from_rgb_source(rgb: impl RGBSource) -> Self

Allocates a new YUV buffer with the given width and height and data.

§Panics

May panic if invoked with an RGB source where the dimensions are not multiples of 2.

Source

pub fn from_rgb8_source(rgb: impl RGB8Source) -> Self

Allocates a new YUV buffer with the given width and height and data.

This is the faster version of Self::from_rgb_source and you should generally use this one.

§Panics

May panic if invoked with an RGB source where the dimensions are not multiples of 2.

Source

pub fn read_rgb(&mut self, rgb: impl RGBSource)

Reads an RGB buffer, converts it to YUV and stores it.

§Panics

May panic if the given rgb does not match the internal format.

Source

pub fn read_rgb8(&mut self, rgb: impl RGB8Source)

Reads an RGB8 buffer, converts it to YUV and stores it.

This is the faster version of Self::read_rgb and you should generally use this one.

§Panics

May panic if the given rgb does not match the internal format.

Trait Implementations§

Source§

impl YUVSource for YUVBuffer

Source§

fn dimensions(&self) -> (usize, usize)

Size of the image as (w, h).
Source§

fn strides(&self) -> (usize, usize, usize)

YUV strides as (y, u, v). Read more
Source§

fn y(&self) -> &[u8]

Y buffer, should be of size dimension.1 * strides.0.
Source§

fn u(&self) -> &[u8]

U buffer, should be of size dimension.1 * strides.1.
Source§

fn v(&self) -> &[u8]

V buffer, should be of size dimension.1 * strides.2.
Source§

fn dimensions_i32(&self) -> (i32, i32)

Size of the image as (w, h).
Source§

fn strides_i32(&self) -> (i32, i32, i32)

YUV strides as (y, u, v). Read more
Source§

fn rgb8_len(&self) -> usize

Estimates how many bytes you’ll need to store this YUV in an &[u8] RGB array. Read more
Source§

fn rgba8_len(&self) -> usize

Estimates how many bytes you’ll need to store this YUV in an &[u8] RGBA array. Read more

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