Advertisement
Guest User

AntiAliasRG (Old)

a guest
Oct 7th, 2011
505
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, dull antialiasing. Expect updates/tweaking in the future. No guarantees though. (Lazy, lazy me!)
  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.
  9. # Though if said source is downscaled, everything looks alright. (More or less better than just downsized.)
  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. thrl = Default(thrl, 8) # Luma threshold for the masks.
  16. thrc = Default(thrc, 8) # Chroma threshold for the masks. (Color)
  17. ox = orig.width
  18. oy = orig.height
  19. sx = Default(sx, 0.75) # Potential artifact reduction (supersampling), except here I use it to speed the RemoveGrain performance up. :-)
  20. sy = Default(sx, 0.75) # Though the resizing may or may not eliminate that gain. Again, expect tweaking.
  21. 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!
  22. mode = Default(mode, "laplace") # Kernel for detecting edges, I prefer this one.
  23. clp = orig.IsYV12() ? orig : orig.ConvertToYV12() # Is the source in YV12? If not, convert to it. (Shameless ripoff!)
  24.  
  25. ##############
  26.  
  27. a=clp
  28. b=clp.BilinearResize(m4(ox*sx),m4(oy*sy))
  29. c=b.RemoveGrain(mode=9).GaussResize(ox,oy,p=sharpness)
  30. d=b.RemoveGrain(mode=1).GaussResize(ox,oy,p=sharpness)
  31. e=clp.MotionMask(thrl,thrl,thrc,thrc,128)
  32. f=clp.EdgeMask(thrl,thrl,thrc,thrc,mode).Inflate() # Expanding (?) the mask to get smoother edges. (?Perhaps a slight median filter needed?)
  33. g=MaskedMerge(a,c,e) # I'll probably be messing aroudn with those.
  34. h=MaskedMerge(a,d,f)
  35. i=MaskedMerge(g,h,f)
  36. j=MaskedMerge(a,i,f)
  37. q=f.Invert().Deflate().Deflate() # This seems to clarify things outside the edges a bit. At the prize of about 3.8% worth of FPS. Worth it though.
  38. MaskedMerge(j,a,q) # Uses the above mask to do it's dirty business.
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement