Advertisement
Guest User

Untitled

a guest
Jan 24th, 2016
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # MotionThresh by mf
  2. # Simple scenechange-proof motion threshold
  3. # Tile outputs 16x16 clip for speed
  4. # Use tile=true for conditional filtering, tile=false for masking
  5.  
  6. function MotionThresh(clip input, float thresh, bool "tile") {
  7. tile = Default(tile, false)
  8.  
  9. black = BlankClip(input, width=16, height=16)
  10. white = BlankClip(input, width=16, height=16, color=$FFFFFF)
  11. cond1 = ConditionalFilter(input, white, black, "YDifferenceFromPrevious()", "greaterthan", String(thresh))
  12. cond2 = ConditionalFilter(input, white, black, "YDifferenceToNext()", "greaterthan", String(thresh))
  13. Overlay(cond1, cond2, mode="darken")
  14. tile ? last : PointResize(input.width, input.height)
  15. }
  16.  
  17. ######################################################################
  18. # MotionRamp by mf
  19. # Average motion soft-thresholding based on 5 thresholds
  20. # Dependancies: MotionThresh, BlendMulti
  21.  
  22. function MotionRamp(clip input, int thresh1, int thresh2, int thresh3, int thresh4, int thresh5, int "min", int "max", int "floor", int "ceil", int "radius", bool "tile") {
  23. min = Default(min, 0)
  24. max = Default(max, 255)
  25. floor = Default(floor, 0)
  26. ceil  = Default(ceil, 255)
  27. radius = Default(radius, 2)
  28. tile = Default(tile, false)
  29.  
  30. input
  31. BlendMulti(MotionThresh(thresh1, tile=true), MotionThresh(thresh2, tile=true), MotionThresh(thresh3, tile=true), MotionThresh(thresh4, tile=true), MotionThresh(thresh5, tile=true))
  32. TemporalSoften(radius,255,0,255,2)
  33. Levels(floor, 1, ceil, min, max)
  34. ColorYUV(levels="TV->PC")
  35. tile ? last : PointResize(input.width, input.height)
  36. }
  37.  
  38.  
  39. ##########
  40. function admfilter(clip input)
  41. {
  42. input
  43. MotionRampadc=last.MotionRamp(5,10,15,20,25,Max=255,Tile=True)
  44. return ScriptClip("""
  45.                     adden=dfttestmc(pp=blur(1.53),lsb=true, Sigma=(AverageLuma(MotionRampadc)/16.0))
  46.                     Dither_merge16_8(adden, last.Dither_convert_8_to_16(), last.mt_lut("x 16 < 255 x 75 > 0 255 x 16 - 255 75 16 - / * - ? ?",u=1,v=1), luma=true, u=3,v=3).Ditherpost(mode=7, slice=false)
  47.                     """, args="MotionRampadc")
  48. }
  49.  
  50.  
  51. ##########
  52. #edge side bleed
  53. ##########
  54. function edgesidebleed(clip input, float "w32", float "w16", float "w8", float "w4", float "w2", int "y", int "u", int "v") {
  55. w2 = Default(w2, 0.001)
  56. w4 = Default(w4, 0.055)
  57. w8 = Default(w8, 0.015)
  58. w16 = Default(w16, 0.02)
  59. w32 = Default(w32, 0.001)
  60. input
  61. shift32 = Crop(Width()-32,0,32,0,true).StackHorizontal(Crop(0,0,-32,0,true))
  62. w32==0 ? last : raveragew(last,1+w32,shift32,-w32,y=y,u=u,v=v)
  63. shift16 = Crop(Width()-16,0,16,0,true).StackHorizontal(Crop(0,0,-16,0,true))
  64. w16==0 ? last : raveragew(last,1+w16,shift16,-w16,y=y,u=u,v=v)
  65. shift8 = Crop(Width()-8,0,8,0,true).StackHorizontal(Crop(0,0,-8,0,true))
  66. w8==0 ? last : raveragew(last,1+w8,shift8,-w8,y=y,u=u,v=v)
  67. shift4 = Crop(Width()-4,0,4,0,true).StackHorizontal(Crop(0,0,-4,0,true))
  68. w4==0 ? last : raveragew(last,1+w4,shift4,-w4,y=y,u=u,v=v)
  69. shift2 = Crop(Width()-2,0,2,0,true).StackHorizontal(Crop(0,0,-2,0,true))
  70. w2==0 ? last : raveragew(last,1+w2,shift2,-w2,y=y,u=u,v=v)
  71. }
  72.  
  73.  
  74. ###############
  75. #motion adaptive by A.SONY
  76.  
  77. function smam(clip input, clip "prefilter", val "filter", int "pel", int "blksize") {
  78. defined(filter) ? Assert((Isclip(filter) || IsString(filter)),        "'filter' only accepts clip or string") : nop()
  79. preclip= defined(prefilter) ? prefilter : input.HQdn3d().FFT3DFilter()
  80. filclip= defined(filter) ? isclip(filter) ? filter : eval("input." + filter) : input.QTGMC(InputType=1, tr0=0, tr1=1, tr2=1, lsb=true, lsbd=true, rep0=11, rep1=11, rep2=11, Sharpness=0.0).daa3mod()
  81. sup    = preclip.MSuper(pel=pel,sharp=1)
  82. fv1    = sup.MAnalyse(isb=false,delta=1,DCT=2,Truemotion=false,blksize=blksize)
  83. fv2    = sup.MAnalyse(isb=true,delta=1,DCT=2,Truemotion=true,blksize=blksize)
  84. csaa   = filclip
  85. momask1 = input.MMask(fv1, kind = 1, ml=2)
  86. momask2 = input.MMask(fv2, kind = 1, ml=3)
  87. momask = mt_average(momask1,momask2,u=3,v=3)
  88. mt_merge(input,csaa,momask,u=3,v=3)
  89. }
  90.  
  91. ##############
  92. # sanimebob by A.SONY
  93.  
  94. function sanimebob(clip i, int "useqtgmc", bool "bobpresmooth") {
  95. bobpresmooth    = default (bobpresmooth      , false)
  96. useqtgmc        = default (useqtgmc              , 0)
  97. iforbob = bobpresmooth ? i.QTGMC_bob(0,0.5).reduceflicker(strength=2).interlaced60or50(BFF=!(GetParity(i))) : i
  98. iforbob = bobpresmooth ? isyuy2(i) ? iforbob.SeparateFields.Interleaved2Planar.Repair(i.SeparateFields.Interleaved2Planar,Planar=true).Planar2Interleaved.weave : iforbob.SeparateFields.Repair(i.SeparateFields).weave : i
  99.  
  100. pi       =      i.pointresize(width(i),height(i)+8,0,-4,width(i),height(i)+8.0001)
  101.  
  102. yadifclip= isyuy2(i) ? pi.yadifmod(mode=3, edeint=i.eedi3(-2,sclip=iforbob.nnedi3(-2)).pointresize(width(i),height(i)+8,0,-4,width(i),height(i)+8.0001)).crop(0,4,-0,-4).Interleaved2Planar.Repair(i.TDeint(1,emask=iforbob.tmm(1)).Interleaved2Planar,Planar=true).Planar2Interleaved : \
  103.                        pi.yadifmod(mode=3, edeint=i.eedi3(-2,sclip=iforbob.nnedi3(-2)).pointresize(width(i),height(i)+8,0,-4,width(i),height(i)+8.0001)).crop(0,4,-0,-4).Repair(i.TDeint(1,emask=iforbob.tmm(1)))
  104. useqtgmc==0 ? yadifclip : \
  105. useqtgmc==1 ? iforbob.QTGMC(SourceMatch=3, Lossless=2, EdiExt=yadifclip, tr0=1, tr1=1, tr2=1, lsb=true, lsbd=true, rep0=11, rep1=11, rep2=11, Sharpness=0.1) : \
  106. useqtgmc==2 ? yadifclip.smam(filter=iforbob.QTGMC(SourceMatch=3, Lossless=2, EdiExt=yadifclip, tr0=1, tr1=1, tr2=1, lsb=true, lsbd=true, rep0=11, rep1=11, rep2=11, Sharpness=0.1)) : \
  107. useqtgmc==3 ? yadifclip.smam(filter=yadifclip.QTGMC(InputType=1, tr0=1, tr1=1, tr2=1, lsb=true, lsbd=true, rep0=11, rep1=11, rep2=11, Sharpness=0.1)) : \
  108. useqtgmc==4 ? yadifclip.smam(filter=iforbob.QTGMC(SourceMatch=3, Lossless=2, EdiExt=yadifclip, tr0=1, tr1=1, tr2=1, lsb=true, lsbd=true, rep0=11, rep1=11, rep2=11, Sharpness=0.1).daa3mod) : \
  109. useqtgmc==5 ? yadifclip.smam(filter=yadifclip.QTGMC(InputType=1, tr0=1, tr1=1, tr2=1, lsb=true, lsbd=true, rep0=11, rep1=11, rep2=11, Sharpness=0.1).daa3mod) : \
  110. useqtgmc==6 ? yadifclip.smam(filter=yadifclip.QTGMC(InputType=1, tr0=0, lsb=true, lsbd=true, Sharpness=0.1)) : \
  111.               yadifclip.smam(filter=yadifclip.QTGMC(InputType=1, tr0=0, lsb=true, lsbd=true, Sharpness=0.0).daa3mod)
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement