complex ¶
This module defines the abstract classes for scaling, descaling and resampling operations.
Classes:
-
ComplexDescaler
–Abstract descaler class with support for border handling and sampling grid alignment.
-
ComplexKernel
–Comprehensive abstract kernel class combining scaling, descaling,
-
ComplexScaler
–Abstract composite scaler class with support for aspect ratio preservation, linear light processing,
-
KeepArScaler
– -
LinearDescaler
–Abctract descaler class that applies linearization before descaling.
-
LinearScaler
–Abstract scaler class that applies linearization before scaling.
Attributes:
-
ComplexDescalerLike
–Type alias for anything that can resolve to a ComplexDescaler.
-
ComplexKernelLike
–Type alias for anything that can resolve to a ComplexKernel.
-
ComplexScalerLike
–Type alias for anything that can resolve to a ComplexScaler.
ComplexDescalerLike module-attribute
¶
ComplexDescalerLike = Union[str, type[ComplexDescaler], ComplexDescaler]
Type alias for anything that can resolve to a ComplexDescaler.
This includes: - A string identifier. - A class type subclassing ComplexDescaler
. - An instance of a ComplexDescaler
.
ComplexKernelLike module-attribute
¶
ComplexKernelLike = Union[str, type[ComplexKernel], ComplexKernel]
Type alias for anything that can resolve to a ComplexKernel.
This includes: - A string identifier. - A class type subclassing ComplexKernel
. - An instance of a ComplexKernel
.
ComplexScalerLike module-attribute
¶
ComplexScalerLike = Union[str, type[ComplexScaler], ComplexScaler]
Type alias for anything that can resolve to a ComplexScaler.
This includes: - A string identifier. - A class type subclassing ComplexScaler
. - An instance of a ComplexScaler
.
ComplexDescaler ¶
ComplexDescaler(**kwargs: Any)
Bases: LinearDescaler
Abstract descaler class with support for border handling and sampling grid alignment.
Extends LinearDescaler
by introducing mechanisms to control how image borders are handled and how the sampling grid is aligned during 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:
Classes:
-
cached_property
–Read only version of functools.cached_property.
Methods:
-
descale
–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
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.
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
pretty_string
–Cached property returning a user-friendly string representation.
-
rescale
–Rescale a clip to the given resolution from a previously descaled clip,
Attributes:
-
descale_function
(Callable[..., ConstantFormatVideoNode]
) –Descale function called internally when performing descaling operations.
-
kwargs
(dict[str, Any]
) –Arguments passed to the implemented funcs or internal scale function.
-
rescale_function
(Callable[..., ConstantFormatVideoNode]
) –Rescale function called internally when performing upscaling operations.
Source code
281 282 283 284 285 286 287 288 289 290 291 292 |
|
descale_function instance-attribute
¶
descale_function: Callable[..., ConstantFormatVideoNode]
Descale function called internally when performing descaling operations.
kwargs instance-attribute
¶
Arguments passed to the implemented funcs or internal scale function.
rescale_function instance-attribute
¶
rescale_function: Callable[..., ConstantFormatVideoNode]
Rescale function called internally when performing upscaling operations.
cached_property ¶
cached_property(func: Callable[Concatenate[_BaseScalerT, P], T_co])
Bases: cached_property[T_co]
Read only version of functools.cached_property.
Source code
265 |
|
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: ShiftT = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedT | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
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 descaled width (defaults to clip width if None).
-
height
¶int | None
, default:None
) –Target descaled height (defaults to clip height if None).
-
shift
¶ShiftT
, default:(0, 0)
) –Subpixel shift (top, left) or per-field shifts.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
border_handling
¶int | BorderHandling
, default:MIRROR
) –Method for handling image borders during sampling.
-
sample_grid_model
¶int | SampleGridModel
, default:MATCH_EDGES
) –Model used to align sampling grid.
-
field_based
¶FieldBasedT | None
, default:None
) –Field-based processing mode (interlaced or progressive).
-
ignore_mask
¶VideoNode | None
, default:None
) –Optional mask specifying areas to ignore during descaling.
-
blur
¶float | None
, default:None
) –Amount of blur to apply during scaling.
-
kwargs
¶Any
, default:{}
) –Additional arguments passed to
descale_function
.
Returns:
-
ConstantFormatVideoNode
–The descaled video node, optionally processed in linear light.
Source code
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 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 730 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 |
|
ensure_obj classmethod
¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–Scaler instance.
Source code
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
from_param classmethod
¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–Resolved scaler type.
Source code
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
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
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
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
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Returns:
-
int
–Kernel radius.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Source code
347 348 349 350 351 352 353 354 355 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
368 369 370 371 372 373 374 375 |
|
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: ShiftT = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedT | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
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 scaled width (defaults to clip width if None).
-
height
¶int | None
, default:None
) –Target scaled height (defaults to clip height if None).
-
shift
¶ShiftT
, default:(0, 0)
) –Subpixel shift (top, left) or per-field shifts.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
border_handling
¶int | BorderHandling
, default:MIRROR
) –Method for handling image borders during sampling.
-
sample_grid_model
¶int | SampleGridModel
, default:MATCH_EDGES
) –Model used to align sampling grid.
-
field_based
¶FieldBasedT | None
, default:None
) –Field-based processing mode (interlaced or progressive).
-
ignore_mask
¶VideoNode | None
, default:None
) –Optional mask specifying areas to ignore during rescaling.
-
blur
¶float | None
, default:None
) –Amount of blur to apply during rescaling.
-
kwargs
¶Any
, default:{}
) –Additional arguments passed to
rescale_function
.
Returns:
-
ConstantFormatVideoNode
–The scaled clip.
Source code
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
|
ComplexKernel ¶
ComplexKernel(**kwargs: Any)
Bases: Kernel
, ComplexDescaler
, ComplexScaler
Comprehensive abstract kernel class combining scaling, descaling, and resampling with linear light and aspect ratio support.
This class merges the full capabilities of Kernel
, ComplexDescaler
, and ComplexScaler
.
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:
Classes:
-
cached_property
–Read only version of functools.cached_property.
Methods:
-
descale
–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj
–Ensure that the given kernel input is returned as a kernel instance.
-
from_param
–Resolve and return a kernel class from a string name, class 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.
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
multi
–Deprecated alias for
supersample
. -
pretty_string
–Cached property returning a user-friendly string representation.
-
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 the given resolution, with aspect ratio and linear light support.
-
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[..., ConstantFormatVideoNode]
) –Descale function called internally when performing descaling operations.
-
kwargs
(dict[str, Any]
) –Arguments passed to the implemented funcs or internal scale function.
-
resample_function
(Callable[..., ConstantFormatVideoNode]
) –Resample function called internally when performing resampling operations.
-
rescale_function
(Callable[..., ConstantFormatVideoNode]
) –Rescale function called internally when performing upscaling operations.
-
scale_function
(Callable[..., VideoNode]
) –Scale function called internally when performing scaling operations.
Source code
281 282 283 284 285 286 287 288 289 290 291 292 |
|
descale_function instance-attribute
¶
descale_function: Callable[..., ConstantFormatVideoNode]
Descale function called internally when performing descaling operations.
kwargs instance-attribute
¶
Arguments passed to the implemented funcs or internal scale function.
resample_function instance-attribute
¶
resample_function: Callable[..., ConstantFormatVideoNode]
Resample function called internally when performing resampling operations.
rescale_function instance-attribute
¶
rescale_function: Callable[..., ConstantFormatVideoNode]
Rescale function called internally when performing upscaling operations.
scale_function instance-attribute
¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
cached_property ¶
cached_property(func: Callable[Concatenate[_BaseScalerT, P], T_co])
Bases: cached_property[T_co]
Read only version of functools.cached_property.
Source code
265 |
|
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: ShiftT = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedT | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
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 descaled width (defaults to clip width if None).
-
height
¶int | None
, default:None
) –Target descaled height (defaults to clip height if None).
-
shift
¶ShiftT
, default:(0, 0)
) –Subpixel shift (top, left) or per-field shifts.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
border_handling
¶int | BorderHandling
, default:MIRROR
) –Method for handling image borders during sampling.
-
sample_grid_model
¶int | SampleGridModel
, default:MATCH_EDGES
) –Model used to align sampling grid.
-
field_based
¶FieldBasedT | None
, default:None
) –Field-based processing mode (interlaced or progressive).
-
ignore_mask
¶VideoNode | None
, default:None
) –Optional mask specifying areas to ignore during descaling.
-
blur
¶float | None
, default:None
) –Amount of blur to apply during scaling.
-
kwargs
¶Any
, default:{}
) –Additional arguments passed to
descale_function
.
Returns:
-
ConstantFormatVideoNode
–The descaled video node, optionally processed in linear light.
Source code
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 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 730 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 |
|
ensure_obj classmethod
¶
ensure_obj(
kernel: KernelLike | None = None, /, func_except: FuncExceptT | None = None
) -> Self
Ensure that the given kernel input is returned as a kernel instance.
Parameters:
-
kernel
¶KernelLike | None
, default:None
) –Kernel name, class, or instance. Defaults to current class if None.
-
func_except
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–The resolved and instantiated kernel.
Source code
804 805 806 807 808 809 810 811 812 813 814 |
|
from_param classmethod
¶
from_param(
kernel: KernelLike | None = None, /, func_except: FuncExceptT | None = None
) -> type[Self]
Resolve and return a kernel class from a string name, class type, or instance.
Parameters:
-
kernel
¶KernelLike | None
, default:None
) –Kernel identifier as a string, class type, or instance. If None, defaults to the current class.
-
func_except
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–The resolved kernel class.
Raises:
-
UnknownKernelError
–If the kernel could not be identified.
Source code
791 792 793 794 795 796 797 798 799 800 801 802 |
|
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
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 |
|
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
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 |
|
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatT | HoldsVideoFormatT,
matrix: MatrixT | None,
matrix_in: MatrixT | None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
clip
¶VideoNode
) –The source clip.
-
format
¶int | VideoFormatT | HoldsVideoFormatT
) –The target video format, which can either be: - an integer format ID, - a
vs.PresetVideoFormat
orvs.VideoFormat
, - or a source from which a validVideoFormat
can be extracted. -
matrix
¶MatrixT | None
) –Target color matrix.
-
matrix_in
¶MatrixT | None
) –Source color matrix.
-
kwargs
¶Any
, default:{}
) –Additional arguments to pass to the resample function.
Returns:
Source code
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
|
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
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
|
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
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Returns:
-
int
–Kernel radius.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Source code
347 348 349 350 351 352 353 354 355 |
|
multi ¶
multi(
clip: VideoNodeT,
multi: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Deprecated alias for supersample
.
Parameters:
-
clip
¶VideoNodeT
) –The source clip.
-
multi
¶float
, default:2.0
) –Supersampling factor.
-
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:
-
VideoNodeT
–The supersampled clip.
Source code
451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
368 369 370 371 372 373 374 375 |
|
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatT | HoldsVideoFormatT,
matrix: MatrixT | None = None,
matrix_in: MatrixT | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
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 | VideoFormatT | HoldsVideoFormatT
) –The target video format, which can either be: - an integer format ID, - a
vs.PresetVideoFormat
orvs.VideoFormat
, - or a source from which a validVideoFormat
can be extracted. -
matrix
¶MatrixT | None
, default:None
) –An optional color transformation matrix to apply.
-
matrix_in
¶MatrixT | None
, default:None
) –An optional input matrix for color transformations.
-
kwargs
¶Any
, default:{}
) –Additional keyword arguments passed to the
resample_function
.
Returns:
-
ConstantFormatVideoNode
–The resampled clip.
Source code
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
|
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: ShiftT = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedT | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
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 scaled width (defaults to clip width if None).
-
height
¶int | None
, default:None
) –Target scaled height (defaults to clip height if None).
-
shift
¶ShiftT
, default:(0, 0)
) –Subpixel shift (top, left) or per-field shifts.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
border_handling
¶int | BorderHandling
, default:MIRROR
) –Method for handling image borders during sampling.
-
sample_grid_model
¶int | SampleGridModel
, default:MATCH_EDGES
) –Model used to align sampling grid.
-
field_based
¶FieldBasedT | None
, default:None
) –Field-based processing mode (interlaced or progressive).
-
ignore_mask
¶VideoNode | None
, default:None
) –Optional mask specifying areas to ignore during rescaling.
-
blur
¶float | None
, default:None
) –Amount of blur to apply during rescaling.
-
kwargs
¶Any
, default:{}
) –Additional arguments passed to
rescale_function
.
Returns:
-
ConstantFormatVideoNode
–The scaled clip.
Source code
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
|
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode | ConstantFormatVideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
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 | list[TopShift], LeftShift | list[LeftShift]]
, default:(0, 0)
) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
border_handling
¶BorderHandling
, default:MIRROR
) –Method for handling image borders during sampling.
-
sample_grid_model
¶SampleGridModel
, default:MATCH_EDGES
) –Model used to align sampling grid.
-
sar
¶Sar | float | bool | None
, default:None
) –Sample aspect ratio to assume or convert to.
-
dar
¶Dar | float | bool | None
, default:None
) –Desired display aspect ratio.
-
dar_in
¶Dar | bool | float | None
, default:None
) –Input display aspect ratio, if different from clip's.
-
keep_ar
¶bool | None
, default:None
) –Whether to adjust dimensions to preserve aspect ratio.
-
blur
¶float | None
, default:None
) –Amount of blur to apply during scaling.
Returns:
-
VideoNode | ConstantFormatVideoNode
–Scaled clip, optionally aspect-corrected and linearized.
Source code
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 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 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 606 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 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
|
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> ConstantFormatVideoNode
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_top
is a tuple. -
kwargs
¶Any
, default:{}
) –Additional arguments passed to the internal
scale
call.
Returns:
-
ConstantFormatVideoNode
–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
727 728 729 730 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 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
|
supersample ¶
supersample(
clip: VideoNodeT,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Supersample a clip by a given scaling factor.
Parameters:
-
clip
¶VideoNodeT
) –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.
Returns:
-
VideoNodeT
–The supersampled clip.
Raises:
-
CustomValueError
–If resulting resolution is non-positive.
Source code
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
|
ComplexScaler ¶
ComplexScaler(**kwargs: Any)
Bases: KeepArScaler
, LinearScaler
Abstract composite scaler class with support for aspect ratio preservation, linear light processing, and per-plane subpixel shifting.
Combines KeepArScaler
for handling sample/display aspect ratios and LinearScaler
for linear and sigmoid processing. Additionally, it introduces support for specifying per-plane subpixel shifts.
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:
Classes:
-
cached_property
–Read only version of functools.cached_property.
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.
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
multi
–Deprecated alias for
supersample
. -
pretty_string
–Cached property returning a user-friendly string representation.
-
scale
–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
supersample
–Supersample a clip by a given scaling factor.
Attributes:
-
kwargs
(dict[str, Any]
) –Arguments passed to the implemented funcs or internal scale function.
-
scale_function
(Callable[..., VideoNode]
) –Scale function called internally when performing scaling operations.
Source code
281 282 283 284 285 286 287 288 289 290 291 292 |
|
kwargs instance-attribute
¶
Arguments passed to the implemented funcs or internal scale function.
scale_function instance-attribute
¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
cached_property ¶
cached_property(func: Callable[Concatenate[_BaseScalerT, P], T_co])
Bases: cached_property[T_co]
Read only version of functools.cached_property.
Source code
265 |
|
ensure_obj classmethod
¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–Scaler instance.
Source code
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
from_param classmethod
¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–Resolved scaler type.
Source code
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
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
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Returns:
-
int
–Kernel radius.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Source code
347 348 349 350 351 352 353 354 355 |
|
multi ¶
multi(
clip: VideoNodeT,
multi: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Deprecated alias for supersample
.
Parameters:
-
clip
¶VideoNodeT
) –The source clip.
-
multi
¶float
, default:2.0
) –Supersampling factor.
-
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:
-
VideoNodeT
–The supersampled clip.
Source code
451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
368 369 370 371 372 373 374 375 |
|
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode | ConstantFormatVideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
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 | list[TopShift], LeftShift | list[LeftShift]]
, default:(0, 0)
) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
border_handling
¶BorderHandling
, default:MIRROR
) –Method for handling image borders during sampling.
-
sample_grid_model
¶SampleGridModel
, default:MATCH_EDGES
) –Model used to align sampling grid.
-
sar
¶Sar | float | bool | None
, default:None
) –Sample aspect ratio to assume or convert to.
-
dar
¶Dar | float | bool | None
, default:None
) –Desired display aspect ratio.
-
dar_in
¶Dar | bool | float | None
, default:None
) –Input display aspect ratio, if different from clip's.
-
keep_ar
¶bool | None
, default:None
) –Whether to adjust dimensions to preserve aspect ratio.
-
blur
¶float | None
, default:None
) –Amount of blur to apply during scaling.
Returns:
-
VideoNode | ConstantFormatVideoNode
–Scaled clip, optionally aspect-corrected and linearized.
Source code
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 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 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 606 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 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
|
supersample ¶
supersample(
clip: VideoNodeT,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Supersample a clip by a given scaling factor.
Parameters:
-
clip
¶VideoNodeT
) –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.
Returns:
-
VideoNodeT
–The supersampled clip.
Raises:
-
CustomValueError
–If resulting resolution is non-positive.
Source code
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
|
KeepArScaler ¶
KeepArScaler(**kwargs: Any)
Bases: Scaler
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:
Classes:
-
cached_property
–Read only version of functools.cached_property.
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.
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
multi
–Deprecated alias for
supersample
. -
pretty_string
–Cached property returning a user-friendly string representation.
-
scale
–Scale a clip to the given resolution with aspect ratio support.
-
supersample
–Supersample a clip by a given scaling factor.
Attributes:
-
kwargs
(dict[str, Any]
) –Arguments passed to the implemented funcs or internal scale function.
-
scale_function
(Callable[..., VideoNode]
) –Scale function called internally when performing scaling operations.
Source code
281 282 283 284 285 286 287 288 289 290 291 292 |
|
kwargs instance-attribute
¶
Arguments passed to the implemented funcs or internal scale function.
scale_function instance-attribute
¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
cached_property ¶
cached_property(func: Callable[Concatenate[_BaseScalerT, P], T_co])
Bases: cached_property[T_co]
Read only version of functools.cached_property.
Source code
265 |
|
ensure_obj classmethod
¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–Scaler instance.
Source code
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
from_param classmethod
¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–Resolved scaler type.
Source code
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
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
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Returns:
-
int
–Kernel radius.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Source code
347 348 349 350 351 352 353 354 355 |
|
multi ¶
multi(
clip: VideoNodeT,
multi: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Deprecated alias for supersample
.
Parameters:
-
clip
¶VideoNodeT
) –The source clip.
-
multi
¶float
, default:2.0
) –Supersampling factor.
-
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:
-
VideoNodeT
–The supersampled clip.
Source code
451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
368 369 370 371 372 373 374 375 |
|
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
*,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
**kwargs: Any
) -> VideoNode | ConstantFormatVideoNode
Scale a clip to the given resolution with aspect ratio support.
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.
-
border_handling
¶BorderHandling
, default:MIRROR
) –Method for handling image borders during sampling.
-
sample_grid_model
¶SampleGridModel
, default:MATCH_EDGES
) –Model used to align sampling grid.
-
sar
¶Sar | float | bool | None
, default:None
) –Sample aspect ratio to assume or convert to.
-
dar
¶Dar | float | bool | None
, default:None
) –Desired display aspect ratio.
-
dar_in
¶Dar | bool | float | None
, default:None
) –Input display aspect ratio, if different from clip's.
-
keep_ar
¶bool | None
, default:None
) –Whether to adjust dimensions to preserve aspect ratio.
Returns:
-
VideoNode | ConstantFormatVideoNode
–Scaled clip, optionally aspect-corrected.
Source code
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 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 |
|
supersample ¶
supersample(
clip: VideoNodeT,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Supersample a clip by a given scaling factor.
Parameters:
-
clip
¶VideoNodeT
) –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.
Returns:
-
VideoNodeT
–The supersampled clip.
Raises:
-
CustomValueError
–If resulting resolution is non-positive.
Source code
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
|
LinearDescaler ¶
LinearDescaler(**kwargs: Any)
Bases: Descaler
Abctract descaler class that applies linearization before descaling.
Only affects descaling results when linear
or sigmoid
parameters are specified.
Optionally, subclasses can implement _linear_descale
to override the default behavior with a custom linear descaling algorithm.
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:
Classes:
-
cached_property
–Read only version of functools.cached_property.
Methods:
-
descale
–Descale a clip to the specified resolution, optionally using linear light processing.
-
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.
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
pretty_string
–Cached property returning a user-friendly string representation.
-
rescale
–Rescale a clip to the given resolution from a previously descaled clip,
Attributes:
-
descale_function
(Callable[..., ConstantFormatVideoNode]
) –Descale function called internally when performing descaling operations.
-
kwargs
(dict[str, Any]
) –Arguments passed to the implemented funcs or internal scale function.
-
rescale_function
(Callable[..., ConstantFormatVideoNode]
) –Rescale function called internally when performing upscaling operations.
Source code
281 282 283 284 285 286 287 288 289 290 291 292 |
|
descale_function instance-attribute
¶
descale_function: Callable[..., ConstantFormatVideoNode]
Descale function called internally when performing descaling operations.
kwargs instance-attribute
¶
Arguments passed to the implemented funcs or internal scale function.
rescale_function instance-attribute
¶
rescale_function: Callable[..., ConstantFormatVideoNode]
Rescale function called internally when performing upscaling operations.
cached_property ¶
cached_property(func: Callable[Concatenate[_BaseScalerT, P], T_co])
Bases: cached_property[T_co]
Read only version of functools.cached_property.
Source code
265 |
|
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
**kwargs: Any
) -> ConstantFormatVideoNode
Descale a clip to the specified resolution, optionally using linear light processing.
This method behaves like the base Descaler.descale()
but adds support for linear or sigmoid-based preprocessing and postprocessing. When enabled, the clip is linearized before the descaling operation and de-linearized afterward.
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 descaled width (defaults to clip width if None).
-
height
¶int | None
, default:None
) –Target descaled height (defaults to clip height if None).
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Subpixel shift (top, left) applied during descaling.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive).
Returns:
-
ConstantFormatVideoNode
–The descaled video node, optionally processed in linear light.
Source code
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
ensure_obj classmethod
¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–Scaler instance.
Source code
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
from_param classmethod
¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–Resolved scaler type.
Source code
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
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
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
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
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Returns:
-
int
–Kernel radius.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Source code
347 348 349 350 351 352 353 354 355 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
368 369 370 371 372 373 374 375 |
|
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
**kwargs: Any
) -> ConstantFormatVideoNode
Rescale a clip to the given resolution from a previously descaled clip, optionally using linear light processing.
This method behaves like the base Descaler.rescale()
but adds support for linear or sigmoid-based preprocessing and postprocessing. When enabled, the clip is linearized before the rescaling operation and de-linearized afterward.
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 scaled width (defaults to clip width if None).
-
height
¶int | None
, default:None
) –Target scaled height (defaults to clip height if None).
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Subpixel shift (top, left) applied during rescaling.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive).
Returns:
-
ConstantFormatVideoNode
–The rescaled video node, optionally processed in linear light.
Source code
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
LinearScaler ¶
LinearScaler(**kwargs: Any)
Bases: Scaler
Abstract scaler class that applies linearization before scaling.
Only affects scaling results when linear
or sigmoid
parameters are specified.
Optionally, subclasses can implement _linear_scale
to override the default behavior with a custom linear scaling algorithm.
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:
Classes:
-
cached_property
–Read only version of functools.cached_property.
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.
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
multi
–Deprecated alias for
supersample
. -
pretty_string
–Cached property returning a user-friendly string representation.
-
scale
–Scale a clip to the given resolution with optional linearization.
-
supersample
–Supersample a clip by a given scaling factor.
Attributes:
-
kwargs
(dict[str, Any]
) –Arguments passed to the implemented funcs or internal scale function.
-
scale_function
(Callable[..., VideoNode]
) –Scale function called internally when performing scaling operations.
Source code
281 282 283 284 285 286 287 288 289 290 291 292 |
|
kwargs instance-attribute
¶
Arguments passed to the implemented funcs or internal scale function.
scale_function instance-attribute
¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
cached_property ¶
cached_property(func: Callable[Concatenate[_BaseScalerT, P], T_co])
Bases: cached_property[T_co]
Read only version of functools.cached_property.
Source code
265 |
|
ensure_obj classmethod
¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–Scaler instance.
Source code
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
from_param classmethod
¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | 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
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–Resolved scaler type.
Source code
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
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
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Returns:
-
int
–Kernel radius.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Source code
347 348 349 350 351 352 353 354 355 |
|
multi ¶
multi(
clip: VideoNodeT,
multi: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Deprecated alias for supersample
.
Parameters:
-
clip
¶VideoNodeT
) –The source clip.
-
multi
¶float
, default:2.0
) –Supersampling factor.
-
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:
-
VideoNodeT
–The supersampled clip.
Source code
451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
368 369 370 371 372 373 374 375 |
|
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
**kwargs: Any
) -> VideoNode | ConstantFormatVideoNode
Scale a clip to the given resolution with optional linearization.
This method behaves like the base Scaler.descale()
but adds support for linear or sigmoid-based preprocessing and postprocessing. When enabled, the clip is linearized before the scaling operation and de-linearized afterward.
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.
-
linear
¶bool | None
, default:None
) –Whether to linearize the input before scaling. If None, inferred from sigmoid.
-
sigmoid
¶bool | tuple[Slope, Center]
, default:False
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
kwargs
¶Any
, default:{}
) –Additional arguments forwarded to the scale function.
Returns:
-
VideoNode | ConstantFormatVideoNode
–Scaled video clip.
Source code
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
supersample ¶
supersample(
clip: VideoNodeT,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Supersample a clip by a given scaling factor.
Parameters:
-
clip
¶VideoNodeT
) –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.
Returns:
-
VideoNodeT
–The supersampled clip.
Raises:
-
CustomValueError
–If resulting resolution is non-positive.
Source code
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
|