From b4eb5d839903b1d79d72f2d79f78266d2723c8b9 Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 2 Jun 2019 14:43:53 +0200 Subject: [PATCH] only enable mask filter and properly check the input format --- src/lib.rs | 26 ++++++++++++++++---------- src/mask.rs | 2 -- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7b39ac6..fa4036f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,8 @@ use vapoursynth::frame::{FrameRef, FrameRefMut}; use vapoursynth::map::Map; use vapoursynth::node::Node; use vapoursynth::plugins::{Filter, FilterArgument, FrameContext, Metadata}; -use vapoursynth::video_info::VideoInfo; +use vapoursynth::video_info::{VideoInfo, Property}; +use vapoursynth::format::SampleType; pub const PLUGIN_NAME: &str = "adaptivegrain"; pub const PLUGIN_IDENTIFIER: &str = "moe.kageru.adaptivegrain"; @@ -76,7 +77,7 @@ make_filter_function! { _api: API, _core: CoreRef<'core>, clip: Node<'core>, - ) -> Result + 'core>>, Error> { + ) -> Result + 'core>>, Error> { Ok(Some(Box::new(AdaptiveGrain { source: clip }))) } } @@ -88,7 +89,7 @@ make_filter_function! { _api: API, _core: CoreRef<'core>, clip: Node<'core>, - ) -> Result + 'core>>, Error> { + ) -> Result + 'core>>, Error> { Ok(Some(Box::new(Grain { source: clip }))) } } @@ -101,15 +102,20 @@ make_filter_function! { _core: CoreRef<'core>, clip: Node<'core>, luma_scaling: Option - ) -> Result + 'core>>, Error> { + ) -> Result + 'core>>, Error> { let luma_scaling = match luma_scaling { Some(i) => i as f32, None => 10.0 }; - Ok(Some(Box::new(Mask { - source: clip, - luma_scaling - }))) + if let Property::Constant(format) = clip.info().format { + if format.bits_per_sample() == 32 && format.sample_type() == SampleType::Float { + return Ok(Some(Box::new(Mask { + source: clip, + luma_scaling + }))); + } + } + bail!("Currently, only constant 32bit float input is supported" ) } } @@ -121,8 +127,8 @@ export_vapoursynth_plugin! { read_only: false, }, [ - AdaptiveGrainFunction::new(), - GrainFunction::new(), + //AdaptiveGrainFunction::new(), + //GrainFunction::new(), MaskFunction::new() ] } diff --git a/src/mask.rs b/src/mask.rs index 27c950d..5e0b919 100644 --- a/src/mask.rs +++ b/src/mask.rs @@ -1,6 +1,4 @@ use failure::Error; -use faster::into_iters::*; -use faster::iters::*; use super::PLUGIN_NAME; use vapoursynth::api::API; use vapoursynth::core::CoreRef;