Advertisement
Zastin

Super DAA

Dec 7th, 2017
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import havsfunc as haf
  2. import mvsfunc as mvf
  3. import kagefunc as kgf
  4.  
  5. def super_daa(clip, w=320, h=720, sharp=3, mask=None):
  6.     cfmt = clip.format
  7.     bits, st = cfmt.bits_per_sample, cfmt.sample_type
  8.     sfmt = core.register_format(cfmt.color_family, st, bits, cfmt.subsampling_w, cfmt.subsampling_h)
  9.     mfmt = core.register_format(vs.GRAY, st, bits, 0, 0)
  10.     numframes = clip.num_frames
  11.     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
  12.     clpy = kgf.getY(clip)
  13.     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]
  14.     dbl = nn.std.Transpose().znedi3.nnedi3(1, True, 0, 0, 3, 1)
  15.     while dbl.height < clip.width:
  16.         dbl = dbl.znedi3.nnedi3(0, True, 0, 0, 3, 1)
  17.     dbl = dbl.fmtc.resample(clip.height, clip.width, 0, -0.5, kernel='spline64', flt=False).std.Transpose()
  18.     dblD    = clpy.std.MakeDiff(dbl)
  19.     shrpD   = dbl.rgvs.RemoveGrain(11)
  20.     for _ in range(sharp-1):
  21.         shrpD = shrpD.std.Convolution([1]*9)
  22.     shrpD = dbl.std.MakeDiff(shrpD)
  23.     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')
  24.     daa = dbl.std.MergeDiff(DD)
  25.     lim = mvf.LimitFilter(clpy, daa, thr=1.25, elast=2)
  26.     stab = haf.SMDegrain(lim, tr=2, thSAD=120, search=3, prefilter=3, RefineMotion=True, truemotion=False)
  27.     if stab.format != cfmt:
  28.         stab = stab.resize.Point(format=sfmt.id)
  29.     return clip.std.MaskedMerge(stab, mask, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement