增加的一个函数Resize8_Separate()可以用于替换TAA中所有的resize,解决了之前存在的chroma center shift处理错误的问题,resize kernel自适应,而且对于upscale会自动应用non-ringing算法。
如果后续TAA加入chroma处理的开关的话也可以方便设置U、V为False来避免chroma处理,从而加速(不过直接在resize、turn的前后加上ConvertToY8()和ConvertToYV12()是更快速的选择)。
代码: 全选
Function TAAmbk_mainpass(clip preaaC, int "aatype", int "cycle", bool "useOpenCL", bool "preferSangNom2", float "p1", float "p2", float "p3", float "p4", float "p5", float "p6", int "w", int "h", int "uph4", int "upw4", int "eedi3mask") {
nnedi3type = (useOpenCL == true) ? "nnedi3ocl" : "nnedi3"
sangnomtype = (preferSangNom2 == true) ? "SangNom2" : "SangNom"
eedi3mclip = (eedi3mask == 0 ) ? nop() : preaaC.MSharpen(threshold=eedi3mask/5, strength=0, mask=true, highq=false)
eedi3mclip_r = (eedi3mask == 0 ) ? nop() : eedi3mclip.BilinearResize(w, uph4).mt_binarize(63, U=3, V=3).TAAmbk_TurnRight()
Eval("""
aa_clip =
\ (aatype == -3 || aatype == 4) ? preaaC."""+nnedi3type+"""(dh=true, field=1, nsize=int(p2), nns=int(p3), qual=int(p4)).Resize8_Separate(w, uph4, 0, -0.5).TAAmbk_TurnRight()
\ ."""+nnedi3type+"""(dh=true, field=1, nsize=int(p2), nns=int(p3), qual=int(p4)).Resize8_Separate(uph4, upw4, 0, -0.5)
\ ."""+sangnomtype+"""(aa=int(p1)).TAAmbk_TurnLeft()."""+sangnomtype+"""(aa=int(p1)).Resize8_Separate(w, h) :
\ (aatype == -2) ? (eedi3mask == 0) ? preaaC.eedi3(dh=true, field=1, alpha=p2, beta=p3, gamma=p4, nrad=int(p5), mdis=int(p6)).Resize8_Separate(w, uph4, 0, -0.5).TAAmbk_TurnRight()
\ .eedi3(dh=true, field=1, alpha=p2, beta=p3, gamma=p4, nrad=int(p5), mdis=int(p6)).Resize8_Separate(uph4, upw4, 0, -0.5)."""+sangnomtype+"""(aa=int(p1)).TAAmbk_TurnLeft()."""+sangnomtype+"""(aa=int(p1)).Resize8_Separate(w, h) :
\ preaaC.eedi3(dh=true, field=1, alpha=p2, beta=p3, gamma=p4, nrad=int(p5), mdis=int(p6), mclip=eedi3mclip).Resize8_Separate(w, uph4, 0, -0.5).TAAmbk_TurnRight()
\ .eedi3(dh=true, field=1, alpha=p2, beta=p3, gamma=p4, nrad=int(p5), mdis=int(p6),mclip=eedi3mclip_r).Resize8_Separate(uph4, upw4, 0, -0.5)."""+sangnomtype+"""(aa=int(p1)).TAAmbk_TurnLeft()."""+sangnomtype+"""(aa=int(p1)).Resize8_Separate(w, h) :
\ (aatype == -1) ? preaaC.eedi2(field=1, mthresh=int(p2), lthresh=int(p3), vthresh=int(p4), maxd=int(p5), nt=int(p6)).Resize8_Separate(w, uph4, 0, -0.5).TAAmbk_TurnRight()
\ .eedi2(field=1, mthresh=int(p2), lthresh=int(p3), vthresh=int(p4), maxd=int(p5), nt=int(p6)).Resize8_Separate(uph4, upw4, 0, -0.5)
\ ."""+sangnomtype+"""(aa=int(p1)).TAAmbk_TurnLeft()."""+sangnomtype+"""(aa=int(p1)).Resize8_Separate(w, h) :
\ (aatype == 1) ? preaaC.eedi2(field=1, mthresh=int(p1), lthresh=int(p2), vthresh=int(p3), maxd=int(p4), nt=int(p5)).Resize8_Separate(w, h, 0, -0.5).TAAmbk_TurnRight()
\ .eedi2(field=1, mthresh=int(p1), lthresh=int(p2), vthresh=int(p3), maxd=int(p4), nt=int(p5)).Resize8_Separate(h, w, 0, -0.5).TAAmbk_TurnLeft() :
\ (aatype == 2) ? (eedi3mask == 0) ? preaaC.eedi3(dh=true, field=1, alpha=p1, beta=p2, gamma=p3, nrad=int(p4), mdis=int(p5)).Resize8_Separate(w, h, 0, -0.5).TAAmbk_TurnRight()
\ .eedi3(dh=true, field=1, alpha=p1, beta=p2, gamma=p3, nrad=int(p4), mdis=int(p5)).Resize8_Separate(h, w, 0, -0.5).TAAmbk_TurnLeft() :
\ preaaC.eedi3(dh=true, field=1, alpha=p1, beta=p2, gamma=p3, nrad=int(p4), mdis=int(p5),mclip=eedi3mclip).Resize8_Separate(w, h, 0, -0.5).TAAmbk_TurnRight()
\ .eedi3(dh=true, field=1, alpha=p1, beta=p2, gamma=p3, nrad=int(p4), mdis=int(p5),mclip=eedi3mclip.TAAmbk_TurnRight()).Resize8_Separate(h, w, 0, -0.5).TAAmbk_TurnLeft() :
\ (aatype == 3) ? preaaC."""+nnedi3type+"""(dh=true, field=1, nsize=int(p1), nns=int(p2), qual=int(p3)).Resize8_Separate(w, h, 0, -0.5).TAAmbk_TurnRight()
\ ."""+nnedi3type+"""(dh=true, field=1, nsize=int(p1), nns=int(p2), qual=int(p3)).Resize8_Separate(h, w, 0, -0.5).TAAmbk_TurnLeft() :
\ (aatype == 5) ? preaaC.Resize8_Separate(upw4, uph4)
\ ."""+sangnomtype+"""(aa=int(p1)).TAAmbk_TurnRight()
\ ."""+sangnomtype+"""(aa=int(p1)).Resize8_Separate(h, w).TAAmbk_TurnLeft() :
\ (aatype == 6) ? preaaC.Resize8_Separate(w, uph4)."""+sangnomtype+"""(aa=int(p1)).Resize8_Separate(w, h).TAAmbk_TurnRight()
\ .Resize8_Separate(h, upw4)."""+sangnomtype+"""(aa=int(p1)).Resize8_Separate(h, w).TAAmbk_TurnLeft().Repair(preaaC, mode=int(p2)) :
\ predown ? preaaC."""+nnedi3type+"""(dh=true, field=1, nsize=1, nns=3, qual=2).Resize8_Separate(preaaC.Width(), h, 0, -0.5).TAAmbk_TurnRight()
\ ."""+nnedi3type+"""(dh=true, field=1, nsize=1, nns=3, qual=2).Resize8_Separate(h, w, 0, -0.5) :
\ preaaC
""")
return (cycle == 0 ) ? aa_clip : aa_clip.TAAmbk_mainpass(aatype, cycle - 1, useOpenCL, preferSangNom2, p1, p2, p3, p4, p5, p6, w, h, uph4, upw4, eedi3mask)
}
Function TAAmbk_TurnLeft(clip input)
{
try
{
return input.fturnleft()
}
catch(error_msg)
{
return input.TurnLeft()
}
}
Function TAAmbk_TurnRight(clip input)
{
try
{
return input.fturnright()
}
catch(error_msg)
{
return input.TurnRight()
}
}