Skip to content

types

DescaleAttempt

Bases: NamedTuple

Tuple representing a descale attempt.

descaled instance-attribute

descaled: VideoNode

Descaled frame in native resolution.

diff instance-attribute

diff: VideoNode

The subtractive difference between the original and descaled frame.

kernel instance-attribute

kernel: Kernel

Kernel used for descaling.

rescaled instance-attribute

rescaled: VideoNode

Descaled frame reupscaled with the same kernel.

resolution instance-attribute

resolution: Resolution

The native resolution.

from_args classmethod

from_args(
    clip: VideoNode,
    width: int,
    height: int,
    shift: tuple[float, float],
    kernel: Kernel,
    mode: DescaleModeWithInfo,
    **kwargs: VSMapValue
) -> DescaleAttempt

Get a DescaleAttempt from args. Calculate difference nodes too.

Source code
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@classmethod
def from_args(
    cls, clip: vs.VideoNode, width: int, height: int, shift: tuple[float, float],
    kernel: Kernel, mode: DescaleModeWithInfo, **kwargs: VSMapValue
) -> DescaleAttempt:
    """Get a DescaleAttempt from args. Calculate difference nodes too."""

    descaled = kernel.descale(clip, width, height, shift)
    descaled = descaled.std.SetFrameProps(**kwargs)

    rescaled = kernel.scale(descaled, clip.width, clip.height)

    diff = expr_func([rescaled, clip], 'x y - abs').std.PlaneStats(
        None, prop=DescaleMode.PlaneDiff.prop_key
    )

    if mode.mode in {DescaleMode.KernelDiff, DescaleMode.KernelDiffMin, DescaleMode.KernelDiffMax}:
        diff_props = rescaled.std.PlaneStats(clip, prop=DescaleMode.KernelDiff.prop_key)

        diff = merge_clip_props(diff, diff_props)

    resolution = Resolution(width, height)

    return DescaleAttempt(resolution, descaled, rescaled, diff, kernel)

DescaleMode

Bases: CustomIntEnum

Descale modes for vsscale.descale.

KernelDiff class-attribute instance-attribute

KernelDiff = 3

Simple PlaneStats between original and descaled kernels differences.

KernelDiffMax class-attribute instance-attribute

KernelDiffMax = 4

Get the video descaled with the kernel with the maximum absolute difference from original.

KernelDiffMin class-attribute instance-attribute

KernelDiffMin = 5

Get the video descaled with the kernel with the minimum absolute difference from original.

PlaneDiff class-attribute instance-attribute

PlaneDiff = 0

Simple PlaneStatsDiff between original and descaled.

PlaneDiffMax class-attribute instance-attribute

PlaneDiffMax = 1

Get the video with the maximum absolute difference from original.

PlaneDiffMin class-attribute instance-attribute

PlaneDiffMin = 2

Get the video with the minimum absolute difference from original.

diff_op property

diff_op: ComparatorFunc

Get the operator for calculating sort operation between two props.

is_average property

is_average: bool

Whether this DescaleMode is of PlaneDiff kind.

is_kernel_diff property

is_kernel_diff: bool

Whether this DescaleMode is of KernelDiff kind.

prop_key property

prop_key: str

Get the props key for this DescaleMode.

res_op property

res_op: ComparatorFunc

Get the operator for calculating sort operation between two resolutions.

__call__

__call__(
    thr: float = 5e-08, op: ComparatorFunc | None = None
) -> DescaleModeWithInfo
Source code
136
137
def __call__(self, thr: float = 5e-8, op: ComparatorFunc | None = None) -> DescaleModeWithInfo:
    return DescaleModeWithInfo(self, thr) if op is None else DescaleModeWithInfo(self, thr, op)

prop_value

prop_value(kind: PlaneStatsKind) -> str

Get props key for getting the value of the PlaneStatsKind.

Source code
186
187
188
189
def prop_value(self, kind: PlaneStatsKind) -> str:
    """Get props key for getting the value of the PlaneStatsKind."""

    return f'{self.prop_key}{kind.value}'

DescaleModeWithInfo dataclass

DescaleModeWithInfo(
    mode: DescaleMode, thr: float = 5e-08, op: ComparatorFunc = lambda: max()
)

mode instance-attribute

Actual descale mode used for descaling.

op class-attribute instance-attribute

op: ComparatorFunc = field(default_factory=lambda: max)

Operator used for generic sorting.

thr class-attribute instance-attribute

thr: float = field(default=5e-08)

Diff threshold.

DescaleResult dataclass

DescaleResult(
    descaled: VideoNode,
    rescaled: VideoNode,
    upscaled: VideoNode | None,
    error_mask: VideoNode | None,
    pproc_mask: VideoNode | None,
    attempts: list[DescaleAttempt],
    out: VideoNode,
)

Dataclass representing a complete result of vsscale.descale.

attempts instance-attribute

attempts: list[DescaleAttempt]

Descale attempts made. These are used to determine the correct kernel if multiple "Kernels" were passed.

descaled instance-attribute

descaled: VideoNode

The descaled clip. Can be a variable resolution.

error_mask instance-attribute

error_mask: VideoNode | None

The descale error mask. This catches the big differences between the source clip and the rescaled clip as a mask. If no "mask" is passed, this attribute will be None.

out instance-attribute

out: VideoNode

The final clip that is returned during regular usage with "result=False".

pproc_mask instance-attribute

pproc_mask: VideoNode | None

The post-processing mask. This is the second mask passed to "mask". If no "mask" is passed, this attribute will be None.

rescaled instance-attribute

rescaled: VideoNode

The descaled clip reupscaled to the source resolution using the same kernel used to descale. Can be a variable resolution clip.

upscaled instance-attribute

upscaled: VideoNode | None

The descaled clip reupscaled using the given upscaler.

PlaneStatsKind

Bases: CustomStrEnum

Type of PlaneStats comparing to use.

AVG class-attribute instance-attribute

AVG = 'Average'

DIFF class-attribute instance-attribute

DIFF = 'Diff'

MAX class-attribute instance-attribute

MAX = 'Max'

MIN class-attribute instance-attribute

MIN = 'Min'