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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th April 2010, 23:36   #1  |  Link
Leinad4Mind
Please, DeInterlace me!
 
Leinad4Mind's Avatar
 
Join Date: Jan 2007
Location: Portugal, Porto
Posts: 81
LSharpAAF - AntiAliasing Combo

Another AntiAliasing Script. It's more a combo... a combination of all antialiasing I know.

And it has some Extras like FastLineDarkenMOD, Presharpening, Postsharpening and Postsmoothing.

It's very alike SharpAAMCmod...

It contains: Sangnom, EEDI2, maa, daa, ediaa, aaa, ssa, splinaa, supaa, naa, shaarp, aaf, nnedi, nnedi2 and antialiasing

Okay... I will post it... Here is the Code:
Code:
# LSharpAAF() by Leinad4Mind
# v1.50 updated in 2011-12-06
# 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()
\ : 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)
}
Here is all the require dll or extra functions: http://www.megaupload.com/?d=HQ7NLMW0

If u want to test it. Or improve the code, you're welcome
Attached Files
File Type: 7z LSharpAAF.v1.5.avsi.7z (4.0 KB, 1242 views)

Last edited by Leinad4Mind; 6th December 2011 at 22:37. Reason: Added v1.5
Leinad4Mind is offline   Reply With Quote
Old 6th April 2010, 23:43   #2  |  Link
Frank K Abbott
Registered User
 
Join Date: Mar 2010
Posts: 69
So this is an all-in-one anti-aliasing solution script? And how does it compare to other anti-aliasing methods that have been out?
Frank K Abbott is offline   Reply With Quote
Old 6th April 2010, 23:49   #3  |  Link
Leinad4Mind
Please, DeInterlace me!
 
Leinad4Mind's Avatar
 
Join Date: Jan 2007
Location: Portugal, Porto
Posts: 81
Well, it has 5 new methods: splinaa, supaa, naa, shaarp and aaf. And it's too an denoiser. You can apply sharpening and it has the LSFMod included to sharp and a line darkening to darken the lines as u wish.
And this AIO includes SAA by soulhunter and others antialiasing by didée that can be lost in some pages of doom9. So, this is good for everyone to not forget about the good AA we already have.

And I think it can be helpful. Because an AIO is always good. xD

Best Regards.

Last edited by Leinad4Mind; 13th May 2010 at 05:39.
Leinad4Mind is offline   Reply With Quote
Old 7th April 2010, 16:25   #4  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 299
Cool, all AA functions/filters in place.
markanini is offline   Reply With Quote
Old 8th April 2010, 03:05   #5  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
Damn, if only we could get x64 version of all the required plugins
osgZach is offline   Reply With Quote
Old 19th April 2010, 10:39   #6  |  Link
thanhtu5013
Registered User
 
Join Date: Jan 2009
Location: Lyon. France
Posts: 40
@Leinad4Mind.

I made my script and it works on VirtualDub and MeGui but unfortunately there has no effects in my video...
There has still a lot of aliasing...

Watch my screens.

- Original AVI :
http://img697.imageshack.us/img697/1...enoriginal.png

- My script :
http://img21.imageshack.us/img21/636...nretouched.png


My code:

Code:
AVISOURCE("C:\GTA IV_ENB Series 0.079 SORA  - 02 - It'S Your Call_1080p.avi")

FUNCTION LSharpAAF(clip orig, int "StrDrk", int "ShPre", int "ShPost", int "SmPost", string "aatype"){
StrDrk = default(StrDrk,38) #FastLineDarkenMOD
ShPre = default(ShPre,80) #Presharpening
ShPost = default(ShPost,300) #Postsharpening
SmPost = default(SmPost,100) #Postsmoothing
aatype = default(aatype,"EEDI2") # Use EEDI2() or Sangnom() or maa() or daa() or ediaa() or aaa() or saa() or splinaa() or supaa() or naa() or shaarp() or nnedi() or nnedi2() or antialiasing() for anti-aliasing.
a=orig.AssumeTFF()
w=width(a)
h=height(a)
m=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").greyscale().levels(0,0.8,128,0,255,false)
b=a.fastlinedarkenmod(thinning=0, strength=StrDrk)
 b=(aatype=="EEDI2") ? b.TurnLeft().EEDI2().TurnRight().EEDI2().spline64resize(w,h,0.5,-0.5,2*w+.001,2*h+.001) : (aatype=="Sangnom") ? b.spline36resize(w*2,h*2).TurnLeft().SangNom(aa=255).TurnRight().SangNom(aa=255).spline36resize(w,h) : (aatype=="maa") ? b.maa() : (aatype=="daa") ? b.daa() : (aatype=="ediaa") ? b.ediaa() : (aatype=="aaa") ? b.aaa() : (aatype=="saa") ? b.SAA() : (aatype=="splinaa") ? b.splinaa() : (aatype=="supaa") ? b.supaa() : (aatype=="naa") ? b.naa() : (aatype=="shaarp") ? b.shaarp() : (aatype=="nnedi") ? b.NNEDI(dh=true,field=1).TurnRight().NNEDI(dh=true,field=1).TurnLeft().Spline36Resize(w,h) : (aatype=="nnedi2") ? b.nnedi2(dh=true,field=1) : (aatype=="antialiasing") ? b.antialiasing() : blankclip(pixel_type="YV12").subtitle("Please use Sangnom, EEDI2, maa, daa, ediaa, aaa, ssa, splinaa, supaa, naa, shaarp, nnedi, nnedi2 or antialiasing for aatype")
b=b.LSFMod(edgemode=1,strength=ShPost,overshoot=1,soft=SmPost)
mt_merge(a,b,m,Y=3,U=3,V=3)
sD=mt_makediff(a,last)
bv1 = a.MVAnalyse(isb=true, delta=1,idx=13)
bv2 = a.MVAnalyse(isb=true, delta=2,idx=13)
fv2 = a.MVAnalyse(isb=false,delta=2,idx=13)
fv1 = a.MVAnalyse(isb=false,delta=1,idx=13)
sDD = sD.MVDegrain2(bv1,fv1,bv2,fv2,idx=14)
reduc = 0.4
sDD = mt_lutxy(sD,sDD,"x 128 - abs y 128 - abs < x y ?").mergeluma(sDD,1.0-reduc)
a.mt_makediff(sDD,U=2,V=2)
return last
}

FUNCTION ediaa(clip a) {
return a.EEDI2(field=1).TurnRight().EEDI2(field=1).TurnLeft().spline36resize(a.width,a.height,-0.5,-0.5) }

FUNCTION daa(clip c) {
nn	= c.nnedi2(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) }

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) }

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) }

FUNCTION AAA(clip clp, int "Xres", int "Yres", int "Xshrp", int "Yshrp", 
 \ 	 int "US", int "DS", bool "chroma")
       {
         clp = clp.isYV12() ? clp : clp.ConvertToYV12()
         ox = clp.width
         oy = clp.height
         Xres  = default(Xres,  ox)
         Yres  = default(Yres,  oy)
         us  = default(us, 1)
	 ds = default(ds, 2)
         Xshrp = default(Xshrp, 15)
         Yshrp = default(Yshrp, 15)
	 chroma = default(chroma, false)
         
         us==0 ? clp.PointResize(ox*2,oy*2) : clp.LanczosResize(ox*2,oy*2)

         TurnLeft()
         SangNom()

         TurnRight()
         SangNom()

         ds==0 ? BilinearResize(Xres,Yres) : 
 \	 ds==1 ? BicubicResize(Xres,Yres) : 
 \	 LanczosResize(Xres,Yres)

         Unfilter(Xshrp,Yshrp)

         chroma ? MergeChroma(clp.Lanczosresize(Xres,Yres)) : last }

FUNCTION antialiasing(clip orig,int "th_luma",int "th_croma",string "type",int "aath") {

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) }

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.nnedi2_rpow2(rfactor=SS,cshift="spline36resize",qual=3).nnedi2(qual=3).TurnRight()
\  .nnedi2(qual=3).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) }

Last edited by thanhtu5013; 19th April 2010 at 10:47.
thanhtu5013 is offline   Reply With Quote
Old 19th April 2010, 11:16   #7  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Quote:
Originally Posted by thanhtu5013
unfortunately there has no effects in my video
Medicine doesn't help when it's just lying in the shelf. You need to ingest it.

Wrong:
1.) Have a clip
2.) Define a function
Code:
some_clip

function foo(clip c, param p) { blablabla }
This does nothing. The "function" statement does only create a function. After a function has been defined, it still has to be used.


Correct:
1.) Define a function
2.) Have a clip
3.) Use function on the clip

Code:
function foo(clip c, param p) { blablabla }

some_clip

foo()
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 19th April 2010, 11:25   #8  |  Link
thanhtu5013
Registered User
 
Join Date: Jan 2009
Location: Lyon. France
Posts: 40
OK.
I understand what you say Didée.

So I have to import the script of Leinad4Mind at first.
then adding my video source (AVISOURCE("C:\...")).

But the last step I don't understand...
I have really to write "foo()" at last ?
thanhtu5013 is offline   Reply With Quote
Old 19th April 2010, 12:06   #9  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
No. "Foo" is frequently used as a placeholder for "[use whatever name does fit here]".

So, instead of "foo()", you would call

either

LSharpAAF()

or

ediaa()

or

daa()

or

saa()

or

AAA()

or

antialias()

or

splinaa()

or

supaa()

or

naa()

or

shaarp()
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 19th April 2010, 13:14   #10  |  Link
thanhtu5013
Registered User
 
Join Date: Jan 2009
Location: Lyon. France
Posts: 40
Thanks a lot Didée.

I tried all functions. Every of them works except "antialias()".
"ediaa()" & "saa()" give me the best results.

Unfortunately, I still have a bit of aliasing.

Does it possible to make antialiasing filter works stronger ?
( Maybe it could make my video blurrer but anyway I want to try and I'll take a decision later. )

Sorry if I ask stupid questions.
I'm a noobs with Avisynth.
thanhtu5013 is offline   Reply With Quote
Old 19th April 2010, 15:45   #11  |  Link
Great Dragon
Registered User
 
Great Dragon's Avatar
 
Join Date: Feb 2005
Location: Ukraine, Lviv
Posts: 121
thanhtu5013, why don't you try an in-game AA option? I'm sure it's more powerful that AA-scripts for Avisynth.
Leinad4Mind, is it any benefits to SharpAAMCmod?
Great Dragon is offline   Reply With Quote
Old 19th April 2010, 15:46   #12  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by thanhtu5013 View Post
Does it possible to make antialiasing filter works stronger ?
You can run it multiple times. For example, in the following script you can select the strength for horizontal and vertical antialiasing. Set strh and strv between 0 and 3, over this value there is not much improvement and it generates artifacts.

Code:
# santiag v1.6
# Simple antialiasing

# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.

# type = "nnedi3", "eedi2", "eedi3" or "sangnom"
# "eedi3" requires v0.9.2 or later
# "sangnom" requires sangnom2
Function santiag (clip c, int "strh", int "strv", string "type", int "nns", int "aa", int "aac", int "threads", int "nsize", int "vcheck", int "fw", int "fh", bool "halfres", string "scaler_post", int "maskt", string "typeh", string "typev")
{
	strh        = Default (strh,                       1)
	strv        = Default (strv,                       1)
	type        = Default (type,                "nnedi3")
	typeh       = Default (typeh,                   type)
	typev       = Default (typev,                   type)
	halfres     = Default (halfres,                false)
	scaler_post = Default (scaler_post, "Spline36Resize")

	c

	w   = Width ()
	h   = Height ()
	fwh = (strv < 0) ? fw : w
	fhh = (strv < 0) ? fh : h

	(strh >= 0) ?             santiag_dir (strh, typeh, halfres, scaler_post, nns=nns, aa=aa, aac=aac, threads=threads, nsize=nsize, vcheck=vcheck, maskt=maskt, fw=fwh, fh=fhh)              : last
	(strv >= 0) ? TurnLeft ().santiag_dir (strv, typev, halfres, scaler_post, nns=nns, aa=aa, aac=aac, threads=threads, nsize=nsize, vcheck=vcheck, maskt=maskt, fw=fh,  fh=fw ).TurnRight () : last

	fwx = Default (fw, w)
	fhx = Default (fh, h)
	(strh < 0 && strv < 0) ? Eval (scaler_post + " (fwx, fhx)") : last
}

Function santiag_dir (clip c, int strength, string type, bool halfres, string scaler_post, int "nns", int "aa", int "aac", int "threads", int "nsize", int "vcheck", int "maskt", int "fw", int "fh")
{
	c
	w = Width ()
	h = Height ()
	fw = Default (fw, w)
	fh = Default (fh, h)

	multi = (IsYUV () && ! IsYV12 ())
	c_y = (multi             ) ?         ConvertToYV12 () : last
	c_u = (multi && ! IsY8 ()) ? UToY ().ConvertToYV12 () : last
	c_v = (multi && ! IsY8 ()) ? VToY ().ConvertToYV12 () : last
	c_y =                        c_y.santiag_stronger (strength, type, halfres, multi, nns=nns, aa=aa, aac=aac, threads=threads, nsize=nsize, vcheck=vcheck, maskt=maskt)
	c_u = (multi && ! IsY8 ()) ? c_u.santiag_stronger (strength, type, halfres, true , nns=nns, aa=aa, aac=aac, threads=threads, nsize=nsize, vcheck=vcheck, maskt=maskt) : c_u
	c_v = (multi && ! IsY8 ()) ? c_v.santiag_stronger (strength, type, halfres, true , nns=nns, aa=aa, aac=aac, threads=threads, nsize=nsize, vcheck=vcheck, maskt=maskt) : c_v
	  (multi && ! IsY8 ()) ? YToUV (c_u, c_v, c_y)
\	: IsY8 ()              ? c_y.ConvertToY8 ()
\	:                        c_y

	Eval (scaler_post + " (fw, fh, src_left=0, src_top=(halfres)?0:0.5, src_width=Width (), src_height=Height ())")
}

Function santiag_stronger (clip c, int strength, string type, bool halfres, bool lumaonly, int "nns", int "aa", int "aac", int "threads", int "nsize", int "vcheck", int "maskt")
{
	strength = (strength < 0) ? 0 : strength
	field = strength % 2
	dh = (strength <= 0 && ! halfres)

	(strength > 0) ? c.santiag_stronger (strength - 1, type, halfres, lumaonly, nns=nns, aa=aa, aac=aac, threads=threads, nsize=nsize, vcheck=vcheck, maskt=maskt) : c

	  (type == "nnedi3" ) ? santiag_nnedi3  (dh, field, lumaonly, nns=nns, threads=threads, nsize=nsize)
\	: (type == "eedi2"  ) ? santiag_eedi2   (dh, field)
\	: (type == "eedi3"  ) ? santiag_eedi3   (dh, field, lumaonly, nns=nns, threads=threads, nsize=nsize, vcheck=vcheck, maskt=maskt)
\	: (type == "sangnom") ? santiag_sangnom (dh, field, aa=aa, aac=aac)
\	: Assert (false, "Santiag: unexpected value for type.")
}

Function santiag_nnedi3 (clip c, bool dh, int field, bool lumaonly, int "nns", int "threads", int "nsize")
{
	c.nnedi3 (dh=dh, field=field, nns=nns, threads=threads, nsize=nsize, u=!lumaonly, v=!lumaonly)
}

Function santiag_eedi2 (clip c, bool dh, int field)
{
	c
	w = Width ()
	h = Height ()
	(dh) ? last : PointResize (w, h / 2, 0, 1-field, w, h)
	eedi2 (field=field)
}

# maskt = 24
Function santiag_eedi3 (clip c, bool dh, int field, bool lumaonly, int "nns", int "threads", int "nsize", int "vcheck", int "maskt")
{
	chroma = (lumaonly) ? 1 : 3
	sclip = c.santiag_nnedi3 (dh, field, lumaonly, nns=nns, threads=threads, nsize=nsize)
	mclip_flag = (Defined (maskt) && maskt > 0)

	mclip = (mclip_flag && dh) ? sclip.BicubicResize (c.Width (), c.Height (), src_top=0.5-field) : sclip
	mclip = (mclip_flag)
\	?	mclip.mt_edge (mode="1 2 1 0 0 0 -1 -2 -1 1", thY1=0, thY2=255, u=chroma, v=chroma)
\			.mt_binarize (threshold=maskt, y=3, u=chroma, v=chroma)
\			.mt_expand (y=3, u=chroma, v=chroma)
\	:	santiag_undef ()

	c.eedi3 (dh=dh, field=field, threads=threads, vcheck=vcheck, sclip=sclip, mclip=mclip, u=!lumaonly, v=!lumaonly)
}

Function santiag_sangnom (clip c, bool dh, int field, int "aa", int "aac")
{
	c
	w = Width ()
	h = Height ()
	(dh) ? Spline36Resize (w, h * 2, 0, -0.25, w, h) : last
	SangNom2 (order=field, aa=aa, aac=aac)
}

Function santiag_undef () { }
NNEDI3 is a CPU hog but gives excellent results. Replace it with NNEDI2 if it takes too long. Here is an example of santiag (3, 3) with the picture you linked on a previous message.

Last edited by cretindesalpes; 17th November 2015 at 10:14. Reason: Updated to v1.6 (Support for 4:4:4 colorspace)
cretindesalpes is offline   Reply With Quote
Old 19th April 2010, 15:57   #13  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
Quote:
Originally Posted by cretindesalpes View Post
NNEDI3 is a CPU hog but gives excellent results. Replace it with NNEDI2 if it takes too long. Here is an example of santiag (3, 3) with the picture you linked on a previous message.
Very impressive.

Though the tree looks rather strange now.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 19th April 2010, 16:02   #14  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 299
Is it wise to believe that needi2 and eedi2 are the most effective for AA or could SangNom and unfilter serve as acomplement?

Here's an image I'm trying to improve:
http://homepages.ihug.co.nz/~online/...er/blpic-s.jpg

I want to resize x2 and AA.

With:
Quote:
nnedi3_rpow2(rfactor=2,cshift="Spline36Resize",nsize=1,qual=1).nnedi3(nsize=1,qual=1).turnright().needi3(nsize=1,qual=1).turnleft()
I get:
http://img695.yfrog.com/img695/7528/blpics0422x0562.jpg

Last edited by markanini; 19th April 2010 at 16:53.
markanini is offline   Reply With Quote
Old 19th April 2010, 16:03   #15  |  Link
thanhtu5013
Registered User
 
Join Date: Jan 2009
Location: Lyon. France
Posts: 40
Quote:
Originally Posted by Great Dragon View Post
thanhtu5013, why don't you try an in-game AA option? I'm sure it's more powerful that AA-scripts for Avisynth.
Because if I activate AA when I'm capturing during my plays, the framerate fall a lot.
( Under 9-10 fps so it's not possible to make a video )

I prefer playing without and apply a one through AviSynth.

Quote:
Originally Posted by cretindesalpes View Post
You can run it multiple times. For example, in the following script you can select the strength for horizontal and vertical antialiasing. Set strh and strv between 0 and 3, over this value there is not much improvement and it generates artifacts.

NNEDI3 is a CPU hog but gives excellent results. Replace it with NNEDI2 if it takes too long. Here is an example of santiag (3, 3) with the picture you linked on a previous message.
It's exactly what I need.
Congratulations ! You're my man !

Unfortunately, it doesn't work with me...
Maybe I made a mistake on my script or I don't have the required plugin.

Code:
Function santiag (clip c, int "strh", int "strv")
{
	strh = Default (strh, 1)
	strv = Default (strv, 1)

	c
	santiag_dir (strh)
	TurnLeft ()
	santiag_dir (strv)
	TurnRight ()
}

Function santiag_dir (clip c, int strength)
{
	c
	w = Width ()
	h = Height ()
	santiag_stronger (strength)
	Spline36Resize (w, h, 0, -0.5, w, h * 2)
}

Function santiag_stronger (clip c, int strength)
{
	c
	(strength <= 0)
\	?	NNEDI3 (dh=true, field=0)
\	:	santiag_stronger (strength - 1)
\	.	NNEDI3 (dh=false, field=(strength % 2))
}

AVISOURCE("C:\GTA IV_ENB Series 0.079 SORA  - 02 - It'S Your Call_1080p.avi")
ConvertToYV12

santiag()
thanhtu5013 is offline   Reply With Quote
Old 19th April 2010, 16:09   #16  |  Link
thanhtu5013
Registered User
 
Join Date: Jan 2009
Location: Lyon. France
Posts: 40
I've just watched on my AviSynth plugins folder. I have nnedi2.dll but I don't have nnedi3.dll...

Unfortuantely, I can't find it on the web.
Someone could send me it ?
thanhtu5013 is offline   Reply With Quote
Old 19th April 2010, 16:17   #17  |  Link
thanhtu5013
Registered User
 
Join Date: Jan 2009
Location: Lyon. France
Posts: 40
I've just tried with nnedi2.dll. It works nice.
I'm still seeking for nnedi3.dll
thanhtu5013 is offline   Reply With Quote
Old 19th April 2010, 16:47   #18  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
NNEDI3 is here.
cretindesalpes is offline   Reply With Quote
Old 19th April 2010, 17:31   #19  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 299
I upped NNEDI3 qual and nszie parameters to 2 and prescrn=false and didnt get much better results:

Note the artifacts in the neck area of the guitar.
markanini is offline   Reply With Quote
Old 19th April 2010, 18:42   #20  |  Link
thanhtu5013
Registered User
 
Join Date: Jan 2009
Location: Lyon. France
Posts: 40
I've just tried with Nnedi2... 0,74FPS.
With Nnedi3... Forget it !
Maybe in 2013, it will finish...

Anyway, I prefer personally Nnedi2 that blurring less the video than Nnedi3 and keeps mode details than Nnedi3.

Thanks to everyone.
Specially to cretindesalpes.

P.S: Your pseudo sounds french, you're french like me, right ?
thanhtu5013 is offline   Reply With Quote
Reply

Tags
antialiasing, fastlinedarken, lsf, lsharpaaf, sharpen

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:09.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.