docs ¶
Classes:
-
ExampleBicubicKernel
–Example Kernel class for documentation purposes.
ExampleBicubicKernel ¶
Bases: Kernel
Example Kernel class for documentation purposes.
Classes:
-
cached_property
–Read only version of functools.cached_property.
Methods:
-
descale
–Perform a regular descaling operation.
-
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
–Perform a regular resampling operation.
-
rescale
–Rescale a clip to the given resolution from a previously descaled clip.
-
scale
–Perform a regular scaling operation.
-
shift
–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample
–Supersample a clip by a given scaling factor.
Attributes:
-
b
– -
c
– -
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
28 29 30 31 |
|
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
291 |
|
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> ConstantFormatVideoNode
Perform a regular descaling operation.
Parameters:
-
clip
¶VideoNode
) –Input clip.
-
width
¶int | None
, default:None
) –Output width.
-
height
¶int | None
, default:None
) –Output height.
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Shift clip during the operation. Expects a tuple of (src_top, src_left).
Returns:
-
ConstantFormatVideoNode
–The descaled clip.
Source code
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
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
906 907 908 909 910 911 912 913 914 915 916 917 918 |
|
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
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 |
|
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
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 |
|
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
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 |
|
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 valid
VideoFormat
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
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
|
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
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
|
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
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
|
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
392 393 394 395 396 397 398 399 400 401 402 403 |
|
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
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
419 420 421 422 423 424 425 426 427 |
|
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatT | HoldsVideoFormatT,
matrix: MatrixT | None = None,
matrix_in: MatrixT | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Perform a regular resampling operation.
Parameters:
-
clip
¶VideoNode
) –Input clip
-
format
¶int | VideoFormatT | HoldsVideoFormatT
) –Output format
-
matrix
¶MatrixT | None
, default:None
) –Output matrix. If
None
, will take the matrix from the input clip's frameprops. -
matrix_in
¶MatrixT | None
, default:None
) –Input matrix. If
None
, will take the matrix from the input clip's frameprops.
Returns:
-
ConstantFormatVideoNode
–Resampled clip.
Source code
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
rescale ¶
rescale(
clip: VideoNode,
width: int | None,
height: int | None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> ConstantFormatVideoNode
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:
-
ConstantFormatVideoNode
–The scaled clip.
Source code
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 |
|
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Perform a regular scaling operation.
Parameters:
-
clip
¶VideoNode
) –Input clip.
-
width
¶int | None
, default:None
) –Output width.
-
height
¶int | None
, default:None
) –Output height.
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Shift clip during the operation. Expects a tuple of (src_top, src_left).
Returns:
-
VideoNode
–The scaled clip.
Source code
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
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
821 822 823 824 825 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 882 883 884 885 886 887 |
|
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.
Raises:
-
CustomValueError
–If resulting resolution is non-positive.
Returns:
-
VideoNodeT
–The supersampled clip.
Source code
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
|