Add thread pool support for BGI CBG Decoder

This commit is contained in:
2025-09-13 18:44:45 +08:00
parent 8df08f487b
commit e5e437b1e3
10 changed files with 280 additions and 13 deletions

View File

@@ -426,6 +426,11 @@ pub struct ExtraConfig {
#[default(true)]
/// Whether to filter ascii strings in Favorite HCB script.
pub favorite_hcb_filter_ascii: bool,
#[cfg(feature = "bgi-img")]
#[default(get_default_threads())]
/// Workers count for decode BGI compressed images v2 in parallel. Default is half of CPU cores.
/// Set this to 1 to disable parallel decoding. 0 means same as 1.
pub bgi_img_workers: usize,
}
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]
@@ -915,3 +920,9 @@ impl AsRef<str> for LosslessAudioFormat {
}
}
}
#[cfg(feature = "utils-threadpool")]
#[allow(unused)]
pub(crate) fn get_default_threads() -> usize {
num_cpus::get().max(2) / 2
}