diff --git a/vsdeband/noise.py b/vsdeband/noise.py index 2c7e631..2b5dc47 100644 --- a/vsdeband/noise.py +++ b/vsdeband/noise.py @@ -12,7 +12,7 @@ from vstools import ( CustomIndexError, CustomOverflowError, CustomValueError, InvalidColorFamilyError, KwargsT, Matrix, MatrixT, VSFunctionNoArgs, check_variable, core, depth, fallback, get_neutral_values, get_peak_value, get_y, inject_self, - join, mod_x, plane, scale_8bit, split, vs + join, mod_x, plane, scale_8bit, split, vs, normalize_seq ) from .f3kdb import F3kdb @@ -221,30 +221,17 @@ def _try_grain(src: vs.VideoNode, stre: tuple[float, float] = strength, **args: grained = grained[self.temporal_radius:-self.temporal_radius] if self.fade_limits: - ... low, high = (None, None) if self.fade_limits is True else self.fade_limits - if low is None: - low = [scale_8bit(clip, 16), scale_8bit(clip, 16, True)] - elif not isinstance(low, Iterable): - low = [scale_8bit(clip, low), scale_8bit(clip, low, True)] - else: - low = [scale_8bit(clip, l, not not i) for i, l in enumerate(low)] - - if high is None: - high = [scale_8bit(clip, 235), scale_8bit(clip, 240, True)] - elif not isinstance(high, Iterable): - high = [scale_8bit(clip, high), scale_8bit(clip, high, True)] - else: - high = [scale_8bit(clip, h, not not i) for i, h in enumerate(high)] + low = [scale_8bit(clip, l, not not i) for i, l in enumerate(normalize_seq(fallback(low, 16)))] + high = [scale_8bit(clip, h, not not i) for i, h in enumerate(normalize_seq(fallback(high, [235, 240])))] - if complexpr_available: - limit_expr = 'y range_half - abs A! x A@ - {low} < x A@ + {high} > or range_half y ?' + if clip.format.sample_type is vs.FLOAT: + limit_expr = 'x y abs - {low} < x y abs + {high} > or range_diff y ?' + elif complexpr_available: + limit_expr = 'y range_diff - abs A! x A@ - {low} < x A@ + {high} > or range_diff y ?' else: - limit_expr = 'x y range_half - abs - {low} < x y range_half - abs + {high} > or range_half y ?' - - if clip.format.sample_type == vs.FLOAT: - limit_expr = [limit_expr, 'x y abs + {high} > x abs y - {low} < or range_half y ?'] + limit_expr = 'x y range_diff - abs - {low} < x y range_diff - abs + {high} > or range_diff y ?' grained = norm_expr([clip, grained], limit_expr, planes, low=low, high=high) diff --git a/vsdeband/placebo.py b/vsdeband/placebo.py index 70284a0..4e66896 100644 --- a/vsdeband/placebo.py +++ b/vsdeband/placebo.py @@ -121,9 +121,7 @@ def _placebo(clip: vs.VideoNode, thr: float, grain: float, planes: Iterable[int] set_grn = set(grain) if set_grn == {0} or clip.format.num_planes == 1: - def_grain = grain[0] if clip.format.num_planes == 1 else 0 - - debs = [_placebo(p, thr, def_grain, [0]) for p, thr in zip(split(clip), thr)] + debs = [_placebo(p, thr, grain[0], [0]) for p, thr in zip(split(clip), thr)] if len(debs) == 1: return debs[0]