sample_indices

Function sample_indices 

Source
pub fn sample_indices(
    n_frames: usize,
    native_fps: f32,
    target_fps: f32,
    min_frames: usize,
    max_frames: usize,
    temporal_patch_size: usize,
) -> Vec<usize>
Expand description

Pick which frame indices to keep so the clip plays at fps.

native_fps is what the container says it runs at. Sampling is by NEAREST-INDEX over a uniform grid rather than by dropping every Nth frame: the latter quantises badly when the ratio is not an integer (a 30fps clip sampled at 2fps by “keep every 15th” is fine, at 2.5fps it is not).

The result is clamped into [min_frames, max_frames] and then to a multiple of temporal_patch_size, because a partial group cannot be encoded. Returns indices into the decoded frame list.