Skip to content

Commit

Permalink
Replace deprecated scale_8bit
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Oct 5, 2024
1 parent 2adf65a commit a4e566b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions vsmasktools/hardsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ?'
Expand Down
6 changes: 3 additions & 3 deletions vsmasktools/spat_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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
))

Expand Down

0 comments on commit a4e566b

Please sign in to comment.