Skip to content

Commit

Permalink
Update value scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
emotion3459 committed Oct 14, 2024
1 parent fbf794e commit 2a0e2ae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions vsdenoise/mvtools/mvtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ def degrain(
'"limit" values should be between 0 and 255 (inclusive)!', self.degrain
)

limitf = scale_value(limit, 8, ref, ColorRange.FULL)
limitCf = scale_value(limitC, 8, ref, ColorRange.FULL)
limitf = scale_value(limit, 8, ref, ColorRange.FULL, ColorRange.FULL)
limitCf = scale_value(limitC, 8, ref, ColorRange.FULL, ColorRange.FULL)

thSCD1, thSCD2 = self.normalize_thscd(thSCD, thSAD, self.degrain)

Expand Down
7 changes: 4 additions & 3 deletions vsdenoise/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def decrease_size(
if pm_min > pm_max:
raise CustomIndexError('The mask min must be lower than max!', decrease_size, dict(min=pm_min, max=pm_max))

pm_min, pm_max = scale_value(pm_min, 32, clip, ColorRange.FULL), scale_value(pm_max, 32, clip, ColorRange.FULL)
pm_min = scale_value(pm_min, 32, clip, range_out=ColorRange.FULL)
pm_max = scale_value(pm_max, 32, clip, range_out=ColorRange.FULL)

yuv444 = Bilinear.resample(
range_mask(clip, rad=3, radc=2), clip.format.replace(subsampling_h=0, subsampling_w=0)
Expand All @@ -120,8 +121,8 @@ def decrease_size(
else:
pre = gauss_blur(pre, prefilter)

minf = scale_value(min_in, 8, pre, ColorRange.FULL)
maxf = scale_value(max_in, 8, pre, ColorRange.FULL)
minf = scale_value(min_in, 8, pre, ColorRange.FULL, ColorRange.FULL)
maxf = scale_value(max_in, 8, pre, ColorRange.FULL, ColorRange.FULL)

mask = norm_expr(
[pre, mask], # type: ignore
Expand Down
12 changes: 6 additions & 6 deletions vsdenoise/prefilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def _run(clip: vs.VideoNode, planes: PlanesT, **kwargs: Any) -> vs.VideoNode:
if pref_type == Prefilter.MINBLURFLUX:
temp_thr, spat_thr = kwargs.get('temp_thr', 2), kwargs.get('spat_thr', 2)
return min_blur(clip, 2, planes).flux.SmoothST( # type: ignore
scale_value(temp_thr, 8, clip, ColorRange.FULL),
scale_value(spat_thr, 8, clip, ColorRange.FULL),
scale_value(temp_thr, 8, clip, ColorRange.FULL, ColorRange.FULL),
scale_value(spat_thr, 8, clip, ColorRange.FULL, ColorRange.FULL),
planes
)

Expand All @@ -98,7 +98,7 @@ def _run(clip: vs.VideoNode, planes: PlanesT, **kwargs: Any) -> vs.VideoNode:
if pref_type == Prefilter.DFTTEST:
dftt = DFTTest(sloc={0.0: 4, 0.2: 9, 1.0: 15}, tr=0).denoise(clip, **kwargs)

i, j = (scale_value(x, 8, clip, ColorRange.FULL) for x in (16, 75))
i, j = (scale_value(x, 8, clip, ColorRange.FULL, ColorRange.FULL) for x in (16, 75))

pref_mask = norm_expr(
get_y(clip),
Expand Down Expand Up @@ -179,7 +179,7 @@ def _run(clip: vs.VideoNode, planes: PlanesT, **kwargs: Any) -> vs.VideoNode:
gaussblur = gauss_blur(boxblur, **(kwargs | dict[str, Any](planes=planes)))

if pref_type == Prefilter.GAUSSBLUR2:
i2, i7 = (scale_value(x, 8, clip, ColorRange.FULL) for x in (2, 7))
i2, i7 = (scale_value(x, 8, clip, ColorRange.FULL, ColorRange.FULL) for x in (2, 7))

merge_expr = f'x {i7} + y < x {i2} + x {i7} - y > x {i2} - x {strg} * y {100 - strg} * + 100 / ? ?'
else:
Expand Down Expand Up @@ -866,8 +866,8 @@ def prefilter_to_full_range(pref: vs.VideoNode, range_conversion: float, planes:
k = (range_conversion - 1) * c

if is_integer:
t = f'x {scale_value(16, 8, pref, ColorRange.FULL)} '
t += f'- {scale_value(219, 8, pref, ColorRange.FULL)} '
t = f'x {scale_value(16, 8, pref)} '
t += f'- {scale_value(219, 8, pref)} '
t += f'/ {ExprOp.clamp(0, 1)}'
else:
t = ExprOp.clamp(0, 1, 'x').to_str()
Expand Down

0 comments on commit 2a0e2ae

Please sign in to comment.