Remove unneeded dependency, replace helper with macro

This commit is contained in:
kageru 2020-02-19 20:20:45 +01:00
parent a687dd90c4
commit ecab0b5028
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
2 changed files with 11 additions and 12 deletions

View File

@ -7,7 +7,6 @@ edition = "2018"
[dependencies] [dependencies]
failure = "0.1" failure = "0.1"
lazy_static = "1.3.0" lazy_static = "1.3.0"
num = "0.2"
vapoursynth = "0.2" vapoursynth = "0.2"
vapoursynth-sys = "0.2" vapoursynth-sys = "0.2"

View File

@ -1,6 +1,5 @@
use super::PLUGIN_NAME; use super::PLUGIN_NAME;
use failure::Error; use failure::Error;
use std::fmt::Debug;
use std::ptr; use std::ptr;
use vapoursynth::core::CoreRef; use vapoursynth::core::CoreRef;
use vapoursynth::format::ColorFamily; use vapoursynth::format::ColorFamily;
@ -31,12 +30,13 @@ fn get_mask_value(x: f32, y: f32, luma_scaling: f32) -> f32 {
) )
} }
#[inline] macro_rules! from_property {
fn from_property<T: Debug + Clone + Copy + Eq + PartialEq>(prop: Property<T>) -> T { ($prop: expr) => (
match prop { match $prop {
Property::Constant(p) => p, Property::Constant(p) => p,
Property::Variable => unreachable!(), Property::Variable => unreachable!(),
} }
)
} }
macro_rules! int_filter { macro_rules! int_filter {
@ -131,13 +131,13 @@ impl<'core> Filter<'core> for Mask<'core> {
context: FrameContext, context: FrameContext,
n: usize, n: usize,
) -> Result<FrameRef<'core>, Error> { ) -> Result<FrameRef<'core>, Error> {
let new_format = from_property(self.video_info(_api, core)[0].format); let new_format = from_property!(self.video_info(_api, core)[0].format);
let mut frame = unsafe { let mut frame = unsafe {
FrameRefMut::new_uninitialized( FrameRefMut::new_uninitialized(
core, core,
None, None,
new_format, new_format,
from_property(self.source.info().resolution), from_property!(self.source.info().resolution),
) )
}; };
let src_frame = self.source.get_frame_filter(context, n).ok_or_else(|| { let src_frame = self.source.get_frame_filter(context, n).ok_or_else(|| {
@ -151,9 +151,9 @@ impl<'core> Filter<'core> for Mask<'core> {
)), )),
}; };
match from_property(self.source.info().format).sample_type() { match from_property!(self.source.info().format).sample_type() {
SampleType::Integer => { SampleType::Integer => {
let depth = from_property(self.source.info().format).bits_per_sample(); let depth = from_property!(self.source.info().format).bits_per_sample();
match depth { match depth {
0..=8 => { 0..=8 => {
int_filter!(u8, filter_8bit); int_filter!(u8, filter_8bit);