base ¶
This module defines the base abstract interfaces for general scaling operations.
Type Aliases:
-
BobberLike–Type alias for anything that can resolve to a Bobber.
-
DescalerLike–Type alias for anything that can resolve to a Descaler.
-
KernelLike–Type alias for anything that can resolve to a Kernel.
-
ResamplerLike–Type alias for anything that can resolve to a Resampler.
-
ScalerLike–Type alias for anything that can resolve to a Scaler.
Classes:
-
BaseScaler–Base abstract scaling interface for VapourSynth scalers.
-
Bobber–Abstract scaler class that applies bob deinterlacing.
-
Descaler–Abstract descaling interface.
-
Kernel–Abstract kernel interface combining scaling, descaling, resampling, and shifting functionality.
-
Resampler–Abstract resampling interface.
-
Scaler–Abstract scaling interface.
abstract_kernels module-attribute ¶
abstract_kernels: list[BaseScalerMeta] = []
List of fully abstract kernel classes.
Used internally to track kernel base classes that should not be used directly.
partial_abstract_kernels module-attribute ¶
partial_abstract_kernels: list[BaseScalerMeta] = []
List of partially abstract kernel classes.
These may implement some but not all kernel functionality.
BobberLike ¶
DescalerLike ¶
KernelLike ¶
ResamplerLike ¶
ScalerLike ¶
BaseScaler ¶
Bases: VSObjectABC
Base abstract scaling interface for VapourSynth scalers.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
Attributes:
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
Source code in vskernels/abstract/base.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
444 445 446 447 448 449 450 451 452 453 454 455 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/abstract/base.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
BaseScalerMeta ¶
Bases: VSObjectABCMeta
Metaclass for scaler classes.
This metaclass can be used to enforce abstraction rules by specifying abstract or partial_abstract as keyword arguments in the class definition.
- If
abstract=True: The class is marked as fully abstract and added to theabstract_kernelsregistry. It should not be instantiated. - If
partial_abstract=True: The class is considered partially abstract, meaning it may lack certain implementations (e.g., kernel radius) but is still allowed to be instantiated. It is added topartial_abstract_kernels.
Classes:
-
cachedproperty–Read only version of jetpytools.cachedproperty.
Attributes:
cachedproperty ¶
cachedproperty(func: Callable[Concatenate[_BaseScalerT, P], R])
Bases: cachedproperty[R]
Read only version of jetpytools.cachedproperty.
Source code in vskernels/abstract/base.py
224 225 226 | |
Bobber ¶
Bases: BaseScaler
Abstract scaler class that applies bob deinterlacing.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
Attributes:
-
bob_function(Callable[..., VideoNode]) –Bob function called internally when performing bobbing operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
Source code in vskernels/abstract/base.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
bob_function instance-attribute ¶
bob_function: Callable[..., VideoNode]
Bob function called internally when performing bobbing operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/abstract/base.py
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
444 445 446 447 448 449 450 451 452 453 454 455 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/abstract/base.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
Descaler ¶
Bases: BaseScaler
Abstract descaling interface.
Subclasses must define the descale_function used to perform the descaling.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
descale–Descale a clip to the given resolution.
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_descale_args–Construct the argument dictionary used for descaling.
-
get_rescale_args–Construct the argument dictionary used for upscaling.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip.
Attributes:
-
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
Source code in vskernels/abstract/base.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
descale_function instance-attribute ¶
descale_function: Callable[..., VideoNode]
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
rescale_function instance-attribute ¶
rescale_function: Callable[..., VideoNode]
Rescale function called internally when performing upscaling operations.
descale ¶
descale(
clip: VideoNode,
width: int | None,
height: int | None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
Returns:
-
VideoNode–The descaled clip.
Source code in vskernels/abstract/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Construct the argument dictionary used for descaling.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(width¶int | None, default:None) –Target width for descaling.
-
(height¶int | None, default:None) –Target height for descaling.
-
(**kwargs¶Any, default:{}) –Extra keyword arguments to merge.
Returns:
Source code in vskernels/abstract/base.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Construct the argument dictionary used for upscaling.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(width¶int | None, default:None) –Target width for upscaling.
-
(height¶int | None, default:None) –Target height for upscaling.
-
(**kwargs¶Any, default:{}) –Extra keyword arguments to merge.
Returns:
Source code in vskernels/abstract/base.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
444 445 446 447 448 449 450 451 452 453 454 455 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/abstract/base.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None,
height: int | None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/base.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
Kernel ¶
Bases: Scaler, Descaler, Resampler
Abstract kernel interface combining scaling, descaling, resampling, and shifting functionality.
Subclasses are expected to implement the actual transformation logic by overriding the methods or providing the respective *_function callables (scale_function, descale_function, resample_function).
This class is abstract and should not be used directly.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
descale–Descale a clip to the given resolution.
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip.
-
scale–Scale a clip to a specified resolution.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/abstract/base.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
descale_function instance-attribute ¶
descale_function: Callable[..., VideoNode]
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function instance-attribute ¶
resample_function: Callable[..., VideoNode]
Resample function called internally when performing resampling operations.
rescale_function instance-attribute ¶
rescale_function: Callable[..., VideoNode]
Rescale function called internally when performing upscaling operations.
scale_function instance-attribute ¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
descale ¶
descale(
clip: VideoNode,
width: int | None,
height: int | None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
Returns:
-
VideoNode–The descaled clip.
Source code in vskernels/abstract/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/abstract/base.py
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
444 445 446 447 448 449 450 451 452 453 454 455 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/abstract/base.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None,
height: int | None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/base.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Scale a clip to a specified resolution.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/base.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | |
Resampler ¶
Bases: BaseScaler
Abstract resampling interface.
Subclasses must define the resample_function used to perform the resampling.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_resample_args–Construct the argument dictionary used for resampling.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
Attributes:
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
Source code in vskernels/abstract/base.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function instance-attribute ¶
resample_function: Callable[..., VideoNode]
Resample function called internally when performing resampling operations.
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
**kwargs: Any
) -> dict[str, Any]
Construct the argument dictionary used for resampling.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –The matrix for color transformation.
-
(matrix_in¶MatrixLike | None) –The input matrix for color transformation.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments for resampling.
Returns:
Source code in vskernels/abstract/base.py
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
444 445 446 447 448 449 450 451 452 453 454 455 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/abstract/base.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | |
Scaler ¶
Bases: BaseScaler
Abstract scaling interface.
Subclasses should define a scale_function to perform the actual scaling logic.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_scale_args–Generate the keyword arguments used for scaling.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
scale–Scale a clip to a specified resolution.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/abstract/base.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
scale_function instance-attribute ¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for scaling.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/abstract/base.py
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
444 445 446 447 448 449 450 451 452 453 454 455 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/abstract/base.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Scale a clip to a specified resolution.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/base.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | |