def test_aatype(self): aatypes = [ 0, 1, 2, 3, 4, 5, 6, -1, -2, -3, 'Nnedi3', 'Nnedi3SangNom', 'Nnedi3UpscaleSangNom', 'Eedi2', 'Eedi2SangNom', 'Eedi3', 'Eedi3SangNom', 'PointSangNom', 'Spline64SangNom', 'Spline64NrSangNom' ] test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] for clip in test_clips: for aatype in aatypes: aa = taa.TAAmbk(clip, aatype=aatype) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'aatype {}: {}bit {} format test passed' message = message.format(aatype, clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message) with self.assertRaises(ValueError): aa = taa.TAAmbk(test_clips[1], aatype='DoNotExist') print('aatype negative test passed')
def test_preaa(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] preaa_types = [-1, 0, 1, 2] for clip in test_clips: for preaa_type in preaa_types: preaa_with_main_aa = taa.TAAmbk(clip, aatype=0, preaa=preaa_type) preaa_without_main_aa = taa.TAAmbk(clip, aatype=1, preaa=preaa_type) self.assertTrue(isinstance(preaa_with_main_aa, vs.VideoNode)) self.assertEqual(preaa_with_main_aa.width, clip.width) self.assertEqual(preaa_with_main_aa.height, clip.height) self.assertEqual(preaa_with_main_aa.format.bits_per_sample, clip.format.bits_per_sample) self.assertTrue(isinstance(preaa_without_main_aa, vs.VideoNode)) self.assertEqual(preaa_without_main_aa.width, clip.width) self.assertEqual(preaa_without_main_aa.height, clip.height) self.assertEqual(preaa_without_main_aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'preaa {}: {}bit {} format test passed' message = message.format(str(preaa_type), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_mtype(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] mtypes = [ 0, 1, 2, 3, 4, 5, 6, 'Canny', 'Sobel', 'Prewitt', 'Canny_Old', 'Robert', 'MSharpen', 'TEdge' ] for clip in test_clips: for mtype in mtypes: aa = taa.TAAmbk(clip, aatype=1, mtype=mtype) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'mtype {}: {}bit {} format test passed' message = message.format(str(mtype), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message) with self.assertRaises(ValueError): aa = taa.TAAmbk(test_clips[1], aatype=1, mtype='DoNotExist') print('mtype: negative test passed')
def test_txtmask(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] txtmasks = [0, 255, 128] txtfades = [0, 3, (3, 0), [0, 5], [2, 3]] for clip in test_clips: for txtmask in txtmasks: for txtfade in txtfades: aa = taa.TAAmbk(clip, aatype=1, mtype=1, txtmask=txtmask, txtfade=txtfade) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'txtmask {} txtfade {}: {}bit {} format test passed' message = message.format( str(txtmask), str(txtfade), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_aatype_seperate(self): aatypes = [ 'Nnedi3', 'Nnedi3SangNom', 'Nnedi3UpscaleSangNom', 'Eedi2', 'Eedi2SangNom', 'Eedi3', 'Eedi3SangNom', 'PointSangNom', 'Spline64SangNom', 'Spline64NrSangNom' ] test_clips = [ self.yuv420p8, self.yuv444p8, self.yuv420p16, self.yuv444p16 ] for clip in test_clips: for aatype_y in aatypes: for aatype_u in aatypes: for aatype_v in aatypes: aa = taa.TAAmbk(clip, aatype=aatype_y, aatypeu=aatype_u, aatypev=aatype_v) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'aatype {}. aatypeu {}, aatypev {}: {}bit {} format test passed' message = message.format( aatype_y, aatype_u, aatype_v, clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_stabilize(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] stabilizes = [i for i in range(4)] for clip in test_clips: for stabilize in stabilizes: aa = taa.TAAmbk(clip, aatype=1, mtype=3, preaa=-1, sharp=-1, postaa=True, stabilize=stabilize) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'stabilize {}: {}bit {} format test passed' message = message.format(str(stabilize), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def NnEedi3(src: vs.VideoNode, strength=1, alpha=0.25, beta=0.5, gamma=40, nrad=2, mdis=20, nsize=3, nns=3, qual=1): """ Script written by Zastin. What it does is clamp the "change" done by eedi3 to the "change" of nnedi3. This should fix every issue created by eedi3. For example: https://i.imgur.com/hYVhetS.jpg """ clip = get_y(src) if clip.format.bits_per_sample != 16: clip = fvf.Depth(clip, 16) thr = strength * 256 strong = taa.TAAmbk(clip, aatype='Eedi3', alpha=alpha, beta=beta, gamma=gamma, nrad=nrad, mdis=mdis, mtype=0) weak = taa.TAAmbk(clip, aatype='Nnedi3', nsize=nsize, nns=nns, qual=qual, mtype=0) expr = 'x z - y z - * 0 < y x y {l} + min y {l} - max ?'.format(l=thr) aa = core.std.Expr([strong, weak, clip], expr) mask = clip.std.Prewitt().std.Binarize(50 >> 8).std.Maximum().std.Convolution([1] * 9) merged = core.std.MaskedMerge(clip, aa, mask) return clip if src.format.color_family == vs.GRAY else core.std.ShufflePlanes([clip, src], [0, 1, 2], vs.YUV)
def test_src(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] src_clips = list(test_clips) for clip, src in zip(test_clips, src_clips): aa = taa.TAAmbk(clip, aatype=1, mtype=3, sharp=-1, src=src) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'src clip: {}bit {} format test passed' message = message.format(clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message) with self.assertRaises(ValueError): aa2 = taa.TAAmbk(self.gray16, aatype=1, mtype=2, src=self.gray8) print('src clip: negative test passed')
def test_custom_aatype(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] my_aa_kernel = type('', (taa.AANnedi3, ), {'out': lambda self: self.output(self.aa_clip)}) for clip in test_clips: aa = taa.TAAmbk(clip, aatype='Custom', aatypeu='Custom', aatypev='Nnedi3', aakernel=my_aa_kernel) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) with self.assertRaises(RuntimeError): aa2 = taa.TAAmbk(clip, aatype='Custom', aatypeu=1, aatypev=1) message = 'custom aatype: {}bit {} format test passed' message = message.format(clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_default_value(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] for clip in test_clips: aa = taa.TAAmbk(clip) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'default value test: {}bit {} format test passed' message = message.format(clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_preprocess(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] for clip in test_clips: aa = taa.TAAmbk(clip, aatype=1, mtype=1, dark=8.0, thin=4) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'thin and dark: {}bit {} format test passed' message = message.format(clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def general_antialiasing(src, strength='weak'): """ A function for generic antialiasing (AA). Uses either Nnedi3 or Eedi3. strength: - weak (Nnedi3) - strong (Eedi3) - stronger (Eedi3SangNom) """ strengths = { 'weak': 'Nnedi3', 'strong': 'Eedi3', 'stronger': 'Eedi3SangNom' } try: return taa.TAAmbk(src, aatype=strengths[strength]) except KeyError: raise ValueError("general_antialiasing: Unknown strength!")
def test_cycle(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] cycles = [i for i in range(6)] for clip in test_clips: for cycle in cycles: aa = taa.TAAmbk(clip, aatype=1, strength=0.3, cycle=cycle) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'cycle {}: {}bit {} format test passed' message = message.format(str(cycle), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_sharp(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] sharps = [0, 30, 0.6, -0.08, -1] for clip in test_clips: for sharp in sharps: aa = taa.TAAmbk(clip, aatype=1, mtype=3, preaa=-1, sharp=sharp) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'sharp {}: {}bit {} format test passed' message = message.format(str(sharp), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_aarepair(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] repairs = [-i for i in range(25)] + [i for i in range(25)] for clip in test_clips: for repair in repairs: aa = taa.TAAmbk(clip, aatype=1, mtype=1, aarepair=repair, sharp=-1) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'aarepair {}: {}bit {} format test passed' message = message.format(str(repair), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_predown(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] strengths = [i / 10 for i in range(6)] for clip in test_clips: for strength in strengths: aa = taa.TAAmbk(clip, aatype=-1, aatypeu=3, aatypev=0, strength=strength) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'predown strength {}: {}bit {} format test passed' message = message.format(str(strength), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_mpand(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] mpands = [0, (0, 1), (1, 0), (2, 2), [2, 1]] for clip in test_clips: for mpand in mpands: aa = taa.TAAmbk(clip, aatype=1, mtype=3, mthr=[24, 46], mlthresh=59, mpand=mpand) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'mpand {}: {}bit {} format test passed' message = message.format(str(mpand), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
def test_mthr(self): test_clips = [ self.gray8, self.yuv420p8, self.yuv444p8, self.gray16, self.yuv420p16, self.yuv444p16 ] mtypes = [ 'Canny', 'Sobel', 'Prewitt', 'Canny_Old', 'Robert', 'MSharpen', 'TEdge' ] mthrs = range(1, 255, 15) for clip in test_clips: for mtype in mtypes: for mthr in mthrs: aa = taa.TAAmbk(clip, aatype=1, mtype=mtype, mthr=mthr) self.assertTrue(isinstance(aa, vs.VideoNode)) self.assertEqual(aa.width, clip.width) self.assertEqual(aa.height, clip.height) self.assertEqual(aa.format.bits_per_sample, clip.format.bits_per_sample) message = 'mtype {} mthr {}: {}bit {} format test passed' message = message.format( str(mtype), str(mthr), clip.format.bits_per_sample, self.format_id[str(clip.format.id)]) print(message)
gambo = gambo2[:121] + gambo[118:] gambo = gambo[:4506] gambo = fvf.GradFun3(gambo, thr=0.35, radius=12, elast=8.0, mode=3, ampo=1, ampn=0, pat=32, dyn=False, staticnoise=False, thr_det=2 + round(max(1 - 0.35, 0) / 0.3), debug=False, thrc=1, radiusc=12, planes=list(range(gambo.format.num_planes)), ref=gambo, bits=gambo.format.bits_per_sample) gambo = core.asharp.ASharp(gambo) gambo = haf.FineDehalo(gambo) gambo = taa.TAAmbk(gambo, "Nnedi3SangNom") gambo = gambo.resize.Bicubic(height=844, width=int(gambo.width / gambo.height * 844 + 0.5)) gambo.set_output()
import vsTAAmbk as taa import awsmfunc as awf import fvsfunc as fvf import kagefunc as kgf a = core.ffms2.Source("azuki-chan episode 1.mkv") a = a.vinverse.Vinverse() a = a.std.Crop(left=4, right=8, top=2) a = a.fb.FillBorders(right=1) a = a.fb.FillBorders(left=1, mode="fixborders") a = awf.bbmod(a, top=4, thresh=60, blur=10) a = awf.bbmod(a, left=4, thresh=3, blur=500) a = awf.bbmod(a, right=1, thresh=90, blur=40) a = awf.bbmod(a, right=6, thresh=2, blur=100) a = haf.FineDehalo(a) a = taa.TAAmbk(a, "Nnedi3") a = fvf.GradFun3(a, thr=0.35, radius=12, elast=8.0, mode=3, ampo=1, ampn=0, pat=32, dyn=False, staticnoise=False, thr_det=2 + round(max(1 - 0.35, 0) / 0.3), debug=False, thrc=1, radiusc=12, planes=list(range(a.format.num_planes)),
apple_d = core.placebo.Deband(apple, dither=False) apple_ds = core.placebo.Deband(apple, iterations=2, threshold=10, radius=20, dither=False) apple_dv = core.placebo.Deband(apple, iterations=4, threshold=23, radius=20, grain=0.7, dither=False) apple = taa.TAAmbk( apple_d[:814] + apple_ds[814:821] + apple_d[821:1709] + apple_dv[1709:1812] + apple_d[1812:2950] + apple_ds[2950:3320] + apple_d[3320:3786], 2) + taa.TAAmbk(apple_d[3786:3793], 1) + taa.TAAmbk( apple_d[3793:4250], 2) + taa.TAAmbk(apple_d[4250:4316], 1) + taa.TAAmbk( apple_d[4316:4447], 2) + taa.TAAmbk(apple_d[4447:4559], 1) + taa.TAAmbk( apple_d[4559:4586], 2) + taa.TAAmbk(apple_d[4586:4612], 1) + taa.TAAmbk( apple_d[4612:4627], 2) + taa.TAAmbk( apple_d[4627:4652], 1) + taa.TAAmbk(apple_d[4652:4666], 2) + taa.TAAmbk( apple_d[4666:4836], 1) + taa.TAAmbk( apple_d[4836:5395], 2 ) + taa.TAAmbk(apple_d[5395:5653], 1) + taa.TAAmbk( apple_d[5653:5896], 2
cunny = core.d2v.Source("Imouto Jiru/DISC1.d2v") cunny = cunny.vivtc.VFM(1) cunny = cunny.vivtc.VDecimate() cunny = cunny[:44972] cunny = cunny.std.Crop(left=6, right=4) cunny = awf.fb(cunny, top=1) cunny = cunny.resize.Bicubic(src_top=1) cunny = cunny.fb.FillBorders(top=1, bottom=1, mode="fixborders") cunny = cunny.vinverse.Vinverse() black = core.tcm.TColorMask(cunny.std.Minimum(), ["$000000"], tolerance=7, bt601=True, gray=False, lutthr=9) cunny = rektlvls(cunny, colnum=[1, 709], colval=[-9, 35]) aa = taa.TAAmbk(cunny, "Nnedi3") sangnom = taa.TAAmbk(cunny, "Nnedi3SangNom") mask = kgf.retinex_edgemask(cunny).std.Binarize(200).std.Deflate(threshold=250) cunny = cunny.placebo.Deband(threshold=6, radius=16, grain=4) cunny = awf.ReplaceFrames(core.std.MaskedMerge(cunny, aa, mask), core.std.MaskedMerge(cunny, sangnom, mask), "[4708 4850] [5290 5421] [5542 5698] [5770 5803]") no_bbmod = cunny censor = cunny.fb.FillBorders(top=2, mode="fixborders") censor = awf.bbmod(censor, top=4, thresh=200, blur=10) censor = awf.bbmod(censor, right=4, thresh=2, blur=5) censor = awf.bbmod(censor, left=4, thresh=6, blur=8) censor = awf.bbmod(censor, right=1) cunny = awf.bbmod(cunny, right=4, top=4, thresh=2, blur=5) cunny = awf.bbmod(cunny, left=4, thresh=6, blur=8) cunny = awf.bbmod(cunny, right=1)
from vapoursynth import core import awsmfunc as awf import havsfunc as haf import muvsfunc as muf import vsTAAmbk as taa src = core.lsmas.LWLibavSource("VBR.mkv") src = src[:54023] sr = muf.Cdeblend(src, omode=3) sr = awf.ReplaceFrames(sr, src, "[0 441] [2791 2793] [2796 2797] [2807 2808] [2937 2951] [3006 3048] [4193 4228] [4981 4994] [5042 5146] [5358 5431] [51869 54022]") sr = sr.placebo.Deband(threshold=3, radius=8, grain=0) sr = taa.TAAmbk(sr, "Nnedi3SangNom") dehalo = haf.DeHalo_alpha(sr) dehalo.set_output()
) out = fvf.ReplaceFrames(out, av2, "[5286 5405] [6194 6273]") out = fvf.ReplaceFrames( out, h264, "[281 286] [1731 1734] [1739 1759] [2183 2213] [2250 2253] [2453 2455] [2464 2467] [2480 2482] [2486 2489] [2494 2495] [2646 2747] [3662 3671] [3951 3955] [4563 4583] [6025 6049] [6056 6061] [6069 6109] [6367 6416] [6580 6583] [6586 6598] [6560 6612] [6629 6637] [6641 6643] [6651 6657] [6698 6700] 6735 [6835 6878] [7197 7198]" ) out = fvf.ReplaceFrames(out, core.std.MaskedMerge(h264, av1, av1.std.Binarize(46)), "[3951 3955]") out = fvf.ReplaceFrames( out, haf.YAHR(core.std.MaskedMerge(muf.abcxyz(out), out, out.std.Binarize(100))), "[1790 1794] [2266 2279]") out = fvf.ReplaceFrames( out, taa.TAAmbk(out, 2), "[357 409] [761 850] [1785 1804] [2224 2252] [2258 2343] [2346 2430] [2436 2444] [2501 2588] [2646 3047] [3068 3249] [3472 3574] [3575 3671] [3575 3660] [3775 3824] [4355 4362] [4529 4539] [4770 4877] [4891 4995] [6417 6476] [7197 7204] [7795 7921]" ) out = fvf.ReplaceFrames( out, core.placebo.Deband(out, iterations=2, threshold=10, radius=20), "[3672 3677]") deband_s = core.placebo.Deband(av1, iterations=2, threshold=18, radius=9, dither=False) sky_mask = out.std.Binarize(69) # nice out = fvf.ReplaceFrames(out, core.std.MaskedMerge(out, deband_s, sky_mask), "[3886 4279]")