Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AntiAliasRG(clip orig,float "sx", float "sy",string "mode",int "thrl",int "thrc",float "sharpness") {
- # Fast antialiasing using RemoveGrain. (It is dull no more!)
- # > Requirements: MaskTools, RemoveGrain(SSE3).dll
- # By Bloax, based on the "Antialiasing" script (stealing parts of ;)), authors of which are; SpikeSpiegel, Didée, mf, scharfis_brain and Soulhunter.
- # Note: This script is pretty weak, so tough edges (huge, curved ones) end up looking plain blurred. < It's rather strong now.
- # 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.
- # 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.)
- # Though for eliminating tons of aliasing in a noisy game (Eg. Doom), this is certainly better than the usual SangNom ones.
- # Due to the fact that it doesn't smoothen out the noise to abstract shapes, and instead eliminates it. (RemoveGrain. :))
- # Due to recent changes the above may or may not be absolutely true. :-)
- # (Because I'm totally way too lazy to rewrite all of this!)
- # UpdateUpdate: "sx" And "sy" are now the options to prevent (extreme) text smearing.
- # Don't set them both at 1 though, or you'll end up reducing the antialiasing to a single RemoveGrain(mode=21)
- thrl = Default(thrl, 10) # Luma threshold for the mask(s).
- thrc = Default(thrc, 10) # Chroma threshold for the mask(s). (Color)
- ox = orig.width
- oy = orig.height
- sx = Default(sx, 1.33) # Horizontal supersampling, reducing either to <1 will make text almost unreadable.
- sy = Default(sy, 1.33) # Vertical supersampling, once again, setting both of those results in getting a slower RemoveGrain(mode=21) filter.
- #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!
- #Gaussresize replaced with BilinearResize. (Speed!)
- mode = Default(mode, "laplace") # Kernel for detecting edges, I prefer this one.
- clp = orig.IsYV12() ? orig : orig.ConvertToYV12() # Is the source in YV12? If not, convert to it. (Shameless ripoff!)
- ##############
- a=clp
- b=clp.BilinearResize(m4(ox*sx),m4(oy*sy))
- c=b.RemoveGrain(mode=5).RemoveGrain(mode=21).RemoveGrain(mode=19).BilinearResize(ox,oy).RemoveGrain(mode=22)
- # RemoveGrain mode 5 is for removing noise, mode 19 is a blurring filter, and 21/22 are kind of like SangNom antialiasing.
- # Well, except that they're insanely fast. ;)
- e=clp.EdgeMask(round(thrl/6),thrl,round(thrc/5),thrc,mode).RemoveGrain(mode=19).Inflate()
- # Expanding the mask quite a bit, just to make sure the antialiasing gets a more or less smooth area.
- # I may have to switch to MaskTools2 for that, though.
- f=MaskedMerge(a,c,e) # I'll probably be messing around with those.
- MaskedMerge(a,f,e).RemoveGrain(mode=22) # Killing the jaggies that got past the mask. ;)
- # The stuff below ended up as a bad experiment. Ended up killing more detail than giving. D:
- #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.
- #MaskedMerge(g,a,h) # Uses the above mask to do it's dirty business.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement