pub struct VideoDecoder { /* private fields */ }Expand description
Stateful hardware decoder for one demuxed video stream.
The Experimental codec paths accept progressive H.264 Baseline/Main/High, H.265 Main, AV1 Main 8-bit 4:2:0 without film grain, or VP9 Profile 0 8-bit 4:2:0. AVC and HEVC access units contain one complete slice per picture; admitted AV1 and VP9 access units may contain hidden and show-existing pictures. Host-planar and retained native output are synchronous; Vulkan handles and queue ownership remain private.
Implementations§
Source§impl VideoDecoder
impl VideoDecoder
Sourcepub fn new(engine: &Engine, info: VideoContainerInfo) -> Result<Self>
pub fn new(engine: &Engine, info: VideoContainerInfo) -> Result<Self>
Create a decoder for the selected track described by info.
§Errors
Returns an error unless the track is representable as progressive H.264 Baseline/Main/High, H.265 Main, AV1 Main 8-bit 4:2:0 without film grain, or VP9 Profile 0 8-bit 4:2:0 and the selected Engine admits the qualified Vulkan path.
Sourcepub fn decode(&mut self, packet: &VideoPacket) -> Result<Option<VideoFrame>>
pub fn decode(&mut self, packet: &VideoPacket) -> Result<Option<VideoFrame>>
Decode one demuxed access unit and emit the next display-order frame when ready.
Packets enter in decode order. The decoder retains up to the SPS reorder
depth and returns None while no display-order frame is safe to emit.
Call flush at end of stream to retrieve the delayed tail.
§Errors
Returns an error after close, for a packet from another track, when the first packet after create/flush is not random access, for unsupported bitstream shapes, or when Vulkan submission, status, or readback fails.
Sourcepub fn decode_native(
&mut self,
packet: &VideoPacket,
) -> Result<Option<VideoFrame>>
pub fn decode_native( &mut self, packet: &VideoPacket, ) -> Result<Option<VideoFrame>>
Decode one access unit while retaining its native multi-plane output.
This path omits the decoder-to-host pixel copy. It currently waits for the
exact decode submission and verifies its result status before publishing
the frame; asynchronous delivery is a later checkpoint. The returned frame
retains its decoder image slot. Register every GPU consumer through
VideoFrame::mark_consumed before dropping the last frame clone.
A decode sequence uses either host-planar decode or native
output until flush establishes a new random-access boundary.
§Errors
Returns the same stream, capability, and state errors as
decode, plus FailedPrecondition when output modes are
mixed before a flush and ResourceExhausted while every recyclable DPB
slot remains retained by native frames or consumer completions.
Sourcepub fn read_native_yuv420p(&mut self, frame: &VideoFrame) -> Result<Vec<u8>>
pub fn read_native_yuv420p(&mut self, frame: &VideoFrame) -> Result<Vec<u8>>
Read one retained native frame as tightly packed planar 8-bit YUV 4:2:0.
The exact frame slot is copied; this does not observe the decoder’s newest slot by accident. The synchronous operation waits for producer readiness, performs explicit decode/compute queue-family ownership transfers, restores the image to its codec layout, and registers the final submission as a consumer completion before reading host bytes.
§Errors
Returns an error after close, for a non-native frame, for a frame produced by another decoder, for an unsupported native format, or when submission, synchronization, or readback fails.
Sourcepub fn read_native_yuv420p10(&mut self, frame: &VideoFrame) -> Result<Vec<u16>>
pub fn read_native_yuv420p10(&mut self, frame: &VideoFrame) -> Result<Vec<u16>>
Read a retained native frame into packed 10-bit yuv420p10le samples.
Samples are little-endian u16 lanes with the significant bits
right-justified. The same synchronization contract as
read_native_yuv420p applies.
§Errors
Returns an error after close, for a non-native frame, for an 8-bit frame, or when submission, synchronization, or readback fails.
Sourcepub fn native_frame_texture(&mut self, frame: &VideoFrame) -> Result<Texture>
pub fn native_frame_texture(&mut self, frame: &VideoFrame) -> Result<Texture>
Convert one retained native frame into a packed RGBA8 Texture.
The plane pack and color conversion execute on the device; no decoded
samples cross to the host. The frame’s color metadata selects the Y’CbCr
matrix and component range with the same Unspecified fallback as
crate::video::to_matrix (BT.709, limited range). The decoder slot is
released once the conversion submission completes; the returned texture
is an independent image-backed value with its own producer event.
§Errors
Returns an error after close, for a non-native frame, for a frame produced by another decoder, for an unsupported native format, for a Compatibility-profile build without the conversion kernel, or when submission or synchronization fails.
Sourcepub fn stage_native_planes(&self, frame: &VideoFrame) -> Result<VideoFrame>
pub fn stage_native_planes(&self, frame: &VideoFrame) -> Result<VideoFrame>
Copy an already-decoded I420, NV12, or P010 frame into device plane buffers.
The output supports VideoFrame::to_matrix. I420 and NV12 also support
native geometry and luma operations. The copy can be recorded inside
Engine::capture. The plan retains the decoder image layer and restores
its ownership on each replay.
§Errors
Returns an error for closed or mismatched decoders, unsupported formats, or failure to allocate or record the planes.
Sourcepub fn record_to_planes(
&self,
packets: &[VideoPacket],
) -> Result<Vec<VideoFrame>>
pub fn record_to_planes( &self, packets: &[VideoPacket], ) -> Result<Vec<VideoFrame>>
Record a self-contained packet sequence into an active execution capture.
Packets enter in decode order, beginning with a random-access access unit. H.264 requires an IDR with SPS/PPS, HEVC an IRAP with VPS/SPS/PPS, AV1 a key picture with its sequence header, and VP9 a key picture. The returned device-planar frames follow presentation order. Hidden pictures update decode state and show-existing pictures reuse their reconstructed image. No packet pixels cross the host.
The plan owns its compressed bytes and decode session. This decoder’s live packet position and pending frames are unaffected.
§Errors
Returns an error outside capture, after close, for an empty sequence, for packets from another track or with changing codec parameters, or when the decoder cannot plan the sequence.
Sourcepub fn flush(&mut self) -> Result<Vec<VideoFrame>>
pub fn flush(&mut self) -> Result<Vec<VideoFrame>>
Reset stream sequencing at a seek boundary.
Return every delayed frame in presentation order and require the next packet to be random access. A second flush returns an empty vector.
Sourcepub fn info(&self) -> Option<VideoContainerInfo>
pub fn info(&self) -> Option<VideoContainerInfo>
Return the selected stream metadata while open.