Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function MDegrain (clip input, int "method", clip "pp", int "thSAD", int "thSCD1", int "thSCD2", int "blksize", int "pel", int "overlap", int "dct", int "search")
  2. {
  3.     method = default(method, 1)
  4.     pp = default(pp, input)
  5.     thSAD = default(thSAD, 400)
  6.     thSCD1 = default(thSCD1, 400)
  7.     thSCD2 = default(thSCD2, 130)
  8.     blksize = default(blksize, 8)
  9.     pel = default(pel, 4)
  10.     overlap = default(overlap, blksize / 2)
  11.     dct = default(dct, 7)
  12.     search = default(search, 4)
  13.  
  14.     # MSuper
  15.     pp_super = pp.MSuper(pel=pel)
  16.  
  17.     # Motion vector search
  18.     b3vec = (method>=3) ? MAnalyse(pp_super,isb=true,search=search,delta=3,overlap=overlap,blksize=blksize,dct=dct) : NOP
  19.     b2vec = (method>=2) ? MAnalyse(pp_super,isb=true,search=search,delta=2,overlap=overlap,blksize=blksize,dct=dct) : NOP
  20.     b1vec = MAnalyse(pp_super,isb=true,search=search,delta=1,overlap=overlap,blksize=blksize,dct=dct)
  21.     f1vec = MAnalyse(pp_super,isb=false,search=search,delta=1,overlap=overlap,blksize=blksize,dct=dct)
  22.     f2vec = (method>=2) ? MAnalyse(pp_super,isb=false,search=search,delta=2,overlap=overlap,blksize=blksize,dct=dct) : NOP
  23.     f3vec = (method>=3) ? MAnalyse(pp_super,isb=false,search=search,delta=3,overlap=overlap,blksize=blksize,dct=dct) : NOP
  24.  
  25.     # Now we perform the actual MDegrain.
  26.     super = input.MSuper(pel=pel,levels=1)
  27.     output =    (method>=3) ? input.MDegrain3(super,b1vec,f1vec,b2vec,f2vec,b3vec,f3vec,thSAD=thSAD,thSCD1=thSCD1,thSCD2=thSCD2) :
  28.         \       (method==2) ? input.MDegrain2(super,b1vec,f1vec,b2vec,f2vec,thSAD=thSAD,thSCD1=thSCD1,thSCD2=thSCD2) :
  29.         \       input.MDegrain1(super,b1vec,f1vec,thSAD=thSAD,thSCD1=thSCD1,thSCD2=thSCD2)
  30.  
  31.     return(output)
  32. }
  33.  
  34. function AAA(clip input, int "type", bool "mask", bool "chroma", bool "mc", float "reduc", clip "pp")
  35. {
  36.     ox = input.width
  37.     oy = input.height
  38.  
  39.     type = default(type, 1).max(0).min(2)
  40.     mask = default(mask, true)
  41.     chroma = default(chroma, false)
  42.     mc = default(mc, false)
  43.     reduc = default(reduc, 0.6).max(0).min(1)
  44.     pp = default(pp, input)
  45.  
  46.     gscale = (chroma) ? input : input.Greyscale()
  47.  
  48.     aa = (type==2) ? gscale.TurnLeft().nnedi2(dh=true,field=1).TurnRight().nnedi2(dh=true,field=1) :
  49.     \ (type==1) ? gscale.TurnLeft().EEDI2(field=1).TurnRight().EEDI2(field=1) :
  50.     \ gscale.PointResize(ox*2,oy*2).TurnLeft().SangNom().TurnRight().SangNom()
  51.  
  52.     edge = mt_logic(aa.mt_edge("5 10 5 0 0 0 -5 -10 -5 4",0,255,0,255),
  53.     \ aa.mt_edge("5 0 -5 10 0 -10 5 0 -5 4",0,255,0,255),"max").Greyscale().
  54.     \ Levels(0,0.8,128,0,255,false)
  55.  
  56.     edge_ds = (type>=1) ? edge.Spline36Resize(ox,oy,0.5,-0.5,2*ox+.001,2*oy+.001) : edge.Spline36Resize(ox,oy)
  57.     ds = (type>=1) ? aa.Spline36Resize(ox,oy,0.5,-0.5,2*ox+.001,2*oy+.001) : aa.Spline36Resize(ox,oy)
  58.  
  59.     maskmerge = (mask) ? mt_merge(input,ds,edge_ds,U=1,V=1) : ds
  60.     chromamerge = (chroma) ? maskmerge.MergeChroma(ds) : maskmerge.MergeChroma(input)
  61.  
  62.     aadiff = mt_makediff(input,chromamerge)
  63.     aadiffd = aadiff.MDeGrain(method=2,pp=pp)
  64.     mcmerge = mt_lutxy(aadiff,aadiffd,"x 128 - abs y 128 - abs < x y ?").MergeLuma(aadiffd,reduc)
  65.  
  66.     output = (mc) ? input.mt_makediff(mcmerge,U=2,V=2) : chromamerge
  67.  
  68.     return(output)
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement