From a4e566b86aa21b6eb4c8ed4580bbe94d72bd4194 Mon Sep 17 00:00:00 2001 From: LightArrowsEXE Date: Sat, 5 Oct 2024 02:29:01 +0200 Subject: [PATCH] Replace deprecated scale_8bit --- vsmasktools/hardsub.py | 13 ++++++------- vsmasktools/spat_funcs.py | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/vsmasktools/hardsub.py b/vsmasktools/hardsub.py index bd2172c..fb7c20f 100644 --- a/vsmasktools/hardsub.py +++ b/vsmasktools/hardsub.py @@ -10,10 +10,9 @@ from vsrgtools.util import mean_matrix from vssource import IMWRI, Indexer from vstools import ( - ColorRange, CustomOverflowError, FileNotExistsError, FilePathType, FrameRangeN, FrameRangesN, - Matrix, VSFunction, check_variable, core, depth, fallback, get_neutral_value, - get_neutral_values, get_y, iterate, normalize_ranges, replace_ranges, scale_8bit, scale_value, - vs, vs_object + ColorRange, CustomOverflowError, FileNotExistsError, FilePathType, FrameRangeN, FrameRangesN, Matrix, VSFunction, + check_variable, core, depth, fallback, get_neutral_value, get_neutral_values, get_y, iterate, normalize_ranges, + replace_ranges, scale_value, vs, vs_object ) from .abstract import DeferredMask, GeneralMask @@ -239,9 +238,9 @@ def _mask(self, clip: vs.VideoNode, ref: vs.VideoNode, **kwargs: Any) -> vs.Vide expand_n = fallback(self.expand, clip.width // 200) - y_range = scale_8bit(clip, 219) if clip.format.sample_type == vs.INTEGER else 1 - uv_range = scale_8bit(clip, 224) if clip.format.sample_type == vs.INTEGER else 1 - offset = scale_8bit(clip, 16) if clip.format.sample_type == vs.INTEGER else 0 + y_range = scale_value(219, 8, clip, ColorRange.FULL) if clip.format.sample_type == vs.INTEGER else 1 + uv_range = scale_value(224, 8, clip, ColorRange.FULL) if clip.format.sample_type == vs.INTEGER else 1 + offset = scale_value(16, 8, clip, ColorRange.FULL) if clip.format.sample_type == vs.INTEGER else 0 uv_abs = ' abs ' if clip.format.sample_type == vs.FLOAT else f' {get_neutral_value(clip)} - abs ' yexpr = f'x y - abs {y_range * 0.7} > 255 0 ?' diff --git a/vsmasktools/spat_funcs.py b/vsmasktools/spat_funcs.py index 68db3af..1122cf2 100644 --- a/vsmasktools/spat_funcs.py +++ b/vsmasktools/spat_funcs.py @@ -6,7 +6,7 @@ from vsrgtools import box_blur, gauss_blur from vstools import ( ColorRange, CustomRuntimeError, DitherType, FuncExceptT, StrList, check_variable, core, depth, fallback, - get_lowest_value, get_peak_value, get_sample_type, get_y, plane, scale_8bit, scale_value, to_arr, vs + get_lowest_value, get_peak_value, get_sample_type, get_y, plane, scale_value, to_arr, vs ) from .edge import MinMax @@ -161,7 +161,7 @@ def texture_mask( points: list[tuple[bool, float]] = [(False, 1.75), (True, 2.5), (True, 5), (False, 10)] ) -> vs.VideoNode: levels = [x for x, _ in points] - _points = [scale_8bit(clip, x) for _, x in points] + _points = [scale_value(x, 8, clip, ColorRange.FULL) for _, x in points] qm, peak = len(points), get_peak_value(clip) @@ -170,7 +170,7 @@ def texture_mask( emask = clip.std.Prewitt() rm_txt = ExprOp.MIN(rmask, ( - Morpho.minimum(Morpho.binarize(emask, scale_8bit(32, thr), 1.0, 0), iterations=it) + Morpho.minimum(Morpho.binarize(emask, scale_value(thr, 8, 32, ColorRange.FULL), 1.0, 0), iterations=it) for thr, it in stages ))