Skip to main content

Vp8Decoder

Struct Vp8Decoder 

Source
pub struct Vp8Decoder { /* private fields */ }
Expand description

oxideav_core::Decoder impl driving [Vp8DecoderState].

Each send_packet queues one compressed packet; receive_frame consumes queued packets and feeds them to Vp8DecoderState::decode_frame, which threads reference frames and entropy carry-state across calls. Both key frames and interframes decode end-to-end; the only DecodeError::Unsupported returned now is “interframe arrived before any key frame” (a stream-mis-feed error, not a missing feature).

§Invisible frames

A frame whose §9.1 show_frame bit is 0 is “not for display”: it is decoded (its §9.7 / §9.8 reference-slot side effects apply) but no picture is returned for it — receive_frame moves on to the next queued packet, and answers Error::NeedMore when that was the last one. Only shown pictures reach the caller.

§Stream parameters

Decoder::output_params answers the resolved description of the pictures this decoder returns: the §9.1 visible width / height (the cropped size of the emitted planes, not the macroblock-aligned one), PixelFormat::Yuv420P, and the §9.2 color_space as the colour signal’s matrix. Before the first picture it answers from the key frame already decoded, else from the first queued key frame’s headers.

Only a key frame can change that description (§9.1 / §9.2 are key-frame-only fields). When the first shown picture of a new description is about to be returned, the decoder bumps Decoder::output_params_generation and returns one Frame::StreamParams event carrying the new output_params() first; the picture follows on the next call. No event is returned for the first description, for a key frame that repeats the current one, or for an invisible key frame (the event waits for the first shown picture of the new size). Decoder::reset keeps the description of the last picture returned, so a seek into a segment of a different size announces it the same way.

The §9.1 upscale codes and the §9.2 clamping_type bit do not change the emitted planes and are not part of the description; Vp8Decoder::upscale / Vp8Decoder::clamping_type expose them.

The decoder runs serially; it keeps the default no-op Decoder::set_execution_context.

Implementations§

Source§

impl Vp8Decoder

Source

pub fn new(codec_id: CodecId) -> Self

Build a fresh decoder bound to the supplied codec id. The id is reported verbatim by Decoder::codec_id. The internal Vp8DecoderState starts empty — the first packet fed to send_packet / receive_frame must be a key frame.

Source

pub fn with_limits(codec_id: CodecId, limits: DecoderLimits) -> Self

Build a decoder that enforces limits.max_pixels_per_frame as the §9.1 declared-frame-size cap. Any key frame whose declared width × height exceeds the cap is refused with Error::ResourceExhausted before the decoder allocates its macroblock grid. Constructed by make_decoder from the CodecParameters::limits the registry threads in. The cap survives Decoder::reset.

Source

pub fn upscale(&self) -> Option<(ScaleCode, ScaleCode)>

§9.1 (horizontal_scale, vertical_scale) upscale codes of the most recently decoded key frame — a display hint that does not change the emitted planes. None before any key frame.

Source

pub fn clamping_type(&self) -> Option<bool>

§9.2 clamping_type bit of the most recently decoded key frame (Some(true) = the encoder guarantees in-range pixels). None before any key frame.

Trait Implementations§

Source§

impl Debug for Vp8Decoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Decoder for Vp8Decoder

Source§

fn set_execution_context(&mut self, ctx: &ExecutionContext)

Take the thread budget for each frame’s decode from the framework (serial unless one is announced). The pictures do not depend on it.

Source§

fn codec_id(&self) -> &CodecId

Identifier of the codec this decoder handles.
Source§

fn send_packet(&mut self, packet: &Packet) -> Result<()>

Feed one compressed packet. May or may not produce a frame immediately — call receive_frame in a loop afterwards.
Source§

fn receive_frame(&mut self) -> Result<Frame>

Pull the next decoded frame, if any. Returns Error::NeedMore when the decoder needs another packet. Read more
Source§

fn flush(&mut self) -> Result<()>

Signal end-of-stream. After this, receive_frame will drain buffered frames and eventually return Error::Eof.
Source§

fn reset(&mut self) -> Result<()>

Discard all carry-over state so the decoder can resume from a new bitstream position without producing stale output. Called by the player after a container seek. Read more
Source§

fn output_pixel_format(&self) -> Option<PixelFormat>

Pixel layout of the video frames this decoder emits, stated before the first frame — from the codec’s configuration record in extradata, from a negotiated hardware session, or from the decoder’s fixed output policy. Some is a fact about the frames to come and takes precedence over the container’s CodecParameters::pixel_format (a stream label is a claim the container made; the decoder is the one producing the planes). None — the default — means “not known yet: trust the stream parameters”, and a decoder whose output depends on the first packet (an untagged file that decides its layout per picture) answers None until it has seen one and the real layout afterwards. Read more
Source§

fn output_params(&self) -> Option<CodecParameters>

The decoder’s resolved description of the frames it emits — the stream-level home for what Frames deliberately do not repeat (a VideoFrame / AudioFrame carries no width, height, format or rate: the shape does not change 60 times a second, so it is stated once, here, and re-stated only when it changes). Read more
Source§

fn output_params_generation(&self) -> u64

A cheap change signal for output_params: an integer that changes whenever the output description changes mid-stream (a resolution switch at a keyframe, a new pixel format at a new sequence header, a sample-rate change in a chained stream). Consumers keep the last value they saw and compare one integer after each successful receive_frame; only when it differs do they re-read output_params(). Frames carry nothing extra. Read more
Source§

fn receive_arena_frame(&mut self) -> Result<Arc<FrameInner>, Error>

Pull the next decoded frame as an arena-backed arena::sync::Frame. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.