Skip to main content

PlaneView

Struct PlaneView 

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

Validated borrowed view of one plane inside a PlanarView.

Implementations§

Source§

impl<'a> PlaneView<'a>

Source

pub fn new( data: &'a [u8], width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneView<'a>, At<BufferError>>

Construct a validated borrowed plane view.

Source

pub fn from_samples<S>( samples: &'a [S], width: u32, height: u32, format: PlaneFormat, ) -> Result<PlaneView<'a>, At<BufferError>>
where S: StorageSample,

Construct a validated borrowed plane view from a tightly packed typed sample slice (&[u8], &[u16], &[f32], etc.) zero-copy.

Row stride is derived automatically as width * format.components() samples (e.g. width for luma Y, width * 2 for semi-planar CbCr). For padded row strides, use from_samples_strided.

Source

pub fn from_samples_strided<S>( samples: &'a [S], width: u32, height: u32, stride: SampleStride, format: PlaneFormat, ) -> Result<PlaneView<'a>, At<BufferError>>
where S: StorageSample,

Construct a validated borrowed plane view from a strided typed sample slice (&[u8], &[u16], &[f32], etc.) zero-copy with an explicit SampleStride measured in S elements (NOT bytes).

Source

pub const fn format(&self) -> PlaneFormat

Plane specification.

Source

pub const fn width(&self) -> u32

Plane width in elements.

Source

pub const fn height(&self) -> u32

Plane height in rows.

Source

pub const fn stride_bytes(&self) -> usize

Row stride in bytes.

Source

pub const fn data(&self) -> &'a [u8] ⓘ

Strided backing byte slice.

Source

pub fn row(&self, y: u32) -> &'a [u8] ⓘ

Active bytes of row y.

Source

pub fn row_as<S>(&self, y: u32) -> Result<&'a [S], At<BufferError>>
where S: StorageSample,

Zero-copy typed slice view of row y (e.g. plane.row_as::<u16>(y)), tied directly to 'a.

Source

pub fn code_u32(&self, x: u32, y: u32, component: usize) -> Option<u32>

Extract the unpacked integer code for (x, y, component) respecting BitPacking.

component is the 0-based channel index within this plane: pass 0 for single-channel planes (Y, Cb, Cr, R, G, B, Alpha), or 0/1 for interleaved CbCr.

Source

pub fn as_code_plane( self, component: usize, ) -> Result<CodePlane<'a>, CodePlaneError>

Borrow component of this plane as a zero-copy CodePlane<'a> using the SampleEncoding implied by self.format().

Source

pub fn as_code_plane_with( self, component: usize, encoding: SampleEncoding, ) -> Result<CodePlane<'a>, CodePlaneError>

Borrow component of this plane as a zero-copy CodePlane<'a> with an explicit SampleEncoding.

Source

pub fn crop(&self, rect: PixelRect) -> Result<PlaneView<'a>, At<BufferError>>

Zero-copy rectangular crop of this single plane retaining 'a.

Source

pub fn sub_rows( &self, start_y: u32, row_count: u32, ) -> Result<PlaneView<'a>, At<BufferError>>

Zero-copy full-width horizontal strip of this single plane retaining 'a.

Source§

impl PlaneView<'_>

Source

pub fn hash_with(&self, inclusions: HashInclusions) -> u64

Compute a portable, endian- and stride-independent XXH3 fingerprint of this plane.

Trait Implementations§

Source§

impl<'a> Clone for PlaneView<'a>

Source§

fn clone(&self) -> PlaneView<'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 PlaneView<'a>

Source§

impl<'a> Debug for PlaneView<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PlaneView<'a>

§

impl<'a> RefUnwindSafe for PlaneView<'a>

§

impl<'a> Send for PlaneView<'a>

§

impl<'a> Sync for PlaneView<'a>

§

impl<'a> Unpin for PlaneView<'a>

§

impl<'a> UnsafeUnpin for PlaneView<'a>

§

impl<'a> UnwindSafe for PlaneView<'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.