From 8c3a6beab427848af00322dc223e71308bdf9641 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Thu, 13 Feb 2025 22:15:02 +0100 Subject: [PATCH] Add blur parameter --- resize.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/resize.cpp b/resize.cpp index fd0e690..b3a099d 100644 --- a/resize.cpp +++ b/resize.cpp @@ -835,6 +835,22 @@ class CustomZimgFilter : public Filter { }; +class BlurFilter : public Filter { + std::unique_ptr impl; + double blur; + +public: + BlurFilter(std::unique_ptr impl, double blur = 1.0) + : impl(std::move(impl)) + , blur(blur) + {} + + unsigned support() const override { return ceil(blur * impl->support()); } + + double operator()(double x) const override { return (*impl)(x / blur); } +}; + + struct vszimg_userdata { zimg_resample_filter_e filter; bool custom; @@ -1046,6 +1062,11 @@ class vszimg { filters[1] = translate_resize_filter(resample_filter_uv, filter_param_a_uv, filter_param_b_uv); } + double blur = propGetScalarDef(in, "blur", 1.0, vsapi); + for (int i = 0; i < 2; i++) { + filters[i] = std::make_unique(std::move(filters[i]), blur); + } + lookup_enum_str_opt(in, "dither_type", g_dither_type_table, h_dither_type_table, &m_params.dither_type, vsapi); lookup_enum_str_opt(in, "cpu_type", g_cpu_type_table, h_cpu_type_table, &m_params.cpu_type, vsapi); @@ -1429,6 +1450,7 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin *plugin, const VSPLUGINAPI INT_OPT(force) \ INT_OPT(force_h) \ INT_OPT(force_v) \ + FLOAT_OPT(blur) \ static const char RESAMPLE_ARGS[] = "clip:vnode;"