Skip to main content

Vp8AltrefStreamEncoder

Struct Vp8AltrefStreamEncoder 

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

Lagged multi-frame VP8 encoder with automatic invisible-altref management — the B-frame-less GOLDEN / ALTREF pattern assembled from this round’s building blocks:

  1. Source frames buffer into lookahead groups of AltrefStreamConfig::altref_window frames.
  2. When a group completes, crate::arnr::build_arnr_altref synthesizes a noise-reduced anchor aligned to the group’s last frame, and crate::encoder::encode_invisible_altref_update ships it as an invisible frame (§9.1 show_frame = 0, §9.7 refresh_alternate_frame = 1 / refresh_last = 0).
  3. The group’s frames then encode as visible multi-reference P-frames whose per-MB §16.2 ref_frame selector can predict from the anchor — forward prediction from a picture that is never displayed.

Because the pipeline is lagged, Self::push_frame returns zero or more packets per call and Self::finish drains the tail group. Packets must reach the decoder in emission order; visible packets map 1:1 onto source frames (source_index), invisible anchors carry source_index = None.

The encoder mirrors the §9.7 / §9.8 slot ladder exactly as crate::state::Vp8DecoderState applies it, so every packet self-decodes in pixel lockstep (pinned by tests/encoder_altref_stream.rs).

Implementations§

Source§

impl Vp8AltrefStreamEncoder

Source

pub fn new(config: AltrefStreamConfig) -> Option<Self>

Build a fresh lagged encoder. Returns None when config.altref_window == 0 (a zero-frame lookahead group cannot make progress).

Source

pub fn config(&self) -> &AltrefStreamConfig

The configuration this stream was built with.

Source

pub fn next_qindex(&self) -> u8

The §9.6 quantiser index the next frame will be coded at: the configured params.y_ac_qi, or the rate control’s current choice.

Source

pub fn input_count(&self) -> u64

Total source frames pushed so far (buffered + encoded).

Source

pub fn buffered(&self) -> usize

Source frames currently buffered awaiting their group to complete (the current lag, 0..altref_window).

Source

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

Feed one source frame; returns every packet the stream can emit so far (empty while the lookahead group is still filling).

Dimensions are locked at the first frame (StreamEncodeError::DimensionsChanged otherwise). A frame scheduled as a key frame closes the in-progress group early so the key frame starts a fresh group.

Source

pub fn finish(&mut self) -> Result<Vec<AltrefStreamPacket>, StreamEncodeError>

Drain the in-progress lookahead group (call once after the final push_frame). Idempotent — a drained stream returns no packets.

Trait Implementations§

Source§

impl Clone for Vp8AltrefStreamEncoder

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 Vp8AltrefStreamEncoder

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.