DSS2("D:\Rurouni Kenshin Shin Kyoto\00000.ts") src = last emask = src.tcanny(sigma=1.2, mode=1, plane=1) w = width(src) h = height(src) upw4 = Round(w*0.375)*4 uph4 = Round(h*0.375)*4 dehalo = src.Dehalo_Alpha_mt(darkstr=0.0,brightstr=1.0,rx=1.8,ry=1.8,highsens=100,lowsens=30) #aa_clip = dehalo.nnedi3_rpow2(rfactor=2, fwidth=upw4, fheight=upw4, nsize=1, nns=3, qual=2).SangNom(aa=48).TurnRight().SangNom(aa=48).binomialBlur(varY=1.0,varC=1.0,usemmx=true).Spline36Resize(h, w, 0.5, -0.5).TurnLeft() aa_clip = dehalo.Spline64Resize(upw4, uph4).Repair(dehalo.GaussResize(upw4, uph4, p=100), 1).SangNom(aa=13).TurnRight().SangNom(aa=13).binomialBlur(varY=0.5,varC=0.5,usemmx=true).Spline36Resize(h, w).TurnLeft() #aa_clip = dehalo.eedi2(field=1, mthresh=10, lthresh=20, vthresh=20, maxd=24, nt=50).Spline36Resize(w, h, 0, -0.5).TurnRight().eedi2(field=1, mthresh=10, lthresh=20, vthresh=20, maxd=24, nt=50).Spline36Resize(h, w, 0, -0.5).TurnLeft() aa_cs = mt_adddiff(aa_clip, mt_makediff(aa_clip, aa_clip.RemoveGrain(20,11), U=3, V=3).Repair(mt_makediff(dehalo, aa_clip, U=3, V=3), 13), U=3,V=3) aamask = emask.mt_lut("x 20 < 0 x 20 - 3 << ?", U=1, V=1).mt_deflate()#.RemoveGrain(20, -1) aaed = mt_merge(src, aa_cs, aamask, luma=true, U=3, V=3 ) aaed16 = aaed.U16 mask2 = emask.mt_lut("x 10 <= 0 x 10 - 4 << ?", U=1, V=1).mt_inflate() last = aaed s_str = 1.2 s_reverse = s_str + 0.25 s_divisor = 1.5 s_indexR = 1.281 sstring = "x 128 - abs "+String(s_divisor)+" / 1 "+String(s_indexR)+" / ^ "+String(s_str)+" * x 128 - x 128 - abs 0.001 + / * x 128 - 2 ^ x 128 - 2 ^ "+String(s_reverse)+" + / * 128 +" pre_nr = RemoveGrain(11, 11).RemoveGrain(4, 4) dif_nr = mt_makediff(pre_nr, Y=3, U=3, V=3) temp = 70 radius = 3 adapt = -1 rep = 3 luma = true chroma = true Y = luma ? 3 : 2 U = chroma ? 3 : 2 V = chroma ? 3 : 2 diff_nr = dif_nr diff_sb = diff_nr.TemporalSoften(radius, 255, 255, scenechange=255, mode=2) diff_mg = (temp == 0) ? diff_nr \ : (temp == 100) ? diff_sb \ : Merge(diff_nr, diff_sb, temp/100.) stabled = rep==0 ? mt_adddiff(pre_nr, diff_mg, Y=Y, U=U, V=V) \ : mt_adddiff(pre_nr, diff_mg, Y=Y, U=U, V=V).Repair(last, mode=rep) Lmask = last.mt_lut("x "+string(adapt)+" - abs 255 * "+string(adapt)+" 128 - abs 128 + /", U=1, V=1).RemoveGrain(19, -1) bright = mt_merge(last, stabled, Lmask, luma=chroma, Y=Y, U=U, V=V).STPresso(tthr=0) nr = pre_nr.U16.Dither_resize16(width, height, kernel="Gauss", fh=-1, fv=-1, a1=1) noise = makediff16( aaed16, nr, Y=3, U=3, V=3 ) nrdb16 = nr.GradFun3(thr=0.40, radius=16, smode=1, mask=0, ampn=0, lsb=true, lsb_in=true) db16 = Dither_add16( nrdb16, noise, Y=3, U=3, V=3, dif=true) db8 = db16.DitherPost(mode=0) sharp8 = dif_nr.mt_lut(sstring) dif_db = mt_makediff(pre_nr, db8).mt_lut(sstring) shfx8 = sharp8.Repair(dif_db, 1, -1) shfx8 = mt_lutxy(sharp8, shfx8, "x 128 - abs y 128 - abs < x y ?") shfx16 = shfx8.U16 sharp16 = sharp8.U16.Dither_limit_dif16(shfx8.U16, thr=2.5, U=1, V=1) d_lm8 = mt_lutxy(sharp8, shfx8, "x y != 255 0 ?") shpFin = shfx16.Dither_merge16_8(sharp16, d_lm8, U=1, V=1) dark = db16.Dither_add16(shpFin, Y=3, U=2, V=2, dif=true) flat = ALMerge(dark, bright, pre_nr, U=3, V=3) Dither_merge16_8(flat, aaed.U16, mask2, luma=true, U=3, V=3) #Down10(depth=10,dither=-2,smooth=0,tvrange=true,stack=false) Interleave( src.Dither_Convert_YUV_TO_RGB(mode=8, ampn=0), \ last.Dither_Convert_YUV_TO_RGB(mode=8, lsb_in=true, ampn=0))