From 2bcb5ba152ed428d26ef2924a411defb0852ae2e Mon Sep 17 00:00:00 2001 From: akarin Date: Wed, 9 Jun 2021 08:13:29 -0400 Subject: [PATCH 1/2] muvsfunc.py: use akarin.Expr instead of mt_lutspa Signed-off-by: akarin --- muvsfunc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/muvsfunc.py b/muvsfunc.py index ace7808..7d90fc4 100644 --- a/muvsfunc.py +++ b/muvsfunc.py @@ -2029,7 +2029,7 @@ def ColorBarsHD(clip: Optional[vs.VideoNode] = None, width: int = 1288, height: ''' funcName = 'ColorBarsHD' - from mt_lutspa import lutspa + #from mt_lutspa import lutspa if clip is not None and not isinstance(clip, vs.VideoNode): raise TypeError(funcName + ': \"clip\" must be a clip!') @@ -2065,7 +2065,8 @@ def ColorBarsHD(clip: Optional[vs.VideoNode] = None, width: int = 1288, height: pattern3_colors = dict(Yellow100=[219, 16, 138], Red100=[63, 102, 240]) Yellow100 = core.std.BlankClip(clip, d, p23, color=pattern3_colors['Yellow100'], **blkclip_args) Y_Ramp_tmp = core.std.BlankClip(clip, c*7, 1, color=[0, 128, 128], **blkclip_args) - Y_Ramp = lutspa(Y_Ramp_tmp, mode='absolute', y_expr='220 x * {c} 7 * / 16 +'.format(c=c), chroma='copy') + #Y_Ramp = lutspa(Y_Ramp_tmp, mode='absolute', y_expr='220 x * {c} 7 * / 16 +'.format(c=c), chroma='copy') + Y_Ramp = core.akarin.Expr(Y_Ramp_tmp, ['220 X * {c} 7 * / 16 +'.format(c=c), '']) Y_Ramp = core.resize.Point(Y_Ramp, c*7, p23) Red100 = core.std.BlankClip(clip, d, p23, color=pattern3_colors['Red100'], **blkclip_args) pattern3 = core.std.StackHorizontal([Yellow100, Y_Ramp, Red100]) From d5d115a273dcca6cb40800c9f2a96394592cfa56 Mon Sep 17 00:00:00 2001 From: akarin Date: Fri, 3 Sep 2021 03:59:50 -0400 Subject: [PATCH 2/2] ColorBarsHD: support both mt_lutspa and lexpr (prefer lexpr as it's more generally available and faster.) Signed-off-by: akarin --- muvsfunc.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/muvsfunc.py b/muvsfunc.py index 7d90fc4..e748612 100644 --- a/muvsfunc.py +++ b/muvsfunc.py @@ -82,6 +82,10 @@ hasattr(core, "akarin") and b'x.property' in core.akarin.Version()["expr_features"] ) +_has_lexpr_lutspa: bool = ( + hasattr(core, "akarin") and + b'X' in core.akarin.Version()["expr_features"] +) # Type aliases PlanesType = Optional[Union[int, Sequence[int]]] @@ -2011,6 +2015,7 @@ def ColorBarsHD(clip: Optional[vs.VideoNode] = None, width: int = 1288, height: By default, a 1288×720, YV24, TV range, 29.97 fps, 1 frame clip is produced. Requirment: + lexpr (https://github.com/AkarinVS/vapoursynth-plugin), or mt_lutspa by tp7 (https://gist.githubusercontent.com/tp7/1e39044e1b660ef0a02c) Args: @@ -2029,7 +2034,6 @@ def ColorBarsHD(clip: Optional[vs.VideoNode] = None, width: int = 1288, height: ''' funcName = 'ColorBarsHD' - #from mt_lutspa import lutspa if clip is not None and not isinstance(clip, vs.VideoNode): raise TypeError(funcName + ': \"clip\" must be a clip!') @@ -2065,8 +2069,11 @@ def ColorBarsHD(clip: Optional[vs.VideoNode] = None, width: int = 1288, height: pattern3_colors = dict(Yellow100=[219, 16, 138], Red100=[63, 102, 240]) Yellow100 = core.std.BlankClip(clip, d, p23, color=pattern3_colors['Yellow100'], **blkclip_args) Y_Ramp_tmp = core.std.BlankClip(clip, c*7, 1, color=[0, 128, 128], **blkclip_args) - #Y_Ramp = lutspa(Y_Ramp_tmp, mode='absolute', y_expr='220 x * {c} 7 * / 16 +'.format(c=c), chroma='copy') - Y_Ramp = core.akarin.Expr(Y_Ramp_tmp, ['220 X * {c} 7 * / 16 +'.format(c=c), '']) + if _has_lexpr_lutspa: + Y_Ramp = core.akarin.Expr(Y_Ramp_tmp, ['220 X * {c} 7 * / 16 +'.format(c=c), '']) + else: + from mt_lutspa import lutspa + Y_Ramp = lutspa(Y_Ramp_tmp, mode='absolute', y_expr='220 x * {c} 7 * / 16 +'.format(c=c), chroma='copy') Y_Ramp = core.resize.Point(Y_Ramp, c*7, p23) Red100 = core.std.BlankClip(clip, d, p23, color=pattern3_colors['Red100'], **blkclip_args) pattern3 = core.std.StackHorizontal([Yellow100, Y_Ramp, Red100])