Last active
April 6, 2024 15:37
-
-
Save wiwaz/91751d5a564f194f2805530f761b3e71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def descale_args( | |
clip: vs.VideoNode, | |
width: int | float = None, | |
height: int | float = None, | |
src_left: float = None, | |
src_top: float = None, | |
width_parity: int = None, | |
height_parity: int = None, | |
): | |
out_args = dict() | |
if not float(width).is_integer(): | |
src_width = width | |
width_parity = clip.width - width_parity | |
width = width_parity - 2 * floor((width_parity - src_width) / 2) | |
shift_left = (width - src_width) / 2 | |
src_left = shift_left + src_left if src_left else shift_left | |
out_args.update(src_width=src_width) | |
if not float(height).is_integer(): | |
src_height = height | |
height_parity = clip.height - height_parity | |
height = height_parity - 2 * floor((height_parity - src_height) / 2) | |
shift_top = (height - src_height) / 2 | |
src_top = shift_top + src_top if src_top else shift_top | |
out_args.update(src_height=src_height) | |
out_args.update(width=width, height=height) | |
if src_left: | |
out_args.update(src_left=src_left) | |
if src_top: | |
out_args.update(src_top=src_top) | |
return out_args |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment