From 677c409eed219f8bd28b1863a840a1052f7a8acc Mon Sep 17 00:00:00 2001 From: emotion3459 <176516814+emotion3459@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:36:24 -0400 Subject: [PATCH] vdecimate: refactor, fix weight override (#40) * vdecimate: refactor * Update ivtc.py --- vsdeinterlace/ivtc.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/vsdeinterlace/ivtc.py b/vsdeinterlace/ivtc.py index db38afb..7ff8ac1 100644 --- a/vsdeinterlace/ivtc.py +++ b/vsdeinterlace/ivtc.py @@ -217,28 +217,19 @@ def vdecimate(clip: vs.VideoNode, weight: float = 0.0, **kwargs: Any) -> vs.Vide if not kwargs.get('clip2', None) and func.work_clip.format is not clip.format: vdecimate_kwargs |= dict(clip2=clip) - if kwargs.get('dryrun', None): - weight = 0.0 + dryrun = kwargs.pop('dryrun', False) - if weight: - vdecimate_kwargs |= dict(dryrun=True) + if dryrun or weight: + stats = func.work_clip.vivtc.VDecimate(dryrun=True, **(vdecimate_kwargs | kwargs)) - avg = clip.std.AverageFrames(weights=[0, 1 - weight, weight]) - - if kwargs.get('dryrun', None): - stats = func.work_clip.vivtc.VDecimate(**(vdecimate_kwargs | kwargs)) - - if not weight: + if dryrun: return stats - vdecimate_kwargs.pop('dryrun', None) + clip = kwargs.pop('clip2', clip) + avg = clip.std.AverageFrames(weights=[0, 1 - weight, weight]) splice = find_prop_rfs(clip, avg, "VDecimateDrop", "==", 1, stats) - - if kwargs.get('clip2', None): - vdecimate_kwargs |= dict(clip2=splice) - else: - func.work_clip = splice + vdecimate_kwargs |= dict(clip2=splice) decimate = func.work_clip.vivtc.VDecimate(**(vdecimate_kwargs | kwargs))