12.04.2025, 15:59
# FUNCTION RemoveDirtSMC
#============================================================================================================================================.
function RemoveTempGrain(clip clp, int "_mode")
{
_mode = Default(_mode, 17)
rg = RemoveGrain(clp, mode=_mode)
return TemporalRepair(rg, clp)
}
function RemoveDirtS(clip clp, int "limit", bool "_grey")
{
_grey = Default(_grey, false)
limit = Default(limit, 6)
clensed = clp.Clense(grey=_grey, cache=4)
alt = clp.RemoveGrain(10)
return (RestoreMotionBlocks(clensed, clp, alternative=alt, pthreshold=4, cthreshold=6, gmthreshold=40, \
dist=1, dmode=2, debug=false, noise=limit, noisy=16, grey=_grey))
}
function RemoveDirtSMC(clip clp, int "limit", bool "_grey")
{
_grey = Default(_grey, false)
limit = Default(limit, 6)
super1 = MSuper(clp, pel=2, sharp=2)
bvec1 = MAnalyse(super1, isb=true, blksize=16, delta=1, truemotion=true)
fvec1 = MAnalyse(super1, isb=false, blksize=16, delta=1, truemotion=true)
backw1 = MFlow(clp, super1, bvec1)
forw1 = MFlow(clp, super1, fvec1)
clp = Interleave(backw1, clp, forw1)
clp = clp.RemoveDirtS(limit, _grey).removetempgrain(10)
clp = clp.SelectEvery(3, 1)
return clp
}
function McDegrainSharp(clip c, int "frames", int"strenght",float "bblur", float "csharp", bool "bsrch")
{ # Based on MCDegrain By Didee, http://forum.doom9.org/showthread.php?t=161594
# Also based on DiDee observations in this thread: http://forum.doom9.org/showthread.php?t=161580
# "Denoise with MDegrainX, do slight sharpening where motionmatch is good, do slight blurring where motionmatch is bad"
# In areas where MAnalyse cannot find good matches, the blur() will be dominant.
# In areas where good matches are found, the sharpen()'ed pixels will overweight the blur()'ed pixels
# when the pixel averaging is performed.
frames = default(frames, 2)
strenght = default(strenght,400)
bblur = default(bblur, 1.0)
csharp = default(csharp, 1.0)
bsrch = default(bsrch, true)
blocks = 16
overl = 8
c2 = c.blur(bblur)
super = bsrch ? c2.MSuper(pel=2, sharp=1) : c.MSuper(pel=2, sharp=1)
super_rend = c.sharpen(csharp).MSuper(pel=2, sharp=1,levels=1)
backward_vec3 = MAnalyse(super, isb = true, delta = 3, blksize=blocks, overlap=overl)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=blocks, overlap=overl)
backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=blocks, overlap=overl)
forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=blocks, overlap=overl)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=blocks, overlap=overl)
forward_vec3 = MAnalyse(super, isb = false, delta = 3, blksize=blocks, overlap=overl)
(frames<=0) ? c :\
(frames==1) ? c2.MDegrain1(super_rend, backward_vec1,forward_vec1,thSAD=strenght) :\
(frames==2) ? c2.MDegrain2(super_rend, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=strenght) :\
c2.MDegrain3(super_rend, backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=strenght)
return(last)
}
McDegrainSharp()