Skip to main content

Yuv420pFrameBuffer

Struct Yuv420pFrameBuffer 

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

A reusable FFmpeg YUV420P frame the caller writes into directly.

Avoids yuv420p_frame’s per-frame allocation and copy. Yuv420pFrameBuffer::begin_write returns plane memory only once FFmpeg no longer shares the buffer, copying it if needed.

Implementations§

Source§

impl Yuv420pFrameBuffer

Source

pub fn new(width: i32, height: i32) -> Result<Yuv420pFrameBuffer, BridgeError>

Allocates one reusable frame for this exact coded size.

§Errors

Returns an error for a non-positive size or a failed allocation.

Source

pub fn with_format( width: i32, height: i32, format: i32, planes: &[(usize, usize)], ) -> Result<Yuv420pFrameBuffer, BridgeError>

Allocates one reusable frame of format; planes gives each plane’s visible bytes per row and rows in FFmpeg order.

§Errors

Returns an error for a non-positive size, a failed allocation, or planes the format lacks.

Source

pub fn begin_write_planes( &mut self, ) -> Result<Vec<(&mut [u8], usize)>, BridgeError>

Each plane’s memory and stride after making the frame unshared, for any format.

§Errors

As Self::begin_write.

Source

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

Luma width and height in pixels.

Source

pub fn begin_write(&mut self) -> Result<Yuv420pFramePlanes<'_>, BridgeError>

Returns the plane memory to overwrite, after making the frame unshared.

§Errors

Returns an error when the buffer cannot be made writable or its planes changed layout.

Source

pub fn set_presentation(&mut self, pts: i64, time_base: AVRational)

Stamps the presentation timestamp this frame will be encoded with.

Source

pub const fn frame(&self) -> &AVFrame

The frame to hand to an encoder.

Source

pub const fn size(&self) -> (usize, usize)

Coded luma dimensions this buffer was allocated for.

Trait Implementations§

Source§

impl Debug for Yuv420pFrameBuffer

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,