Skip to content

nnedi3

NNEDI3 dataclass

NNEDI3(
    nsize: int = 0,
    nns: int = 4,
    qual: int = 2,
    etype: int = 0,
    pscrn: int = 1,
    opencl: bool | None = None,
    *,
    field: int = 0,
    drop_fields: bool = True,
    transpose_first: bool = False,
    shifter: KernelT | None = None,
    scaler: ScalerT | None = None
)

Bases: _FullInterpolate, _Antialiaser

drop_fields class-attribute instance-attribute

drop_fields: bool = field(default=True, kw_only=True)

etype class-attribute instance-attribute

etype: int = 0

field class-attribute instance-attribute

field: int = field(default=0, kw_only=True)

nns class-attribute instance-attribute

nns: int = 4

nsize class-attribute instance-attribute

nsize: int = 0

opencl class-attribute instance-attribute

opencl: bool | None = None

pscrn class-attribute instance-attribute

pscrn: int = 1

qual class-attribute instance-attribute

qual: int = 2

scaler class-attribute instance-attribute

scaler: ScalerT | None = field(default=None, kw_only=True)

shifter class-attribute instance-attribute

shifter: KernelT | None = field(default=None, kw_only=True)

transpose_first class-attribute instance-attribute

transpose_first: bool = field(default=False, kw_only=True)

copy

copy(**kwargs: Any) -> T
Source code
71
72
73
@inject_self
def copy(self: T, **kwargs: Any) -> T:
    return replace(self, **kwargs)

full_interpolate

full_interpolate(
    clip: VideoNode, double_y: bool, double_x: bool, **kwargs: Any
) -> VideoNode
Source code
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def full_interpolate(self, clip: vs.VideoNode, double_y: bool, double_x: bool, **kwargs: Any) -> vs.VideoNode:
    if hasattr(core, 'sneedif'):
        clip = core.sneedif.NNEDI3(
            clip, self.field, double_y, double_x, transpose_first=self.transpose_first, **kwargs
        )
    else:
        if not self.transpose_first:
            clip = clip.std.Transpose()

        clip = core.nnedi3cl.NNEDI3CL(clip, self.field, double_y, double_x, **kwargs)

        if not self.transpose_first:
            clip = clip.std.Transpose()

    return clip

get_aa_args

get_aa_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
28
29
30
31
32
def get_aa_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    assert clip.format
    is_float = clip.format.sample_type == vs.FLOAT
    pscrn = 1 if is_float else self.pscrn
    return dict(nsize=self.nsize, nns=self.nns, qual=self.qual, etype=self.etype, pscrn=pscrn)

interpolate

interpolate(clip: VideoNode, double_y: bool, **kwargs: Any) -> VideoNode
Source code
34
35
36
37
38
39
40
41
42
43
44
45
46
def interpolate(self, clip: vs.VideoNode, double_y: bool, **kwargs: Any) -> vs.VideoNode:
    if not (hasattr(core, 'znedi3') or hasattr(core, 'nnedi3')):
        interpolated: vs.VideoNode = self.full_interpolate(
            clip, double_y or not self.drop_fields, False, **kwargs
        )
    else:
        interpolated = getattr(
            core, 'znedi3' if hasattr(core, 'znedi3') else 'nnedi3'
        ).nnedi3(
            clip, self.field, double_y or not self.drop_fields, **kwargs
        )

    return self.shift_interpolate(clip, interpolated, double_y, **kwargs)

is_full_interpolate_enabled

is_full_interpolate_enabled(x: bool, y: bool) -> bool
Source code
25
26
def is_full_interpolate_enabled(self, x: bool, y: bool) -> bool:
    return not not (hasattr(core, 'sneedif') if self.opencl is None else self.opencl)

kernel_radius

kernel_radius() -> int
Source code
66
67
68
69
70
71
72
73
74
75
76
@inject_self.property
def kernel_radius(self) -> int:
    match self.nsize:
        case 1 | 5:
            return 16
        case 2 | 6:
            return 32
        case 3:
            return 48
        case _:
            return 8

preprocess_clip

preprocess_clip(clip: VideoNode) -> VideoNode
Source code
53
54
def preprocess_clip(self, clip: vs.VideoNode) -> vs.VideoNode:
    return clip

shift_interpolate

shift_interpolate(
    clip: VideoNode, inter: VideoNode, double_y: bool, **kwargs: Any
) -> VideoNode
Source code
59
60
61
62
63
64
65
66
67
68
69
def shift_interpolate(
    self, clip: vs.VideoNode, inter: vs.VideoNode, double_y: bool, **kwargs: Any
) -> vs.VideoNode:
    if not double_y and not self.drop_fields:
        shift = (self._shift * int(not self.field), 0)

        inter = (self._scaler if self._scaler else self._shifter).scale(inter, clip.width, clip.height, shift)

        return self._post_interpolate(clip, inter, double_y, **kwargs)

    return inter

Nnedi3 dataclass

Nnedi3(
    nsize: int = 0,
    nns: int = 4,
    qual: int = 2,
    etype: int = 0,
    pscrn: int = 1,
    opencl: bool | None = None,
    *,
    field: int = 0,
    drop_fields: bool = True,
    transpose_first: bool = False,
    shifter: KernelT | None = None,
    scaler: ScalerT | None = None
)

Bases: NNEDI3, Antialiaser

drop_fields class-attribute instance-attribute

drop_fields: bool = field(default=True, kw_only=True)

etype class-attribute instance-attribute

etype: int = 0

field class-attribute instance-attribute

field: int = field(default=0, kw_only=True)

merge_func class-attribute instance-attribute

merge_func: Callable[[VideoNode, VideoNode], VideoNode] = Merge

nns class-attribute instance-attribute

nns: int = 4

nsize class-attribute instance-attribute

nsize: int = 0

opencl class-attribute instance-attribute

opencl: bool | None = None

pscrn class-attribute instance-attribute

pscrn: int = 1

qual class-attribute instance-attribute

qual: int = 2

scaler class-attribute instance-attribute

scaler: ScalerT | None = field(default=None, kw_only=True)

shifter class-attribute instance-attribute

shifter: KernelT | None = field(default=None, kw_only=True)

transpose_first class-attribute instance-attribute

transpose_first: bool = field(default=False, kw_only=True)

aa

aa(clip: VideoNode, dir: AADirection = BOTH, /, **kwargs: Any) -> VideoNode
aa(
    clip: VideoNode, y: bool = True, x: bool = True, /, **kwargs: Any
) -> VideoNode
aa(
    clip: VideoNode,
    y_or_dir: bool | AADirection = True,
    x: bool = True,
    /,
    **kwargs: Any,
) -> VideoNode

Single rate aa with this antialiaser

Source code
275
276
277
278
279
280
281
282
283
284
285
286
287
288
@inject_self.init_kwargs.clean
def aa(
    self, clip: vs.VideoNode, y_or_dir: bool | AADirection = True, x: bool = True, /, **kwargs: Any
) -> vs.VideoNode:
    """Single rate aa with this antialiaser"""

    if isinstance(y_or_dir, AADirection):
        y, x = y_or_dir.to_yx()
    else:
        y = y_or_dir

    clip = self.preprocess_clip(clip)

    return SingleRater._aa(self, clip, y, x, **kwargs)

copy

copy(**kwargs: Any) -> T
Source code
71
72
73
@inject_self
def copy(self: T, **kwargs: Any) -> T:
    return replace(self, **kwargs)

draa

draa(clip: VideoNode, dir: AADirection = BOTH, /, **kwargs: Any) -> VideoNode
draa(
    clip: VideoNode, y: bool = True, x: bool = True, /, **kwargs: Any
) -> VideoNode
draa(
    clip: VideoNode,
    y_or_dir: bool | AADirection = True,
    x: bool = True,
    /,
    **kwargs: Any,
) -> VideoNode

Double rate aa with this antialiaser

Source code
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
@inject_self.init_kwargs.clean
def draa(
    self, clip: vs.VideoNode, y_or_dir: bool | AADirection = True, x: bool = True, /, **kwargs: Any
) -> vs.VideoNode:
    """Double rate aa with this antialiaser"""

    if isinstance(y_or_dir, AADirection):
        y, x = y_or_dir.to_yx()
    else:
        y = y_or_dir

    clip = self.preprocess_clip(clip)

    kwargs.pop('field', None)

    return DoubleRater._aa(self, clip, y, x, **kwargs)

full_interpolate

full_interpolate(
    clip: VideoNode, double_y: bool, double_x: bool, **kwargs: Any
) -> VideoNode
Source code
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def full_interpolate(self, clip: vs.VideoNode, double_y: bool, double_x: bool, **kwargs: Any) -> vs.VideoNode:
    if hasattr(core, 'sneedif'):
        clip = core.sneedif.NNEDI3(
            clip, self.field, double_y, double_x, transpose_first=self.transpose_first, **kwargs
        )
    else:
        if not self.transpose_first:
            clip = clip.std.Transpose()

        clip = core.nnedi3cl.NNEDI3CL(clip, self.field, double_y, double_x, **kwargs)

        if not self.transpose_first:
            clip = clip.std.Transpose()

    return clip

get_aa_args

get_aa_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
28
29
30
31
32
def get_aa_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    assert clip.format
    is_float = clip.format.sample_type == vs.FLOAT
    pscrn = 1 if is_float else self.pscrn
    return dict(nsize=self.nsize, nns=self.nns, qual=self.qual, etype=self.etype, pscrn=pscrn)

get_sr_args

get_sr_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
177
178
def get_sr_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    return {}

get_ss_args

get_ss_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
85
86
def get_ss_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    return {}

interpolate

interpolate(clip: VideoNode, double_y: bool, **kwargs: Any) -> VideoNode
Source code
34
35
36
37
38
39
40
41
42
43
44
45
46
def interpolate(self, clip: vs.VideoNode, double_y: bool, **kwargs: Any) -> vs.VideoNode:
    if not (hasattr(core, 'znedi3') or hasattr(core, 'nnedi3')):
        interpolated: vs.VideoNode = self.full_interpolate(
            clip, double_y or not self.drop_fields, False, **kwargs
        )
    else:
        interpolated = getattr(
            core, 'znedi3' if hasattr(core, 'znedi3') else 'nnedi3'
        ).nnedi3(
            clip, self.field, double_y or not self.drop_fields, **kwargs
        )

    return self.shift_interpolate(clip, interpolated, double_y, **kwargs)

is_full_interpolate_enabled

is_full_interpolate_enabled(x: bool, y: bool) -> bool
Source code
25
26
def is_full_interpolate_enabled(self, x: bool, y: bool) -> bool:
    return not not (hasattr(core, 'sneedif') if self.opencl is None else self.opencl)

kernel_radius

kernel_radius() -> int
Source code
66
67
68
69
70
71
72
73
74
75
76
@inject_self.property
def kernel_radius(self) -> int:
    match self.nsize:
        case 1 | 5:
            return 16
        case 2 | 6:
            return 32
        case 3:
            return 48
        case _:
            return 8

preprocess_clip

preprocess_clip(clip: VideoNode) -> VideoNode
Source code
53
54
def preprocess_clip(self, clip: vs.VideoNode) -> vs.VideoNode:
    return clip

scale

scale(
    clip: VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[float, float] = (0, 0),
    **kwargs: Any
) -> VideoNode

Scale with this antialiaser

Source code
255
256
257
258
259
260
261
262
@inject_self
def scale(  # type: ignore[override]
    self, clip: vs.VideoNode, width: int | None = None, height: int | None = None,
    shift: tuple[float, float] = (0, 0), **kwargs: Any
) -> vs.VideoNode:
    """Scale with this antialiaser"""
    width, height = Scaler._wh_norm(clip, width, height)
    return SuperSampler.scale(self, clip, width, height, shift, **kwargs)

shift_interpolate

shift_interpolate(
    clip: VideoNode, inter: VideoNode, double_y: bool, **kwargs: Any
) -> VideoNode
Source code
59
60
61
62
63
64
65
66
67
68
69
def shift_interpolate(
    self, clip: vs.VideoNode, inter: vs.VideoNode, double_y: bool, **kwargs: Any
) -> vs.VideoNode:
    if not double_y and not self.drop_fields:
        shift = (self._shift * int(not self.field), 0)

        inter = (self._scaler if self._scaler else self._shifter).scale(inter, clip.width, clip.height, shift)

        return self._post_interpolate(clip, inter, double_y, **kwargs)

    return inter

Nnedi3DR dataclass

Nnedi3DR(
    nsize: int = 0,
    nns: int = 4,
    qual: int = 2,
    etype: int = 0,
    pscrn: int = 1,
    opencl: bool | None = None,
    *,
    field: int = 0,
    drop_fields: bool = True,
    transpose_first: bool = False,
    shifter: KernelT | None = None,
    scaler: ScalerT | None = None
)

Bases: NNEDI3, DoubleRater

drop_fields class-attribute instance-attribute

drop_fields: bool = field(default=True, kw_only=True)

etype class-attribute instance-attribute

etype: int = 0

field class-attribute instance-attribute

field: int = field(default=0, kw_only=True)

merge_func class-attribute instance-attribute

merge_func: Callable[[VideoNode, VideoNode], VideoNode] = Merge

nns class-attribute instance-attribute

nns: int = 4

nsize class-attribute instance-attribute

nsize: int = 0

opencl class-attribute instance-attribute

opencl: bool | None = None

pscrn class-attribute instance-attribute

pscrn: int = 1

qual class-attribute instance-attribute

qual: int = 2

scaler class-attribute instance-attribute

scaler: ScalerT | None = field(default=None, kw_only=True)

shifter class-attribute instance-attribute

shifter: KernelT | None = field(default=None, kw_only=True)

transpose_first class-attribute instance-attribute

transpose_first: bool = field(default=False, kw_only=True)

aa

aa(clip: VideoNode, dir: AADirection = BOTH, /, **kwargs: Any) -> VideoNode
aa(
    clip: VideoNode, y: bool = True, x: bool = True, /, **kwargs: Any
) -> VideoNode
aa(
    clip: VideoNode,
    y_or_dir: bool | AADirection = True,
    x: bool = True,
    /,
    **kwargs: Any,
) -> VideoNode
Source code
190
191
192
193
194
195
196
197
198
199
200
201
@inject_self.init_kwargs.clean
def aa(
    self, clip: vs.VideoNode, y_or_dir: bool | AADirection = True, x: bool = True, /, **kwargs: Any
) -> vs.VideoNode:
    if isinstance(y_or_dir, AADirection):
        y, x = y_or_dir.to_yx()
    else:
        y = y_or_dir

    clip = self.preprocess_clip(clip)

    return self._aa(clip, y, x, **kwargs)

copy

copy(**kwargs: Any) -> T
Source code
71
72
73
@inject_self
def copy(self: T, **kwargs: Any) -> T:
    return replace(self, **kwargs)

full_interpolate

full_interpolate(
    clip: VideoNode, double_y: bool, double_x: bool, **kwargs: Any
) -> VideoNode
Source code
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def full_interpolate(self, clip: vs.VideoNode, double_y: bool, double_x: bool, **kwargs: Any) -> vs.VideoNode:
    if hasattr(core, 'sneedif'):
        clip = core.sneedif.NNEDI3(
            clip, self.field, double_y, double_x, transpose_first=self.transpose_first, **kwargs
        )
    else:
        if not self.transpose_first:
            clip = clip.std.Transpose()

        clip = core.nnedi3cl.NNEDI3CL(clip, self.field, double_y, double_x, **kwargs)

        if not self.transpose_first:
            clip = clip.std.Transpose()

    return clip

get_aa_args

get_aa_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
28
29
30
31
32
def get_aa_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    assert clip.format
    is_float = clip.format.sample_type == vs.FLOAT
    pscrn = 1 if is_float else self.pscrn
    return dict(nsize=self.nsize, nns=self.nns, qual=self.qual, etype=self.etype, pscrn=pscrn)

get_sr_args

get_sr_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
177
178
def get_sr_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    return {}

interpolate

interpolate(clip: VideoNode, double_y: bool, **kwargs: Any) -> VideoNode
Source code
34
35
36
37
38
39
40
41
42
43
44
45
46
def interpolate(self, clip: vs.VideoNode, double_y: bool, **kwargs: Any) -> vs.VideoNode:
    if not (hasattr(core, 'znedi3') or hasattr(core, 'nnedi3')):
        interpolated: vs.VideoNode = self.full_interpolate(
            clip, double_y or not self.drop_fields, False, **kwargs
        )
    else:
        interpolated = getattr(
            core, 'znedi3' if hasattr(core, 'znedi3') else 'nnedi3'
        ).nnedi3(
            clip, self.field, double_y or not self.drop_fields, **kwargs
        )

    return self.shift_interpolate(clip, interpolated, double_y, **kwargs)

is_full_interpolate_enabled

is_full_interpolate_enabled(x: bool, y: bool) -> bool
Source code
25
26
def is_full_interpolate_enabled(self, x: bool, y: bool) -> bool:
    return not not (hasattr(core, 'sneedif') if self.opencl is None else self.opencl)

kernel_radius

kernel_radius() -> int
Source code
66
67
68
69
70
71
72
73
74
75
76
@inject_self.property
def kernel_radius(self) -> int:
    match self.nsize:
        case 1 | 5:
            return 16
        case 2 | 6:
            return 32
        case 3:
            return 48
        case _:
            return 8

preprocess_clip

preprocess_clip(clip: VideoNode) -> VideoNode
Source code
53
54
def preprocess_clip(self, clip: vs.VideoNode) -> vs.VideoNode:
    return clip

shift_interpolate

shift_interpolate(
    clip: VideoNode, inter: VideoNode, double_y: bool, **kwargs: Any
) -> VideoNode
Source code
59
60
61
62
63
64
65
66
67
68
69
def shift_interpolate(
    self, clip: vs.VideoNode, inter: vs.VideoNode, double_y: bool, **kwargs: Any
) -> vs.VideoNode:
    if not double_y and not self.drop_fields:
        shift = (self._shift * int(not self.field), 0)

        inter = (self._scaler if self._scaler else self._shifter).scale(inter, clip.width, clip.height, shift)

        return self._post_interpolate(clip, inter, double_y, **kwargs)

    return inter

Nnedi3SR dataclass

Nnedi3SR(
    nsize: int = 0,
    nns: int = 4,
    qual: int = 2,
    etype: int = 0,
    pscrn: int = 1,
    opencl: bool | None = None,
    *,
    field: int = 0,
    drop_fields: bool = True,
    transpose_first: bool = False,
    shifter: KernelT | None = None,
    scaler: ScalerT | None = None
)

Bases: NNEDI3, SingleRater

drop_fields class-attribute instance-attribute

drop_fields: bool = field(default=True, kw_only=True)

etype class-attribute instance-attribute

etype: int = 0

field class-attribute instance-attribute

field: int = field(default=0, kw_only=True)

nns class-attribute instance-attribute

nns: int = 4

nsize class-attribute instance-attribute

nsize: int = 0

opencl class-attribute instance-attribute

opencl: bool | None = None

pscrn class-attribute instance-attribute

pscrn: int = 1

qual class-attribute instance-attribute

qual: int = 2

scaler class-attribute instance-attribute

scaler: ScalerT | None = field(default=None, kw_only=True)

shifter class-attribute instance-attribute

shifter: KernelT | None = field(default=None, kw_only=True)

transpose_first class-attribute instance-attribute

transpose_first: bool = field(default=False, kw_only=True)

aa

aa(clip: VideoNode, dir: AADirection = BOTH, /, **kwargs: Any) -> VideoNode
aa(
    clip: VideoNode, y: bool = True, x: bool = True, /, **kwargs: Any
) -> VideoNode
aa(
    clip: VideoNode,
    y_or_dir: bool | AADirection = True,
    x: bool = True,
    /,
    **kwargs: Any,
) -> VideoNode
Source code
190
191
192
193
194
195
196
197
198
199
200
201
@inject_self.init_kwargs.clean
def aa(
    self, clip: vs.VideoNode, y_or_dir: bool | AADirection = True, x: bool = True, /, **kwargs: Any
) -> vs.VideoNode:
    if isinstance(y_or_dir, AADirection):
        y, x = y_or_dir.to_yx()
    else:
        y = y_or_dir

    clip = self.preprocess_clip(clip)

    return self._aa(clip, y, x, **kwargs)

