Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function CSmod(clip filtered, clip original, string "blurF", float "strength", float "divisor", float "index",
- \ bool "chroma", bool "preblur", bool "preblurc", bool "secure", bool "limit", bool "limit2", bool "Slimit", bool "Tlimit",
- \ int "preR", int "Smethod", int "Smode", int "RGmode", int "RGmodeU", int "Repmode", int "RepmodeU",
- \ int "Sovershoot", int "Sundershoot", int "Tovershoot", int "Tundershoot", int "Soothe")
- {
- chroma = Default(chroma, false )
- preblur = Default(preblur, true )
- preblurc = Default(preblurc,preblur)
- preR = Default(preR, 1 )
- limit = Default(limit, true )
- limit2 = Default(limit2, limit )
- RGmode = Default(RGmode, 11 )
- RGmodeU = Default(RGmodeU, RGmode )
- Repmode = Default(Repmode, 1 )
- RepmodeU = Default(RepmodeU,Repmode)
- limit = Defined(original) ? limit : false
- limit2 = Defined(original) ? limit2 : false
- original = Defined(original) ? original : filtered
- Smethod = Default(Smethod, 1 )
- secure = Default(secure, true )
- Smode = Default(Smode, 2 )
- divisor = Default(divisor, 1.5 )
- index = Default(index, 0.8 )
- strength = Default(strength,Smode==2 ? 3.0 : 1.8)
- Slimit = Default(Slimit, !limit )
- Sovershoot = Default(Sovershoot, 5 )
- Sundershoot = Default(Sundershoot, Sovershoot)
- Tlimit = Default(Tlimit, false )
- Tovershoot = Default(Tovershoot, 3 )
- Tundershoot = Default(Tundershoot, Tovershoot)
- Soothe = Default(Soothe, 24 )
- ch31 = chroma ? 3 : 1
- ch32 = chroma ? 3 : 2
- sw = filtered.width()
- sh = filtered.height()
- HD = (sw > 1024 || sh > 576) ? true : false
- allD = mt_makediff(original, filtered, U=ch31, V=ch31)
- pre = preblur ? Defined(blurF) ? Eval("filtered."+blur)
- \ : filtered.minblur(preR, chroma ? (preblurc ? 3 : 2) : 1)
- \ : filtered
- dark_limit = pre.mt_inpand(U=ch31, V=ch31)
- bright_limit = pre.mt_expand(U=ch31, V=ch31)
- minmaxavg = Smethod==1 ? NOP() : mt_average(dark_limit, bright_limit, U=ch31, V=ch31)
- method = Smethod==1 ? pre .removegrain(RGmode, chroma ? RGmodeU : -1)
- \ : Smethod==2 ? minmaxavg
- \ : minmaxavg.removegrain(RGmode, chroma ? RGmodeU : -1)
- method = secure ? method.mt_lutxy(pre,"x y < x 1 + x y > x 1 - x ? ?", U=ch31, V=ch31) : method
- sharpdiff = mt_makediff(pre, method, U=ch31,V=ch31)
- sharpdiff = Smode==1 ? sharpdiff.mt_lut(expr="x 128 - "+string(strength)+" * 128 +", U=ch31, V=ch31)
- \ : Smode==2 ? sharpdiff.mt_lut("x 128 - "+String(divisor)+" / Abs "+String(index)+" ^ "+String(strength)+" * x 128 > 1 -1 ? * 128 +", U=ch31, V=ch31)
- \ : sharpdiff
- ssDD = limit ? sharpdiff.repair(allD, mode=Repmode, modeU=chroma ? RepmodeU : -1) : sharpdiff
- ssDD = limit2 ? ssDD.mt_lutxy(sharpdiff, "x 128 - abs y 128 - abs < x y ?", U=ch31, V=ch31) : ssDD
- sclp = filtered.mt_adddiff(ssDD, U=ch32, V=ch32)
- sclp = Slimit ? sclp.mt_clamp(bright_limit, dark_limit, Sovershoot, Sundershoot, U=ch32, V=ch32) : sclp
- srcMVS = Tlimit ? pre.MSuper(hpad=0,vpad=0,pel=2,sharp=2,chroma=false) : NOP()
- f1v = Tlimit ? MAnalyse(srcMVS, isb=false, delta=1, truemotion=false, blksize=HD?16:8, overlap=HD?8:4, pelsearch=2, search=2, searchparam=2, DCT=0, global=true, chroma=false) : NOP()
- b1v = Tlimit ? MAnalyse(srcMVS, isb=true, delta=1, truemotion=false, blksize=HD?16:8, overlap=HD?8:4, pelsearch=2, search=2, searchparam=2, DCT=0, global=true, chroma=false) : NOP()
- f1c = Tlimit ? MCompensate(original, srcMVS, f1v, thSAD=300, thSCD1=300, thSCD2=100) : NOP()
- b1c = Tlimit ? MCompensate(original, srcMVS, b1v, thSAD=300, thSCD1=300, thSCD2=100) : NOP()
- Tmax = Tlimit ? original.mt_logic(f1c, "max", U=1, V=1).mt_logic(b1c, "max", U=1, V=1) : NOP()
- Tmin = Tlimit ? original.mt_logic(f1c, "min", U=1, V=1).mt_logic(b1c, "min", U=1, V=1) : NOP()
- sclp = Tlimit ? sclp.mt_clamp(Tmax, Tmin, Tovershoot, Tundershoot, U=2, V=2) : sclp
- (Soothe>=0 && Soothe<=100) ? Soothe(sclp, filtered, keep=Soothe) : sclp
- return last
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement