From 335ba978dbaf203f3603a815147fd75dbf205723 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 27 Apr 2025 20:00:44 +0200 Subject: move cache to own crate --- transcoder/src/lib.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'transcoder/src/lib.rs') diff --git a/transcoder/src/lib.rs b/transcoder/src/lib.rs index 1cf5d0d..c49f52c 100644 --- a/transcoder/src/lib.rs +++ b/transcoder/src/lib.rs @@ -5,11 +5,35 @@ */ #![feature(exit_status_error)] -use tokio::sync::Semaphore; +use serde::{Deserialize, Serialize}; +use std::sync::LazyLock; +use tokio::sync::{Mutex, Semaphore}; + pub mod fragment; pub mod image; pub mod subtitles; pub mod thumbnail; +#[rustfmt::skip] +#[derive(Debug, Deserialize, Serialize, Default)] +pub struct Config { + #[serde(default)] pub enable_rkmpp: bool, + #[serde(default)] pub enable_rkrga: bool, + #[serde(default)] pub use_svtav1: bool, + #[serde(default)] pub use_rav1e: bool, + pub svtav1_preset: Option, // 0..=13, high is fast + pub rav1e_preset: Option, // 0..=10 + pub aom_preset: Option, // 0..=8, high is fast + pub x264_preset: Option, +} + +static CONF: LazyLock = LazyLock::new(|| { + CONF_PRELOAD + .blocking_lock() + .take() + .expect("cache config not preloaded. logic error") +}); +static CONF_PRELOAD: Mutex> = Mutex::const_new(None); + static LOCAL_IMAGE_TRANSCODING_TASKS: Semaphore = Semaphore::const_new(8); static LOCAL_VIDEO_TRANSCODING_TASKS: Semaphore = Semaphore::const_new(2); -- cgit v1.2.3-70-g09d2