Skip to content

various

Classes:

  • ClampScaler

    Clamp a reference Scaler.

  • DPID

    Rapid, Detail-Preserving Image Downscaler for VapourSynth

  • SSIM

    SSIM downsampler is an image downscaling technique that aims to optimize

ClampScaler

ClampScaler(
    base_scaler: ScalerT,
    reference: ScalerT | VideoNode,
    strength: int = 80,
    overshoot: float | None = None,
    undershoot: float | None = None,
    limit: RepairMode | bool = True,
    operator: Literal[MAX, MIN] | None = MIN,
    masked: bool = True,
    *,
    kernel: KernelT = Catrom,
    scaler: ScalerT | None = None,
    shifter: KernelT | None = None,
    **kwargs: Any
)

Bases: GenericScaler

Clamp a reference Scaler.

Parameters:

  • base_scaler

    (ScalerT) –

    Scaler to clamp.

  • reference

    (ScalerT | VideoNode) –

    Reference Scaler used to clamp base_scaler

  • strength

    (int, default: 80 ) –

    Strength of clamping. Default to 80. Must be between 0 and 100 (exclusive)

  • overshoot

    (float | None, default: None ) –

    Overshoot threshold within the 0.0 - 1.0 range.

  • undershoot

    (float | None, default: None ) –

    Undershoot threshold within the 0.0 - 1.0 range.

  • limit

    (RepairMode | bool, default: True ) –

    Whether to use under/overshoot limit (True) or a reference repaired clip for limiting.

  • operator

    (Literal[MAX, MIN] | None, default: MIN ) –

    Whether to take the brightest or darkest pixels in the merge. Defaults to ExprOp.MIN.

  • masked

    (bool, default: True ) –

    Whether to mask with a ringing mask or not. Defaults to True

  • kernel

    (KernelT, default: Catrom ) –

    Base kernel to be used for certain scaling/shifting/resampling operations. Defaults to Catrom.

  • scaler

    (ScalerT | None, default: None ) –

    Scaler used for scaling operations. Defaults to kernel.

  • shifter

    (KernelT | None, default: None ) –

    Kernel used for shifting operations. Defaults to kernel.

Methods:

Attributes:

Source code
27
28
29
30
31
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def __init__(
    self,
    base_scaler: ScalerT,
    reference: ScalerT | vs.VideoNode,
    strength: int = 80,
    overshoot: float | None = None,
    undershoot: float | None = None,
    limit: RepairMode | bool = True,
    operator: Literal[ExprOp.MAX, ExprOp.MIN] | None = ExprOp.MIN,
    masked: bool = True,
    *,
    kernel: KernelT = Catrom,
    scaler: ScalerT | None = None,
    shifter: KernelT | None = None,
    **kwargs: Any
) -> None:
    """
    :param base_scaler:     Scaler to clamp.
    :param reference:       Reference Scaler used to clamp base_scaler
    :param strength:        Strength of clamping. Default to 80. Must be between 0 and 100 (exclusive)
    :param overshoot:       Overshoot threshold within the 0.0 - 1.0 range.
    :param undershoot:      Undershoot threshold within the 0.0 - 1.0 range.
    :param limit:           Whether to use under/overshoot limit (True) or a reference repaired clip for limiting.
    :param operator:        Whether to take the brightest or darkest pixels in the merge. Defaults to ExprOp.MIN.
    :param masked:          Whether to mask with a ringing mask or not. Defaults to True
    :param kernel:          Base kernel to be used for certain scaling/shifting/resampling operations.
                            Defaults to Catrom.
    :param scaler:          Scaler used for scaling operations. Defaults to kernel.
    :param shifter:         Kernel used for shifting operations. Defaults to kernel.
    """
    self.base_scaler = Scaler.ensure_obj(base_scaler, self.__class__)

    self.reference: Scaler | vs.VideoNode

    if not isinstance(reference, vs.VideoNode):
        self.reference = Scaler.ensure_obj(reference, self.__class__)
    else:
        self.reference = reference

    if not 0 < strength < 100:
        raise CustomOverflowError("`strength` must be between 0 and 100 (exclusive)!", self.__class__)

    self.strength = strength

    if overshoot is None:
        self.overshoot = self.strength / 100
    else:
        self.overshoot = overshoot

    if undershoot is None:
        self.undershoot = self.overshoot
    else:
        self.undershoot = undershoot

    self.limit = limit
    self.operator = operator
    self.masked = masked

    super().__init__(None, kernel=kernel, scaler=scaler, shifter=shifter, **kwargs)

