Bevor ich das Material endgültig durchjage hat vielleicht noch jemand was zu dem Script zu sagen.
#Funktion angepasst Original von Heini011 danke
# LimitedSharpen() ( a modded version, 29 Oct 2005 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
#
## - MODIFIED version using MaskTools 2.0 and dedicated support plugin LimitedSupport
function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height
Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4
clp.isYV12() ? clp : clp.converttoyv12()
ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last
edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)
tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? SimpleAverage(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)
Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")
OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")
Lmode==1 ? clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last
normal = last
zero = clamp(normsharp, bright_limit, dark_limit, 0,0)
Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal
edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_lutxy(tmp,last,"x y - 128 +")
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")
soft==0 ? last : mt_lutxy(tmp,sharpdiff2,"x y 128 - -")
(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last
ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)
clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )
(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale
return last
}
# SeeSaw v0.3e (02 Jan 2006)
#
# (Full Name: "Denoiser-and-Sharpener-are-riding-the-SeeSaw" )
#
# This function provides a (simple) implementation of the "crystality sharpen" principle.
# In conjunction with a user-specified denoised clip, the aim is to enhance
# weak detail, hopefully without oversharpening or creating jaggies on strong
# detail, and produce a result that is temporally stable without detail shimmering,
# while keeping everything within reasonable bitrate requirements.
# This is done by intermixing source, denoised source and a modified sharpening process,
# in a seesaw-like manner.
#
# This version is considered alpha.
#
# Usage:
#
# a = TheNoisySource
# b = a.YourPreferredDenoising()
# SeeSaw( a, b, [parameters] )
#
# You're very much encouraged to feed your own custom denoised clip into SeeSaw.
# If the "denoised" clip parameter is omitted, a simple "spatial pressdown" filter is used.
#
#
# Fiddled together by Didée, for your pleasure.
#
# ======= Main function =======
function SeeSaw( clip clp, clip "denoised",
\ int "NRlimit",int "NRlimit2",
\ float "Sstr", int "Slimit", float "Spower", float "SdampLo", float "SdampHi", float "Szp",
\ float "bias", int "Smode", int "sootheT", int "sootheS", float "ssx", float "ssy")
{
ssx = default( ssx, 1.0 ) # supersampling factor x / SeeSaw doesn't require supersampling urgently.
ssy = default( ssy, ssx ) # supersampling factor y / if at all, small values ~1.25 seem to be enough.
NRlimit = default( NRlimit, 2 ) # absolute limit for pixel change by denoising
NRlimit2 = default( NRlimit2, NRlimit+1) # limit for intermediate denoising
Sstr = default( Sstr, 1.5 ) # Sharpening strength (don't touch this too much)
Slimit = default( Slimit, NRlimit+2 ) # positive: absolute limit for pixel change by sharpening
# negative: pixel's sharpening difference is reduced to diff=pow(diff,1/abs(limit))
Spower = default( Spower, 4 ) # exponent for modified sharpener
Szp = default( Szp, 16+2 ) # zero point - below: overdrive sharpening - above: reduced sharpening
SdampLo = default( SdampLo, Spower+1 ) # reduces overdrive sharpening for very small changes
SdampHi = default( SdampHi, 24 ) # further reduces sharpening for big sharpening changes. Try 15~30. "0" disables.
bias = default( bias, 49 ) # bias towards detail ( >= 50 ) , or towards calm result ( < 50 )
Smode = default( Smode, ssx<1.35 ? 11 : ssx<1.51 ? 20 : 19 )
sootheT = default( sootheT, 49 ) # 0=minimum, 100=maximum soothing of sharpener's temporal instableness.
# (-100 .. -1 : will chain 2 instances of temporal soothing.)
sootheS = default( sootheS, 0 ) # 0=minimum, 100=maximum smoothing of sharpener's spatial effect.
Szp = Szp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
SdampLo = SdampLo / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
ox=clp.width
oy=clp.height
xss = m4(ox*ssx)
yss = m4(oy*ssy)
NRL = string( NRlimit )
NRL2 = string( NRlimit2 )
NRLL = string( int(round( NRlimit2 * 100.0/bias - 1.0 )) )
SLIM = string( abs(Slimit) )
BIAS1 = string( bias )
BIAS2 = string( 100-bias )
#ZRP = string( abs(Szp) )
#PWR = string( abs(Spower) )
#DMP = string( SdampLo )
denoised = defined(denoised) ? denoised : yv12lutxy(clp,clp.removegrain(4,-1),"x "+NRL+" + y < x "+NRL+" + x "+NRL+" - y > x "+NRL+" - y ? ?",U=2,V=2)
NRdiff = yv12lutxy(clp,denoised,"x y - 128 +","x y - 128 +","x y - 128 +",U=3,V=3)
tame = yv12lutxy(clp,denoised,"x "+NRLL+" + y < x "+NRL2+" + x "+NRLL+" - y > x "+NRL2+" - x "+BIAS1+" * y "+BIAS2+" * + 100 / ? ?")
head = tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,4)
# head = head.maskedmerge(tame,tame.prewitt(multiplier=1.0).expand().removegrain(20))
(ssx==1.0 && ssy==1.0) ? repair(tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head,1,-1,-1)
\ : repair(tame.lanczosresize(xss,yss).sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head.bicubicresize(xss,yss,-.2,.6),1,-1,-1).lanczosresize(ox,oy)
Soothe(last,tame,sootheT,sootheS)
sharpdiff= yv12lutxy(tame,last,"x y - 128 +",U=1,V=1)
(NRlimit==0) ? clp : \
yv12lutxy(clp,NRdiff,"y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",
\ "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",
\ "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",U=3,V=3)
Slimit>=0 ? yv12lutxy(last,sharpdiff,"y 128 "+SLIM+" + > x "+SLIM+" - y 128 "+SLIM+" - < x "+SLIM+" + x y 128 - - ? ?",U=2,V=2)
\ : yv12lutxy(last,sharpdiff,"y 128 = x x y 128 - abs 1 "+SlIM+" / ^ y 128 - y 128 - abs / * - ?",U=2,V=2)
return( last )
}
# ======= Modified sharpening function =======
function sharpen2(clip clp, float strength, int power, float zp, float lodmp, float hidmp, int rgmode)
{
STR = string( strength )
PWR = string( 1.0/float(power) )
ZRP = string( ZP )
DMP = string( lodmp )
HDMP = (hidmp==0) ? "1" : "1 x y - abs "+string(hidmp)+" / 4 ^ +"
yv12lutxy( clp, clp.RemoveGrain(rgmode,-1,-1), \
"x y = x x x y - abs "+ZRP+" / "+PWR+" ^ "+ZRP+" * "+STR+" * x y - 2 ^ x y - 2 ^ "+DMP+" + / * x y - x y - abs / * "+HDMP+" / + ?",U=2,V=2)
return( last )
}
# ======= Soothe() function to stabilze sharpening =======
function Soothe(clip sharp, clip orig, int "sootheT", int "sootheS")
{
sootheT = default(sootheT, 25 )
sootheS = default(sootheS, 0 )
sootheT = (sootheT > 100) ? 100 : (sootheT < -100) ? -100 : sootheT
sootheS = (sootheS > 100) ? 100 : (sootheS < 0) ? 0 : sootheS
ST = string( 100 - abs(sootheT))
SSPT = string( 100 - abs(sootheS))
yv12lutxy(orig,sharp,"x y - 128 +","x y - 128 +","x y - 128 +", U=1,V=1)
(sootheS==0) ? last
\ : yv12lutxy( last, last.removegrain(20,-1,-1),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+SSPT+" * 128 + x 128 - abs y 128 - abs > x "+SSPT+" * y 100 "+SSPT+" - * + 100 / x ? ?", U=1,V=1)
(sootheT==0) ? last
\ : yv12lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", U=1,V=1)
(sootheT > -1) ? last
\ : yv12lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", U=1,V=1)
yv12lutxy(orig,last,"x y 128 - -","x y 128 - -","x y 128 - -",U=1,V=1)
# mergechroma(sharp) # not needed in SeeSaw
return( last )
}
# ======= MOD4-and-atleast-16 helper function =======
function m4(float x) {x<16?16:int(round(x/4.0)*4)}
function RemoveTempGrain(clip input, int _mode)
{
rg = RemoveGrain(input, mode=_mode)
return TemporalRepair(rg, input)
}
function RemoveDirt(clip input, int limit, int rgrain, bool "_grey")
{
_grey = default(_grey, false)
_dgr1 = 0.35+rgrain*0.3
_dgr2 = 0.45+rgrain*0.4
repmode = 1
clensed = Clense(input, grey=_grey, cache=4)
restore = input.FluxSmoothST(3+3*rgrain,rgrain)
restore = Repair(restore, input, mode=repmode, modeU= _grey ? -1 : repmode)
restore = rgrain==0 ? restore.RemoveGrain(1) : \
restore.VagueDenoiser(threshold=_dgr1, chromaT=_dgr1, nsteps=7, percent=75).RemoveGrain(1)
alt = input.VagueDenoiser(threshold=_dgr2, chromaT=_dgr2, nsteps=7, percent=100).RemoveGrain(5)
return RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, pthreshold=4+2*rgrain, cthreshold=6+2*rgrain, gmthreshold=40, dist=1, dmode=2, debug=false, noise=limit, noisy=12, grey=_grey)
}
global idx_c = 25
function RemoveNoiseMC(clip,int "rdlimit", int "rgrain", int "denoise", bool "sharp", float "csharpen", bool "_grey")
{
rdlimit = default(rdlimit,11)
rgrain = default(rgrain,2)
denoise = default(denoise,8)
sharp = (rgrain<1) ? default(sharp,true) : default(sharp,false)
csharpen = (rgrain>2) ? default(csharpen,0.17) : (rgrain>1) ? default(csharpen,0.15) : default(csharpen,0.13)
csharpen = sharp ? csharpen : csharpen+0.08
_grey = default(_grey,false)
_dgr = 0.45+rgrain*0.4
dummy = clip.BlankClip(length=0)
global idx_c = idx_c+1
cbs = 8
cov = (cbs>4) ? cbs/4 : 0
ccf = cbs*cbs/64
cpn = (denoise>12) ? 50*ccf : (denoise>8) ? 58*ccf : (denoise>5) ? 66*ccf : 72*ccf
csh = sharp ? 1 : 0
bvec2 = clip.MVAnalyse(isb=false, blksize=cbs, delta=2, pel=2, sharp=csh, overlap=cov, truemotion=true, pnew=cpn, idx=idx_c)
bvec1 = clip.MVAnalyse(isb=false, blksize=cbs, delta=1, pel=2, sharp=csh, overlap=cov, truemotion=true, pnew=cpn, idx=idx_c)
fvec1 = clip.MVAnalyse(isb=true, blksize=cbs, delta=1, pel=2, sharp=csh, overlap=cov, truemotion=true, pnew=cpn, idx=idx_c)
fvec2 = clip.MVAnalyse(isb=true, blksize=cbs, delta=2, pel=2, sharp=csh, overlap=cov, truemotion=true, pnew=cpn, idx=idx_c)
backw1 = rdlimit>13 ? \
rdlimit>20 ? \
clip.MVFlow(bvec1, idx=idx_c).Deblock(quant=22, aOffset=6, bOffset=6) : \
clip.MVFlow(bvec1, idx=idx_c).Deblock(quant=16, aOffset=4, bOffset=4) : \
clip.MVFlow(bvec1, idx=idx_c)
forw1 = rdlimit>13 ? \
rdlimit>20 ? \
clip.MVFlow(fvec1, idx=idx_c).Deblock(quant=22, aOffset=6, bOffset=6) : \
clip.MVFlow(fvec1, idx=idx_c).Deblock(quant=16, aOffset=4, bOffset=4) : \
clip.MVFlow(fvec1, idx=idx_c)
clp = interleave(backw1,clip,forw1)
clp = clp.RemoveDirt(rdlimit,rgrain,_grey)
dnc = denoise==0 ? clp.RemoveTempGrain(rgrain).SelectEvery(3,1) : dummy
clp = clp.SelectEvery(3,1)
dnc = denoise==0 ? dnc : \
clp.MVDenoise(bvec2, bvec1, fvec1, fvec2, thT=denoise, thSAD=190+15*denoise, thmv=40, thSCD1=230+5*denoise)
vid_mo = dnc.VagueDenoiser(threshold=_dgr, chromaT=_dgr, nsteps=7, percent=75)
vid_mo = rgrain==1 ? vid_mo.RemoveGrain(1) : vid_mo.RemoveGrain(5)
dnc = dnc.ConditionalFilter(dnc, vid_mo, "(YDifferenceFromPrevious()+YDifferenceToNext())/AverageLuma()", "<", "0.3")
clp = clp.SeeSaw(dnc, Sstr=csharpen, Szp=12, SdampHi=20, bias=40)
return clp
}
function cap_avi_filter(clip c)
{
c=c.RemoveNoiseMC(rdlimit=12,rgrain=2,denoise=6)
c=c.fft3dfilter(sigma=1.2, bt=5, sharpen=0.5, plane=4, dehalo=0.5, interlaced=true)
return c
}
SetMemoryMax(1024)
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\MVtools_20071112\Mvtools.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\deblock12\DeBlock.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\vaguedenoiser0351\VagueDenoiser.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\RemoveGrain\RemoveGrainSSE3.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\fluxsmooth_25_dll_20040729\FluxSmooth.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\RemoveDirt\RemoveDirtSSE2.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\RemoveGrain\RepairSSE3.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\MaskTools-v1.5.8\MaskTools.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\masktools-v2.0a30\mt_masktools.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\LimitedSupport\LimitedSupport_09Jan06B.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\fft3dfilter_20070220\fft3dfilter.dll")
LoadPlugin ("C:\Programme\AviSynth 2.5\plugins\RemoveNoiseMC\ffms2-r725-icl-4\ffms2.dll")
AviSource("D:\1.Zuspieler\1_A_Xanti\A_1.Tag.avi") # DGDecode_mpeg2source, FFVideoSource, AviSource, whatever your source requires
Assumetff()
Crop(16,16,672,544)
ConvertToYV12 (interlaced=true)
cap_avi_filter()
Tweak(bright=1, cont=1, sat=0.9, hue=1, coring=false)
ConvertToYUY2 (interlaced=true)
AddBorders(16,16,16,16)
Alles anzeigen
Es wird in Vdub als Direct stream Copie durchgejagt und später in Edius 5 geschnitten und final in DVD gewandelt.
Ich hatte vor Jahren schon mal das Material in dv.avi mit dem Script behandelt.
Damals gefiel mir, das neben gutem Entrauschen auch kleine VHS Bandfehler mit verschwinden. Das Bild wird ruhiger.