|
2 | 2 | from typing import Sequence, Union |
3 | 3 | from vsaa import Antialiaser, Eedi3 |
4 | 4 | from vskernels import Bicubic, Kernel, KernelT, Lanczos, Scaler, ScalerT |
5 | | -from vsrgtools import unsharp_masked |
6 | | -from vstools import FrameRangesN, KwargsT, mod2, vs, core, get_w, join, plane, scale_mask |
| 5 | +from vstools import FrameRangesN, KwargsT, mod2, vs, get_w, scale_mask |
7 | 6 |
|
8 | | -from .scale import mod_padding |
9 | 7 |
|
10 | | -__all__ = ["pre_aa", "cope_aa", "CopeMode"] |
11 | | - |
12 | | - |
13 | | -def pre_aa(clip: vs.VideoNode, radius: int = 1, strength: float = 100, opencl: bool = True, **nnedi3_args) -> vs.VideoNode: |
14 | | - """ |
15 | | - A prefilter to use in conjunction with an AA function. |
16 | | - The idea is to fix the luminance uniformity on lineart and make AAing more effective. |
17 | | -
|
18 | | - :param radius: Radius used for the unsharp function |
19 | | - :param strength: Strength used for the unsharp function |
20 | | - :param opencl: Use nnedi3cl instead of znedi3 |
21 | | - :param nnedi3_args: Additional args passed to the respective nnedi function |
22 | | -
|
23 | | - :return: Processed clip |
24 | | - """ |
25 | | - args = {"qual": 2, "nsize": 0, "nns": 4, "pscrn": 1} |
26 | | - args.update(**nnedi3_args) |
27 | | - clip_y = plane(clip, 0) |
28 | | - |
29 | | - if opencl: |
30 | | - (left, right, top, bottom) = mod_padding(clip_y, 2, 2) |
31 | | - width = clip.width + left + right |
32 | | - height = clip.height + top + bottom |
33 | | - clip_y = clip_y.resize.Point(width, height, src_left=-left, src_top=-top, src_width=width, src_height=height) |
34 | | - |
35 | | - for i in range(2): |
36 | | - bob = clip_y.nnedi3cl.NNEDI3CL(field=3, **nnedi3_args) if opencl else clip_y.znedi3.nnedi3(field=3, **nnedi3_args) |
37 | | - sharp = unsharp_masked(clip_y, radius, strength) |
38 | | - limit = core.std.Expr([sharp, clip_y, bob[::2], bob[1::2]], "x y z a max max min y z a min min max") |
39 | | - clip_y = limit.std.Transpose() |
40 | | - |
41 | | - if opencl: |
42 | | - clip_y = clip_y.std.Crop(left, right, top, bottom) |
43 | | - clip_y = clip_y.std.CopyFrameProps(clip) |
44 | | - |
45 | | - return clip_y if clip.format.color_family == vs.GRAY else join(clip_y, clip) |
| 8 | +__all__ = ["cope_aa", "CopeMode"] |
46 | 9 |
|
47 | 10 |
|
48 | 11 | class CopeMode(IntEnum): |
|
0 commit comments