Advertisement
Guest User

AntiAlias(ing) Edit (Simple)

a guest
Oct 7th, 2011
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function AntiAlias(clip orig,int "th_luma",int "th_chroma",float "sx",float "sy",string "type",int "aath",float "sharpness") {
  2.  
  3. # >Requirements: MaskTools, SangNom
  4.  
  5. # By SpikeSpiegel, Didée, mf, scharfis_barin and Soulhunter.
  6. # (Shamelessly) Edited by "Bloax" for a slight increase in speed, ~30 FPS at SetMtMode(2) @ 640x480 before, 59-60 now.
  7. # \ On a Intel Core2 (Duo) E8600 @ 3.8 GHz. Speed without MtMode, ~15 Fps vs. ~30.
  8. # \\ Also tuned it for game aliasing. (Used a recording of DooM for tweaking.)
  9. # \\\ And rewrote the instructions (and changed the name), for some reason.
  10.  
  11. # This one is faster (twice so) than the grotesque "Motion Edition" of mine. ;)
  12.  
  13. # Enjoy!
  14.  
  15. # A wild Long Read ambushes you!
  16. # Long Read uses TL;DR
  17. # It was super effective!
  18. # You fainted! ;p
  19.  
  20. # "th_luma" and "th_chroma" Are the thresholds for detection. The lower they are, the more edges the script catches.
  21. # "th_luma" Is the threshold for luma edges and "th_chroma" is well, the threshold for color edges! [/ignorance]
  22. # "type" Is the matrix used for edge detection. Previously "Sobel" was the default, which only detected high-contrast edges.
  23. # Now I replaced it with "laplace", which seems smoother (and causes less visible aliasing).
  24.  
  25. # "aath" Is the anti-aliasing strenght. The default value should be fine.
  26. # Set it too low, and you'll get a blocky image (due to initial upscaling to reduce the aliasing).
  27. # Too high and well, nothing really. 4096 Seems to look pretty much like 64.
  28.  
  29. # "sx" And "sy" are the scaling multipliers (..BilinearResize(m4(ox>>*sx<<)..).
  30. # Set it too low, and the SangNom artifacts start showing up. Too high, and it starts getting blocky. (Upscaling, again.)
  31. # Though it all depends on the source, for highly aliased and thick images higher values may be better.
  32. # Games with their tiny aliasing, however. Benefit from lower values. Don't go below 1 though! ;)
  33. # Note: This is the biggest factor in speed.
  34.  
  35. # "sharpness" Defines the final sharpness of the /antialiasing/ once it gets scaled down again.
  36. # Set it too low, and things get a bit smeared (bad for text). Too high, and well, the antialiasing is pretty much lost.
  37. # Do note that "sharpness" is just the "p" value of GaussResize. :-)
  38.  
  39. th_luma  = Default(th_luma, 9)
  40. th_chroma = Default(th_chroma, 9)
  41. type     = Default(type, "laplace")
  42. aath     = Default(aath, 64)
  43. ox = orig.width
  44. oy = orig.height
  45. sx = Default(sx, 1.25)
  46. sy = Default(sy, 1.25)
  47. sharpness = Default(sharpness, 66)
  48. clp = orig.IsYV12() ? orig : orig.ConvertToYV12()
  49.  
  50. a=clp
  51. b=clp.BilinearResize(m4(ox*sx),m4(oy*sy)).TurnLeft().SangNom(aa=aath).TurnRight().SangNom(aa=aath) \
  52. .GaussResize(ox,oy,p=sharpness)
  53. c=clp.EdgeMask(th_luma,th_luma,th_chroma,th_chroma,type)
  54. MaskedMerge(a,b,c)
  55.  
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement