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
impl Yuv420pFrameBuffer
Sourcepub fn new(width: i32, height: i32) -> Result<Yuv420pFrameBuffer, BridgeError>
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.
Sourcepub fn with_format(
width: i32,
height: i32,
format: i32,
planes: &[(usize, usize)],
) -> Result<Yuv420pFrameBuffer, BridgeError>
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.
Sourcepub fn begin_write_planes(
&mut self,
) -> Result<Vec<(&mut [u8], usize)>, BridgeError>
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
Sourcepub const fn dimensions(&self) -> (usize, usize)
pub const fn dimensions(&self) -> (usize, usize)
Luma width and height in pixels.
Sourcepub fn begin_write(&mut self) -> Result<Yuv420pFramePlanes<'_>, BridgeError>
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.
Sourcepub fn set_presentation(&mut self, pts: i64, time_base: AVRational)
pub fn set_presentation(&mut self, pts: i64, time_base: AVRational)
Stamps the presentation timestamp this frame will be encoded with.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for Yuv420pFrameBuffer
impl Freeze for Yuv420pFrameBuffer
impl RefUnwindSafe for Yuv420pFrameBuffer
impl Send for Yuv420pFrameBuffer
impl Unpin for Yuv420pFrameBuffer
impl UnsafeUnpin for Yuv420pFrameBuffer
impl UnwindSafe for Yuv420pFrameBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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