Last active
March 25, 2024 01:56
-
-
Save wiwaz/9555b86a353bd55c7a2fc2190db7f6aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LowpassType(Enum): | |
Test1 = 0 | |
"""Two horizontal 1x resamples, for DVDs""" | |
Test2 = 1 | |
"""One 1x resample in both directions, for BDs""" | |
class FmtConvLanczos(vskernels.FmtConv): | |
_kernel = "lanczos" | |
def dvd_deblur( | |
clip: vs.VideoNode, | |
clean: vs.VideoNode, | |
method: Enum, | |
blur: float | tuple[float, float], | |
taps: int = 4, | |
postfilter: vstools.GenericVSFunction = None, | |
draft: bool = False, | |
) -> vs.VideoNode: | |
lpf = FmtConvLanczos(taps) | |
if method == LowpassType(0): | |
mangle = lpf.scale(clean, clip.width, clip.height, fh=1 / blur[0]) | |
mangle = lpf.scale(mangle, clip.width, clip.height, fh=1 / blur[1]) | |
elif method == LowpassType(1): | |
mangle = lpf.scale(clean, clip.width, clip.height, fh=1 / blur, fv=1 / blur) | |
diff = core.std.MakeDiff(clean, mangle) | |
if draft: | |
return (mangle, diff) | |
if postfilter: | |
clip = postfilter((clip, mangle)) | |
return core.std.MergeDiff(clip, diff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clever!