Advertisement
mirkosp

MaskCL

Feb 2nd, 2015
1,117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #MaskCL v1.3 by mirkosp
  2. #Mask without the 255 bug and no weird workarounds using opencl.
  3. #Might or might not be faster than dither_merge16 / dither_merge16_8, see if it is for you.
  4. #0 keeps src, 255 keeps overlay, everything else is the intended inbetween (at least it should be).
  5. #Requires tp7's CLExpr: https://github.com/tp7/CLExpr (check "Releases" for download links).
  6. #No error checking so if shit doesn't work as expected blame it on yourself.
  7. #Just supply YUV clips with same colorspace, resolution, framerate, and length to make sure it'll work fine.
  8. #v1.0 and 1.1 were bugged with 16bit because I'm dumb. Like, a lot. YAAAY!
  9. #v1.2 supported yv24 only with luma=true so here goes v1.3.
  10.  
  11. function MaskCL(clip src, clip overlay, clip mask, int "y", int "u", int "v", bool "luma", bool "lsb_inout", bool "mask8") {
  12.  
  13. y = Default(y,3)
  14. u = Default(u,2)
  15. v = Default(v,2)
  16. luma = Default(luma,false)
  17. lsb_inout = Default(lsb_inout,false)
  18. mask8 = lsb_inout ? Default(mask8,false) : false
  19.  
  20. mask = luma ? ytouv(mask,mask,mask) : mask
  21. mask = src.isyv12() ? mask.converttoyv12(matrix="PC.601") : src.isyuy2() ? mask.converttoyuy2(matrix="PC.601") : src.isyv16() ? mask.converttoyv16(matrix="PC.601") : mask
  22. mask = mask8 ? stackvertical(mask,mask) : mask
  23. 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)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement