Advertisement
Guest User

AntiAlias(ing) Edit (Useless "Motion Edition")

a guest
Oct 7th, 2011
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function AntiAliasME(clip orig,int "th_luma",int "th_chroma",float "sx",float "sy",string "type",int "aath",int "blockx",int "blocky",int "superfilter",float "sharpness",int "tempradius") {
  2.  
  3. # >Requirements - MVTools2, MaskTools, SangNom
  4.  
  5. # "Motion" Edition. Just flame the hell out of it. (My useless slowdown of the process in attempt to stabilize the antialiasing.) :)
  6.  
  7. # By SpikeSpiegel, Didée, mf, scharfis_barin and Soulhunter.
  8. # (Shamelessly) Edited by "Bloax" for a slight increase in speed (now), and some more or less stabilizing features.
  9. # With the old one I got ~30 FPS, with this one I get ~36 on the same source.
  10.  
  11. # Enjoy!
  12.  
  13. # A wild Long Read ambushes you!
  14. # Long Read uses TL;DR
  15. # It was super effective!
  16. # You fainted! ;p
  17.  
  18. # "th_luma" and "th_chroma" Are the thresholds for detection. The lower they are, the more edges the script catches.
  19. # "th_luma" Is the threshold for luma edges and "th_chroma" is well, the threshold for color edges! [/ignorance]
  20. # "type" Is the matrix used for edge detection. Previously "Sobel" was the default, which only detected high-contrast edges.
  21. # Now I replaced it with "laplace", which seems smoother (and causes less visible aliasing).
  22.  
  23. # "aath" Is the anti-aliasing strenght. The default value should be fine.
  24. # Set it too low, and you'll get a blocky image (due to initial upscaling to reduce the aliasing).
  25. # Too high and well, nothing really. 4096 Seems to look pretty much like 64.
  26. # >Now it should basically be the 'strength' of the filter. More or less.
  27.  
  28. # "sx" And "sy" are the scaling multipliers (..BilinearResize(m4(ox>>*sx<<)..).
  29. # Set it too low, and the SangNom artifacts start showing up. Too high, and it starts getting blocky. (Upscaling, again.)
  30. # Though it all depends on the source, for highly aliased and thick images higher values may be better.
  31. # Games with their broad aliasing (eg. Walls), however. Benefit from lower values. Don't go below 1 though! ;)
  32. # Note: This is the biggest factor in speed.
  33.  
  34. # "sharpness" Defines the final sharpness of the /antialiasing/ once it gets scaled down again.
  35. # Set it too low, and things get a bit smeared (bad for text). Too high, and well, the antialiasing is pretty much lost.
  36. # Do note that "sharpness" is just the "p" value of GaussResize. :-)
  37.  
  38. # "blockx" And "blocky" are the block sizes for MAnalyse, higher values are faster.
  39. # What exactly lower values offer over the larger I can't notice. The speed reduction is obvious though. ;P
  40. # 16 Actually seems to give the best visual results.
  41. # "superfilter" Is the smoothening filter for MSuper, I can't really notice the difference.
  42. # Messing around with it is welcome.
  43.  
  44. # "tempradius" Is the frame search field for TemporalSoften, which is there to stabilize the antialiased edges.
  45. # Higher values are slightly more stable, a bit slower and produce more slightly more artifacts. :o
  46.  
  47. th_luma  = Default(th_luma, 10)
  48. th_chroma = Default(th_chroma, 10)
  49. type     = Default(type, "laplace")
  50. aath     = Default(aath, 64)
  51. ox = orig.width
  52. blockx = Default(blockx, 16)
  53. blocky = Default(blocky, 16)
  54. superfilter = Default(superfilter, 4)
  55. oy = orig.height
  56. sx = Default(sx, 1.25)
  57. sy = Default(sy, 1.25)
  58. sharpness = Default(sharpness, 66)
  59. tempradius = Default(tempradius, 1)
  60. clp = orig.IsYV12() ? orig : orig.ConvertToYV12()
  61.  
  62. a=clp
  63. b=clp.BilinearResize(m4(ox*sx),m4(oy*sy)).TurnLeft().SangNom(aa=aath).TurnRight().SangNom(aa=aath) \
  64. .GaussResize(ox,oy,p=sharpness).TemporalSoften(tempradius,round(th_luma*1.5),round(th_chroma*1.25),mode=2)
  65. c=clp.MotionMask(th_luma/2,th_luma/2,th_chroma/2,th_chroma/2,4096/aath) # The greater aath is, the more of the mask is actually going to be real pixels.
  66. d=clp.EdgeMask(th_luma,th_luma,th_chroma,th_chroma,type)
  67. e=MSuper(a,pel=1,rfilter=superfilter)
  68.  
  69. # Starting the MVTools2 stuff.
  70.  
  71. f=MAnalyse(e,blockx,blocky,search=2,isb=true,delta=1,overlap=2,levels=3)
  72.  
  73. # Forward motion vector search.
  74.  
  75. g=MAnalyse(e,blockx,blocky,search=2,isb=false,delta=1,overlap=2,levels=3)
  76.  
  77. # Backward motion vector search. (What else!)
  78.  
  79. h=MDeGrain1(b,e,g,f,thSAD=1024/aath)
  80.  
  81. # Degraining the antialiased result based on motion vectors from the original. Higher aath means more stuff is affected.
  82.  
  83. i=MaskedMerge(b,h,d)
  84.  
  85. # Merging the antialiased result with a MDeGrained original. On the edges.
  86.  
  87. j=MaskedMerge(a,b,d)
  88.  
  89. # Merging the original with the antialiased one. On the edges. (See d=clp..)
  90.  
  91. k=MaskedMerge(j,i,c)
  92.  
  93. # Merging the AA'd+MDGrained with the AA'd+Original. On the motion (edges??).
  94.  
  95. MaskedMerge(k,h,c)
  96. # MDeGrain + MotionMask seems pretty awesome. The stabilization certainly benefits from it.
  97. }
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement