Skip to content

docs

Classes:

ExampleBicubicKernel

ExampleBicubicKernel(b: float = 0, c: float = 0.5, **kwargs: Any)

Bases: Kernel

Example Kernel class for documentation purposes.

Methods:

  • descale

    Perform a regular descaling operation.

  • 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

    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[..., 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/docs.py
27
28
29
30
def __init__(self, b: float = 0, c: float = 0.5, **kwargs: Any) -> None:
    self.b = b
    self.c = c
    super().__init__(**kwargs)

b instance-attribute

b = b

c instance-attribute

c = c

descale_function instance-attribute

descale_function: Callable[..., VideoNode]

Descale function called internally when performing descaling operations.

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

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 = None,
    height: int | None = None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode

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:

  • VideoNode

    The descaled clip.

Source code in vskernels/docs.py
64
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
def descale(
    self,
    clip: vs.VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Perform a regular descaling operation.

    Args:
        clip: Input clip.
        width: Output width.
        height: Output height.
        shift: Shift clip during the operation. Expects a tuple of (src_top, src_left).

    Returns:
        The descaled clip.
    """
    width, height = self._wh_norm(clip, width, height)
    return depth(
        core.descale.Debicubic(
            depth(clip, 32),
            width,
            height,
            b=self.b,
            c=self.c,
            src_top=shift[0],
            src_left=shift[1],
            **self.kwargs | kwargs,
        ),
        clip,
    )

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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
@classmethod
def ensure_obj(
    cls,
    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.

    Args:
        scaler: Scaler identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Scaler instance.
    """
    return _base_ensure_obj(cls, scaler, func_except)

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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
@classmethod
def from_param(
    cls,
    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).

    Args:
        scaler: Scaler identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved scaler type.
    """
    return _base_from_param(cls, scaler, cls._err_class, func_except)

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:

  • dict[str, Any]

    Dictionary of keyword arguments for the descale function.

Source code in vskernels/abstract/base.py
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
def get_descale_args(
    self,
    clip: vs.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.

    Args:
        clip: The source clip.
        shift: Vertical and horizontal shift to apply.
        width: Target width.
        height: Target height.
        **kwargs: Additional arguments to pass to the descale function.

    Returns:
        Dictionary of keyword arguments for the descale function.
    """
    return {"src_top": shift[0], "src_left": shift[1]} | self.get_params_args(True, clip, width, height, **kwargs)

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:

  • dict[str, Any]

    Dictionary of combined parameters.

Source code in vskernels/abstract/base.py
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
def get_params_args(
    self, is_descale: bool, clip: vs.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.

    Args:
        is_descale: Whether this is for a descale operation.
        clip: The source clip.
        width: Target width.
        height: Target height.
        **kwargs: Additional keyword arguments to include.

    Returns:
        Dictionary of combined parameters.
    """
    return {"width": width, "height": height} | self.kwargs | kwargs

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.PresetVideoFormat or vs.VideoFormat,
    • or a source from which a valid VideoFormat can 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:

  • dict[str, Any]

    Dictionary of keyword arguments for the resample function.

Source code in vskernels/abstract/base.py
 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
1000
1001
def get_resample_args(
    self,
    clip: vs.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.

    Args:
        clip: The source clip.
        format: The target video format, which can either be:

               - an integer format ID,
               - a `vs.PresetVideoFormat` or `vs.VideoFormat`,
               - or a source from which a valid `VideoFormat` can be extracted.
        matrix: Target color matrix.
        matrix_in: Source color matrix.
        **kwargs: Additional arguments to pass to the resample function.

    Returns:
        Dictionary of keyword arguments for the resample function.
    """
    return {
        "format": get_video_format(format).id,
        "matrix": Matrix.from_param(matrix),
        "matrix_in": Matrix.from_param(matrix_in),
    } | self.get_params_args(False, clip, **kwargs)

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:

  • dict[str, Any]

    Dictionary of keyword arguments for the rescale function.

Source code in vskernels/abstract/base.py
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
def get_rescale_args(
    self,
    clip: vs.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.

    Args:
        clip: The source clip.
        shift: Vertical and horizontal shift to apply.
        width: Target width.
        height: Target height.
        **kwargs: Additional arguments to pass to the rescale function.

    Returns:
        Dictionary of keyword arguments for the rescale function.
    """
    return {"src_top": shift[0], "src_left": shift[1]} | self.get_params_args(True, clip, width, height, **kwargs)

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:

  • dict[str, Any]

    Dictionary of keyword arguments for the scale function.

Source code in vskernels/abstract/base.py
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
def get_scale_args(
    self,
    clip: vs.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.

    Args:
        clip: The source clip.
        shift: Vertical and horizontal shift to apply.
        width: Target width.
        height: Target height.
        **kwargs: Additional arguments to pass to the scale function.

    Returns:
        Dictionary of keyword arguments for the scale function.
    """
    return {"src_top": shift[0], "src_left": shift[1]} | self.get_params_args(False, clip, width, height, **kwargs)

implemented_funcs classmethod

implemented_funcs() -> frozenset[str]

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
443
444
445
446
447
448
449
450
451
452
453
454
@classproperty.cached
@classmethod
def implemented_funcs(cls) -> frozenset[str]:
    """
    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:
        Frozen set of function names.
    """
    return frozenset(func for klass in cls.mro() for func in getattr(klass, "_implemented_funcs", ()))

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
406
407
408
409
410
411
412
413
414
415
416
417
@BaseScalerMeta.cachedproperty
def kernel_radius(self) -> int:
    """
    Return the effective kernel radius for the scaler.

    Raises:
        CustomNotImplementedError: If no kernel radius is defined.

    Returns:
        Kernel radius.
    """
    ...

resample

resample(
    clip: VideoNode,
    format: int | VideoFormatLike | HoldsVideoFormat,
    matrix: MatrixLike | None = None,
    matrix_in: MatrixLike | None = None,
    **kwargs: Any
) -> VideoNode

Perform a regular resampling operation.

Parameters:

  • clip

    (VideoNode) –

    Input clip

  • format

    (int | VideoFormatLike | HoldsVideoFormat) –

    Output format

  • matrix

    (MatrixLike | None, default: None ) –

    Output matrix. If None, will take the matrix from the input clip's frameprops.

  • matrix_in

    (MatrixLike | None, default: None ) –

    Input matrix. If None, will take the matrix from the input clip's frameprops.

Returns:

  • VideoNode

    Resampled clip.

Source code in vskernels/docs.py
 99
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
def resample(
    self,
    clip: vs.VideoNode,
    format: int | VideoFormatLike | HoldsVideoFormat,
    matrix: MatrixLike | None = None,
    matrix_in: MatrixLike | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Perform a regular resampling operation.

    Args:
        clip: Input clip
        format: Output format
        matrix: Output matrix. If `None`, will take the matrix from the input clip's frameprops.
        matrix_in: Input matrix. If `None`, will take the matrix from the input clip's frameprops.

    Returns:
        Resampled clip.
    """
    return core.resize2.Bicubic(
        clip,
        format=get_video_format(format).id,
        filter_param_a=self.b,
        filter_param_b=self.c,
        matrix=Matrix.from_param(matrix),
        matrix_in=Matrix.from_param(matrix_in),
        **self.kwargs | kwargs,
    )

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
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
def rescale(
    self,
    clip: vs.VideoNode,
    width: int | None,
    height: int | None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any,
) -> vs.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.

    Args:
        clip: The source clip.
        width: Target scaled width (defaults to clip width if None).
        height: Target scaled height (defaults to clip height if None).
        shift: Subpixel shift (top, left) applied during scaling.

    Returns:
        The scaled clip.
    """
    width, height = self._wh_norm(clip, width, height)
    check_correct_subsampling(clip, width, height)

    return self.rescale_function(
        clip, **_norm_props_enums(self.get_rescale_args(clip, shift, width, height, **kwargs))
    )

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 in vskernels/docs.py
32
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
def scale(
    self,
    clip: vs.VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Perform a regular scaling operation.

    Args:
        clip: Input clip.
        width: Output width.
        height: Output height.
        shift: Shift clip during the operation. Expects a tuple of (src_top, src_left).

    Returns:
        The scaled clip.
    """
    width, height = self._wh_norm(clip, width, height)
    return core.resize2.Bicubic(
        clip,
        width,
        height,
        src_top=shift[0],
        src_left=shift[1],
        filter_param_a=self.b,
        filter_param_b=self.c,
        **self.kwargs | kwargs,
    )

shift

shift(
    clip: VideoNode, shift: tuple[TopShift, LeftShift], /, **kwargs: Any
) -> VideoNode
shift(
    clip: VideoNode,
    shift_top: float | list[float],
    shift_left: float | list[float],
    /,
    **kwargs: Any,
) -> VideoNode
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_top is a tuple.

  • **kwargs

    (Any, default: {} ) –

    Additional arguments passed to the internal scale call.

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
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
def shift(
    self,
    clip: vs.VideoNode,
    shifts_or_top: float | tuple[float, float] | list[float],
    shift_left: float | list[float] | None = None,
    /,
    **kwargs: Any,
) -> vs.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.

    Args:
        clip: The source clip.
        shifts_or_top: Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
        shift_left: Horizontal shift or list of horizontal shifts. Ignored if `shifts_or_top` is a tuple.
        **kwargs: Additional arguments passed to the internal `scale` call.

    Returns:
        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.
    """

    def _shift(src: vs.VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0)) -> vs.VideoNode:
        return self.scale(src, shift=shift, **kwargs)

    if isinstance(shifts_or_top, tuple):
        return _shift(clip, shifts_or_top)

    if isinstance(shifts_or_top, (int, float)) and isinstance(shift_left, (int, float, NoneType)):
        return _shift(clip, (shifts_or_top, shift_left or 0))

    if shift_left is None:
        shift_left = 0.0

    shifts_top = normalize_seq(shifts_or_top, clip.format.num_planes)
    shifts_left = normalize_seq(shift_left, clip.format.num_planes)

    if clip.format.num_planes == 1:
        return _shift(clip, (shifts_top[0], shifts_left[0]))

    shifted_planes = [
        plane if top == left == 0 else _shift(plane, (top, left))
        for plane, top, left in zip(split(clip), shifts_top, shifts_left)
    ]

    return core.std.ShufflePlanes(shifted_planes, [0, 0, 0], clip.format.color_family, clip)

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
def supersample(
    self, clip: vs.VideoNode, rfactor: float = 2.0, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> vs.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.

    Args:
        clip: The source clip.
        rfactor: Scaling factor for supersampling.
        shift: Subpixel shift (top, left) applied during scaling.
        **kwargs: Additional arguments forwarded to the scale function.

    Raises:
        CustomValueError: If resulting resolution is non-positive.

    Returns:
        The supersampled clip.
    """
    assert check_variable_resolution(clip, self.supersample)

    dst_width, dst_height = ceil(clip.width * rfactor), ceil(clip.height * rfactor)

    if max(dst_width, dst_height) <= 0.0:
        raise CustomValueError(
            'Multiplying the resolution by "rfactor" must result in a positive resolution!',
            self.supersample,
            rfactor,
        )

    return self.scale(clip, dst_width, dst_height, shift, **kwargs)