Advertisement
Guest User

AntiAliasRG (Newer oldie)

a guest
Oct 8th, 2011
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function AntiAliasRG(clip orig,float "sx", float "sy",string "mode",int "thrl",int "thrc",float "sharpness") {
  2.  
  3. # Fast antialiasing using RemoveGrain. (It is dull no more!)
  4.  
  5. # > Requirements: MaskTools, RemoveGrain(SSE3).dll
  6. # By Bloax, based on the "Antialiasing" script (stealing parts of ;)), authors of which are; SpikeSpiegel, Didée, mf, scharfis_brain and Soulhunter.
  7.  
  8. # Note: This script is pretty weak, so tough edges (huge, curved ones) end up looking plain blurred. < It's rather strong now.
  9. # Though if said source is downscaled, everything looks alright. (More or less better than just downsized.) < Applying it BEFORE downscaling gives superior results, for the price of some speed.
  10.  
  11. # It is to be noted that this script loses to the SangNom ones in slightly aliased cases. (Eg. Warcraft 3: The Frozen Throne title screen.)
  12. # Though for eliminating tons of aliasing in a noisy game (Eg. Doom), this is certainly better than the usual SangNom ones.
  13. # Due to the fact that it doesn't smoothen out the noise to abstract shapes, and instead eliminates it. (RemoveGrain. :))
  14.  
  15. # Due to recent changes the above may or may not be absolutely true. :-)
  16. # (Because I'm totally way too lazy to rewrite all of this!)
  17.  
  18. # UpdateUpdate: "sx" And "sy" are now the options to prevent (extreme) text smearing.
  19. # Don't set them both at 1 though, or you'll end up reducing the antialiasing to a single RemoveGrain(mode=21)
  20.  
  21. thrl = Default(thrl, 10) # Luma threshold for the mask(s).
  22. thrc = Default(thrc, 10) # Chroma threshold for the mask(s). (Color)
  23. ox = orig.width
  24. oy = orig.height
  25. sx = Default(sx, 1.33) # Horizontal supersampling, reducing either to <1 will make text almost unreadable.
  26. sy = Default(sy, 1.33) # Vertical supersampling, once again, setting both of those results in getting a slower RemoveGrain(mode=21) filter.
  27. #sharpness = Default(sharpness,(31.25*((sx+sy)/2))) # The sharpness for upscaling of the downscaled clip. Keep low, or else we're going to see some edgy artifacts!
  28. #Gaussresize replaced with BilinearResize. (Speed!)
  29. mode = Default(mode, "laplace") # Kernel for detecting edges, I prefer this one.
  30. clp = orig.IsYV12() ? orig : orig.ConvertToYV12() # Is the source in YV12? If not, convert to it. (Shameless ripoff!)
  31.  
  32. ##############
  33.  
  34. a=clp
  35. b=clp.BilinearResize(m4(ox*sx),m4(oy*sy))
  36. c=b.RemoveGrain(mode=5).RemoveGrain(mode=21).RemoveGrain(mode=19).BilinearResize(ox,oy).RemoveGrain(mode=22)
  37. # RemoveGrain mode 5 is for removing noise, mode 19 is a blurring filter, and 21/22 are kind of like SangNom antialiasing.
  38. # Well, except that they're insanely fast. ;)
  39. e=clp.EdgeMask(round(thrl/6),thrl,round(thrc/5),thrc,mode).RemoveGrain(mode=19).Inflate()
  40. # Expanding the mask quite a bit, just to make sure the antialiasing gets a more or less smooth area.
  41. # I may have to switch to MaskTools2 for that, though.
  42. f=MaskedMerge(a,c,e) # I'll probably be messing around with those.
  43. MaskedMerge(a,f,e).RemoveGrain(mode=22) # Killing the jaggies that got past the mask. ;)
  44.  
  45. # The stuff below ended up as a bad experiment. Ended up killing more detail than giving. D:
  46. #h=e.Invert() # This seems to clarify things outside the edges a bit. At the prize of about 3.8% worth of FPS. Worth it though.
  47. #MaskedMerge(g,a,h) # Uses the above mask to do it's dirty business.
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement