use const_str::cstr;
use strum_macros::EnumString;
use vapoursynth4_rs::{
core::Core,
key,
map::{AppendMode, Value},
node::VideoNode,
};
use crate::errors::VapoursError;
const FMTCONV_NAMESPACE: &str = "fmtc";
#[derive(Clone, Copy, Debug, EnumString, Eq, PartialEq)]
#[strum(ascii_case_insensitive, serialize_all = "snake_case")]
pub enum DitherType {
Auto,
None,
Ordered,
Random,
ErrorDiffusion,
ErrorDiffusionFmtc,
#[strum(serialize = "sierra_2_4a")]
Sierra24a,
Stucki,
Atkinson,
Ostromoukhov,
Void,
Quasirandom,
}
pub trait VapoursCore {
fn depth(&self, clip: VideoNode, bit_depth: u32) -> Result<VideoNode, VapoursError>;
}
impl VapoursCore for Core {
#[allow(unreachable_code)]
#[allow(unused_variables)]
fn depth(&self, clip: VideoNode, bit_depth: u32) -> Result<VideoNode, VapoursError> {
todo!("Needs configurable dither type, non-fmtc dithering, and probably more.");
let Some(fmtc_plugin) = self.get_plugin_by_id(cstr!(FMTCONV_NAMESPACE)) else {
return Err(VapoursError::DependencyNotFoundError(
FMTCONV_NAMESPACE.to_string(),
));
};
let mut args = self.create_map();
args
.set(key!(c"clip"), Value::VideoNode(clip), AppendMode::Replace)
.map_err(|_| VapoursError::FramePropertyError("clip".to_string()))?;
args
.set(
key!(c"bitdepth"),
Value::Int(i64::from(bit_depth)),
AppendMode::Replace,
)
.map_err(|_| VapoursError::FramePropertyError("clip".to_string()))?;
let ret = fmtc_plugin.invoke(cstr!("bitdepth"), &args);
ret
.get_video_node(key!(c"clip"), 0)
.map_err(|_| VapoursError::FramePropertyError("clip".to_string()))
}
}