Advertisement
Guest User

Untitled

a guest
Dec 20th, 2010
2,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Anti-aliasing with contra-sharpening by Didee, modded by Terranigma for nnedi and by thetoof for merge
  2. function daa(clip c) {
  3.     dbl     = merge(c.nnedi3(1),c.nnedi3(0))
  4.     dblD    = mt_makediff(c,dbl,U=3,V=3)
  5.     shrpD   = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
  6.     DD      = shrpD.repair(dblD,13)
  7.    
  8.     return dbl.mt_adddiff(DD,U=3,V=3)
  9. }
  10.  
  11. # Anti-aliasing with contra-sharpening by Didee
  12. FUNCTION daa_orig(clip c) {
  13.     nn      = c.nnedi3(field=-2)
  14.     dbl     = mt_average(selecteven(nn),selectodd(nn),U=3,V=3)
  15.     dblD    = mt_makediff(c,dbl,U=3,V=3)
  16.     shrpD   = mt_makediff(dbl,dbl.removegrain((width(c)>1100) ? 20 : 11),U=3,V=3)
  17.     DD      = shrpD.repair(dblD,13)
  18.    
  19.     return dbl.mt_adddiff(DD,U=3,V=3)
  20. }
  21.  
  22. # Suggested by Mystery Keeper in "Denoise of tv-anime" thread
  23. function ediaa(clip a) {
  24.     return a.EEDI2(field=1).TurnRight().EEDI2(field=1).TurnLeft().spline36resize(a.width,a.height,-0.5,-0.5,2*a.width+.001,2*a.height+.001)
  25. }
  26.  
  27. # Anti-aliasing with edge masking by martino, mask using "sobel" taken from Kintaro's useless filterscripts and modded by thetoof for spline36
  28. function maa(clip input, int "mask") {
  29.     mask = input.mt_edge("sobel",7,7,5,5).mt_inflate()
  30.     aa_clip=input.spline36Resize(width(input)*2,height(input)*2).TurnLeft().SangNom().TurnRight().SangNom().spline36Resize(width(input),height(input)).MergeChroma(input)
  31.     return mt_merge(input,aa_clip,mask)
  32. }
  33.  
  34. # Developped in the "fine anime antialiasing thread"
  35. function SharpAAMCmod(clip orig, int "aastr", float "ds", int "ShPre", int "ShPost", int "SmPost", bool "MC", bool "MT", int "tradius", int "pel", int "ov", int "blk", string "aatype")
  36. {
  37.     aastr   = default ( aastr,  255 ) # antialiasing strength
  38.     ds      = default ( ds,     0.2 ) # strokes darkening strength
  39.     ShPre   = default ( ShPre,   80 ) # Presharpening
  40.     ShPost  = default ( ShPost, 300 ) # Postsharpening
  41.     SmPost  = default ( SmPost, 100 ) # Postsmoothing
  42.     MC      = default ( MC,    true ) # Use post stabilization with Motion Compensation
  43.     MT      = default ( MT,    true ) # Use josey_wells' branch of MVTools
  44.     Tradius = default ( Tradius,  2 ) # 2 = MVDegrain2 / 3 = MVDegrain3 /// 28 = MVDegrain 28
  45.     assert(mt || tradius<4, "You must use MT=true with josey_wells' branch of MVTools to use a higher tradius than 3")
  46.     pel     = default ( pel,      1 ) # accuracy of the motion estimation (Value can only be 1, 2 or 4. 1 means a precision to the pixel. 2 means a precision to half a pixel, 4 means a precision to quarter a pixel, produced by spatial interpolation (better but slower).)
  47.     ov      = default ( ov,       4 ) # block overlap value (horizontal). Must be even and less than block size. (Higher = more precise & slower)
  48.     blk     = default ( blk,      8 ) # Size of a block (horizontal). It's either 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.
  49.     aatype  = default ( aatype,   "Sangnom" ) # Use Sangnom() or EEDI2() for anti-aliasing
  50.  
  51.     w=width(orig)
  52.     h=height(orig)
  53.     m=logic( orig.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=4,Y=3,U=3,V=3)
  54.     \       ,orig.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=4,Y=3,U=3,V=3)
  55.     \       ,"max").greyscale().levels(0,0.8,128,0,255,false)
  56.     preaa=(ShPre==0 && ds==0) ? orig : (ShPre==0) ? orig.Toon(ds) : (ds==0) ? orig.Warpsharp(depth=ShPre) : orig.Toon(ds).Warpsharp(depth=ShPre)
  57.     aa= (aatype=="Sangnom") ? preaa.spline36resize(w*2,h*2).TurnLeft().SangNom(aa=aastr).TurnRight().SangNom(aa=aastr).spline36resize(w,h) : (aatype=="EEDI2") ? preaa.ediaa() : blankclip(pixel_type="YV12").subtitle("Please use Sangnom or EEDI2 for aatype")
  58.     postsh=(ShPost==0 && SmPost==0) ? aa : aa.LimitedSharpenFaster(edgemode=1,strength=ShPost,overshoot=1,soft=SmPost)
  59.     merged=mt_merge(orig,postsh,m,Y=3,U=3,V=3)
  60.    
  61.     sD=mt_makediff(orig,merged)
  62.    
  63.     fv3 = orig.MVAnalyse(isb=false,delta=3,pel=pel,overlap=ov,blksize=blk,idx=21)
  64.     fv2 = orig.MVAnalyse(isb=false,delta=2,pel=pel,overlap=ov,blksize=blk,idx=21)
  65.     fv1 = orig.MVAnalyse(isb=false,delta=1,pel=pel,overlap=ov,blksize=blk,idx=21)
  66.     bv1 = orig.MVAnalyse(isb=true, delta=1,pel=pel,overlap=ov,blksize=blk,idx=21)
  67.     bv2 = orig.MVAnalyse(isb=true, delta=2,pel=pel,overlap=ov,blksize=blk,idx=21)
  68.     bv3 = orig.MVAnalyse(isb=true, delta=3,pel=pel,overlap=ov,blksize=blk,idx=21)
  69.     allv = mt ? orig.MVAnalyseMulti(refframes=tradius,pel=pel,overlap=ov,blksize=blk,idx=21) : nop()
  70.     fiz = (tradius==1) ? sD.MVDegrain1(bv1,fv1,idx=22) : (tradius==2) ? sD.MVDegrain2(bv1,fv1,bv2,fv2,idx=22) : (tradius==3) ? sD.MVDegrain3(bv1,fv1,bv2,fv2,bv3,fv3,idx=22) : blankclip(pixel_type="yv12").subtitle("You must use MT=true with josey_wells' branch of MVTools to use a higher tradius than 3")
  71.     sDD = (MT) ? sD.MVDegrainMulti(allv,idx=22) : fiz
  72.    
  73.     reduc = 0.4
  74.     sDD = mt_lutxy(sD,sDD,"x 128 - abs y 128 - abs < x y ?").mergeluma(sDD,1.0-reduc)
  75.    
  76.     return MC ? orig.mt_makediff(sDD,U=2,V=2) : merged
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement