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,
impl<T> Plane<T>where
T: Pixel,
Sourcepub fn new(
width: usize,
height: usize,
xdec: usize,
ydec: usize,
xpad: usize,
ypad: usize,
) -> Plane<T>
pub fn new( width: usize, height: usize, xdec: usize, ydec: usize, xpad: usize, ypad: usize, ) -> Plane<T>
Allocates and returns a new plane.
Sourcepub fn from_slice(data: &[T], stride: usize) -> Plane<T>
pub fn from_slice(data: &[T], stride: usize) -> Plane<T>
§Panics
- If
len
is not a multiple ofstride
pub fn pad(&mut self, w: usize, h: usize)
Sourcepub fn probe_padding(&self, w: usize, h: usize) -> bool
pub fn probe_padding(&self, w: usize, h: usize) -> bool
Minimally test that the plane has been padded.
pub fn slice(&self, po: PlaneOffset) -> PlaneSlice<'_, T>
pub fn mut_slice(&mut self, po: PlaneOffset) -> PlaneMutSlice<'_, T>
Sourcepub fn row_range_cropped(&self, x: isize, y: isize) -> Range<usize>
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
Sourcepub fn row_range(&self, x: isize, y: isize) -> Range<usize>
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
Sourcepub fn data_origin(&self) -> &[T]
pub fn data_origin(&self) -> &[T]
Returns plane data starting from the origin.
Sourcepub fn data_origin_mut(&mut self) -> &mut [T]
pub fn data_origin_mut(&mut self) -> &mut [T]
Returns mutable plane data starting from the origin.
Sourcepub fn copy_from_raw_u8(
&mut self,
source: &[u8],
source_stride: usize,
source_bytewidth: usize,
)
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 genericT
ofPlane
Sourcepub fn copy_to_raw_u8(
&self,
dest: &mut [u8],
dest_stride: usize,
dest_bytewidth: usize,
)
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 genericT
ofPlane
Sourcepub fn downsampled(&self, frame_width: usize, frame_height: usize) -> Plane<T>
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
Sourcepub fn downscale<const SCALE: usize>(&self) -> Plane<T>
pub fn downscale<const SCALE: usize>(&self) -> Plane<T>
Returns a plane downscaled from the source plane by a factor of scale
(not padded)
Sourcepub fn downscale_in_place<const SCALE: usize>(&self, in_plane: &mut Plane<T>)
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 thein_plane
’s
Sourcepub fn iter(&self) -> PlaneIter<'_, T>
pub fn iter(&self) -> PlaneIter<'_, T>
Iterates over the pixels in the plane, skipping the padding.
pub fn rows_iter_mut(&mut self) -> RowsIterMut<'_, T>
Trait Implementations§
impl<T> Eq for Plane<T>
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>where
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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