Skip to content

Commit

Permalink
Add blur parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Feb 13, 2025
1 parent f2c97f8 commit 8c3a6be
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,22 @@ class CustomZimgFilter : public Filter {
};


class BlurFilter : public Filter {
std::unique_ptr<Filter> impl;
double blur;

public:
BlurFilter(std::unique_ptr<Filter> 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;
Expand Down Expand Up @@ -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<double>(in, "blur", 1.0, vsapi);
for (int i = 0; i < 2; i++) {
filters[i] = std::make_unique<BlurFilter>(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);

Expand Down Expand Up @@ -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;"
Expand Down

0 comments on commit 8c3a6be

Please # to comment.