Skip to content

Commit

Permalink
Fix LinearLight/Linear[De]Scaler typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Oct 15, 2023
1 parent 5440e7f commit c51d52c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions vskernels/kernels/complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def func(
from ..util import LinearLight

has_custom_op = hasattr(self, f'_linear_{op_name}')
operation = getattr(self, f'_linear_{op_name}') if has_custom_op else super().scale # type: ignore
operation = getattr(self, f'_linear_{op_name}') if has_custom_op else getattr(super(), op_name)
sigmoid = self.orig_kwargs.get('sigmoid', sigmoid)
linear = self.orig_kwargs.get('linear', False) or linear or not not sigmoid

Expand All @@ -56,7 +56,7 @@ def scale( # type: ignore[override]
) -> vs.VideoNode:
...
else:
scale = _BaseLinearOperation._linear_op('scale')
scale = inject_self.cached(_BaseLinearOperation._linear_op('scale'))


class LinearDescaler(_BaseLinearOperation, Descaler):
Expand All @@ -68,7 +68,7 @@ def descale( # type: ignore[override]
) -> vs.VideoNode:
...
else:
descale = _BaseLinearOperation._linear_op('descale')
descale = inject_self.cached(_BaseLinearOperation._linear_op('descale'))


class KeepArScaler(Scaler):
Expand Down
13 changes: 7 additions & 6 deletions vskernels/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ class LinearLightProcessing(cachedproperty.baseclass):

@cachedproperty
def linear(self) -> vs.VideoNode:
wclip = self.ll._wclip

if self.ll._wclip.format.color_family is vs.YUV:
wclip = Catrom.from_param(self.ll.kernel).resample(self.ll._wclip, vs.RGBS, None, self.ll._matrix)
wclip = Catrom.from_param(self.ll.kernel).resample(wclip, vs.RGBS, None, self.ll._matrix)

if self.ll.linear:
wclip = Point.scale_function(wclip, transfer_in=self.ll._curve, transfer=Transfer.LINEAR)
Expand Down Expand Up @@ -164,16 +165,16 @@ def __enter__(self) -> LinearLightProcessing:
if self.sigmoid is True:
self.sigmoid = (6.5, 0.75)

sslope, scenter = self.sigmoid
self._sslope, self._scenter = self.sigmoid

if 1.0 > sslope or sslope > 20.0:
if 1.0 > self._sslope or self._sslope > 20.0:
raise CustomValueError('sigmoid slope has to be in range 1.0-20.0 (inclusive).', self.__class__)

if 0.0 > scenter or scenter > 1.0:
if 0.0 > self._scenter or self._scenter > 1.0:
raise CustomValueError('sigmoid center has to be in range 0.0-1.0 (inclusive).', self.__class__)

self._soffset = 1.0 / (1 + exp(sslope * scenter))
self._sscale = 1.0 / (1 + exp(sslope * (scenter - 1))) - self._soffset
self._soffset = 1.0 / (1 + exp(self._sslope * self._scenter))
self._sscale = 1.0 / (1 + exp(self._sslope * (self._scenter - 1))) - self._soffset

self._fmt = self.clip.format
assert self._fmt
Expand Down

0 comments on commit c51d52c

Please sign in to comment.