pub struct FrameLease { /* private fields */ }Expand description
Frame container holding one or more planes plus metadata.
§Example
use styx_core::prelude::*;
let pool = BufferPool::with_capacity(1, 256);
let res = Resolution::new(4, 4).unwrap();
let fmt = MediaFormat::new(FourCc::new(*b"RG24"), res, ColorSpace::Srgb);
let layout = plane_layout_from_dims(res.width, res.height, 3);
let meta = FrameMeta::new(fmt, 0);
let frame = FrameLease::single_plane(meta, pool.lease(), layout.len, layout.stride);
assert_eq!(frame.planes().len(), 1);Implementations§
Source§impl FrameLease
impl FrameLease
Sourcepub fn single_plane(
meta: FrameMeta,
buffer: BufferLease,
len: usize,
stride: usize,
) -> FrameLease
pub fn single_plane( meta: FrameMeta, buffer: BufferLease, len: usize, stride: usize, ) -> FrameLease
Construct a single-plane frame using the provided buffer.
Sourcepub unsafe fn single_plane_uninit(
meta: FrameMeta,
buffer: BufferLease,
len: usize,
stride: usize,
) -> FrameLease
pub unsafe fn single_plane_uninit( meta: FrameMeta, buffer: BufferLease, len: usize, stride: usize, ) -> FrameLease
Construct a single-plane frame assuming the caller will fully initialize the buffer.
§Safety
The caller must write every byte of the buffer before the frame is read.
Sourcepub fn multi_plane(
meta: FrameMeta,
buffers: SmallVec<[BufferLease; 3]>,
layouts: SmallVec<[PlaneLayout; 3]>,
) -> FrameLease
pub fn multi_plane( meta: FrameMeta, buffers: SmallVec<[BufferLease; 3]>, layouts: SmallVec<[PlaneLayout; 3]>, ) -> FrameLease
Construct a multi-plane frame from a list of buffers and layouts.
Sourcepub fn from_external(
meta: FrameMeta,
layouts: SmallVec<[PlaneLayout; 3]>,
backing: Arc<dyn ExternalBacking>,
) -> FrameLease
pub fn from_external( meta: FrameMeta, layouts: SmallVec<[PlaneLayout; 3]>, backing: Arc<dyn ExternalBacking>, ) -> FrameLease
Construct a frame from an external backing (zero-copy).
Sourcepub fn is_external(&self) -> bool
pub fn is_external(&self) -> bool
Returns true when the frame data is backed by an external zero-copy mapping (e.g. DMA / mmap).
In this case the frame does not own CPU buffers, so consumers that need an owned Vec<u8>
must copy.
Sourcepub fn planes(&self) -> SmallVec<[Plane<'_>; 3]>
pub fn planes(&self) -> SmallVec<[Plane<'_>; 3]>
Iterate planes as borrowed slices (zero-copy).
Sourcepub fn planes_mut(&mut self) -> SmallVec<[PlaneMut<'_>; 3]>
pub fn planes_mut(&mut self) -> SmallVec<[PlaneMut<'_>; 3]>
Iterate mutable planes for in-place writes.
Sourcepub fn layouts(&self) -> SmallVec<[PlaneLayout; 3]>
pub fn layouts(&self) -> SmallVec<[PlaneLayout; 3]>
Return a copy of plane layouts.
Sourcepub fn plane_strides(&self) -> SmallVec<[usize; 3]>
pub fn plane_strides(&self) -> SmallVec<[usize; 3]>
Return strides for each plane.
Sourcepub fn into_parts(
self,
) -> (FrameMeta, SmallVec<[PlaneLayout; 3]>, SmallVec<[Vec<u8>; 3]>)
pub fn into_parts( self, ) -> (FrameMeta, SmallVec<[PlaneLayout; 3]>, SmallVec<[Vec<u8>; 3]>)
Convert into owned buffers and metadata.
Auto Trait Implementations§
impl Freeze for FrameLease
impl !RefUnwindSafe for FrameLease
impl Send for FrameLease
impl Sync for FrameLease
impl Unpin for FrameLease
impl !UnwindSafe for FrameLease
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
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