copy

copy(**kwargs: Any) -> T
Source code
71
72
73
@inject_self
def copy(self: T, **kwargs: Any) -> T:
    return replace(self, **kwargs)

full_interpolate

full_interpolate(
    clip: VideoNode, double_y: bool, double_x: bool, **kwargs: Any
) -> VideoNode
Source code
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def full_interpolate(self, clip: vs.VideoNode, double_y: bool, double_x: bool, **kwargs: Any) -> vs.VideoNode:
    if hasattr(core, 'sneedif'):
        clip = core.sneedif.NNEDI3(
            clip, self.field, double_y, double_x, transpose_first=self.transpose_first, **kwargs
        )
    else:
        if not self.transpose_first:
            clip = clip.std.Transpose()

        clip = core.nnedi3cl.NNEDI3CL(clip, self.field, double_y, double_x, **kwargs)

        if not self.transpose_first:
            clip = clip.std.Transpose()

    return clip

get_aa_args

get_aa_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
28
29
30
31
32
def get_aa_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    assert clip.format
    is_float = clip.format.sample_type == vs.FLOAT
    pscrn = 1 if is_float else self.pscrn
    return dict(nsize=self.nsize, nns=self.nns, qual=self.qual, etype=self.etype, pscrn=pscrn)

get_sr_args

get_sr_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
177
178
def get_sr_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    return {}

interpolate

interpolate(clip: VideoNode, double_y: bool, **kwargs: Any) -> VideoNode
Source code
34
35
36
37
38
39
40
41
42
43
44
45
46
def interpolate(self, clip: vs.VideoNode, double_y: bool, **kwargs: Any) -> vs.VideoNode:
    if not (hasattr(core, 'znedi3') or hasattr(core, 'nnedi3')):
        interpolated: vs.VideoNode = self.full_interpolate(
            clip, double_y or not self.drop_fields, False, **kwargs
        )
    else:
        interpolated = getattr(
            core, 'znedi3' if hasattr(core, 'znedi3') else 'nnedi3'
        ).nnedi3(
            clip, self.field, double_y or not self.drop_fields, **kwargs
        )

    return self.shift_interpolate(clip, interpolated, double_y, **kwargs)

is_full_interpolate_enabled

is_full_interpolate_enabled(x: bool, y: bool) -> bool
Source code
25
26
def is_full_interpolate_enabled(self, x: bool, y: bool) -> bool:
    return not not (hasattr(core, 'sneedif') if self.opencl is None else self.opencl)

kernel_radius

kernel_radius() -> int
Source code
66
67
68
69
70
71
72
73
74
75
76
@inject_self.property
def kernel_radius(self) -> int:
    match self.nsize:
        case 1 | 5:
            return 16
        case 2 | 6:
            return 32
        case 3:
            return 48
        case _:
            return 8

preprocess_clip

preprocess_clip(clip: VideoNode) -> VideoNode
Source code
53
54
def preprocess_clip(self, clip: vs.VideoNode) -> vs.VideoNode:
    return clip

shift_interpolate

shift_interpolate(
    clip: VideoNode, inter: VideoNode, double_y: bool, **kwargs: Any
) -> VideoNode
Source code
59
60
61
62
63
64
65
66
67
68
69
def shift_interpolate(
    self, clip: vs.VideoNode, inter: vs.VideoNode, double_y: bool, **kwargs: Any
) -> vs.VideoNode:
    if not double_y and not self.drop_fields:
        shift = (self._shift * int(not self.field), 0)

        inter = (self._scaler if self._scaler else self._shifter).scale(inter, clip.width, clip.height, shift)

        return self._post_interpolate(clip, inter, double_y, **kwargs)

    return inter

Nnedi3SS dataclass

Nnedi3SS(
    nsize: int = 0,
    nns: int = 4,
    qual: int = 2,
    etype: int = 0,
    pscrn: int = 1,
    opencl: bool | None = None,
    *,
    field: int = 0,
    drop_fields: bool = True,
    transpose_first: bool = False,
    shifter: KernelT | None = None,
    scaler: ScalerT | None = None
)

Bases: NNEDI3, SuperSampler

drop_fields class-attribute instance-attribute

drop_fields: bool = field(default=True, kw_only=True)

etype class-attribute instance-attribute

etype: int = 0

field class-attribute instance-attribute

field: int = field(default=0, kw_only=True)

nns class-attribute instance-attribute

nns: int = 4

nsize class-attribute instance-attribute

nsize: int = 0

opencl class-attribute instance-attribute

opencl: bool | None = None

pscrn class-attribute instance-attribute

pscrn: int = 1

qual class-attribute instance-attribute

qual: int = 2

scaler class-attribute instance-attribute

scaler: ScalerT | None = field(default=None, kw_only=True)

shifter class-attribute instance-attribute

shifter: KernelT | None = field(default=None, kw_only=True)

transpose_first class-attribute instance-attribute

transpose_first: bool = field(default=False, kw_only=True)

copy

copy(**kwargs: Any) -> T
Source code
71
72
73
@inject_self
def copy(self: T, **kwargs: Any) -> T:
    return replace(self, **kwargs)

full_interpolate

full_interpolate(
    clip: VideoNode, double_y: bool, double_x: bool, **kwargs: Any
) -> VideoNode
Source code
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def full_interpolate(self, clip: vs.VideoNode, double_y: bool, double_x: bool, **kwargs: Any) -> vs.VideoNode:
    if hasattr(core, 'sneedif'):
        clip = core.sneedif.NNEDI3(
            clip, self.field, double_y, double_x, transpose_first=self.transpose_first, **kwargs
        )
    else:
        if not self.transpose_first:
            clip = clip.std.Transpose()

        clip = core.nnedi3cl.NNEDI3CL(clip, self.field, double_y, double_x, **kwargs)

        if not self.transpose_first:
            clip = clip.std.Transpose()

    return clip

get_aa_args

get_aa_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
28
29
30
31
32
def get_aa_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    assert clip.format
    is_float = clip.format.sample_type == vs.FLOAT
    pscrn = 1 if is_float else self.pscrn
    return dict(nsize=self.nsize, nns=self.nns, qual=self.qual, etype=self.etype, pscrn=pscrn)

get_ss_args

get_ss_args(clip: VideoNode, **kwargs: Any) -> dict[str, Any]
Source code
85
86
def get_ss_args(self, clip: vs.VideoNode, **kwargs: Any) -> dict[str, Any]:
    return {}

interpolate

interpolate(clip: VideoNode, double_y: bool, **kwargs: Any) -> VideoNode
Source code
34
35
36
37
38
39
40
41
42
43
44
45
46
def interpolate(self, clip: vs.VideoNode, double_y: bool, **kwargs: Any) -> vs.VideoNode:
    if not (hasattr(core, 'znedi3') or hasattr(core, 'nnedi3')):
        interpolated: vs.VideoNode = self.full_interpolate(
            clip, double_y or not self.drop_fields, False, **kwargs
        )
    else:
        interpolated = getattr(
            core, 'znedi3' if hasattr(core, 'znedi3') else 'nnedi3'
        ).nnedi3(
            clip, self.field, double_y or not self.drop_fields, **kwargs
        )

    return self.shift_interpolate(clip, interpolated, double_y, **kwargs)

is_full_interpolate_enabled

is_full_interpolate_enabled(x: bool, y: bool) -> bool
Source code
25
26
def is_full_interpolate_enabled(self, x: bool, y: bool) -> bool:
    return not not (hasattr(core, 'sneedif') if self.opencl is None else self.opencl)

kernel_radius

kernel_radius() -> int
Source code
66
67
68
69
70
71
72
73
74
75
76
@inject_self.property
def kernel_radius(self) -> int:
    match self.nsize:
        case 1 | 5:
            return 16
        case 2 | 6:
            return 32
        case 3:
            return 48
        case _:
            return 8

