pub struct FrameRef<'core> { /* private fields */ }
Expand description
A reference to a ref-counted frame.
Methods from Deref<Target = Frame<'core>>§
pub fn video_format(&self) -> Option<VideoFormat>
sourcepub fn width(&self, plane: i32) -> i32
pub fn width(&self, plane: i32) -> i32
Returns the width of a plane, in pixels.
The width depends on the plane number because of the possible chroma subsampling.
Panics
Panics if plane >= format().plane_count()
.
sourcepub fn height(&self, plane: i32) -> i32
pub fn height(&self, plane: i32) -> i32
Returns the height of a plane, in pixels.
The height depends on the plane number because of the possible chroma subsampling.
Panics
Panics if plane >= format().plane_count()
.
sourcepub fn stride(&self, plane: i32) -> isize
pub fn stride(&self, plane: i32) -> isize
Returns the distance in bytes between two consecutive lines of a plane.
Panics
Panics if plane >= format().plane_count()
.
pub fn length(&self) -> i32
sourcepub fn plane_row<T: Component>(&self, plane: i32, row: i32) -> &[T]
pub fn plane_row<T: Component>(&self, plane: i32, row: i32) -> &[T]
Returns a slice of a plane’s pixel row.
Panics
Panics if the requested plane, row or component type is invalid.
sourcepub fn plane<T: Component>(&self, plane: i32) -> Result<&[T], NonZeroPadding>
pub fn plane<T: Component>(&self, plane: i32) -> Result<&[T], NonZeroPadding>
Returns a slice of the plane’s pixels.
The length of the returned slice is height() * width()
. If the pixel data has non-zero
padding (that is, stride()
is larger than width()
), an error is returned, since
returning the data slice would open access to uninitialized bytes.
Panics
Panics if the requested plane or component type is invalid.
sourcepub fn data_ptr(&self, plane: i32) -> *const u8
pub fn data_ptr(&self, plane: i32) -> *const u8
Returns a pointer to the plane’s pixels.
The pointer points to an array with a length of height() * stride()
and is valid for as
long as the frame is alive.
Panics
Panics if plane >= format().plane_count()
.
sourcepub fn data_row(&self, plane: i32, row: i32) -> &[u8] ⓘ
pub fn data_row(&self, plane: i32, row: i32) -> &[u8] ⓘ
Returns a slice of a plane’s pixel row.
The length of the returned slice is equal to width() * format().bytes_per_sample()
.
Panics
Panics if plane >= format().plane_count()
or if row >= height()
.
sourcepub fn data(&self, plane: i32) -> Result<&[u8], NonZeroPadding>
pub fn data(&self, plane: i32) -> Result<&[u8], NonZeroPadding>
Returns a slice of the plane’s pixels.
The length of the returned slice is height() * width() * format().bytes_per_sample()
. If
the pixel data has non-zero padding (that is, stride()
is larger than width()
), an
error is returned, since returning the data slice would open access to uninitialized bytes.
Panics
Panics if plane >= format().plane_count()
or if row >= height()
.