Struct openh264::formats::YUVBuffer

source ·
pub struct YUVBuffer { /* private fields */ }
Expand description

Converts RGB to YUV data.

Implementations§

source§

impl YUVBuffer

source

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

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

source

pub fn with_rgb(width: usize, height: usize, rgb: &[u8]) -> Self

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

Data rgb is assumed to be [rgb rgb rgb ...], starting at y = 0, continuing downwards, in other words how you’d naively store an RGB image buffer.

§Panics

Will panic if rgb does not match the formats given.

source

pub fn read_rgb(&mut self, rgb: &[u8])

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

Data rgb is assumed to be [rgb rgb rgb ...], starting at y = 0, continuing downwards, in other words how you’d naively store an RGB image buffer.

§Panics

Will panic if rgb does not match the formats given.

Trait Implementations§

source§

impl YUVSource for YUVBuffer

source§

fn width(&self) -> i32

source§

fn height(&self) -> i32

source§

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

source§

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

source§

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

source§

fn y_stride(&self) -> i32

source§

fn u_stride(&self) -> i32

source§

fn v_stride(&self) -> i32

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

§

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

§

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.