preprocess_clip

preprocess_clip(clip: VideoNode) -> VideoNode
Source code
53
54
def preprocess_clip(self, clip: vs.VideoNode) -> vs.VideoNode:
    return clip

scale

scale(
    clip: VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[float, float] = (0, 0),
    **kwargs: Any
) -> VideoNode
Source code
 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
@inject_self
def scale(  # type: ignore[override]
    self, clip: vs.VideoNode, width: int | None = None, height: int | None = None,
    shift: tuple[float, float] = (0, 0), **kwargs: Any
) -> vs.VideoNode:

    if FieldBased.from_video(clip).is_inter:
        raise UnsupportedFieldBasedError('Only progressive video is supported!', self.scale)

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

    assert clip.format and clip.width and clip.height

    if (clip.width, clip.height) == (width, height):
        return clip

    kwargs = self.get_aa_args(clip, **kwargs) | self.get_ss_args(clip, **kwargs) | kwargs

    divw, divh = (ceil(size) for size in (width / clip.width, height / clip.height))

    mult_x, mult_y = (int(log2(divs)) for divs in (divw, divh))

    cdivw, cdivh = 1 << clip.format.subsampling_w, 1 << clip.format.subsampling_h

    upscaled = clip

    def _transpose(before: bool, is_width: int, y: int, x: int) -> None:
        nonlocal upscaled

        before = self.transpose_first if before else not self.transpose_first

        if ((before or not y) if is_width else (before and x)):
            upscaled = upscaled.std.Transpose()

    for (y, x) in zip_longest([True] * mult_y, [True] * mult_x, fillvalue=False):
        if isinstance(self, _FullInterpolate) and self.is_full_interpolate_enabled(x, y):
            upscaled = self.full_interpolate(upscaled, y, x, **kwargs)
        else:
            for isx, val in enumerate([y, x]):
                if val:
                    _transpose(True, isx, y, x)

                    upscaled = self.interpolate(upscaled, True, **kwargs)

                    _transpose(False, isx, y, x)

        topshift = leftshift = cleftshift = ctopshift = 0.0

        if y and self._shift:
            topshift = ctopshift = self._shift

            if cdivw == 2 and cdivh == 2:
                ctopshift -= 0.125
            elif cdivw == 1 and cdivh == 2:
                ctopshift += 0.125

        cresshift = 0.0

        if x and self._shift:
            leftshift = cleftshift = self._shift

            if cdivw in {4, 2} and cdivh in {4, 2, 1}:
                cleftshift = self._shift + 0.5

                if cdivw == 4 and cdivh == 1:
                    cresshift = 0.125 * 1
                elif cdivw == 2 and cdivh == 2:
                    cresshift = 0.125 * 2
                elif cdivw == 2 and cdivh == 1:
                    cresshift = 0.125 * 3

                cleftshift -= cresshift

        if isinstance(self._shifter, NoShift):
            if upscaled.format.subsampling_h or upscaled.format.subsampling_w:
                upscaled = Catrom.shift(upscaled, 0, [0, cleftshift + cresshift])  # type: ignore
        else:
            upscaled = self._shifter.shift(
                upscaled, [topshift, ctopshift], [leftshift, cleftshift]
            )

    if self._scaler:
        return self._scaler.scale(upscaled, width, height, shift)

    return self._shifter.scale(upscaled, width, height, shift)

shift_interpolate

shift_interpolate(
    clip: VideoNode, inter: VideoNode, double_y: bool, **kwargs: Any
) -> VideoNode
Source code
59
60
61
62
63
64
65
66
67
68
69
def shift_interpolate(
    self, clip: vs.VideoNode, inter: vs.VideoNode, double_y: bool, **kwargs: Any
) -> vs.VideoNode:
    if not double_y and not self.drop_fields:
        shift = (self._shift * int(not self.field), 0)

        inter = (self._scaler if self._scaler else self._shifter).scale(inter, clip.width, clip.height, shift)

        return self._post_interpolate(clip, inter, double_y, **kwargs)

    return inter