Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Aug 4, 2024
1 parent 4340ab5 commit 285be1f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
18 changes: 14 additions & 4 deletions vskernels/kernels/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,25 @@ def kernel(x: float) -> float:
return self.kernel, support

@inject_self
def scale_function(self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, *args: Any, **kwargs: Any) -> vs.VideoNode:
clean_kwargs = {k: v for k, v in kwargs.items() if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys()}
def scale_function(
self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, *args: Any, **kwargs: Any
) -> vs.VideoNode:
clean_kwargs = {
k: v for k, v in kwargs.items()
if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys()
}
return core.resize2.Custom(clip, *self._modify_kernel_func(**kwargs), width, height, *args, **clean_kwargs)

resample_function = scale_function

@inject_self
def descale_function(self, clip: vs.VideoNode, width: int, height: int, *args: Any, **kwargs: Any) -> vs.VideoNode:
clean_kwargs = {k: v for k, v in kwargs.items() if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys()}
def descale_function(
self, clip: vs.VideoNode, width: int, height: int, *args: Any, **kwargs: Any
) -> vs.VideoNode:
clean_kwargs = {
k: v for k, v in kwargs.items()
if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys()
}
return core.descale.Decustom(clip, width, height, *self._modify_kernel_func(**kwargs), *args, **clean_kwargs)

def get_params_args(
Expand Down
18 changes: 15 additions & 3 deletions vskernels/kernels/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ def _naturalCubicSpline(self, values: list[int]) -> list[float]:
# right value = sample
eqns += [[0] * (4 * i) + [(i + 1) ** 3, (i + 1) ** 2, i + 1, 1] + [0] * (4 * (n - i - 1)) for i in range(n)]
# derivatives match
eqns += [[0] * (4 * i) + [3 * (i + 1) ** 2, 2 * (i + 1), 1, 0] + [-3 * (i + 1) ** 2, -2 * (i + 1), -1, 0] + [0] * (4 * (n - i - 2)) for i in range(n - 1)]
eqns += [
(
[0] * (4 * i) +
[3 * (i + 1) ** 2, 2 * (i + 1), 1, 0] +
[-3 * (i + 1) ** 2, -2 * (i + 1), -1, 0] +
[0] * (4 * (n - i - 2))
)
for i in range(n - 1)
]
# second derivatives match
eqns += [[0] * (4 * i) + [6 * (i + 1), 2, 0, 0] + [-6 * (i + 1), -2, 0, 0] + [0] * (4 * (n - i - 2)) for i in range(n - 1)]
eqns += [
[0] * (4 * i) + [6 * (i + 1), 2, 0, 0] + [-6 * (i + 1), -2, 0, 0] + [0] * (4 * (n - i - 2))
for i in range(n - 1)
]
eqns += [[0, 2, 0, 0] + [0] * (4 * (n - 1))]
eqns += [[0] * (4 * (n - 1)) + [6 * n ** 2, 2 * n, 0, 0]]

Expand All @@ -57,7 +68,8 @@ def _splineKernelCoeff(self) -> list[float]:

def _shiftPolynomial(coeffs: list[float], shift: float) -> list[float]:
return [
sum(c * comb(k, m) * (-shift) ** max(0, k - m) for k, c in enumerate(coeffs[::-1])) for m in range(len(coeffs))
sum(c * comb(k, m) * (-shift) ** max(0, k - m) for k, c in enumerate(coeffs[::-1]))
for m in range(len(coeffs))
][::-1]

for i in range(taps):
Expand Down

0 comments on commit 285be1f

Please sign in to comment.