Skip to content

limit

Functions:

  • limit_filter

    Performs a soft-limiting between two clips to limit the difference of filtering while avoiding artifacts.

limit_filter

limit_filter(
    flt: VideoNode,
    src: VideoNode,
    ref: VideoNode | None = None,
    dark_thr: float | Sequence[float] = 1.0,
    bright_thr: float | Sequence[float] = 1.0,
    elast: float | Sequence[float] = 2.0,
    planes: Planes = None,
) -> VideoNode

Performs a soft-limiting between two clips to limit the difference of filtering while avoiding artifacts.

Parameters:

  • flt

    (VideoNode) –

    Filtered clip.

  • src

    (VideoNode) –

    Source clip.

  • ref

    (VideoNode | None, default: None ) –

    Reference clip, to compute the weight to be applied on filtering diff.

  • dark_thr

    (float | Sequence[float], default: 1.0 ) –

    Threshold (8-bit scale) to limit dark filtering diff.

  • bright_thr

    (float | Sequence[float], default: 1.0 ) –

    Threshold (8-bit scale) to limit bright filtering diff.

  • elast

    (float | Sequence[float], default: 2.0 ) –

    Elasticity of the soft threshold.

  • planes

    (Planes, default: None ) –

    Planes to process. Defaults to all.

Returns:

  • VideoNode

    Limited clip.

Source code in vsrgtools/limit.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@deprecated(
    "limit_filter is deprecated and will be removed in a future version. Use vszip.LimitFilter instead.",
    category=DeprecationWarning,
)
def limit_filter(
    flt: vs.VideoNode,
    src: vs.VideoNode,
    ref: vs.VideoNode | None = None,
    dark_thr: float | Sequence[float] = 1.0,
    bright_thr: float | Sequence[float] = 1.0,
    elast: float | Sequence[float] = 2.0,
    planes: Planes = None,
) -> vs.VideoNode:
    """
    Performs a soft-limiting between two clips to limit the difference of filtering while avoiding artifacts.

    Args:
        flt: Filtered clip.
        src: Source clip.
        ref: Reference clip, to compute the weight to be applied on filtering diff.
        dark_thr: Threshold (8-bit scale) to limit dark filtering diff.
        bright_thr: Threshold (8-bit scale) to limit bright filtering diff.
        elast: Elasticity of the soft threshold.
        planes: Planes to process. Defaults to all.

    Returns:
        Limited clip.
    """

    return norm_expr(
        [flt, src, fallback(ref, src)],
        "x z - dup {bright_thr} {dark_thr} ? THR1! abs DIFF! THR1@ {elast} * THR2! "
        "DIFF@ THR1@ <= x DIFF@ THR2@ >= y y x y - THR2@ DIFF@ - * THR2@ THR1@ - / + ? ?",
        dark_thr=[scale_delta(x, 8, flt) for x in to_arr(dark_thr)],
        bright_thr=[scale_delta(x, 8, flt) for x in to_arr(bright_thr)],
        elast=elast,
        planes=planes,
    )