pub struct PlaneView<'a> { /* private fields */ }Expand description
Validated borrowed view of one plane inside a PlanarView.
Implementations§
Source§impl<'a> PlaneView<'a>
impl<'a> PlaneView<'a>
Sourcepub fn new(
data: &'a [u8],
width: u32,
height: u32,
stride_bytes: usize,
format: PlaneFormat,
) -> Result<PlaneView<'a>, At<BufferError>>
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.
Sourcepub fn from_samples<S>(
samples: &'a [S],
width: u32,
height: u32,
format: PlaneFormat,
) -> Result<PlaneView<'a>, At<BufferError>>where
S: StorageSample,
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.
Sourcepub fn from_samples_strided<S>(
samples: &'a [S],
width: u32,
height: u32,
stride: SampleStride,
format: PlaneFormat,
) -> Result<PlaneView<'a>, At<BufferError>>where
S: StorageSample,
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).
Sourcepub const fn format(&self) -> PlaneFormat
pub const fn format(&self) -> PlaneFormat
Plane specification.
Sourcepub const fn stride_bytes(&self) -> usize
pub const fn stride_bytes(&self) -> usize
Row stride in bytes.
Sourcepub fn row_as<S>(&self, y: u32) -> Result<&'a [S], At<BufferError>>where
S: StorageSample,
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.
Sourcepub fn code_u32(&self, x: u32, y: u32, component: usize) -> Option<u32>
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.
Sourcepub fn as_code_plane(
self,
component: usize,
) -> Result<CodePlane<'a>, CodePlaneError>
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().
Sourcepub fn as_code_plane_with(
self,
component: usize,
encoding: SampleEncoding,
) -> Result<CodePlane<'a>, CodePlaneError>
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.