Advertisement
Guest User

BlindDeHalo3_mt2

a guest
Feb 1st, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function BlindDeHalo3( clip input, 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. ssispmt   = Findstr(VersionString(), "AviSynth+") != 0 && Findstr(VersionString(), "r1576") == 0
  29.  
  30. sislumaonly = ssispmt ? input.isy() : VersionNumber() < 2.6 ? true : input.isy8()
  31.  
  32. clp = sislumaonly ? input : ssispmt ? input.converttoy() : input.converttoy8()
  33.  
  34. i     = (interlaced==false) ? clp : clp.separatefields()
  35. oxi   = i.width
  36. oyi   = i.height
  37. sm    = i.bicubicresize(bh_m4(oxi/rx),bh_m4(oyi/ry))
  38. 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()
  39. sm    = sm.bicubicresize(oxi,oyi,1.0,.0)
  40. smd   = mt_lutxy(i.sharpen(tweaker),sm,TWK_HLIGHT)
  41. smd   = (sharpness==0.0) ? smd : smd.blur(sharpness)
  42. clean = mt_lutxy(i,smd,yexpr="x y 128 - -").mergechroma(i)
  43. clean = mt_merge(i,clean,mm)
  44.  
  45. LL    = string(PPlimit)
  46. LIM   = "x "+LL+" + y < x "+LL+" + x "+LL+" - y > x "+LL+" - y ? ?"
  47.  
  48. base  = (PPmode<0) ? i : clean
  49. small = base .bicubicresize(bh_m4(oxi/sqrt(rx*1.5)),bh_m4(oyi/sqrt(ry*1.5)))
  50. ex1   = small.mt_expand().blur(.5)
  51. in1   = small.mt_inpand().blur(.5)
  52. hull  = mt_logic( mt_lutxy( ex1.mt_expand().RemoveGrain(12,-1), ex1, "x y - 1 1 / * 1.0 ^ 1 - 5 *" )
  53.  \               ,mt_lutxy( in1, in1.mt_inpand().RemoveGrain(12,-1), "x y - 1 1 / * 1.0 ^ 1 - 5 *" )
  54.  \               ,"max")
  55.  \     .bicubicresize(oxi,oyi,1.0,.0)
  56.  
  57. postclean = (abs(PPmode)== 1) ?  mt_merge(base,small.bicubicresize(oxi,oyi,1.0,.0),hull,Y=3,U=2,V=2)
  58.  \        : (abs(PPmode)== 2) ?  mt_merge(base,base.RemoveGrain(19,-1),hull,Y=3,U=2,V=2)
  59.  \        : (abs(PPmode)== 3) ?  mt_merge(base,base.RemoveGrain(4,-1),hull,Y=3,U=2,V=2)
  60.  \        :                      clean
  61.  
  62. postclean = (PPlimit==0) ?  postclean
  63.  \        :                 mt_lutxy(base,postclean,yexpr=LIM,U=2,V=2)
  64.  
  65. (PPmode==0) ? clean   : postclean
  66. interlaced  ? weave() : last
  67. sislumaonly ? last : ssispmt ? CombinePlanes(last,input,planes="YUV",sample_clip=input) : ytouv(input.utoy8(),input.vtoy8(),last)
  68.  
  69. return( last )
  70. }
  71. #---------------------------------------------------------
  72. function bh_m4(float x) {
  73. nx=VersionNumber() < 2.6 ? x<16?16:int(round(x/4.0)*4) : round(x)
  74. return(nx)
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement