Skip to main content

CoverFetch

Trait CoverFetch 

Source
pub trait CoverFetch {
    // Required methods
    fn total_positions(&self) -> usize;
    fn num_segments(&self) -> usize;
    fn segment_size_in_blocks(&self) -> usize;
    fn fetch_segment(&mut self, seg_idx: usize) -> (Vec<u8>, Vec<f32>);
}
Expand description

Cover-fetch callback signature for streaming-segmented STC.

get_segment(seg_idx) -> (bits, costs) returns the cover bits and costs for segment seg_idx. Each segment is K × w cover positions where K is the segment size in message blocks.

The callback may be invoked multiple times for the same seg_idx (Phase A and Phase B both visit each segment). Implementations must return identical data on repeated calls for correctness.

Required Methods§

Source

fn total_positions(&self) -> usize

Total cover position count n.

Source

fn num_segments(&self) -> usize

Number of segments. Equals m.div_ceil(K) where K is the segment size.

Source

fn segment_size_in_blocks(&self) -> usize

Segment size in message blocks (constant across segments except possibly the last). The last segment may have fewer blocks if m doesn’t divide evenly by K.

Source

fn fetch_segment(&mut self, seg_idx: usize) -> (Vec<u8>, Vec<f32>)

Fetch one segment’s cover bits and costs.

Returned vectors have length (K × w) (full segment) or shorter if seg_idx == num_segments() - 1 and m doesn’t divide evenly by K.

Implementations should free transient state (the encoder per-GOP working set) after returning; the caller releases the returned vectors after a single segment’s traceback.

Implementors§