performance improvement

This commit is contained in:
2026-05-28 14:00:38 +05:30
parent 0b5510636e
commit 413f06fb97
13 changed files with 1254 additions and 79 deletions

View File

@@ -15,6 +15,15 @@ pub struct Settings {
pub sam_model: Option<String>,
#[serde(default = "default_cache_capacity")]
pub cache_capacity: usize,
/// ffmpeg `-hwaccel` argument. Empty string = software decode (default).
/// Recognized: "auto", "vaapi", "cuda", "vdpau". Applied on next
/// `open_video` or worker respawn.
#[serde(default)]
pub hwaccel: String,
/// Decimation factor used by playback (advance by N frames per tick) and
/// bulk extract (take every Nth frame in range). 1 = no decimation.
#[serde(default = "default_frame_skip")]
pub frame_skip: u64,
}
fn default_sam_url() -> String {
@@ -25,11 +34,18 @@ fn default_cache_capacity() -> usize {
crate::decoder::DEFAULT_CACHE_CAPACITY
}
fn default_frame_skip() -> u64 {
1
}
fn normalize(mut s: Settings) -> Settings {
s.cache_capacity = s.cache_capacity.clamp(
crate::decoder::MIN_CACHE_CAPACITY,
crate::decoder::MAX_CACHE_CAPACITY,
);
if s.frame_skip < 1 {
s.frame_skip = 1;
}
s
}
@@ -40,6 +56,8 @@ impl Default for Settings {
sam_enabled: false,
sam_model: None,
cache_capacity: default_cache_capacity(),
hwaccel: String::new(),
frame_skip: default_frame_skip(),
}
}
}