pub struct PlaneGeometry { /* private fields */ }Expand description
Describes the geometry of a plane, including dimensions and padding.
This struct contains all the information needed to interpret the layout of a plane’s data buffer, including the visible dimensions and the padding on all four sides.
The stride represents the number of pixels per row in the data buffer,
which is equal to width + pad_left + pad_right.
Implementations§
Source§impl PlaneGeometry
impl PlaneGeometry
Sourcepub fn new(
width: usize,
height: usize,
pad_left: usize,
pad_right: usize,
pad_top: usize,
pad_bottom: usize,
subsampling_x: u8,
subsampling_y: u8,
) -> Option<Self>
pub fn new( width: usize, height: usize, pad_left: usize, pad_right: usize, pad_top: usize, pad_bottom: usize, subsampling_x: u8, subsampling_y: u8, ) -> Option<Self>
Returns a new PlaneGeometry with the given dimensions, padding and subsampling.
Will return None if:
width,height,subsampling_xorsubsampling_yare zero or- the data stride would overflow a
usize.
Sourcepub fn unpadded(
width: usize,
height: usize,
subsampling_x: u8,
subsampling_y: u8,
) -> Option<Self>
pub fn unpadded( width: usize, height: usize, subsampling_x: u8, subsampling_y: u8, ) -> Option<Self>
Returns a new PlaneGeometry with the given dimensions, subsampling and zero padding.
Returns None if width, height, subsampling_x or subsampling_y are zero.
Sourcepub fn stride(&self) -> usize
pub fn stride(&self) -> usize
Data stride (pixels per row in the buffer, including padding).
Guaranteed to be non-zero.
Sourcepub fn pad_bottom(&self) -> usize
pub fn pad_bottom(&self) -> usize
Number of padding pixels on the bottom.
Sourcepub fn subsampling_x(&self) -> u8
pub fn subsampling_x(&self) -> u8
The horizontal subsampling ratio of this plane compared to the luma plane.
Guaranteed to be non-zero, and 1 if not subsampled.
Sourcepub fn subsampling_y(&self) -> u8
pub fn subsampling_y(&self) -> u8
The horizontal subsampling ratio of this plane compared to the luma plane.
Guaranteed to be non-zero, and 1 if not subsampled.
Sourcepub fn for_subsampling(
self,
subsampling: ChromaSubsampling,
) -> Result<Option<Self>, SubsamplingError>
pub fn for_subsampling( self, subsampling: ChromaSubsampling, ) -> Result<Option<Self>, SubsamplingError>
Returns a new PlaneGeometry based on self and according to subsampling.
Returns:
Ok(None)if the subsampling specifies no other planes (i.e. monochrome),Ok(Some(g))ifselfwas successfully subsampled into a new geometryg,Err(..)ifselfcould not be subsampled into a new geometry, for example due toselfhaving an odd width or height.
§Errors
See SubsamplingError.
Sourcepub fn data_origin(&self) -> usize
pub fn data_origin(&self) -> usize
Returns the index for the first visible pixel.
Sourcepub fn alloc_height(&self) -> usize
pub fn alloc_height(&self) -> usize
Returns the total height of the plane, including padding.
Sourcepub fn alloc_size(&self) -> usize
pub fn alloc_size(&self) -> usize
Returns the total allocation size of the plane, including padding.
Trait Implementations§
Source§impl Clone for PlaneGeometry
impl Clone for PlaneGeometry
Source§fn clone(&self) -> PlaneGeometry
fn clone(&self) -> PlaneGeometry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PlaneGeometry
Source§impl Debug for PlaneGeometry
impl Debug for PlaneGeometry
impl Eq for PlaneGeometry
Source§impl PartialEq for PlaneGeometry
impl PartialEq for PlaneGeometry
Source§fn eq(&self, other: &PlaneGeometry) -> bool
fn eq(&self, other: &PlaneGeometry) -> bool
self and other values to be equal, and is used by ==.