Skip to content

Commit

Permalink
rescale(): add decorator to static method (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtlnor authored Mar 28, 2024
1 parent cde2828 commit 713f207
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions muvsfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5929,6 +5929,7 @@ class rescale:
"""

@staticmethod
def _get_descale_args(W: int, H: int, width: Union[float, int], height: Union[float, int], base_height: int = None):
if base_height is None:
width, height = round(width), round(height)
Expand All @@ -5952,6 +5953,7 @@ def _get_descale_args(W: int, H: int, width: Union[float, int], height: Union[fl
"src_height": src_height,
}

@staticmethod
def _get_descale_args_pro(width: Union[float, int], height: Union[float, int], base_height: int = None, base_width: int = None):
if base_height is None:
height = round(height)
Expand Down Expand Up @@ -5979,6 +5981,7 @@ def _get_descale_args_pro(width: Union[float, int], height: Union[float, int], b
"src_height": src_height,
}

@staticmethod
def Upscale(clip: vs.VideoNode, width: int, height: int, kernel: str = "bicubic", taps: int = 3, b: float = 0.0, c: float = 0.5,
src_left: float = None, src_top: float = None, src_width: float = None, src_height: float = None) -> vs.VideoNode:
upscaler = getattr(core.resize, kernel.capitalize())
Expand Down Expand Up @@ -6055,21 +6058,27 @@ def upscale(self, clip: vs.VideoNode, width: int, height: int, upscaler: Optiona
raise TypeError("Your upscaler must have resize-like (src_left, src_width) or fmtc-like (sx, sw) argument names")
return upscaler(clip, width, height, **kwargs)

@staticmethod
def Bilinear():
return rescale.Rescaler(kernel="bilinear")

@staticmethod
def Bicubic(b: float = 0.0, c: float = 0.5):
return rescale.Rescaler(kernel="bicubic", b=b, c=c)

@staticmethod
def Lanczos(taps: int = 3):
return rescale.Rescaler(kernel="lanczos", taps=taps)

@staticmethod
def Spline16():
return rescale.Rescaler(kernel="spline16")

@staticmethod
def Spline36():
return rescale.Rescaler(kernel="spline36")

@staticmethod
def Spline64():
return rescale.Rescaler(kernel="spline64")

Expand Down

0 comments on commit 713f207

Please sign in to comment.