Advertisement
Guest User

BlindDeHalo3_MT2

a guest
Oct 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function BlindDeHalo3( clip clp, float "rx", float "ry", int "strength",
  2.  \                     float "lodamp", float "hidamp", float "sharpness", float "tweaker",
  3.  \                     int "PPmode", int "PPlimit", bool "interlaced")
  4. {
  5. rx =         default( rx,           3.0 )
  6. ry =         default( ry,           3.0 )
  7. strength =   default( strength,     125 )
  8. lodamp =     default( lodamp,       0.0 )
  9. hidamp =     default( hidamp,       0.0 )
  10. sharpness =  default( sharpness,    0.0 )
  11. tweaker =    default( tweaker,      0.0 )
  12. PPmode =     default( PPmode,         0 )
  13. PPlimit =    default( PPlimit, (abs(PPmode)==3) ? 4 : 0 )
  14. interlaced = default( interlaced, false )
  15.  
  16. sharpness = (sharpness>1.58) ? 1.58 : sharpness
  17. tweaker   = (tweaker > 1.00) ? 1.00 : tweaker
  18. strength  = float(strength)*(1.0+sharpness*0.25)
  19. RR   = string((rx+ry)/2.0)
  20. ST   = string(float(strength)/100.0)
  21. LD   = string(lodamp)
  22. HD   = string(pow(hidamp,2))
  23. TWK0 = "x y - 12 "+ST+" / "+RR+" / /"
  24. TWK  = "x y - 12 "+ST+" / "+RR+" / / abs"
  25. TWK_HLIGHT = "x y - abs 1 < 128 "+TWK+" 128 "+TWK+" - "+TWK+" 128 / * + "+TWK0+" "+TWK+" "+LD+" + / * "
  26.  \         + "128 "+TWK+" - 20 / 2 ^ 128 "+TWK+" - 20 / 2 ^ "+HD+" + / * 128 + ?"
  27.  
  28. i     = (interlaced==false) ? clp : clp.separatefields()
  29. oxi   = i.width
  30. oyi   = i.height
  31. sm    = i.bicubicresize(m4(oxi/rx),m4(oyi/ry))
  32. mm    = mt_lutxy(sm.mt_expand(),sm.mt_inpand(),"x y - 4 *").mt_expand().mt_deflate().blur(1.58).mt_inflate().bicubicresize(oxi,oyi,1.0,.0).mt_inflate()
  33. sm    = sm.bicubicresize(oxi,oyi,1.0,.0)
  34. smd   = mt_lutxy(i.sharpen(tweaker),sm,TWK_HLIGHT)
  35. smd   = (sharpness==0.0) ? smd : smd.blur(sharpness)
  36. clean = mt_lutxy(i,smd,yexpr="x y 128 - -").mergechroma(i)
  37. clean = mt_merge(i,clean,mm)
  38.  
  39. LL    = string(PPlimit)
  40. LIM   = "x "+LL+" + y < x "+LL+" + x "+LL+" - y > x "+LL+" - y ? ?"
  41.  
  42. base  = (PPmode<0) ? i : clean
  43. small = base .bicubicresize(m4(oxi/sqrt(rx*1.5)),m4(oyi/sqrt(ry*1.5)))
  44. ex1   = small.mt_expand().blur(.5)
  45. in1   = small.mt_inpand().blur(.5)
  46. hull  = mt_logic( mt_lutxy( ex1.mt_expand().RemoveGrain(12,-1), ex1, "x y - 1 1 / * 1.0 ^ 1 - 5 *" )
  47.  \               ,mt_lutxy( in1, in1.mt_inpand().RemoveGrain(12,-1), "x y - 1 1 / * 1.0 ^ 1 - 5 *" )
  48.  \               ,"max", U=-128, V=-128)
  49.  \     .bicubicresize(oxi,oyi,1.0,.0)
  50.  
  51. postclean = (abs(PPmode)== 1) ?  mt_merge(base,small.bicubicresize(oxi,oyi,1.0,.0),hull,Y=3,U=2,V=2)
  52.  \        : (abs(PPmode)== 2) ?  mt_merge(base,base.RemoveGrain(19,-1),hull,Y=3,U=2,V=2)
  53.  \        : (abs(PPmode)== 3) ?  mt_merge(base,base.RemoveGrain(4,-1),hull,Y=3,U=2,V=2)
  54.  \        :                      clean
  55.  
  56. postclean = (PPlimit==0) ?  postclean
  57.  \        :                 mt_lutxy(base,postclean,yexpr=LIM,U=2,V=2)
  58.  
  59. (PPmode==0) ? clean   : postclean
  60. interlaced  ? weave() : last
  61.  
  62. return( last )
  63. }
  64. #---------------------------------------------------------
  65. function m4(float x) {return(x<16?16:int(round(x/4.0))*4)}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement