#MaskCL v1.3 by mirkosp #Mask without the 255 bug and no weird workarounds using opencl. #Might or might not be faster than dither_merge16 / dither_merge16_8, see if it is for you. #0 keeps src, 255 keeps overlay, everything else is the intended inbetween (at least it should be). #Requires tp7's CLExpr: https://github.com/tp7/CLExpr (check "Releases" for download links). #No error checking so if shit doesn't work as expected blame it on yourself. #Just supply YUV clips with same colorspace, resolution, framerate, and length to make sure it'll work fine. #v1.0 and 1.1 were bugged with 16bit because I'm dumb. Like, a lot. YAAAY! #v1.2 supported yv24 only with luma=true so here goes v1.3. function MaskCL(clip src, clip overlay, clip mask, int "y", int "u", int "v", bool "luma", bool "lsb_inout", bool "mask8") { y = Default(y,3) u = Default(u,2) v = Default(v,2) luma = Default(luma,false) lsb_inout = Default(lsb_inout,false) mask8 = lsb_inout ? Default(mask8,false) : false mask = luma ? ytouv(mask,mask,mask) : mask mask = src.isyv12() ? mask.converttoyv12(matrix="PC.601") : src.isyuy2() ? mask.converttoyuy2(matrix="PC.601") : src.isyv16() ? mask.converttoyv16(matrix="PC.601") : mask mask = mask8 ? stackvertical(mask,mask) : mask lsb_inout ? cl_exprxyz(src,overlay,mask,"x 65535 z - * y z * + 65535 /",y=y,u=u,v=v,lsb=true) : cl_exprxyz(src,overlay,mask,"x 255 z - * y z * + 255 /",y=y,u=u,v=v,lsb=false) }