Skip to content

Commit

Permalink
Put mod_padding in vstools
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Jun 17, 2024
1 parent 7e039f9 commit b1effc1
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions vsscale/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,9 @@ def scale( # type: ignore
_static_kernel_radius = 2


@lru_cache
def mod_padding(sizes: tuple[int, int], mod: int = 16, min: int = 4) -> tuple[int, int, int, int]:
ph, pv = (mod - (((x + min * 2) - 1) % mod + 1) for x in sizes)
left, top = floor(ph / 2), floor(pv / 2)
return tuple(x + min for x in (left, ph - left, top, pv - top)) # type: ignore


class Waifu2xPadHelper(ProcessVariableResClip):
def normalize(self, clip: vs.VideoNode, cast_to: tuple[int, int]) -> vs.VideoNode:
padding = mod_padding(cast_to)
padding = padder.mod_padding(cast_to)

return padder.MIRROR(super().normalize(clip, cast_to), *padding).std.SetFrameProp('_PadValues', padding)

Expand Down

0 comments on commit b1effc1

Please sign in to comment.