Struct Plane

Source
pub struct Plane<T>
where T: Pixel,
{ pub data: PlaneData<T>, pub cfg: PlaneConfig, }
Expand description

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§

Source§

impl<T> Plane<T>
where T: Pixel,

Source

pub fn new( width: usize, height: usize, xdec: usize, ydec: usize, xpad: usize, ypad: usize, ) -> Plane<T>

Allocates and returns a new plane.

Source

pub fn from_slice(data: &[T], stride: usize) -> Plane<T>

§Panics
  • If len is not a multiple of stride
Source

pub fn pad(&mut self, w: usize, h: usize)

Source

pub fn probe_padding(&self, w: usize, h: usize) -> bool

Minimally test that the plane has been padded.

Source

pub fn slice(&self, po: PlaneOffset) -> PlaneSlice<'_, T>

Source

pub fn mut_slice(&mut self, po: PlaneOffset) -> PlaneMutSlice<'_, T>

Source

pub 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

Source

pub 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

Source

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

Returns the pixel at the given coordinates.

Source

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

Returns plane data starting from the origin.

Source

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

Returns mutable plane data starting from the origin.

Source

pub 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
Source

pub 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
Source

pub 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
Source

pub fn downscale<const SCALE: usize>(&self) -> Plane<T>

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

Source

pub 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
Source

pub fn iter(&self) -> PlaneIter<'_, T>

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

Source

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

Iterates over the lines of the plane

Source

pub fn rows_iter_mut(&mut self) -> RowsIterMut<'_, T>

Source

pub fn row(&self, y: isize) -> &[T]

Return a line

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Plane<T>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

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

Source§

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

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

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

Source§

fn eq(&self, other: &Plane<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Source§

impl<T> StructuralPartialEq for Plane<T>
where T: Pixel,

Auto Trait Implementations§

§

impl<T> Freeze for Plane<T>

§

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

§

impl<T> Send for Plane<T>

§

impl<T> Sync for Plane<T>

§

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

§

impl<T> UnwindSafe for Plane<T>

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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.