Skip to content

Commit 4d27011

Browse files
authored
NNEDI3: swap sneedif for nnedi3vk (#354)
1 parent 1501ef2 commit 4d27011

4 files changed

Lines changed: 68 additions & 80 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ aa = [
113113
"vsjetpack[scale]",
114114
"vapoursynth-bwdif>=5.0",
115115
"vapoursynth-sangnom>=43",
116-
"vapoursynth-sneedif>=4.2",
117116
"vapoursynth-znedi3>=2.1",
118117
]
119118
denoise = [
@@ -138,7 +137,11 @@ deinterlace = [
138137
deband = ["vsjetpack[denoise]", "vsnoise>=1.2"]
139138
gpu = ["vapoursynth-mlrt-ort>=15.16"]
140139
cl = ["vapoursynth-vszipcl>=1.2.0"]
141-
vulkan = ["vapoursynth-eedi3vk2>=1.0", "vapoursynth-mlrt-ncnn>=15.16"]
140+
vulkan = [
141+
"vapoursynth-eedi3vk2>=1.0",
142+
"vapoursynth-mlrt-ncnn>=15.16",
143+
"vapoursynth-nnedi3vk>=1.0",
144+
]
142145
nvidia = [
143146
"vsjetpack[cl,vulkan]",
144147
"onnx>=1.21.0",

stubs/vapoursynth/__init__.pyi

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,10 @@ class VideoNode(RawNode):
18441844
nlm_ispc: Final[_nlm_ispc._VideoNode_bound.Plugin]
18451845
"""Non-local means denoise filter implemented in ISPC"""
18461846
# </attribute/VideoNode_bound/nlm_ispc>
1847+
# <attribute/VideoNode_bound/nnedi3vk>
1848+
nnedi3vk: Final[_nnedi3vk._VideoNode_bound.Plugin]
1849+
"""Neural Network Edge Directed Interpolation 3, using Vulkan compute"""
1850+
# </attribute/VideoNode_bound/nnedi3vk>
18471851
# <attribute/VideoNode_bound/noise>
18481852
noise: Final[_noise._VideoNode_bound.Plugin]
18491853
"""Noise generator"""
@@ -1872,10 +1876,6 @@ class VideoNode(RawNode):
18721876
sangnom: Final[_sangnom._VideoNode_bound.Plugin]
18731877
"""VapourSynth Single Field Deinterlacer"""
18741878
# </attribute/VideoNode_bound/sangnom>
1875-
# <attribute/VideoNode_bound/sneedif>
1876-
sneedif: Final[_sneedif._VideoNode_bound.Plugin]
1877-
"""Setsugen No Ensemble of Edge Directed Interpolation Functions"""
1878-
# </attribute/VideoNode_bound/sneedif>
18791879
# <attribute/VideoNode_bound/std>
18801880
std: Final[_std._VideoNode_bound.Plugin]
18811881
"""VapourSynth Core Functions"""
@@ -2134,6 +2134,10 @@ class Core:
21342134
nlm_ispc: Final[_nlm_ispc._Core_bound.Plugin]
21352135
"""Non-local means denoise filter implemented in ISPC"""
21362136
# </attribute/Core_bound/nlm_ispc>
2137+
# <attribute/Core_bound/nnedi3vk>
2138+
nnedi3vk: Final[_nnedi3vk._Core_bound.Plugin]
2139+
"""Neural Network Edge Directed Interpolation 3, using Vulkan compute"""
2140+
# </attribute/Core_bound/nnedi3vk>
21372141
# <attribute/Core_bound/noise>
21382142
noise: Final[_noise._Core_bound.Plugin]
21392143
"""Noise generator"""
@@ -2162,10 +2166,6 @@ class Core:
21622166
sangnom: Final[_sangnom._Core_bound.Plugin]
21632167
"""VapourSynth Single Field Deinterlacer"""
21642168
# </attribute/Core_bound/sangnom>
2165-
# <attribute/Core_bound/sneedif>
2166-
sneedif: Final[_sneedif._Core_bound.Plugin]
2167-
"""Setsugen No Ensemble of Edge Directed Interpolation Functions"""
2168-
# </attribute/Core_bound/sneedif>
21692169
# <attribute/Core_bound/std>
21702170
std: Final[_std._Core_bound.Plugin]
21712171
"""VapourSynth Core Functions"""
@@ -3049,6 +3049,20 @@ class _nlm_ispc:
30493049

30503050
# </implementation/nlm_ispc>
30513051

3052+
# <implementation/nnedi3vk>
3053+
class _nnedi3vk:
3054+
class _Core_bound:
3055+
class Plugin(_VSPlugin):
3056+
@_Wrapper.Function
3057+
def NNEDI3(self, /, clip: VideoNode, field: _IntLike, dh: _IntLike | None = None, planes: _IntLike | _SequenceLike[_IntLike] | None = None, nsize: _IntLike | None = None, nns: _IntLike | None = None, qual: _IntLike | None = None, etype: _IntLike | None = None, pscrn: _IntLike | None = None, coopvec: _IntLike | None = None, device_index: _IntLike | None = None, list_device: _IntLike | None = None, num_streams: _IntLike | None = None) -> VideoNode: ...
3058+
3059+
class _VideoNode_bound:
3060+
class Plugin(_VSPlugin):
3061+
@_Wrapper.Function
3062+
def NNEDI3(self, /, field: _IntLike, dh: _IntLike | None = None, planes: _IntLike | _SequenceLike[_IntLike] | None = None, nsize: _IntLike | None = None, nns: _IntLike | None = None, qual: _IntLike | None = None, etype: _IntLike | None = None, pscrn: _IntLike | None = None, coopvec: _IntLike | None = None, device_index: _IntLike | None = None, list_device: _IntLike | None = None, num_streams: _IntLike | None = None) -> VideoNode: ...
3063+
3064+
# </implementation/nnedi3vk>
3065+
30523066
# <implementation/noise>
30533067
class _noise:
30543068
class _Core_bound:
@@ -3225,30 +3239,6 @@ class _sangnom:
32253239

32263240
# </implementation/sangnom>
32273241

3228-
# <implementation/sneedif>
3229-
_ReturnDict_sneedif_DeviceInfo = TypedDict("_ReturnDict_sneedif_DeviceInfo", {"name": _AnyStr, "vendor": _AnyStr, "profile": _AnyStr, "version": _AnyStr, "max_compute_units": int, "max_work_group_size": int, "max_work_item_sizes": _IntLike | list[_IntLike], "image2D_max_width": int, "image2D_max_height": int, "image_support": int, "global_memory_cache_type": _AnyStr, "global_memory_cache": int, "global_memory_size": int, "max_constant_buffer_size": int, "max_constant_arguments": int, "local_memory_type": _AnyStr, "local_memory_size": int, "available": int, "compiler_available": int, "linker_available": int, "opencl_c_version": _AnyStr, "image_max_buffer_size": int})
3230-
_ReturnDict_sneedif_ListDevices = TypedDict("_ReturnDict_sneedif_ListDevices", {"numDevices": int, "deviceNames": _AnyStr | list[_AnyStr], "platformNames": _AnyStr | list[_AnyStr]})
3231-
_ReturnDict_sneedif_PlatformInfo = TypedDict("_ReturnDict_sneedif_PlatformInfo", {"profile": _AnyStr, "version": _AnyStr, "name": _AnyStr, "vendor": _AnyStr})
3232-
3233-
class _sneedif:
3234-
class _Core_bound:
3235-
class Plugin(_VSPlugin):
3236-
@_Wrapper.Function
3237-
def DeviceInfo(self, /, device: _IntLike | None = None) -> _ReturnDict_sneedif_DeviceInfo: ...
3238-
@_Wrapper.Function
3239-
def ListDevices(self, /) -> _ReturnDict_sneedif_ListDevices: ...
3240-
@_Wrapper.Function
3241-
def NNEDI3(self, /, clip: VideoNode, field: _IntLike, dh: _IntLike | None = None, dw: _IntLike | None = None, planes: _IntLike | _SequenceLike[_IntLike] | None = None, nsize: _IntLike | None = None, nns: _IntLike | None = None, qual: _IntLike | None = None, etype: _IntLike | None = None, pscrn: _IntLike | None = None, transpose_first: _IntLike | None = None, device: _IntLike | None = None) -> VideoNode: ...
3242-
@_Wrapper.Function
3243-
def PlatformInfo(self, /, device: _IntLike | None = None) -> _ReturnDict_sneedif_PlatformInfo: ...
3244-
3245-
class _VideoNode_bound:
3246-
class Plugin(_VSPlugin):
3247-
@_Wrapper.Function
3248-
def NNEDI3(self, /, field: _IntLike, dh: _IntLike | None = None, dw: _IntLike | None = None, planes: _IntLike | _SequenceLike[_IntLike] | None = None, nsize: _IntLike | None = None, nns: _IntLike | None = None, qual: _IntLike | None = None, etype: _IntLike | None = None, pscrn: _IntLike | None = None, transpose_first: _IntLike | None = None, device: _IntLike | None = None) -> VideoNode: ...
3249-
3250-
# </implementation/sneedif>
3251-
32523242
# <implementation/std>
32533243
class _std:
32543244
class _Core_bound:

uv.lock

Lines changed: 24 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vsaa/deinterlacers.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ class NNEDI3(SuperSampler):
383383
"""
384384
Neural Network Edge Directed Interpolation (3rd gen.)
385385
386-
More information: https://github.com/sekrit-twc/znedi3
386+
More information:
387+
- https://github.com/sekrit-twc/znedi3
388+
- https://github.com/HolyWu/VapourSynth-nnedi3vk
387389
"""
388390

389391
nsize: int = 0
@@ -430,7 +432,7 @@ class NNEDI3(SuperSampler):
430432
- 1: Weights trained to minimise squared error.
431433
"""
432434

433-
pscrn: int | None = None
435+
pscrn: int = 4
434436
"""
435437
The prescreener used to decide which pixels should be processed by the predictor neural network,
436438
and which can be handled by simple cubic interpolation.
@@ -442,16 +444,19 @@ class NNEDI3(SuperSampler):
442444
- 3: New prescreener level 1.
443445
- 4: New prescreener level 2.
444446
445-
The new prescreener is not available with float input.
446-
447-
- Wrapper default is 4 for integer input and 1 for float input. When `opencl=True` it is always 1.
448-
- Plugin default is 2 for integer input and 1 for float input.
447+
Wrapper default is 4, plugin default is 2.
449448
"""
450449

451-
opencl: bool = False
452-
"""
453-
Enables the use of the OpenCL variant.
454-
"""
450+
gpu: bool = False
451+
"""Enables the use of the Vulkan variant."""
452+
453+
opencl: Never = cast(Never, MISSING)
454+
"""Unused deprecated parameter."""
455+
456+
def __post_init__(self) -> None:
457+
if self.opencl is not cast(Never, MISSING):
458+
warnings.warn("The 'opencl' argument has been removed and is deprecated.", RuntimeWarning)
459+
return super().__post_init__()
455460

456461
@Scaler.cachedproperty
457462
def kernel_radius(self) -> int:
@@ -466,21 +471,17 @@ def kernel_radius(self) -> int:
466471
return 32
467472

468473
def get_deint_args(self, *, clip: vs.VideoNode | None = None, **kwargs: Any) -> dict[str, Any]:
469-
pscrn = (
470-
fallback(self.pscrn, 1 if self.opencl or clip.format.sample_type is vs.FLOAT else 4) if clip else self.pscrn
471-
)
472-
473474
return {
474475
"nsize": self.nsize,
475476
"nns": self.nns,
476477
"qual": self.qual,
477478
"etype": self.etype,
478-
"pscrn": pscrn,
479+
"pscrn": self.pscrn,
479480
} | kwargs
480481

481482
@property
482483
def _deinterlacer_function(self) -> VSFunctionAllArgs:
483-
return core.lazy.sneedif.NNEDI3 if self.opencl else core.lazy.znedi3.nnedi3
484+
return core.lazy.nnedi3vk.NNEDI3 if self.gpu else core.lazy.znedi3.nnedi3
484485

485486
def _interpolate(self, clip: vs.VideoNode, tff: bool, double_rate: bool, dh: bool, **kwargs: Any) -> vs.VideoNode:
486487
field = tff + double_rate * 2

0 commit comments

Comments
 (0)