Struct Plane

pub struct Plane<T: Pixel> { pub data: PlaneData<T>, pub cfg: PlaneConfig }

One data plane of a frame.

For example, a plane can be a Y luma plane or a U or V chroma plane.

Fields

data: PlaneData<T>
cfg: PlaneConfig

Plane configuration.

Implementations

impl<T: Pixel> Plane<T>

fn new(width: usize, height: usize, xdec: usize, ydec: usize, xpad: usize, ypad: usize) -> Self

Allocates and returns a new plane.

fn from_slice(data: &[T], stride: usize) -> Self

Panics

  • If len is not a multiple of stride
fn pad(&mut self, w: usize, h: usize)
fn probe_padding(&self, w: usize, h: usize) -> bool

Minimally test that the plane has been padded.

fn slice(&self, po: PlaneOffset) -> PlaneSlice<'_, T>
fn mut_slice(&mut self, po: PlaneOffset) -> PlaneMutSlice<'_, T>
fn row_range_cropped(&self, x: isize, y: isize) -> Range<usize>

This version of the function crops off the padding on the right side of the image

fn row_range(&self, x: isize, y: isize) -> Range<usize>

This version of the function includes the padding on the right side of the image

fn p(&self, x: usize, y: usize) -> T

Returns the pixel at the given coordinates.

fn data_origin(&self) -> &[T]

Returns plane data starting from the origin.

fn data_origin_mut(&mut self) -> &mut [T]

Returns mutable plane data starting from the origin.

fn copy_from_raw_u8(&mut self, source: &[u8], source_stride: usize, source_bytewidth: usize)

Copies data into the plane from a pixel array.

Panics

  • If source_bytewidth does not match the generic T of Plane
fn copy_to_raw_u8(&self, dest: &mut [u8], dest_stride: usize, dest_bytewidth: usize)

Copies data from a plane into a pixel array.

Panics

  • If dest_bytewidth does not match the generic T of Plane
fn downsampled(&self, frame_width: usize, frame_height: usize) -> Plane<T>

Returns plane with half the resolution for width and height. Downscaled with 2x2 box filter. Padded to dimensions with frame_width and frame_height.

Panics

  • If the requested width and height are > half the input width or height
fn downscale<const SCALE: usize>(&self) -> Plane<T>

Returns a plane downscaled from the source plane by a factor of scale (not padded)

fn downscale_in_place<const SCALE: usize>(&self, in_plane: &mut Plane<T>)

Downscales the source plane by a factor of scale, writing the result to in_plane (not padded)

Panics

  • If the current plane's width and height are not at least SCALE times the in_plane's
fn iter(&self) -> PlaneIter<'_, T>

Iterates over the pixels in the plane, skipping the padding.

fn rows_iter(&self) -> RowsIter<'_, T>

Iterates over the lines of the plane

fn rows_iter_mut(&mut self) -> RowsIterMut<'_, T>
fn row(&self, y: isize) -> &[T]

Return a line

Trait Implementations

impl<T> Debug for Plane<T> where T: Display + Pixel,

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

impl<T: Clone + Pixel> Clone for Plane<T>

fn clone(&self) -> Self

impl<T: Eq + Pixel> Eq for Plane<T>

impl<T: PartialEq + Pixel> PartialEq for Plane<T>

fn eq(&self, other: &Self) -> bool

impl<T: PartialEq + Pixel> StructuralPartialEq for Plane<T>

Auto Trait Implementations

impl<T> Freeze for Plane<T> where PlaneData<T>: Freeze,

impl<T> RefUnwindSafe for Plane<T> where PlaneData<T>: RefUnwindSafe,

impl<T> Send for Plane<T> where PlaneData<T>: Send,

impl<T> Sync for Plane<T> where PlaneData<T>: Sync,

impl<T> Unpin for Plane<T> where PlaneData<T>: Unpin,

impl<T> UnsafeUnpin for Plane<T> where PlaneData<T>: UnsafeUnpin,

impl<T> UnwindSafe for Plane<T> where PlaneData<T>: UnwindSafe,

Blanket Implementations

impl<T> Any for Plane<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Plane<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Plane<T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Plane<T> where T: Clone,

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

impl<T> From<T> for Plane<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Plane<T> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Plane<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Plane<T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Plane<T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>