base_scaler instance-attribute

base_scaler = ensure_obj(base_scaler, __class__)

func instance-attribute

func = _func_no_op if func is None else func

kernel instance-attribute

kernel = ensure_obj(kernel, __class__)

kwargs instance-attribute

kwargs: KwargsT = kwargs

Arguments passed to the internal scale function

limit instance-attribute

limit = limit

masked instance-attribute

masked = masked

operator instance-attribute

operator = operator

overshoot instance-attribute

overshoot = strength / 100

reference instance-attribute

reference: Scaler | VideoNode

scale_function instance-attribute

scale_function: Callable[..., VideoNode]

Scale function called internally when scaling

scaler instance-attribute

scaler = ensure_obj(scaler or kernel, __class__)

shifter instance-attribute

shifter = ensure_obj(shifter or kernel, __class__)

strength instance-attribute

strength = strength

undershoot instance-attribute

undershoot = overshoot

ensure_obj classmethod

ensure_obj(
    scaler: str | type[BaseScalerT] | BaseScalerT | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> BaseScalerT
Source code
201
202
203
204
205
206
207
208
@classmethod
def ensure_obj(
    cls: type[BaseScalerT], scaler: str | type[BaseScalerT] | BaseScalerT | None = None, /,
    func_except: FuncExceptT | None = None
) -> BaseScalerT:
    return _base_ensure_obj(
        cls, (mro := cls.mro())[mro.index(BaseScaler) - 1], scaler, cls._err_class, [], func_except
    )

from_param classmethod

from_param(
    scaler: str | type[BaseScalerT] | BaseScalerT | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[BaseScalerT]
Source code
192
193
194
195
196
197
198
199
@classmethod
def from_param(
    cls: type[BaseScalerT], scaler: str | type[BaseScalerT] | BaseScalerT | None = None, /,
    func_except: FuncExceptT | None = None
) -> type[BaseScalerT]:
    return _base_from_param(
        cls, (mro := cls.mro())[mro.index(BaseScaler) - 1], scaler, cls._err_class, [], func_except
    )

get_clean_kwargs

get_clean_kwargs(*funcs: Callable[..., Any] | None) -> KwargsT
Source code
216
217
def get_clean_kwargs(self, *funcs: Callable[..., Any] | None) -> KwargsT:
    return _clean_self_kwargs(funcs, self)

get_implemented_funcs

get_implemented_funcs() -> tuple[Callable[..., Any], ...]
Source code
299
300
def get_implemented_funcs(self) -> tuple[Callable[..., Any], ...]:
    return (self.scale, self.supersample)

get_scale_args

get_scale_args(
    clip: VideoNode,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    width: int | None = None,
    height: int | None = None,
    *funcs: Callable[..., Any],
    **kwargs: Any
) -> KwargsT
Source code
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
@inject_kwargs_params
def get_scale_args(
    self, clip: vs.VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0),
    width: int | None = None, height: int | None = None,
    *funcs: Callable[..., Any], **kwargs: Any
) -> KwargsT:
    return (
        dict(
            src_top=shift[0],
            src_left=shift[1]
        )
        | self.get_clean_kwargs(*funcs)
        | dict(width=width, height=height)
        | kwargs
    )

kernel_radius

kernel_radius() -> int
Source code
148
149
150
151
152
@inject_self.cached.property
def kernel_radius(self) -> int:
    if not isinstance(self.reference, vs.VideoNode):
        return max(self.reference.kernel_radius, self.base_scaler.kernel_radius)
    return self.base_scaler.kernel_radius

multi

multi(
    clip: VideoNode,
    multi: float = 2.0,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode
Source code
272
273
274
275
276
277
278
279
280
281
@inject_self.cached
def multi(
    self, clip: vs.VideoNode, multi: float = 2.0, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> vs.VideoNode:

    import warnings

    warnings.warn('The "multi" method is deprecated. Use "supersample" instead.', DeprecationWarning)

    return self.supersample(clip, multi, shift, **kwargs)

pretty_string

pretty_string() -> str
Source code
225
226
227
@inject_self.cached.property
def pretty_string(self) -> str:
    return self._pretty_string()

scale

scale(
    clip: VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[float, float] = (0, 0),
    **kwargs: Any
) -> ConstantFormatVideoNode
Source code
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@inject_self.cached
def scale(
    self,
    clip: vs.VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[float, float] = (0, 0),
    **kwargs: Any
) -> ConstantFormatVideoNode:

    width, height = self._wh_norm(clip, width, height)

    base = self.base_scaler.scale(clip, width, height, shift, **kwargs)

    if isinstance(self.reference, vs.VideoNode):
        smooth = self.reference

        if shift != (0, 0):
            smooth = self.kernel.shift(smooth, shift)
    else:
        smooth = self.reference.scale(clip, width, height, shift)

    check_ref_clip(base, smooth)

    if TYPE_CHECKING:
        from vstools import check_variable_format
        assert check_variable_format(base, self.__class__)
        assert check_variable_format(smooth, self.__class__)

    merge_weight = self.strength / 100

    if self.limit is True:
        expression = 'x {merge_weight} * y {ref_weight} * + a {undershoot} - z {overshoot} + clip'

        merged = norm_expr(
            [base, smooth, smooth.std.Maximum(), smooth.std.Minimum()],
            expression,
            merge_weight=merge_weight,
            ref_weight=1.0 - merge_weight,
            undershoot=scale_delta(self.undershoot, 32, clip),
            overshoot=scale_delta(self.overshoot, 32, clip),
            func=self.__class__
        )
    else:
        merged = smooth.std.Merge(base, merge_weight)

        if isinstance(self.limit, RepairMode):
            merged = self.limit(merged, smooth)

    if self.operator is not None:
        merge2 = combine([smooth, base], self.operator)

        if self.masked:
            merged = merged.std.MaskedMerge(merge2, ringing_mask(smooth))
        else:
            merged = merge2
    elif self.masked:
        merged = merged.std.MaskedMerge(smooth, ringing_mask(smooth))

    return merged

supersample

supersample(
    clip: VideoNode,
    rfactor: float = 2.0,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode
Source code
257
258
259
260
261
262
263
264
265
266
267
268
269
270
@inject_self.cached
def supersample(
    self, clip: vs.VideoNode, rfactor: float = 2.0, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_resolution(clip, self.multi)

    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)

DPID

DPID(
    sigma: float = 0.1,
    ref: VideoNode | ScalerT = Catrom,
    planes: PlanesT = None,
    **kwargs: Any
)

Bases: BaseGenericScaler

Rapid, Detail-Preserving Image Downscaler for VapourSynth

Parameters:

  • sigma

    (float, default: 0.1 ) –

    The power factor of range kernel. It can be used to tune the amplification of the weights of pixels that represent detail—from a box filter over an emphasis of distinct pixels towards a selection of only the most distinct pixels.

  • ref

    (VideoNode | ScalerT, default: Catrom ) –

    VideoNode or Scaler to obtain the downscaled reference for DPID.

  • planes

    (PlanesT, default: None ) –

    Sets which planes will be processed. Any unprocessed planes will be simply copied from ref.

Methods:

Attributes:

Source code
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
def __init__(
    self,
    sigma: float = 0.1,
    ref: vs.VideoNode | ScalerT = Catrom,
    planes: PlanesT = None,
    **kwargs: Any
) -> None:
    """
    :param sigma:       The power factor of range kernel. It can be used to tune the amplification
                        of the weights of pixels that represent detail—from a box filter over an emphasis
                        of distinct pixels towards a selection of only the most distinct pixels.
    :param ref:         VideoNode or Scaler to obtain the downscaled reference for DPID.
    :param planes:      Sets which planes will be processed. Any unprocessed planes will be simply copied from ref.
    """
    super().__init__(**kwargs)

    self.sigma = sigma
    self.ref = ref
    self.planes = planes

    if isinstance(ref, vs.VideoNode):
        self._ref_scaler = self.scaler
    else:
        self._ref_scaler = Scaler.ensure_obj(ref, self.__class__)

kernel instance-attribute

kernel = ensure_obj(kernel, __class__)

kwargs instance-attribute

kwargs: KwargsT = kwargs

Arguments passed to the internal scale function

planes instance-attribute

planes = planes

ref instance-attribute

ref = ref

scale_function instance-attribute

scale_function: Callable[..., VideoNode]

Scale function called internally when scaling

scaler instance-attribute

scaler = ensure_obj(scaler or kernel, __class__)

shifter instance-attribute

shifter = ensure_obj(shifter or kernel, __class__)

sigma instance-attribute

sigma = sigma

ensure_obj classmethod

ensure_obj(
    scaler: str | type[BaseScalerT] | BaseScalerT | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> BaseScalerT
Source code
201
202
203
204
205
206
207
208
@classmethod
def ensure_obj(
    cls: type[BaseScalerT], scaler: str | type[BaseScalerT] | BaseScalerT | None = None, /,
    func_except: FuncExceptT | None = None
) -> BaseScalerT:
    return _base_ensure_obj(
        cls, (mro := cls.mro())[mro.index(BaseScaler) - 1], scaler, cls._err_class, [], func_except
    )

from_param classmethod

from_param(
    scaler: str | type[BaseScalerT] | BaseScalerT | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[BaseScalerT]
Source code
192
193
194
195
196
197
198
199
@classmethod
def from_param(
    cls: type[BaseScalerT], scaler: str | type[BaseScalerT] | BaseScalerT | None = None, /,
    func_except: FuncExceptT | None = None
) -> type[BaseScalerT]:
    return _base_from_param(
        cls, (mro := cls.mro())[mro.index(BaseScaler) - 1], scaler, cls._err_class, [], func_except
    )

get_clean_kwargs

get_clean_kwargs(*funcs: Callable[..., Any] | None) -> KwargsT
Source code
216
217
def get_clean_kwargs(self, *funcs: Callable[..., Any] | None) -> KwargsT:
    return _clean_self_kwargs(funcs, self)

get_implemented_funcs

get_implemented_funcs() -> tuple[Callable[..., Any], ...]
Source code
299
300
def get_implemented_funcs(self) -> tuple[Callable[..., Any], ...]:
    return (self.scale, self.supersample)

get_scale_args

get_scale_args(
    clip: VideoNode,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    width: int | None = None,
    height: int | None = None,
    *funcs: Callable[..., Any],
    **kwargs: Any
) -> KwargsT
Source code
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
@inject_kwargs_params
def get_scale_args(
    self, clip: vs.VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0),
    width: int | None = None, height: int | None = None,
    *funcs: Callable[..., Any], **kwargs: Any
) -> KwargsT:
    return (
        dict(
            src_top=shift[0],
            src_left=shift[1]
        )
        | self.get_clean_kwargs(*funcs)
        | dict(width=width, height=height)
        | kwargs
    )

kernel_radius

kernel_radius() -> int
Source code
216
217
218
@inject_self.cached.property
def kernel_radius(self) -> int:
    return self._ref_scaler.kernel_radius

multi

multi(
    clip: VideoNode,
    multi: float = 2.0,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode
Source code
272
273
274
275
276
277
278
279
280
281
@inject_self.cached
def multi(
    self, clip: vs.VideoNode, multi: float = 2.0, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> vs.VideoNode:

    import warnings

    warnings.warn('The "multi" method is deprecated. Use "supersample" instead.', DeprecationWarning)

    return self.supersample(clip, multi, shift, **kwargs)

pretty_string

pretty_string() -> str
Source code
225
226
227
@inject_self.cached.property
def pretty_string(self) -> str:
    return self._pretty_string()

scale

scale(
    clip: VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[float, float] = (0, 0),
    **kwargs: Any
) -> ConstantFormatVideoNode
Source code
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
@inject_self.cached
def scale(
    self,
    clip: vs.VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[float, float] = (0, 0),
    **kwargs: Any
) -> ConstantFormatVideoNode:
    assert check_variable(clip, self.__class__)

    width, height = self._wh_norm(clip, width, height)

    ref = clip

    if isinstance(self.ref, vs.VideoNode):
        check_ref_clip(clip, self.ref)

        if TYPE_CHECKING:
            assert check_variable_format(self.ref, self.__class__)

        ref = self.ref

    if (ref.width, ref.height) != (width, height):
        ref = self._ref_scaler.scale(ref, width, height)  # type: ignore[assignment]

    kwargs = {
        'lambda': self.sigma, 'planes': self.planes,
        'src_left': shift[1], 'src_top': shift[0]
    } | self.kwargs | kwargs | {'read_chromaloc': True}

    return core.dpid.DpidRaw(clip, ref, **kwargs)

supersample

supersample(
    clip: VideoNode,
    rfactor: float = 2.0,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode
Source code
257
258
259
260
261
262
263
264
265
266
267
268
269
270
@inject_self.cached
def supersample(
    self, clip: vs.VideoNode, rfactor: float = 2.0, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_resolution(clip, self.multi)

    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)

SSIM

SSIM(
    scaler: ScalerT = Hermite,
    smooth: (
        int
        | float
        | VSFunctionNoArgs[VideoNode, ConstantFormatVideoNode]
        | None
    ) = None,
    **kwargs: Any
)

Bases: LinearScaler

SSIM downsampler is an image downscaling technique that aims to optimize for the perceptual quality of the downscaled results.

Image downscaling is considered as an optimization problem where the difference between the input and output images is measured using famous Structural SIMilarity (SSIM) index.

The solution is derived in closed-form, which leads to the simple, efficient implementation. The downscaled images retain perceptually important features and details, resulting in an accurate and spatio-temporally consistent representation of the high resolution input.

Parameters:

  • scaler

    (ScalerT, default: Hermite ) –

    Scaler to be used for downscaling, defaults to Hermite.

  • smooth

    (int | float | VSFunctionNoArgs[VideoNode, ConstantFormatVideoNode] | None, default: None ) –

    Image smoothening method. If you pass an int, it specifies the "radius" of the internally-used boxfilter, i.e. the window has a size of (2smooth+1)x(2smooth+1). If you pass a float, it specifies the "sigma" of gauss_blur, i.e. the standard deviation of gaussian blur. If you pass a function, it acts as a general smoother. Default uses a gaussian blur based on the scaler's kernel radius.

Methods:

Attributes:

Source code
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
def __init__(
    self,
    scaler: ScalerT = Hermite,
    smooth: int | float | VSFunctionNoArgs[vs.VideoNode, ConstantFormatVideoNode] | None = None,
    **kwargs: Any
) -> None:
    """
    :param scaler:      Scaler to be used for downscaling, defaults to Hermite.
    :param smooth:      Image smoothening method.
                        If you pass an int, it specifies the "radius" of the internally-used boxfilter,
                        i.e. the window has a size of (2*smooth+1)x(2*smooth+1).
                        If you pass a float, it specifies the "sigma" of gauss_blur,
                        i.e. the standard deviation of gaussian blur.
                        If you pass a function, it acts as a general smoother.
                        Default uses a gaussian blur based on the scaler's kernel radius.
    """
    super().__init__(**kwargs)

    self.scaler = Hermite.from_param(scaler)

    if smooth is None:
        smooth = (self.scaler.kernel_radius + 1.0) / 3

    if callable(smooth):
        self.filter_func = smooth
    elif isinstance(smooth, int):
        self.filter_func = partial(box_blur, radius=smooth)
    elif isinstance(smooth, float):
        self.filter_func = partial(gauss_blur, sigma=smooth)

filter_func instance-attribute

filter_func = smooth

kwargs instance-attribute

kwargs: KwargsT = kwargs

Arguments passed to the internal scale function

scale_function instance-attribute

scale_function: Callable[..., VideoNode]

Scale function called internally when scaling

scaler instance-attribute

scaler = from_param(scaler)

ensure_obj classmethod

ensure_obj(
    scaler: str | type[BaseScalerT] | BaseScalerT | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> BaseScalerT
Source code
201
202
203
204
205
206
207
208
@classmethod
def ensure_obj(
    cls: type[BaseScalerT], scaler: str | type[BaseScalerT] | BaseScalerT | None = None, /,
    func_except: FuncExceptT | None = None
) -> BaseScalerT:
    return _base_ensure_obj(
        cls, (mro := cls.mro())[mro.index(BaseScaler) - 1], scaler, cls._err_class, [], func_except
    )

from_param classmethod

from_param(
    scaler: str | type[BaseScalerT] | BaseScalerT | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[BaseScalerT]
Source code
192
193
194
195
196
197
198
199
@classmethod
def from_param(
    cls: type[BaseScalerT], scaler: str | type[BaseScalerT] | BaseScalerT | None = None, /,
    func_except: FuncExceptT | None = None
) -> type[BaseScalerT]:
    return _base_from_param(
        cls, (mro := cls.mro())[mro.index(BaseScaler) - 1], scaler, cls._err_class, [], func_except
    )

get_clean_kwargs

get_clean_kwargs(*funcs: Callable[..., Any] | None) -> KwargsT
Source code
216
217
def get_clean_kwargs(self, *funcs: Callable[..., Any] | None) -> KwargsT:
    return _clean_self_kwargs(funcs, self)

get_implemented_funcs

get_implemented_funcs() -> tuple[Callable[..., Any], ...]
Source code
299
300
def get_implemented_funcs(self) -> tuple[Callable[..., Any], ...]:
    return (self.scale, self.supersample)

get_scale_args

get_scale_args(
    clip: VideoNode,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    width: int | None = None,
    height: int | None = None,
    *funcs: Callable[..., Any],
    **kwargs: Any
) -> KwargsT
Source code
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
@inject_kwargs_params
def get_scale_args(
    self, clip: vs.VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0),
    width: int | None = None, height: int | None = None,
    *funcs: Callable[..., Any], **kwargs: Any
) -> KwargsT:
    return (
        dict(
            src_top=shift[0],
            src_left=shift[1]
        )
        | self.get_clean_kwargs(*funcs)
        | dict(width=width, height=height)
        | kwargs
    )

kernel_radius

kernel_radius() -> int
Source code
289
290
291
@inject_self.cached.property
def kernel_radius(self) -> int:
    return self.scaler.kernel_radius

multi

multi(
    clip: VideoNode,
    multi: float = 2.0,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode
Source code
272
273
274
275
276
277
278
279
280
281
@inject_self.cached
def multi(
    self, clip: vs.VideoNode, multi: float = 2.0, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> vs.VideoNode:

    import warnings

    warnings.warn('The "multi" method is deprecated. Use "supersample" instead.', DeprecationWarning)

    return self.supersample(clip, multi, shift, **kwargs)

pretty_string

pretty_string() -> str
Source code
225
226
227
@inject_self.cached.property
def pretty_string(self) -> str:
    return self._pretty_string()

scale

scale(
    clip: VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    *,
    linear: bool = False,
    sigmoid: bool | tuple[Slope, Center] = False,
    **kwargs: Any
) -> VideoNode
Source code
83
84
85
86
87
88
89
90
91
92
@inject_self.cached
@inject_kwargs_params
def scale(
    self, clip: vs.VideoNode, width: int | None = None, height: int | None = None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    *,
    # LinearScaler adds `linear` and `sigmoid` parameters
    linear: bool = False, sigmoid: bool | tuple[Slope, Center] = False, **kwargs: Any
) -> vs.VideoNode:
    ...

supersample

supersample(
    clip: VideoNode,
    rfactor: float = 2.0,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode
Source code
257
258
259
260
261
262
263
264
265
266
267
268
269
270
@inject_self.cached
def supersample(
    self, clip: vs.VideoNode, rfactor: float = 2.0, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_resolution(clip, self.multi)

    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)