FrameLease

Struct FrameLease 

Source
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

Source

pub fn single_plane( meta: FrameMeta, buffer: BufferLease, len: usize, stride: usize, ) -> FrameLease

Construct a single-plane frame using the provided buffer.

Source

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.

Source

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.

Source

pub fn from_external( meta: FrameMeta, layouts: SmallVec<[PlaneLayout; 3]>, backing: Arc<dyn ExternalBacking>, ) -> FrameLease

Construct a frame from an external backing (zero-copy).

Source

pub fn meta(&self) -> &FrameMeta

Metadata describing this frame.

Source

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.

Source

pub fn planes(&self) -> SmallVec<[Plane<'_>; 3]>

Iterate planes as borrowed slices (zero-copy).

Source

pub fn planes_mut(&mut self) -> SmallVec<[PlaneMut<'_>; 3]>

Iterate mutable planes for in-place writes.

Source

pub fn layouts(&self) -> SmallVec<[PlaneLayout; 3]>

Return a copy of plane layouts.

Source

pub fn plane_strides(&self) -> SmallVec<[usize; 3]>

Return strides for each plane.

Source

pub fn into_parts( self, ) -> (FrameMeta, SmallVec<[PlaneLayout; 3]>, SmallVec<[Vec<u8>; 3]>)

Convert into owned buffers and metadata.

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