Skip to main content

VideoPlane

Struct VideoPlane 

Source
pub struct VideoPlane<'a> { /* private fields */ }
Expand description

An allocation-free view of one video plane’s initialized active bytes.

Plane order follows the pixel format: packed pixels; UYVY/A for UYVA; Y/CbCr[/A] for P216/PA16; Y/V/U for YV12; Y/U/V for I420; Y/UV for NV12. The view borrows its captured frame, which keeps the SDK allocation alive. Immutable pixel views are Send + Sync, including views borrowed from FrameSync. Scoped workers must finish before the frame is freed. This does not transfer the SDK-owning frame reference or change its freeing thread.

let plane = frame.plane(0).unwrap();
let rows = plane.rows();
std::thread::scope(|scope| {
    let worker = scope.spawn(move || {
        rows.flatten().map(|&byte| u64::from(byte)).sum::<u64>()
    });
    assert_eq!(worker.join().unwrap(),
        plane.rows().flatten().map(|&byte| u64::from(byte)).sum::<u64>());
});

Implementations§

Source§

impl<'a> VideoPlane<'a>

Source

pub fn row_stride(&self) -> usize

Distance between row starts in bytes, including padding.

Source

pub fn active_row_bytes(&self) -> usize

Number of initialized bytes in each row.

Source

pub fn row_count(&self) -> usize

Number of rows in this plane.

Source

pub fn row(&self, index: usize) -> Option<&'a [u8]>

Get an active row, excluding padding, or None for an invalid index.

Source

pub fn rows(&self) -> VideoRows<'a> ⓘ

Iterate active rows without allocating or copying pixels.

Source

pub fn data(&self) -> Option<&'a [u8]>

Borrow all active bytes when contiguous, excluding trailing padding. Returns None when padding separates rows.

Trait Implementations§

Source§

impl<'a> Clone for VideoPlane<'a>

Source§

fn clone(&self) -> VideoPlane<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for VideoPlane<'a>

Source§

impl<'a> Debug for VideoPlane<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Send for VideoPlane<'_>

Source§

impl Sync for VideoPlane<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for VideoPlane<'a>

§

impl<'a> RefUnwindSafe for VideoPlane<'a>

§

impl<'a> Unpin for VideoPlane<'a>

§

impl<'a> UnsafeUnpin for VideoPlane<'a>

§

impl<'a> UnwindSafe for VideoPlane<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.