Add ability to pass a custom kernel in resize plugin
Setsugennoao opened this issue · 3 comments
It would have a simple API with just a custom_kernel
and taps
parameters, like this function from the descaling plugin.
In other terms this would just be a way of making a dynamic zimg::resize::Filter
taps would be support() and the custom kernel func is operator()
I'm making this issue mainly to ask if there's the interest in adding it into the resize plugin or if it's out of scope for @sekrit-twc; if it's not I can attach a draft PR to this and we can move discussion there 👍🏻
Some of the things this lets us implement without having them in the zimg package:
- kernel blurring
https://imagemagick.org/script/command-line-options.php#filter look forfilter:blur
this for example is essential to recreate photoshop kernels https://entropymine.com/resamplescope/notes/photoshop - custom support or lobes for whatever kernel
- custom windowed kernels https://github.com/Jaded-Encoding-Thaumaturgy/vs-kernels/blob/master/vskernels/kernels/impulse.py
could even make a faster approximate gaussian blur https://github.com/Jaded-Encoding-Thaumaturgy/vs-rgtools/blob/master/vsrgtools/blur.py#L217-L219
Some of this stuff can be accomplished with a mix of fmtc and placebo but the former is not nearly as optimized as zimg and the latter only works with a gpu; both have limited bitdepth/colorspace support and fucky API.
Implementing both would replace a lot of their use cases and make parts of many filterchains way faster.
This is by no means code I intend to PR (since it changes from zimg API to internal zimg stuff etc.), but more of a PoC to show what I meant to implement:
https://github.com/Setsugennoao/vapoursynth/blob/zimg-custom-kernel/src/core/vsresize.cpp