Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#41 | Link | |
Registered User
Join Date: Apr 2005
Posts: 213
|
I've changed the posted function santiag a little bit.
Santiag has now three parameters: type, strh and strv. Type means the anti aliasing type. Possible values are "EEDI3", "NNEDI2" and "NNEDI3". strh is the strength for the horizontal anti aliasing and strv is the strength for the vertical anti aliasing. Default values are: type="nnedi3", strh=1 and strv=1. Contrary to the first posted function, santiag(strh=0, strv=0) now means no anti aliasing. I've also corected the center shift. With NNEDI3 as type, the center shift now works correct for all possible input clips (YV12, YUY2 and RGB24). Requirements: Code:
LoadPlugin("plugins\EEDI3\eedi3.dll") LoadPlugin("plugins\GScript\GScript.dll") LoadPlugin("plugins\NNEDI2\nnedi2.dll") LoadPlugin("plugins\NNEDI3\nnedi3.dll") Code:
function SantiagMod(clip input, string "type", int "strh", int "strv") { type = Default(type, "NNEDI3") strh = Default(strh, 1) strv = Default(strv, 1) input strh > 0 ? AntiAliasing(type=type, strength=strh) : NOP() TurnLeft() strv > 0 ? AntiAliasing(type=type, strength=strv) : NOP() TurnRight() function AntiAliasing(clip input, string "type", int "strength") { input GScript(""" if (type == "EEDI3") { EEDI3(dh=True, field=0) for (i = 2, strength) { EEDI3(dh=False, field=(i + 1) % 2) } } else if (type == "NNEDI2") { NNEDI2(dh=True, field=0) for (i = 2, strength) { NNEDI2(dh=False, field=(i + 1) % 2) } } else { NNEDI3(dh=True, field=0) for (i = 2, strength) { NNEDI3(dh=False, field=(i + 1) % 2) } } """) Spline36Resize(input.Width(), input.Height(), 0, 0.5, input.Width(), input.Height() * 2) } } Quote:
Source: ![]() santiag(strh=2, strv=0): ![]() santiag(strh=0, strv=2): ![]() Last edited by Archimedes; 22nd July 2010 at 22:14. |
|
![]() |
![]() |
![]() |
#42 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,430
|
OK, I understand your terminology now.
I was confused because I saw that strh affected vertical resampling and strv horizontal resampling. However, by horizontal anti-aliasing, I think you mean fix (near-)horizontal lines, which requires vertical resampling, and vice versa. Correct? The code can actually be simplified a bit. The Evals are redundant and, since string comparison is case insensitive, there is no need to convert the type string to upper case. In santiag_dir and santiag_stronger, 'type' and 'strength' should not really be in quotes, since they are not optional parameters there. For example, santiag_stronger could be rewritten (according to taste) as Code:
function santiag_stronger(clip c, string type, int strength) { c type == "EEDI3" ? \ (strength <= 1) ? EEDI3(dh=true, field=0) : santiag_stronger(type=type, strength=strength - 1).EEDI3(dh=false, field=(strength + 1) % 2) \ : \ type == "NNEDI2" ? \ (strength <= 1) ? NNEDI2(dh=true, field=0) : santiag_stronger(type=type, strength=strength - 1).NNEDI2(dh=false, field=(strength + 1) % 2) \ : \ type == "NNEDI3" ? \ (strength <= 1) ? NNEDI3(dh=true, field=0) : santiag_stronger(type=type, strength=strength - 1).NNEDI3(dh=false, field=(strength + 1) % 2) \ : NOP() last } |
![]() |
![]() |
![]() |
#43 | Link | |
Registered User
Join Date: Apr 2005
Posts: 213
|
Quote:
In the meanwhile, I have changed the function again. Now it is an iterative (non recursive) function, called "SantiagMod". It is easier to unterstand than the recursive function. This version looks also more pleasant to me. ![]() Last edited by Archimedes; 23rd July 2010 at 10:58. |
|
![]() |
![]() |
![]() |
#46 | Link |
Beyond Kawaii
Join Date: Feb 2008
Location: Russia
Posts: 724
|
I'm glad that script we assembled is still being improved. But let me remind you the original idea behind it.
I needed a script that would:
Now what the hell with all the interpolators? I used to use EEDI2 for antialiasing real video. Really smoothes some lines, but also blures the picture. In this script Sangnom did just as good as EEDI2, worked twice as fast and didn't introduce a shift like EEDI2 does. So I just threw EEDI2 out of it, it really wasn't needed. But in your script I see all kind of edge-directed interpolators. Apart from EEDI2 they are all quite sharp. They don't do any antialiasing at all. Look at the small AA functions you use. They all use Sangnom. I suggest you take out EDIs from your script at least for the sake of stopping confusing newcomers, making them think that EDIs are good for antialiasing.
__________________
...desu! |
![]() |
![]() |
![]() |
#47 | Link |
Please, DeInterlace me!
Join Date: Jan 2007
Location: Portugal, Porto
Posts: 81
|
I've share the last version of it. Topic updated! I'll in the future try to update more, and do some new stuff.
Cheers
__________________
Who am I?! I'm GOD... 8for it... father of my godchilds. |
![]() |
![]() |
![]() |
#48 | Link |
Registered User
Join Date: Dec 2011
Posts: 4
|
I've been trying to add AA to screenshots/videos from an old XBox game, and though LSharpAAF certainly makes things easier I could still use some help in getting good results. The XBox game in question is called Panzer Dragoon Orta, and I'm currently running it from an Xbox360 (the Xbox360 is capable of emulating certain original Xbox games, this is one of them). I'm capturing the game over HDMI in 720P, and I assume the XBox360 is simply upscaling the image since the original game didn't run in HD resolutions. So basically this is what I'm getting:
Screenshot 1 Screenshot 2 From what I've tried on these images LSharpAAF(aatype="eedi3") seems to deliver the best results: Screenshot 1 - EEDI3 Screenshot 2 - EEDI3 But given how little I know about all these AA methods being used I though someone here might be able to help me get better results. Any help would be appreciated. |
![]() |
![]() |
![]() |
#49 | Link |
The speed of stupid
Join Date: Sep 2011
Posts: 317
|
Does the whole game look like that?
If so, let me cook something alternate up. Meanwhile: Code:
TurnRight() Merge(SangNom(0,255).SangNom(1,255),Merge(SangNom(1,255),SangNom(0,255),0.5),0.25) TurnLeft() Edit: And if that's how it looks, here's another: Code:
PointResize(Width/2,Height/2) TurnRight() Merge(SangNom(0,255),SangNom(1,255),0.5) TurnLeft() NNEDI3_rpow2(2,0,0,1).SangNom(0,255) Last edited by Bloax; 1st January 2012 at 13:35. |
![]() |
![]() |
![]() |
#50 | Link |
Registered User
Join Date: Dec 2011
Posts: 4
|
Thanks Bloax. This is basically how the game looks yes, although I uploaded some actual gameplay footage here.
The second script does seem to deal with the aliasing nicely, although it also softens the image more, which I understand is somewhat inevitable when adding anti-aliasing. Here's a comparison, from left to right is the original, LSharpAAF(aatype=eedi3), your first and then second script. I didn't notice it at first but eedi3 does something weird to the background as well. The last script seems to lose a bit more detail than I'd like. An unfortunate side-effect is also that the game has subtitles at some points and your two scripts seem to add artifacts to those... |
![]() |
![]() |
![]() |
#52 | Link | |
Registered User
Join Date: Dec 2011
Posts: 4
|
Quote:
|
|
![]() |
![]() |
![]() |
#53 | Link |
The speed of stupid
Join Date: Sep 2011
Posts: 317
|
This script really is only "usable" for this. Which is aliased and upscaled stuff.
Anything else, and it wrecks it. No exaggeration. I think it's a bit overkill by now. (Way, way overkill - to be exact.) ;P Edit: Updated to look cool now. Code:
orig = last msk=RAverageW(last,32,last.RemoveGrain(19,-1),-32,u=0,v=0,sse=8,bias=-255).RemoveGrain(4,-1).Mt_Deflate() PointResize(Width/2,Height/2) NNEDI3(0,true,true,true,true,0,0,1).PointResize(Width,Height) TurnLeft() Merge(SangNom(1,30),SangNom(0,30),0.5) TurnRight() NNEDI3_rpow2(2,0,0,1) TurnRight().SangNom(0,64).TurnLeft() RMerge(last,orig,msk) RemoveGrain(2) # Fixing up stuff Code:
PointResize(Width/2,Height/2) TurnLeft() Merge(SangNom(1,30),SangNom(0,30),0.5) TurnRight() Hm, actually. Let me see if I can fix it up. (Seems like parameter overkill.) Edit: Woop! Be careful with them SangNom settings kids, they're daaangerous. Anyways, fixed to look like a cool inflation-antialias instead of the uncool holey mess it was. Last edited by Bloax; 1st January 2012 at 18:40. |
![]() |
![]() |
![]() |
#54 | Link |
Registered User
Join Date: Dec 2011
Posts: 4
|
Thanks Bloax, I have no idea what the first script does but the results seem to look good
![]() |
![]() |
![]() |
![]() |
#59 | Link |
Anime addict
Join Date: Feb 2009
Location: Spain
Posts: 673
|
Hi, using mod by Dogway I have updated this filter: https://dl.dropboxusercontent.com/u/...arpAAF2.00.zip
Updates:
Dependencies:
__________________
Intel i7-6700K + Noctua NH-D15 + Z170A XPower G. Titanium + Kingston HyperX Savage DDR4 2x8GB + Radeon RX580 8GB DDR5 + ADATA SX8200 Pro 1 TB + Antec EDG750 80 Plus Gold Mod + Corsair 780T Graphite Last edited by Overdrive80; 9th April 2015 at 01:20. |
![]() |
![]() |
![]() |
#60 | Link |
Registered User
Join Date: Feb 2005
Location: Ukraine, Lviv
Posts: 121
|
@Overdrive80
LSharpAAF(aatype="maa2") - it doesn't work. I get "Only YV12 colorspace is supported" and errors in 490, 439, 132 lines Sure my source is in YV12 colorspace. I'm using my own modification of LSharpAAF to use maa2 and it work as it should. I've used official 1.50 version to modify. Code:
# LSharpAAF() by Leinad4Mind # v1.60 updated in 2015-03-23 by Great Dragon # Requirements: awarpsharp2; EEDI2.dll; FastLineDarkenMOD.avsi; LSFmod.v1.9.avsi; MaskTools.dll; mt_masktools-26.dll; mvtools.dll; # nnedi2.dll; RemoveGrain*.dll; Repair*.dll; SangNom.dll; UnFilter.dll # * HD; HDS; S; SSE2; SSE3; T; TSSE2; TSSE3 # # All AA Scripts are in this script, so there are no need to download them separately; Except some of them that you can find in AnimeIVTC, as maa, daa. # # This is an Anti-Aliasing Combo with some Extras like FastLineDarkenMOD, Presharpening, Postsharpening and Postsmoothing # # Thanks to @ Didйe, thetoof, Mystery Keeper, Soulhunter, MisterHatt, martino, mf, Akirasuto, SpikeSpiegel, ScharfisBrain, LaTo & Sagekilla # # Example: LSharpAAF(StrDrk=18, ShPre=100, ShPost=280, SmPost=80, aatype="ediaa") # OR: LSharpAAF(18,100,280,80,"ediaa") FUNCTION LSharpAAF(clip a, int "StrDrk", int "ShPre", int "ShPost", int "SmPost", bool "stabilize", int "tradius", bool "MT", int "aapel", int "aaov", int "aablk", string "aatype"){ StrDrk = default(StrDrk,38) #FastLineDarkenMOD ShPre = default(ShPre,18) #Presharpening ShPost = default(ShPost,300) #Postsharpening SmPost = default(SmPost,100) #Postsmoothing stabilize= default(stabilize,false ) # Use post stabilization with Motion Compensation tradius = default(tradius,2) # 2 = MDegrain2 / 3 = MDegrain3 MT=default(MT,false) # Use josey_wells' branch of MVTools aapel = default(aapel,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).) aaov = default ( aaov,(a.width>1100) ? 8 : 4 ) # block overlap value (horizontal). Must be even and less than block size. (Higher = more precise & slower) aablk = default ( aablk,(a.width>1100) ? 16 : 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,"EEDI2") # Use EEDI2() ; EEDI3() ; Sangnom() ; maa() ; daa() ; ediaa() ; aaa() ; saa() ; splinaa() ; supaa() ; naa() ; shaarp() ; aaf() ; laa() ; nnedi() ; nnedi2() ; nnedi3() ; antialiasing() ; nediaa() ; naa3mod(); for anti-aliasing. a=a.AssumeTFF() w=width(a) h=height(a) m=mt_logic(a.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=4,Y=3,U=3,V=3) \ ,a.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=4,Y=3,U=3,V=3) \ ,"max").mt_lut("x 128 / 0.86 ^ 255 *") preaa=(ShPre==0 && StrDrk==0) ? a : (ShPre==0) ? a.fastlinedarkenmod(thinning=0, strength=StrDrk) : (StrDrk==0) ? a.lsfmod(defaults="slow",preblur="ON",strength=ShPre) \ : a.fastlinedarkenmod(thinning=0, strength=StrDrk).lsfmod(defaults="slow",preblur="ON",strength=ShPre) aa=(aatype=="EEDI2") ? preaa.TurnLeft().EEDI2().TurnRight().EEDI2().spline36resize(w,h,0.5,-0.5,2*w+.001,2*h+.001) \ : (aatype=="EEDI3") ? preaa.TurnLeft().EEDI3().TurnRight().EEDI3().spline36resize(w,h) \ : (aatype=="Sangnom") ? preaa.spline64resize(w*2,h*2).TurnLeft().SangNom(aa=255).TurnRight().SangNom(aa=255).spline36resize(w,h) \ : (aatype=="maa") ? preaa.maa() : (aatype=="daa") ? preaa.daa() : (aatype=="ediaa") ? preaa.ediaa() : (aatype=="aaa") ? preaa.aaa() \ : (aatype=="saa") ? preaa.SAA() : (aatype=="splinaa") ? preaa.splinaa() : (aatype=="supaa") ? preaa.supaa() : (aatype=="naa") ? preaa.naa() \ : (aatype=="shaarp") ? preaa.shaarp() : (aatype=="aaf") ? preaa.aaf(aam=-0.7,rep=true) : (aatype=="laa") ? preaa.laa(96, 10, true, 2.0) \ : (aatype=="nnedi") ? preaa.NNEDI(dh=true,field=1).TurnRight().NNEDI(dh=true,field=1).TurnLeft().Spline36Resize(w,h) \ : (aatype=="nnedi2") ? preaa.NNEDI2(dh=true,field=1,nsize=2,qual=2).TurnRight().NNEDI2(dh=true,field=1,nsize=2,qual=2).TurnLeft().Spline36Resize(w,h,0.5,-0.5,2*w+.001,2*h+.001) \ : (aatype=="nnedi3") ? preaa.NNEDI3(dh=true,field=1,nsize=2,qual=2).TurnRight().NNEDI3(dh=true,field=1,nsize=2,qual=2).TurnLeft().Spline36Resize(w, h) \ : (aatype=="antialiasing") ? preaa.antialiasing() \ : (aatype=="maa2") ? preaa.maa2() \ : blankclip(pixel_type="YV12").subtitle("Please use Sangnom, EEDI2, EEDI3, maa, daa, ediaa, aaa, ssa, splinaa, supaa, naa, shaarp, aaf, laa, nnedi, nnedi2, nnedi3, or antialiasing for aatype") postsh=(ShPost==0 && SmPost==0) ? aa : aa.LimitedSharpenFaster(edgemode=1,strength=ShPost,overshoot=1,soft=SmPost) merged=mt_merge(a,postsh,m,Y=3,U=3,V=3) sD=mt_makediff(a,merged) asuper= a.MSuper(pel=aapel) sDsuper = sD.MSuper(pel=aapel, levels=1) fv1 = tradius>=1 ? asuper.MAnalyse(isb=false,delta=1,overlap=aaov,blksize=aablk) : nop() bv1 = tradius>=1 ? asuper.MAnalyse(isb=true, delta=1,overlap=aaov,blksize=aablk) : nop() fv2 = tradius>=2 ? asuper.MAnalyse(isb=false,delta=2,overlap=aaov,blksize=aablk) : nop() bv2 = tradius>=2 ? asuper.MAnalyse(isb=true, delta=2,overlap=aaov,blksize=aablk) : nop() fv3 = tradius==3 ? asuper.MAnalyse(isb=false,delta=3,overlap=aaov,blksize=aablk) : nop() bv3 = tradius==3 ? asuper.MAnalyse(isb=true, delta=3,overlap=aaov,blksize=aablk) : nop() _thSAD = 600 _idx = 13 mbv1 = a.MVAnalyse(isb=true, delta=1,idx=_idx) mbv2 = a.MVAnalyse(isb=true, delta=2,idx=_idx) mfv2 = a.MVAnalyse(isb=false,delta=2,idx=_idx) mfv1 = a.MVAnalyse(isb=false,delta=1,idx=_idx) allv = (MT==false) ? a : a.MVAnalyseMulti(refframes=tradius,idx=_idx) sDD = (MT) ? sD.MVDegrainMulti(allv,idx=14) : sD.MVDegrain2(mbv1,mfv1,mbv2,mfv2,idx=14) sDD2 = tradius==1 ? sDD.MDegrain1(sDsuper,bv1,fv1,thSAD=_thSAD) : tradius==2 ? sDD.MDegrain2(sDsuper,bv1,fv1,bv2,fv2,thSAD=_thSAD) \ : sDD.MDegrain3(sDsuper,bv1,fv1,bv2,fv2,bv3,fv3,thSAD=_thSAD) reduc = 0.4 sDD2 = mt_lutxy(sD,sDD2,"x 128 - abs y 128 - abs < x y ?").mergeluma(sDD2,1.0-reduc) return stabilize ? a.mt_makediff(sDD2,U=2,V=2) : merged } #Simple Anti-aliasing by Soulhunter FUNCTION saa(Clip Clp,Int"SS",Bool"CP") { OX = Clp.Width OY = Clp.Height SS = Default(SS,2) CP = Default(CP,True) Clp = Clp.IsYV12() ? Clp : Clp.ConvertToYV12() Clp.PointResize(OX*SS,OY*SS).SangNom().TurnRight() \ .SangNom().TurnLeft().BilinearResize(OX,OY) CP ? Last : MergeChroma(Clp) Return(Last) } #Normal Anti-aliasing by Didйe FUNCTION antialiasing(clip orig,int "th_luma",int "th_croma",string "type",int "aath") { # "th_luma" & "th_croma" are the edge detection thres.: lower values=more edges filtered # "type" is the matrix used for edge detection: with "sobel" (default) only the # hi-contrast edges, where artefacts are more noticeable, are filtered. If you want # to test other matrices, read the MaskTools Guide for more info. # "aath" = anti-aliasing strenght (default should be fine) th_luma = Default(th_luma, 20) th_croma = Default(th_croma, 20) type = Default(type, "sobel") aath = Default(aath, 48) ox = orig.width oy = orig.height dx = orig.width * 2 dy = orig.height * 2 clp = orig.IsYV12() ? orig : orig.ConvertToYV12() a=clp b=clp.Lanczos4Resize(dx,dy).TurnLeft().SangNom(aa=aath).TurnRight().SangNom(aa=aath) \ .LanczosResize(ox,oy) c=clp.EdgeMask(th_luma,th_luma,th_croma,th_croma,type) MaskedMerge(a,b,c) } # Written by MisterHatt, based off of Soulhunter's SAA() and martino's excellent MAA(), and is slightly # faster at times for some reason or another. These functions work by generally supersampling, usually with # nnedi2, and then running a deinterlacer (sangnom and nnedi2 respectively) to get rid of most jaggies. # I have no idea how destructive these are on whatever random thing people care to throw them at. # For large supersamples, avs2yuv bitches for no real reason and requires assumeframebased() in your script. # Requires nnedi2, sangnom, o9k hours of your life. FUNCTION splinaa(Clip Clp,Int"SS",Bool"CP") { OX = Clp.Width OY = Clp.Height SS = Default(SS,2) CP = Default(CP,True) Clp = Clp.IsYV12() ? Clp : Clp.ConvertToYV12() Clp.PointResize(OX*SS,OY*SS).SangNom().TurnRight() \ .SangNom().TurnLeft().Spline36Resize(OX,OY) CP ? Last : MergeChroma(Clp) Return(Last) } FUNCTION supaa(Clip Clp,Int"SS",Bool"CP") { OX = Clp.Width OY = Clp.Height SS = Default(SS,2) CP = Default(CP,True) Clp = Clp.IsYV12() ? Clp : Clp.ConvertToYV12() Clp.nnedi2_rpow2(rfactor=SS,cshift="spline36resize",qual=3).SangNom().TurnRight() \ .SangNom().TurnLeft().Spline36Resize(OX,OY) CP ? Last : MergeChroma(Clp) Return(Last) } FUNCTION naa(Clip Clp,Int"SS",Bool"CP") { OX = Clp.Width OY = Clp.Height SS = Default(SS,2) CP = Default(CP,True) Clp = Clp.IsYV12() ? Clp : Clp.ConvertToYV12() Clp.nnedi3_rpow2(rfactor=SS,cshift="spline36resize",qual=2).nnedi3(nns=2).TurnRight().nnedi3(nns=2).TurnLeft().Spline36Resize(OX,OY) CP ? Last : MergeChroma(Clp) Return(Last) } FUNCTION shaarp(clip input, int "mask", int "type") { mask = Default(mask,1) type = Default(type,1) Assert(mask == 1 || mask == 2, "Please use mask = 1 or 2") Assert(type == 1 || type == 2, "Please use type = 1 or 2") aa_clip = (type == 1) ? input.spline36Resize(width(input)*2,height(input)*2) : input.nnedi2_rpow2(rfactor=2,qual=3) aa_clip = aa_clip.TurnLeft().nnedi2().TurnRight().nnedi2().spline36Resize(width(input),height(input)).MergeChroma(input) mask = (mask==1) ? input.mt_edge("sobel",7,7,5,5).mt_inflate() : input.mt_edge("roberts",0,4,0,4).mt_inflate() return mt_merge(input,aa_clip,mask) } function aaf(clip input, float "aam", int "aay", "aax", bool "rep") { input = input.isYV12() ? input : input.converttoyv12() aam = default(aam, -0.6) aar = aam<0 ? (aam-1)*0.25 : (aam+1)*0.25 aay = default(aay, 28) aax = default(aax, aay) rep = default(rep, true) sx = width(input) sy = height(input) aa = aar<0 ? input.LanczosResize(sx,int(sy*abs(aar))*4) : \ aar==0.5 ? input.Pointresize(sx*2, sy*2) : \ input.LanczosResize(int(sx*abs(aar)*4),int(sy*abs(aar))*4) aa = aay>0 ? aa.SangNom(aa=aax) : input aa = aar<0 && aax>0 ? aa.LanczosResize(int(sx*abs(aar))*4,sy) : aa aa = aax>0 ? aa.turnright().SangNom(aa=aax).Turnleft() : aa aa = aa.LanczosResize(sx,sy) return rep==true ? aa.repair(input,18) : aa } ### LaTo Antialiasing Script v2 ### Need: asharp.dll & sangnom.dll function LAA(clip input, int "strength", int "threshold", bool "sharp", float "ss") { strength = default(strength, 96) threshold = default(threshold, 10) sharp = default(sharp, true) ss = default(ss, 2.0) aastr = int(strength) /2 asthr = float(strength) /100 ox = input.width oy = input.height ox2 = round(ox*ss/8)*8 oy2 = round(oy*ss/8)*8 process = input.spline36resize(ox2,oy2).turnleft().sangnom(aastr).turnright().sangnom(aastr) process = ( sharp == true ) ? process.asharp(asthr,0,0).spline36resize(ox,oy) : process.spline36resize(ox,oy) mask = mt_average(input,process,u=1,v=1).mt_edge(thy1=threshold,thy2=threshold,u=1,v=1) output = mt_merge(input,process,mask,u=2,v=2) return ( output ) } function NediAA(clip c) { c.nnedi3(field=-2) merge(selecteven(),selectodd()) } FUNCTION naa3mod(Clip Clp,Bool "CP") { OX = Clp.Width() OY = Clp.Height() CP = Default(CP,True) Clp = Clp.IsYV12() ? Clp : Clp.ConvertToYV12() Clpnn1 = Clp.nnedi3(1, dh=true,nsize=2,qual=2,U=CP,V=CP).nnedi3(0,nsize=2,qual=2,U=CP,V=CP) Clpy1 = Clpnn1.Spline36Resize(OX,OY,0,-0.5,OX,OY*2) Clps1 = CP ? Clpy1.MergeChroma(Clpnn1.Spline36Resize(OX,OY,0,-1,OX,OY*2)) : Clpy1.MergeChroma(Clp) Clpnn2 = Clps1.turnright().nnedi3(1, dh=true,nsize=2,qual=2,U=CP,V=CP).nnedi3(0,nsize=2,qual=2,U=CP,V=CP) Clpy2 = Clpnn2.Spline36Resize(OY,OX,0,-0.5,OY,OX*2) CP ? Clpy2.MergeChroma(Clpnn2.Spline36Resize(OY,OX,0,-1,OY,OX*2)).turnleft() : Clpy2.turnleft().MergeChroma(Clp) Return(Last) } function maa2(clip c, int "mask", bool "chroma", float "ss", int "aa", int "aac", int "threads", int "show", int "maskt") { chroma = Default(chroma, false) mask = Default(mask, 1) maskt = Default(maskt, 1) mtresh = (mask < 0) ? -mask : 7 show = Default(show, 0) uv = (chroma) ? 3 : 1 Assert(c.IsY8 || c.IsYV12 || c.IsYV24 || c.IsYV16, "MAA2: Input must be Y8, YV12, YV16 or YV24") Assert(0 <= show <= 2, "MAA2: Parameter 'show' must be between 0 and 2") # create mask if (mask != 0) { m = (maskt != 1) ? c.mt_edge("min/max", 0, mtresh, 0, mtresh-6, u=uv, v=uv).mt_inflate(u=uv, v=uv) : c.mt_edge("sobel", mtresh, mtresh, mtresh-6, mtresh-6, u=uv, v=uv).mt_inflate(u=uv, v=uv) } # run sangnom2-based aa if (!chroma || show > 0) { c_aa = c.ConvertToY8().Sangnom2AA(ss, aa, threads=threads) } else if (c.IsYV16) { c_aa_u = c.UtoY8().Sangnom2AA(ss, aac, threads=threads) c_aa_v = c.VtoY8().Sangnom2AA(ss, aac, threads=threads) c_aa = YToUV(c_aa_u, c_aa_v, c.ConvertToY8().Sangnom2AA(ss, aa, threads=threads)) } else { c_aa = c.Sangnom2AA(ss, aa, aac, threads) } # prepare chroma planes for mask overlay if (show == 1) { c_aa = (c.IsY8) ? c.ConvertToYV12().mt_lut(y=2, u=0, v=0) \ : c.mt_lut("x 2 /", y=2, u=3, v=3) } else if (show == 2) { c_aa = (c.IsY8) ? c_aa.ConvertToYV12().mt_lut(y=2, u=0, v=0) \ : YtoUV(c.UtoY8(), c.VtoY8(), c_aa).mt_lut("x 2 /", y=2, u=3, v=3) } # merge aa'ed lines into source if (mask == 0) { return mt_logic(c_aa, "and", y=4, u=2, v=2) } else if (show > 0) { if (c.IsYV16) { m_uv = BilinearResize(m, m.width/2, m.height) return mt_merge(c, c_aa, YtoUV(m_uv, m_uv, m), u=3, v=3) } else { return (c.IsYV24) ? mt_merge(c, c_aa, m.YtoUV(m,m), u=3, v=3) \ : mt_merge(c.ConvertToYV12(), c_aa, m, u=3, v=3, luma=true) } } else { return (chroma) ? mt_merge(c, c_aa, m, u=3, v=3) \ : mt_merge(c, c_aa, m, u=2, v=2) } } function Sangnom2AA(clip c, float "ss", int "aa", int "aac", int "threads") { threads = Default(threads, 4) aa = Default(aa, 48) aac = Default(aac, aa-8) aac = (aac < 0) ? 0 : aac ss = Default(ss, 2.0) ss_w = int(round(c.width*ss/4.0)*4) ss_h = int(round(c.height*ss/4.0)*4) Assert(ss > 0, "MAA2: Supersampling factor must be > 0") return c.Spline36Resize(ss_w, ss_h).TurnLeft() \ .SangNom2(threads=threads, aa=aa, aac=aac).TurnRight().SangNom2(threads=threads, aa=aa, aac=aac).Spline36Resize(c.width, c.height) } Last edited by Great Dragon; 8th April 2015 at 21:50. |
![]() |
![]() |
![]() |
Tags |
antialiasing, fastlinedarken, lsf, lsharpaaf, sharpen |
Thread Tools | Search this Thread |
Display Modes | |
|
|