Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Anti-aliasing with contra-sharpening by Didee, modded by Terranigma for nnedi and by thetoof for merge
- function daa(clip c) {
- dbl = merge(c.nnedi3(1),c.nnedi3(0))
- dblD = mt_makediff(c,dbl,U=3,V=3)
- shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
- DD = shrpD.repair(dblD,13)
- return dbl.mt_adddiff(DD,U=3,V=3)
- }
- # Anti-aliasing with contra-sharpening by Didee
- FUNCTION daa_orig(clip c) {
- nn = c.nnedi3(field=-2)
- dbl = mt_average(selecteven(nn),selectodd(nn),U=3,V=3)
- dblD = mt_makediff(c,dbl,U=3,V=3)
- shrpD = mt_makediff(dbl,dbl.removegrain((width(c)>1100) ? 20 : 11),U=3,V=3)
- DD = shrpD.repair(dblD,13)
- return dbl.mt_adddiff(DD,U=3,V=3)
- }
- # Suggested by Mystery Keeper in "Denoise of tv-anime" thread
- function ediaa(clip a) {
- return a.EEDI2(field=1).TurnRight().EEDI2(field=1).TurnLeft().spline36resize(a.width,a.height,-0.5,-0.5,2*a.width+.001,2*a.height+.001)
- }
- # Anti-aliasing with edge masking by martino, mask using "sobel" taken from Kintaro's useless filterscripts and modded by thetoof for spline36
- function maa(clip input, int "mask") {
- mask = input.mt_edge("sobel",7,7,5,5).mt_inflate()
- aa_clip=input.spline36Resize(width(input)*2,height(input)*2).TurnLeft().SangNom().TurnRight().SangNom().spline36Resize(width(input),height(input)).MergeChroma(input)
- return mt_merge(input,aa_clip,mask)
- }
- # Developped in the "fine anime antialiasing thread"
- function SharpAAMCmod(clip orig, int "aastr", float "ds", int "ShPre", int "ShPost", int "SmPost", bool "MC", bool "MT", int "tradius", int "pel", int "ov", int "blk", string "aatype")
- {
- aastr = default ( aastr, 255 ) # antialiasing strength
- ds = default ( ds, 0.2 ) # strokes darkening strength
- ShPre = default ( ShPre, 80 ) # Presharpening
- ShPost = default ( ShPost, 300 ) # Postsharpening
- SmPost = default ( SmPost, 100 ) # Postsmoothing
- MC = default ( MC, true ) # Use post stabilization with Motion Compensation
- MT = default ( MT, true ) # Use josey_wells' branch of MVTools
- Tradius = default ( Tradius, 2 ) # 2 = MVDegrain2 / 3 = MVDegrain3 /// 28 = MVDegrain 28
- assert(mt || tradius<4, "You must use MT=true with josey_wells' branch of MVTools to use a higher tradius than 3")
- pel = default ( pel, 1 ) # accuracy of the motion estimation (Value can only be 1, 2 or 4. 1 means a precision to the pixel. 2 means a precision to half a pixel, 4 means a precision to quarter a pixel, produced by spatial interpolation (better but slower).)
- ov = default ( ov, 4 ) # block overlap value (horizontal). Must be even and less than block size. (Higher = more precise & slower)
- blk = default ( blk, 8 ) # Size of a block (horizontal). It's either 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.
- aatype = default ( aatype, "Sangnom" ) # Use Sangnom() or EEDI2() for anti-aliasing
- w=width(orig)
- h=height(orig)
- m=logic( orig.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=4,Y=3,U=3,V=3)
- \ ,orig.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=4,Y=3,U=3,V=3)
- \ ,"max").greyscale().levels(0,0.8,128,0,255,false)
- preaa=(ShPre==0 && ds==0) ? orig : (ShPre==0) ? orig.Toon(ds) : (ds==0) ? orig.Warpsharp(depth=ShPre) : orig.Toon(ds).Warpsharp(depth=ShPre)
- aa= (aatype=="Sangnom") ? preaa.spline36resize(w*2,h*2).TurnLeft().SangNom(aa=aastr).TurnRight().SangNom(aa=aastr).spline36resize(w,h) : (aatype=="EEDI2") ? preaa.ediaa() : blankclip(pixel_type="YV12").subtitle("Please use Sangnom or EEDI2 for aatype")
- postsh=(ShPost==0 && SmPost==0) ? aa : aa.LimitedSharpenFaster(edgemode=1,strength=ShPost,overshoot=1,soft=SmPost)
- merged=mt_merge(orig,postsh,m,Y=3,U=3,V=3)
- sD=mt_makediff(orig,merged)
- fv3 = orig.MVAnalyse(isb=false,delta=3,pel=pel,overlap=ov,blksize=blk,idx=21)
- fv2 = orig.MVAnalyse(isb=false,delta=2,pel=pel,overlap=ov,blksize=blk,idx=21)
- fv1 = orig.MVAnalyse(isb=false,delta=1,pel=pel,overlap=ov,blksize=blk,idx=21)
- bv1 = orig.MVAnalyse(isb=true, delta=1,pel=pel,overlap=ov,blksize=blk,idx=21)
- bv2 = orig.MVAnalyse(isb=true, delta=2,pel=pel,overlap=ov,blksize=blk,idx=21)
- bv3 = orig.MVAnalyse(isb=true, delta=3,pel=pel,overlap=ov,blksize=blk,idx=21)
- allv = mt ? orig.MVAnalyseMulti(refframes=tradius,pel=pel,overlap=ov,blksize=blk,idx=21) : nop()
- fiz = (tradius==1) ? sD.MVDegrain1(bv1,fv1,idx=22) : (tradius==2) ? sD.MVDegrain2(bv1,fv1,bv2,fv2,idx=22) : (tradius==3) ? sD.MVDegrain3(bv1,fv1,bv2,fv2,bv3,fv3,idx=22) : blankclip(pixel_type="yv12").subtitle("You must use MT=true with josey_wells' branch of MVTools to use a higher tradius than 3")
- sDD = (MT) ? sD.MVDegrainMulti(allv,idx=22) : fiz
- reduc = 0.4
- sDD = mt_lutxy(sD,sDD,"x 128 - abs y 128 - abs < x y ?").mergeluma(sDD,1.0-reduc)
- return MC ? orig.mt_makediff(sDD,U=2,V=2) : merged
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement