View difference between Paste ID: LiVG4NFh and xyVhfQFe
SHOW: | | - or go back to the newest paste.
1-
# ASTDR DeRainbow function v1.74
1+
# ASTDR DeRainbow function v1.75
2
 
3-
  function ASTDR(clip input, float "strength", int "tempsoftth", int "tempsoftrad", int "tempsoftsc", float "blstr", int "tht", int "FluxStv", int "dcn", bool "edgem", bool "exmc", clip "edgemprefil")
3+
  function ASTDR(clip input, float "strength", int "tempsoftth", int "tempsoftrad", int "tempsoftsc", float "blstr", int "tht", int "FluxStv", int "dcn", bool "edgem", bool "exmc", clip "edgemprefil", bool "nomask")
4
  {
5
  nomask        = default(nomask, false)
6
  exmc          = default(exmc, false)
7
  sisfield      = input.IsFieldBased()
8
  fnomc         = sisfield && !exmc
9
  strn          = Default(strength, 5)
10
  blstr         = Default(blstr, sisfield ? 0.3 : 0.5)
11
  tht           = Default(tht, 255)
12
  tschrth       = Default(tempsoftth, 30)
13
  tschrrad      = Default(tempsoftrad, 3)
14
  tschrsc       = Default(tempsoftsc, 3)
15
  FluxStv       = Default(FluxStv, sisfield ? 60 : 75)
16
  dcn           = Default(dcn, 15)
17
  edgem         = default(edgem, false)
18-
  momask    = exmc ? nop() : input.tweak(sat=1.1).mt_motion(thc2=1,thc1=1,thy2=1,thy1=1,y=3,v=3,u=3,tht=tht)
18+
19-
  momaskinv = exmc ? nop() : momask.mt_expand(u=3, v=3).mt_inflate(u=3, v=3).Invert().Levels(0,2,255,0,255)
19+
  momask    = exmc || nomask ? nop() : input.tweak(sat=1.1).mt_motion(thc2=1,thc1=1,thy2=1,thy1=1,y=3,v=3,u=3,tht=tht)
20
  momaskinv = exmc || nomask ? nop() : momask.mt_expand(u=3, v=3).mt_inflate(u=3, v=3).Invert().Levels(0,2,255,0,255)
21
 
22
  inrainev    = fnomc ? input.selecteven() : input
23
  filtered_uv = !exmc ? inrainev.DeCross(ThresholdY=15, Noise=dcn, Margin=1) : inrainev
24
  filtered_uv = filtered_uv.FluxSmoothST(FluxStv,sisfield ? FluxStv/2 : FluxStv).Mergeluma(inrainev)
25
  filtered_uv = sisfield ? filtered_uv : filtered_uv.awarpsharp2(depth=4,chroma=6,cplace="MPEG2")
26
  filtered_uv = filtered_uv.hqdn3d(ls=0,lt=0,cs=sisfield ? strn*2/5 : strn*3/5,ct=strn).temporalsoften(tschrrad,0,tschrth,tschrsc,2).blur(blstr).Mergeluma(inrainev)
27
  filtered_uv = sisfield ? filtered_uv : filtered_uv.aWarpSharp2(depth=4,chroma=6,cplace="MPEG2")
28
  filtered_uv = filtered_uv.fft3dfilter(sigma=sisfield ? 0.7 : 1,sigma3=sisfield ? 3 : 4,plane=3,degrid=1)
29
30
  fnomc ? eval("""
31
 filtered_uve = filtered_uv
32
  inputodd    = input.selectodd()
33
  filtered_uv = inputodd.DeCross(ThresholdY=15, Noise=dcn, Margin=1).FluxSmoothST(FluxStv,sisfield ? FluxStv/2 : FluxStv).Mergeluma(inputodd)
34
  filtered_uv = filtered_uv.hqdn3d(ls=0,lt=0,cs=sisfield ? strn*2/5 : strn*3/5.0,ct=strn).temporalsoften(tschrrad,0,tschrth,tschrsc,2).blur(blstr).Mergeluma(inputodd)
35
  filtered_uv = filtered_uv.fft3dfilter(sigma=sisfield ? 0.7 : 1,sigma3=sisfield ? 3 : 4,plane=3,degrid=1)
36
  filtered_uv = interleave(filtered_uve,filtered_uv)
37
                  """) : nop()
38-
  filtered = exmc ? nop() : mt_merge(filtered_uv, input, momaskinv,y=2,u=3,v=3,luma=true)
38+
39
  filtered = exmc || nomask ? nop() : mt_merge(filtered_uv, input, momaskinv,y=2,u=3,v=3,luma=true)
40-
  exmc ? filtered_uv : mt_merge(input, filtered, momask.mt_expand(y=1,u=3,v=3).mt_inflate(y=1,u=3,v=3),y=2,u=3,v=3)
40+
41-
  edgemclip = edgem ? defined(edgemprefil) ? edgemprefil.mt_edge("sobel", 4, 4, 4, 4) : input.mt_edge("sobel", 4, 4, 4, 4) : nop()
41+
  exmc || nomask ? filtered_uv : mt_merge(input, filtered, momask.mt_expand(y=1,u=3,v=3).mt_inflate(y=1,u=3,v=3),y=2,u=3,v=3)
42-
  edgem ? mt_merge(input, last, edgemclip.mt_expand().mt_inflate(),y=2,u=3,v=3,luma=true) : last
42+
  edgemclip = edgem && !nomask ? defined(edgemprefil) ? edgemprefil.mt_edge("sobel", 4, 4, 4, 4) : input.mt_edge("sobel", 4, 4, 4, 4) : nop()
43
  edgem && !nomask ? mt_merge(input, last, edgemclip.mt_expand().mt_inflate(),y=2,u=3,v=3,luma=true) : last
44
  }
45-
# ASTDRmc DeRainbow function v1.74
45+
46
# ASTDRmc DeRainbow function v1.75
47-
  function ASTDRmc(clip input, float "strength", int "tempsoftth", int "tempsoftrad", int "tempsoftsc", float "blstr", int "tht", int "FluxStv", int "dcn", bool "edgem", int "thSAD", clip "prefil", bool "chroma", clip "edgemprefil")
47+
48
  function ASTDRmc(clip input, float "strength", int "tempsoftth", int "tempsoftrad", int "tempsoftsc", float "blstr", int "tht", int "FluxStv", int "dcn", bool "edgem", int "thSAD", clip "prefil", bool "chroma", clip "edgemprefil", bool "nomask")
49
  {
50
sisfield = input.IsFieldBased()
51
52
  nomask   = default(nomask, false)
53
  tht      = Default(tht, 255)
54
  tschrrad = Default(tempsoftrad, sisfield ? 5 : 3).min(5)
55
  tschrth  = Default(tempsoftth, sisfield ? 50 : 30)
56
  thSAD    = Default(thSAD, tht)
57
  edgem    = default(edgem, sisfield)
58-
derbmask = sisfield ? nop() : (VersionNumber() < 2.60) ? input.tedgemask(threshY=2,u=0,v=0).mt_inflate() : input.TEMmod(threshY=2,chroma=0).mt_inflate()
58+
59
60
derbmask = sisfield || nomask ? nop() : (VersionNumber() < 2.60) ? input.tedgemask(threshY=2,u=0,v=0).mt_inflate() : input.TEMmod(threshY=2,chroma=0).mt_inflate()
61
62
exprefil  = defined(prefil)
63
prefil    = exprefil ? prefil : chroma ? sisfield ? input.MinBlur(3).mergeluma(input).Blur(1) : input.MinBlur(3,blurrep=true) : input.Blur(1.5)
64
ieven     = sisfield ? input.selecteven().mc4ASTDRmc(tschrrad,prefil.selecteven(),thSAD,chroma) : nop()
65
iodd      = sisfield ? input.selectodd().mc4ASTDRmc(tschrrad,prefil.selectodd(),thSAD,chroma) : nop()
66-
astev     = sisfield ? ieven.ASTDR(strength=strength,tempsoftth=tschrth,tempsoftrad=tschrrad,tempsoftsc=tempsoftsc,blstr=blstr,tht=tht,FluxStv=FluxStv,dcn=dcn,edgem=edgem,exmc=true,edgemprefil=defined(edgemprefil) ? edgemprefil.selecteven().changefps(framerate(prefil)/2*(tschrrad*2+1)) : !exprefil ? undefined : prefil.selecteven().changefps(framerate(prefil)/2*(tschrrad*2+1))).selectevery(tschrrad * 2 + 1, tschrrad) : nop()
66+
67-
astod     = sisfield ? iodd.ASTDR(strength=strength,tempsoftth=tschrth,tempsoftrad=tschrrad,tempsoftsc=tempsoftsc,blstr=blstr,tht=tht,FluxStv=FluxStv,dcn=dcn,edgem=edgem,exmc=true,edgemprefil=defined(edgemprefil) ? edgemprefil.selectodd().changefps(framerate(prefil)/2*(tschrrad*2+1)) : !exprefil ? undefined : prefil.selectodd().changefps(framerate(prefil)/2*(tschrrad*2+1))).selectevery(tschrrad * 2 + 1, tschrrad) : nop()
67+
68-
ASTDRclip = !sisfield ? mcclip.ASTDR(strength=strength,tempsoftth=tschrth,tempsoftrad=tschrrad,tempsoftsc=tempsoftsc,blstr=blstr,tht=tht,FluxStv=FluxStv,dcn=dcn,edgem=edgem,exmc=true,edgemprefil=defined(edgemprefil) ? edgemprefil.changefps(framerate(prefil)*(tschrrad*2+1)) : prefil.changefps(framerate(prefil)*(tschrrad*2+1))) : interleave(astev,astod)
68+
astev     = sisfield ? ieven.ASTDR(strength=strength,tempsoftth=tschrth,tempsoftrad=tschrrad,tempsoftsc=tempsoftsc,blstr=blstr,tht=tht,FluxStv=FluxStv,dcn=dcn,edgem=edgem,exmc=true,edgemprefil=defined(edgemprefil) ? edgemprefil.selecteven().changefps(framerate(prefil)/2*(tschrrad*2+1)) : !exprefil ? undefined : prefil.selecteven().changefps(framerate(prefil)/2*(tschrrad*2+1)), nomask=nomask).selectevery(tschrrad * 2 + 1, tschrrad) : nop()
69
astod     = sisfield ? iodd.ASTDR(strength=strength,tempsoftth=tschrth,tempsoftrad=tschrrad,tempsoftsc=tempsoftsc,blstr=blstr,tht=tht,FluxStv=FluxStv,dcn=dcn,edgem=edgem,exmc=true,edgemprefil=defined(edgemprefil) ? edgemprefil.selectodd().changefps(framerate(prefil)/2*(tschrrad*2+1)) : !exprefil ? undefined : prefil.selectodd().changefps(framerate(prefil)/2*(tschrrad*2+1)), nomask=nomask).selectevery(tschrrad * 2 + 1, tschrrad) : nop()
70-
sisfield ? ASTDRclip : mt_merge(input,ASTDRclip.selectevery(tschrrad * 2 + 1, tschrrad), derbmask,luma=true,y=2,u=3,v=3)
70+
ASTDRclip = !sisfield ? mcclip.ASTDR(strength=strength,tempsoftth=tschrth,tempsoftrad=tschrrad,tempsoftsc=tempsoftsc,blstr=blstr,tht=tht,FluxStv=FluxStv,dcn=dcn,edgem=edgem,exmc=true,edgemprefil=defined(edgemprefil) ? edgemprefil.changefps(framerate(prefil)*(tschrrad*2+1)) : prefil.changefps(framerate(prefil)*(tschrrad*2+1)), nomask=nomask) : interleave(astev,astod)
71
72
sisfield || nomask ? ASTDRclip : mt_merge(input,ASTDRclip.selectevery(tschrrad * 2 + 1, tschrrad), derbmask,luma=true,y=2,u=3,v=3)
73
  }
74
75
  function mc4ASTDRmc(clip input, int "tschrrad", clip "prefil", int "thSAD", bool "chroma")
76
  {
77
masuper = prefil.MSuper()
78
mcsuper = input.MSuper(levels=1)
79
80
b5v = tschrrad > 4 ? MAnalyse(masuper, delta=5, truemotion = true, isb = true, chroma=chroma) : nop()
81
b4v = tschrrad > 3 ? MAnalyse(masuper, delta=4, truemotion = true, isb = true, chroma=chroma) : nop()
82
b3v = tschrrad > 2 ? MAnalyse(masuper, delta=3, truemotion = true, isb = true, chroma=chroma) : nop()
83
b2v = tschrrad > 1 ? MAnalyse(masuper, delta=2, truemotion = true, isb = true, chroma=chroma) : nop()
84
b1v = MAnalyse(masuper, delta=1, truemotion = true, isb = true, chroma=chroma)
85
f1v = MAnalyse(masuper, delta=1, truemotion = true, isb = false, chroma=chroma)
86
f2v = tschrrad > 1 ? MAnalyse(masuper, delta=2, truemotion = true, isb = false, chroma=chroma) : nop()
87
f3v = tschrrad > 2 ? MAnalyse(masuper, delta=3, truemotion = true, isb = false, chroma=chroma) : nop()
88
f4v = tschrrad > 3 ? MAnalyse(masuper, delta=4, truemotion = true, isb = false, chroma=chroma) : nop()
89
f5v = tschrrad > 4 ? MAnalyse(masuper, delta=5, truemotion = true, isb = false, chroma=chroma) : nop()
90
91
f5c = tschrrad > 4 ? input.MCompensate(mcsuper, f5v, thSAD=thSAD) : nop()
92
f4c = tschrrad > 3 ? input.MCompensate(mcsuper, f4v, thSAD=thSAD) : nop()
93
f3c = tschrrad > 2 ? input.MCompensate(mcsuper, f3v, thSAD=thSAD) : nop()
94
f2c = tschrrad > 1 ? input.MCompensate(mcsuper, f2v, thSAD=thSAD) : nop()
95
f1c = input.MCompensate(mcsuper, f1v)
96
b1c = input.MCompensate(mcsuper, b1v)
97
b2c = tschrrad > 1 ? input.MCompensate(mcsuper, b2v, thSAD=thSAD) : nop()
98
b3c = tschrrad > 2 ? input.MCompensate(mcsuper, b3v, thSAD=thSAD) : nop()
99
b4c = tschrrad > 3 ? input.MCompensate(mcsuper, b4v, thSAD=thSAD) : nop()
100
b5c = tschrrad > 4 ? input.MCompensate(mcsuper, b5v, thSAD=thSAD) : nop()
101
102
         tschrrad == 5 ? interleave(f5c,f4c,f3c,f2c,f1c,input,b1c,b2c,b3c,b4c,b5c) : \
103
         tschrrad == 4 ? interleave(f4c,f3c,f2c,f1c,input,b1c,b2c,b3c,b4c) : \
104
         tschrrad == 3 ? interleave(f3c,f2c,f1c,input,b1c,b2c,b3c) : \
105
         tschrrad == 2 ? interleave(f2c,f1c,input,b1c,b2c) : \
106
                         interleave(f1c,input,b1c)
107
  }