pub struct VideoFrame<P, E, D> { /* private fields */ }Expand description
A decoded video frame.
Generic parameters:
P— pixel-format identifier (e.g.mediadecode_ffmpeg::PixelFormat).E— backend-specific frame extras (HDR mastering display, RAW sensor metadata, picture type, …).D— plane data buffer type. Each populatedPlane<D>carries one plane’s bytes;D: AsRef<[u8]>at the use site (e.g.Bytes,&'a [u8], refcounted FFmpeg buffer).
width / height are the coded dimensions; visible_rect
(when present) is the displayable subregion (FFmpeg crop /
WebCodecs visibleRect / ProRes RAW CleanAperture).
plane_count is the number of populated entries in planes.
Four slots cover every realistic format: NV12 = 2, YUV420P = 3,
YUVA / packed-with-alpha = 4, packed RGB / Bayer CFA = 1.
Implementations§
Source§impl<P, E, D> VideoFrame<P, E, D>
impl<P, E, D> VideoFrame<P, E, D>
Sourcepub const fn new(
dimensions: Dimensions,
pixel_format: P,
planes: [Plane<D>; 4],
plane_count: u8,
extra: E,
) -> Self
pub const fn new( dimensions: Dimensions, pixel_format: P, planes: [Plane<D>; 4], plane_count: u8, extra: E, ) -> Self
Constructs a VideoFrame. Timestamps default to None,
visible_rect to None, color to ColorInfo::UNSPECIFIED.
dimensions is the coded width/height pair (see
Dimensions and Self::dimensions for the visible-vs-
coded distinction).
§Panics
Panics if plane_count > 4. The fixed-size planes array
has four slots; passing a larger plane_count would later
trip the slice indexing inside Self::planes far from
the construction site. Asserting here fails fast with a
clear message instead. Prefer Self::try_new when
plane_count can’t be statically proven <= 4.
Sourcepub fn try_new(
dimensions: Dimensions,
pixel_format: P,
planes: [Plane<D>; 4],
plane_count: u8,
extra: E,
) -> Result<Self, FrameError>
pub fn try_new( dimensions: Dimensions, pixel_format: P, planes: [Plane<D>; 4], plane_count: u8, extra: E, ) -> Result<Self, FrameError>
Fallible counterpart to Self::new. Returns
FrameError::TooManyVideoPlanes when plane_count > 4
(the fixed plane array’s capacity) rather than panicking.
Not const fn — returning Result<Self, _> would require
dropping the moved generic-typed planes / pixel_format /
extra on the error branch, which the const evaluator
can’t prove safe for arbitrary P / E / D.
Sourcepub const fn dimensions(&self) -> Dimensions
pub const fn dimensions(&self) -> Dimensions
Returns the coded dimensions.
Sourcepub const fn visible_rect(&self) -> Option<Rect>
pub const fn visible_rect(&self) -> Option<Rect>
Returns the visible / clean-aperture rectangle, if any.
Sourcepub const fn pixel_format(&self) -> &P
pub const fn pixel_format(&self) -> &P
Returns a reference to the pixel format identifier.
Sourcepub const fn plane_count(&self) -> u8
pub const fn plane_count(&self) -> u8
Returns the populated plane count.
Sourcepub fn plane(&self, i: usize) -> Option<&Plane<D>>
pub fn plane(&self, i: usize) -> Option<&Plane<D>>
Returns one plane by index, or None if out of range.
Sourcepub const fn with_duration(self, v: Option<Timestamp>) -> Self
pub const fn with_duration(self, v: Option<Timestamp>) -> Self
Sets the duration (consuming builder).
Sourcepub const fn with_visible_rect(self, v: Option<Rect>) -> Self
pub const fn with_visible_rect(self, v: Option<Rect>) -> Self
Sets the visible rect (consuming builder).
Sourcepub const fn with_color(self, v: ColorInfo) -> Self
pub const fn with_color(self, v: ColorInfo) -> Self
Sets the color metadata (consuming builder).
Sourcepub const fn set_duration(&mut self, v: Option<Timestamp>) -> &mut Self
pub const fn set_duration(&mut self, v: Option<Timestamp>) -> &mut Self
Sets the duration in place.
Sourcepub const fn set_visible_rect(&mut self, v: Option<Rect>) -> &mut Self
pub const fn set_visible_rect(&mut self, v: Option<Rect>) -> &mut Self
Sets the visible rect in place.