Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import havsfunc as haf
- import mvsfunc as mvf
- import kagefunc as kgf
- def super_daa(clip, w=320, h=720, sharp=3, mask=None):
- cfmt = clip.format
- bits, st = cfmt.bits_per_sample, cfmt.sample_type
- sfmt = core.register_format(cfmt.color_family, st, bits, cfmt.subsampling_w, cfmt.subsampling_h)
- mfmt = core.register_format(vs.GRAY, st, bits, 0, 0)
- numframes = clip.num_frames
- mask = mask.resize.Point(format=mfmt.id, range=1, dither_type='none', matrix_s='709').std.Binarize(1 if st==vs.FLOAT else (1<<bits)-1).std.Inflate()*numframes
- clpy = kgf.getY(clip)
- nn = clpy.fmtc.resample(w, h, kernel='spline64', flt=False).znedi3.nnedi3(3, False, 0, 3, 3).std.SeparateFields(True).std.SelectEvery(4, [0, 3]).std.DoubleWeave()[::2]
- dbl = nn.std.Transpose().znedi3.nnedi3(1, True, 0, 0, 3, 1)
- while dbl.height < clip.width:
- dbl = dbl.znedi3.nnedi3(0, True, 0, 0, 3, 1)
- dbl = dbl.fmtc.resample(clip.height, clip.width, 0, -0.5, kernel='spline64', flt=False).std.Transpose()
- dblD = clpy.std.MakeDiff(dbl)
- shrpD = dbl.rgvs.RemoveGrain(11)
- for _ in range(sharp-1):
- shrpD = shrpD.std.Convolution([1]*9)
- shrpD = dbl.std.MakeDiff(shrpD)
- DD = core.std.Expr([shrpD, kgf.iterate(dblD, core.std.Maximum, max(1, sharp) ), kgf.iterate(dblD, core.std.Minimum, max(1, sharp) )], 'x y min z max')
- daa = dbl.std.MergeDiff(DD)
- lim = mvf.LimitFilter(clpy, daa, thr=1.25, elast=2)
- stab = haf.SMDegrain(lim, tr=2, thSAD=120, search=3, prefilter=3, RefineMotion=True, truemotion=False)
- if stab.format != cfmt:
- stab = stab.resize.Point(format=sfmt.id)
- return clip.std.MaskedMerge(stab, mask, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement