Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from vapoursynth import core
- import vapoursynth as vs
- import vsTAAmbk as taa
- import mvsfunc as mvf
- def aa(clip, str=1, thr=10, elast=2, alpha=0.25, beta=0.5, gamma=40, nrad=2, mdis=20, nsize=3, nns=3, qual=2, **args):
- """ eedi3-based anti-aliasing filter. Stronger than plain nnedi3 but not as much oversmoothing as eedi3, with some limiting for good measure
- How it works: Uses a eedi3-treated clip and nnedi3-treated clip
- The filtered difference of the eedi3 clip is clamped to the diff of the nnedi3 clip + strength
- The resulting clip is then limited with mvsfunc's LimitFilter to protect areas of small, high contrast detail
- Parameters: str - Upper ceiling for eedi3 filtering strength relative to nnedi3, to which all pixels are clamped to (scaled to 8 bit)
- The expression is as follows:
- if nnedi3 and eedi3 have an opposite effect (one brighter and one darker than input clip)
- return input pixel
- else
- eedi3 = min(eedi3, nnedi3 + str)
- eedi3 = max(eedi3, nnedi3 - str)
- return eedi3
- thr - Final limiting of anti-aliased clip (LimitFilter parameter)
- Set to 0 to disable
- elast - Another LimitFilter parameter
- the rest - eedi3 and nnedi3 parameters; see relevant filter documentation for more information
- Most of taa's arguments should work, like masking, repair, etc. They're applied to the eedi3 clip only.
- """
- bits = clip.format.bits_per_sample - 8
- str *= 1 >> bits
- clipy = mvf.GetPlane(clip)
- strong = taa.TAAmbk(clipy, aatype='Eedi3', alpha=alpha, beta=beta, gamma=gamma, nrad=nrad, mdis=mdis, **args)
- weak = taa.TAAmbk(clipy, aatype='Nnedi3', nsize=nsize, nns=nns, qual=qual, mtype=0)
- aa = core.std.Expr([strong, weak, clipy], 'x z - y z - * 0 < y x y {l} + min y {l} - max ?'.format(l=str))
- if thr > 0:
- aa = mvf.LimitFilter(aa, clipy, thr=thr, elast=elast)
- if clip.format.num_planes > 1:
- aa = core.std.ShufflePlanes([aa, clip], [0,1,2], vs.YUV)
- return aa
Add Comment
Please, Sign In to add comment