代码: 全选
MP_Pipeline("""
setMemoryMax(300)
a="F:\llx\BLACK_REBELLION\BDMV\STREAM\00002.m2ts"
#FFIndex(a,demuxer="lavf")
#FFVideoSource(a,threads=1,seekmode=-1)
LWLibavVideoSource(a,threads=1)
src8=last
### prefetch: 64,48
### export clip:src8
### ###
setMemoryMax(3000)
Y = 3
UV = 3
Yt = Y == 3
UVt = UV == 3
Y32 = Yt ? 3 : 2
UV32 = UVt ? 3 : 2
Y11 = (Y==3) ? 11 : 0
Y20 = (Y==3) ? 20 : 0
UV11 = (UV==3) ? 11 : 0
UV20 = (UV==3) ? 20 : 0
src16 = src8.U16()
maskY = src8.tcannyMod(sigma=0.85,mode=1)
maskU = src8.UtoY().tcannyMod(sigma=0.75,mode=1).BilinearResize(1920,1080,src_left=0.25)
maskV = src8.VtoY().tcannyMod(sigma=0.75,mode=1).BilinearResize(1920,1080,src_left=0.25)
mask = mt_logic(maskY,mt_logic(maskU,maskV,"max"),"max")
nr16 = src16.GSMC_SBR(lsb_in=true,lsb=true,r=3,Y=Y32,U=UV32,V=UV32)
pre_nr = nr16.ditherpost(mode=-1)
dif_nr = mt_makediff(src8, pre_nr, Y=3, U=3, V=3)
### prefetch: 36,28
### export clip:pre_nr,dif_nr,src16,mask,nr16
### pass clip:src8
### ###
setMemoryMax(3000)
Preset = "Faster"
pnum = preset == "Very Fast" ? 0
\ : preset == "Faster" ? 1
\ : preset == "Fast" ? 2
\ : preset == "Medium" ? 3
\ : preset == "Slow" ? 4
\ : preset == "Slower" ? 5
\ : preset == "Very Slow" ? 6
\ : 7
radius = 3
HD = True
Y = 3
UV = 3
Yt = Y == 3
UVt = UV == 3
bs = HD ? 16 : 8
bs2 = HD ? 32 : 16
blksize = Select(pnum, bs2, bs2, bs2, bs, bs, bs, bs )
ol = blksize/2
ol2 = blksize/4
overlap = Select(pnum, ol2, ol2, ol2, ol, ol, ol, ol )
thSAD = 400
thSADC = 200
thSCD1 = 400
thSCD2 = 150
truemotion = False
pel = Select(pnum, 1, 1, HD?1:2,HD?1:2,2, 2, 2 )
pelsearch = Select(pnum, 1, 2, 2, 2, 2, 2, 2 )
search = Select(pnum, 2, 4, HD?5:2,HD?3:4,4, 5, 3 )
searchparam = Select(pnum, 1, 2, 2, 2, 2, 2, 2 )
plane = !Yt ? 3: !UVt ? 0 : 4
psuper = pre_nr.MSuper(pel=pel, levels=0, sharp=2, chroma=UVt)
difsuper = dif_nr.MSuper(pel=pel, levels=1, sharp=2, chroma=UVt)
fv3 = radius>=3 ? psuper.MAnalyse(isb=False, delta=3, truemotion=truemotion, blksize=blksize, overlap=overlap, pelsearch=pelsearch, search=search, searchparam=searchparam, chroma=UVt) : NOP()
fv2 = radius>=2 ? psuper.MAnalyse(isb=False, delta=2, truemotion=truemotion, blksize=blksize, overlap=overlap, pelsearch=pelsearch, search=search, searchparam=searchparam, chroma=UVt) : NOP()
fv1 = radius>=1 ? psuper.MAnalyse(isb=False, delta=1, truemotion=truemotion, blksize=blksize, overlap=overlap, pelsearch=pelsearch, search=search, searchparam=searchparam, chroma=UVt) : NOP()
bv1 = radius>=1 ? psuper.MAnalyse(isb=True, delta=1, truemotion=truemotion, blksize=blksize, overlap=overlap, pelsearch=pelsearch, search=search, searchparam=searchparam, chroma=UVt) : NOP()
bv2 = radius>=2 ? psuper.MAnalyse(isb=True, delta=2, truemotion=truemotion, blksize=blksize, overlap=overlap, pelsearch=pelsearch, search=search, searchparam=searchparam, chroma=UVt) : NOP()
bv3 = radius>=3 ? psuper.MAnalyse(isb=True, delta=3, truemotion=truemotion, blksize=blksize, overlap=overlap, pelsearch=pelsearch, search=search, searchparam=searchparam, chroma=UVt) : NOP()
dif_sb = radius==1 ? dif_nr.MDegrain1(difsuper, bv1, fv1 , thSAD=thSAD, thSADC=thSADC, thSCD1=thSCD1, thSCD2=thSCD2, plane=plane, lsb=true)
\ : radius==2 ? dif_nr.MDegrain2(difsuper, bv1, fv1, bv2, fv2 , thSAD=thSAD, thSADC=thSADC, thSCD1=thSCD1, thSCD2=thSCD2, plane=plane, lsb=true)
\ : dif_nr.MDegrain3(difsuper, bv1, fv1, bv2, fv2, bv3, fv3, thSAD=thSAD, thSADC=thSADC, thSCD1=thSCD1, thSCD2=thSCD2, plane=plane, lsb=true)
dif_sb = dif_sb.dither_repair16(dif_nr.U16(),13)
### prefetch: 26,18
### export clip:dif_sb
### pass clip:src8,src16,mask,nr16
### ###
setMemoryMax(3000)
nr16
f3kdb( 12, 52, 24, 24, 0, 0, input_mode=1, output_mode=1).Dither_limit_dif16(last, ref=nr16, thr=0.40, elast=2.0, y=3, u=3, v=3)
f3kdb( 24, 36, 16, 16, 0, 0, input_mode=1, output_mode=1).Dither_limit_dif16(last, ref=nr16, thr=0.35, elast=1.5, y=3, u=3, v=3)
dbed = Dither_add16(last, dif_sb, Y=3, U=3, V=3, dif=True)
Lmask=src8.mt_lut("x 36 <= 170 255 ?",u=1,v=1)
nonedge=dither_merge16_8(src16,dbed,Lmask,luma=true)
### export clip:nonedge
### pass clip:src8,src16,mask
### prefetch: 16,8
### ###
setMemoryMax(3000)
sharp = src8.mt_adddiff(mt_makediff(src8, src8.RemoveGrain(20).RemoveGrain(20), U=3, V=3), U=3,V=3)
eemask = mask.mt_expand(u=1,v=1).mt_expand(u=1,v=1).removeGrain(20,-1).mt_inpand(u=1,v=1).mt_inpand(u=1,v=1).mt_lut(" 0.2 x x x * * *",u=1,v=1).removeGrain(20,-1)
edge16 = mt_merge(sharp, src8, eemask, luma=true).removeGrain(2).U16()
dbmask=mask.mt_lut("x 1 <= x 3 >> x 10 << ?",u=1,v=1).removeGrain(20,-1).mt_expand(u=1,v=1).removeGrain(20,-1).mt_inpand(u=1,v=1).removeGrain(20,-1).mt_inpand(u=1,v=1).mt_inpand(u=1,v=1).removeGrain(20,-1).mt_lut(" x 1 << ",u=1,v=1)
dither_merge16_8(nonedge,edge16,dbmask,luma=true)
down10(stack=false)
""")