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:
- Source frames buffer into lookahead groups of
AltrefStreamConfig::altref_windowframes. - When a group completes,
crate::arnr::build_arnr_altrefsynthesizes a noise-reduced anchor aligned to the group’s last frame, andcrate::encoder::encode_invisible_altref_updateships it as an invisible frame (§9.1show_frame = 0, §9.7refresh_alternate_frame = 1/refresh_last = 0). - The group’s frames then encode as visible multi-reference
P-frames whose per-MB §16.2
ref_frameselector 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
impl Vp8AltrefStreamEncoder
Sourcepub fn new(config: AltrefStreamConfig) -> Option<Self>
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).
Sourcepub fn config(&self) -> &AltrefStreamConfig
pub fn config(&self) -> &AltrefStreamConfig
The configuration this stream was built with.
Sourcepub fn next_qindex(&self) -> u8
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.
Sourcepub fn input_count(&self) -> u64
pub fn input_count(&self) -> u64
Total source frames pushed so far (buffered + encoded).
Sourcepub fn buffered(&self) -> usize
pub fn buffered(&self) -> usize
Source frames currently buffered awaiting their group to
complete (the current lag, 0..altref_window).
Sourcepub fn push_frame(
&mut self,
frame: &I420Frame<'_>,
) -> Result<Vec<AltrefStreamPacket>, StreamEncodeError>
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.
Sourcepub fn finish(&mut self) -> Result<Vec<AltrefStreamPacket>, StreamEncodeError>
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.