Skip to content

Instantly share code, notes, and snippets.

@wiwaz
Last active March 25, 2024 01:56
Show Gist options
  • Save wiwaz/9555b86a353bd55c7a2fc2190db7f6aa to your computer and use it in GitHub Desktop.
Save wiwaz/9555b86a353bd55c7a2fc2190db7f6aa to your computer and use it in GitHub Desktop.
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)
@notcancername
Copy link

Clever!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment