Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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") {
- # >Requirements - MVTools2, MaskTools, SangNom
- # "Motion" Edition. Just flame the hell out of it. (My useless slowdown of the process in attempt to stabilize the antialiasing.) :)
- # By SpikeSpiegel, Didée, mf, scharfis_barin and Soulhunter.
- # (Shamelessly) Edited by "Bloax" for a slight increase in speed (now), and some more or less stabilizing features.
- # With the old one I got ~30 FPS, with this one I get ~36 on the same source.
- # Enjoy!
- # A wild Long Read ambushes you!
- # Long Read uses TL;DR
- # It was super effective!
- # You fainted! ;p
- # "th_luma" and "th_chroma" Are the thresholds for detection. The lower they are, the more edges the script catches.
- # "th_luma" Is the threshold for luma edges and "th_chroma" is well, the threshold for color edges! [/ignorance]
- # "type" Is the matrix used for edge detection. Previously "Sobel" was the default, which only detected high-contrast edges.
- # Now I replaced it with "laplace", which seems smoother (and causes less visible aliasing).
- # "aath" Is the anti-aliasing strenght. The default value should be fine.
- # Set it too low, and you'll get a blocky image (due to initial upscaling to reduce the aliasing).
- # Too high and well, nothing really. 4096 Seems to look pretty much like 64.
- # >Now it should basically be the 'strength' of the filter. More or less.
- # "sx" And "sy" are the scaling multipliers (..BilinearResize(m4(ox>>*sx<<)..).
- # Set it too low, and the SangNom artifacts start showing up. Too high, and it starts getting blocky. (Upscaling, again.)
- # Though it all depends on the source, for highly aliased and thick images higher values may be better.
- # Games with their broad aliasing (eg. Walls), however. Benefit from lower values. Don't go below 1 though! ;)
- # Note: This is the biggest factor in speed.
- # "sharpness" Defines the final sharpness of the /antialiasing/ once it gets scaled down again.
- # Set it too low, and things get a bit smeared (bad for text). Too high, and well, the antialiasing is pretty much lost.
- # Do note that "sharpness" is just the "p" value of GaussResize. :-)
- # "blockx" And "blocky" are the block sizes for MAnalyse, higher values are faster.
- # What exactly lower values offer over the larger I can't notice. The speed reduction is obvious though. ;P
- # 16 Actually seems to give the best visual results.
- # "superfilter" Is the smoothening filter for MSuper, I can't really notice the difference.
- # Messing around with it is welcome.
- # "tempradius" Is the frame search field for TemporalSoften, which is there to stabilize the antialiased edges.
- # Higher values are slightly more stable, a bit slower and produce more slightly more artifacts. :o
- th_luma = Default(th_luma, 10)
- th_chroma = Default(th_chroma, 10)
- type = Default(type, "laplace")
- aath = Default(aath, 64)
- ox = orig.width
- blockx = Default(blockx, 16)
- blocky = Default(blocky, 16)
- superfilter = Default(superfilter, 4)
- oy = orig.height
- sx = Default(sx, 1.25)
- sy = Default(sy, 1.25)
- sharpness = Default(sharpness, 66)
- tempradius = Default(tempradius, 1)
- clp = orig.IsYV12() ? orig : orig.ConvertToYV12()
- a=clp
- b=clp.BilinearResize(m4(ox*sx),m4(oy*sy)).TurnLeft().SangNom(aa=aath).TurnRight().SangNom(aa=aath) \
- .GaussResize(ox,oy,p=sharpness).TemporalSoften(tempradius,round(th_luma*1.5),round(th_chroma*1.25),mode=2)
- 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.
- d=clp.EdgeMask(th_luma,th_luma,th_chroma,th_chroma,type)
- e=MSuper(a,pel=1,rfilter=superfilter)
- # Starting the MVTools2 stuff.
- f=MAnalyse(e,blockx,blocky,search=2,isb=true,delta=1,overlap=2,levels=3)
- # Forward motion vector search.
- g=MAnalyse(e,blockx,blocky,search=2,isb=false,delta=1,overlap=2,levels=3)
- # Backward motion vector search. (What else!)
- h=MDeGrain1(b,e,g,f,thSAD=1024/aath)
- # Degraining the antialiased result based on motion vectors from the original. Higher aath means more stuff is affected.
- i=MaskedMerge(b,h,d)
- # Merging the antialiased result with a MDeGrained original. On the edges.
- j=MaskedMerge(a,b,d)
- # Merging the original with the antialiased one. On the edges. (See d=clp..)
- k=MaskedMerge(j,i,c)
- # Merging the AA'd+MDGrained with the AA'd+Original. On the motion (edges??).
- MaskedMerge(k,h,c)
- # MDeGrain + MotionMask seems pretty awesome. The stabilization certainly benefits from it.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement