Skip to main content

Vp8KeyframeStreamEncoder

Struct Vp8KeyframeStreamEncoder 

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

Multi-frame VP8 keyframe encoder driver.

One instance owns the cross-frame state of a single VP8 elementary stream: the frame counter, the locked-after-first-frame dimensions, and the §9 three-slot reference-frame buffer (LAST / GOLDEN / ALTREF).

All emitted frames are key frames this round. Each successful Self::encode_frame call:

  1. Validates that this frame’s dimensions match the first frame’s (or, on the first call, locks them in).
  2. Calls encode_keyframe_with_reconstruction with the driver’s KeyframeParams.
  3. Replaces all three reference slots with a clone of the macroblock-aligned post-§15 reconstruction (§9.7 / §9.8 keyframe refresh).
  4. Increments the frame counter.
  5. Returns the emitted bytes.

Construct with Self::new and drive with Self::encode_frame. Self::frame_count, Self::dimensions, and the per-slot accessors Self::last, Self::golden, Self::altref expose the running state.

Implementations§

Source§

impl Vp8KeyframeStreamEncoder

Source

pub fn new(params: KeyframeParams) -> Self

Build a fresh stream encoder configured with the supplied per-frame KeyframeParams. Same parameters are applied to every encoded frame in this stream.

The frame counter starts at 0 and all three reference slots start as None. The dimensions are not locked until the first encode_frame call.

Source

pub fn encode_frame( &mut self, frame: &I420Frame<'_>, ) -> Result<Vec<u8>, StreamEncodeError>

Encode one frame of the stream as a VP8 key frame.

On the first call this also locks the stream’s dimensions to frame’s visible width/height. Every subsequent call must supply a frame with the same dimensions; a mismatch is surfaced as StreamEncodeError::DimensionsChanged and leaves the encoder state unchanged.

Returns the raw bytes of one VP8 elementary-stream frame (one packet = one frame) ready to be fed to a container muxer (e.g. IVF) or decoded directly through crate::decode_vp8 / crate::state::Vp8DecoderState::decode_frame.

Source

pub fn encode_frame_with_fitted_token_prob_updates( &mut self, frame: &I420Frame<'_>, ) -> Result<Vec<u8>, StreamEncodeError>

Encode one frame of the stream as a VP8 key frame, with an automatically-fitted §13.4 token_prob_update() payload per crate::encoder::encode_keyframe_with_reconstruction_and_fitted_token_prob_updates.

Drop-in fitted companion to Self::encode_frame: same K/P scheduling rules (every emitted frame is a key frame on this driver), same dimension-lock semantics, same §9.7 / §9.8 three-slot refresh — only the bitstream differs (the fitter is allowed to shrink the wire by overlaying observed-counts probabilities on the §13.5 defaults, with the round-157 fitter’s safety guard that never grows the wire relative to the caller-driven None baseline).

The returned bytes always decode through crate::state::Vp8DecoderState::decode_frame and every compliant VP8 decoder; the §9 reference-frame slots are refreshed with the matching reconstruction (the round-157 safety-guard fall-back returns the default-pass planes alongside the default-pass bytes, so the slot state stays consistent with the wire on both fitter outcomes).

Closes the round-157 / round-158 follow-up identified in crate::encoder::encode_p_frame_multi_ref_with_refresh_and_lf_deltas_and_fitted_token_prob_updates (“Out of round-158 scope: threading the fitter into Vp8KeyframeStreamEncoder / Vp8InterStreamEncoder”).

Source

pub fn frame_count(&self) -> u64

Number of frames successfully encoded so far.

Source

pub fn dimensions(&self) -> Option<(u32, u32)>

Stream dimensions, locked at the first successful encode_frame call. None before then.

Source

pub fn last(&self) -> Option<&RefFrameSlot>

Borrow the current LAST reference slot. None before the first frame.

Source

pub fn golden(&self) -> Option<&RefFrameSlot>

Borrow the current GOLDEN reference slot. None before the first frame.

Source

pub fn altref(&self) -> Option<&RefFrameSlot>

Borrow the current ALTREF reference slot. None before the first frame.

Source

pub fn params(&self) -> &KeyframeParams

Borrow the KeyframeParams applied to every frame this stream emits.

Trait Implementations§

Source§

impl Clone for Vp8KeyframeStreamEncoder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Vp8KeyframeStreamEncoder

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.