SHOW:
|
|
- or go back to the newest paste.
1 | # Motion-compensated dfttest by twc | |
2 | # Aka: Really Really Really Slow | |
3 | # | |
4 | # v2 by BakaProxy | |
5 | # Aka: Even more Really Really Really slow | |
6 | # Added: Recalculate, (proper) 16 bit input handling, dither_luma_rebuild and some masking to prevent 16 bit data loss from 8 bit Mdegrain and Mcompensate | |
7 | # | |
8 | # | |
9 | # v3.91 by A.SONY | |
10 | # make it work in normal avs again and some fix, and not that slow if you use it without lsb/lsb_in | |
11 | # add slice bool to use it to avoid artifacts with avstp | |
12 | # clean up | |
13 | # New Features | |
14 | # | |
15 | # Requirements: | |
16 | # dfttest | |
17 | # MVTools2 | |
18 | # | |
19 | # Suggested: | |
20 | # Dither (for stack16 processing) | |
21 | # | |
22 | # Description of function parameters: | |
23 | # | |
24 | # pp = Clip to calculate vectors from (default input) | |
25 | # mc = Number of frames in each direction to compensate (default 2, max 5) | |
26 | # mdg = Run MDeGrain before dfttest (default false) | |
27 | # mdgSAD = thSAD for MDeGrain (default 400) | |
28 | # lsb = stack16 output and processing (default false) | |
29 | # | |
30 | # dfttest Y, U, V, sigma, sbsize, sosize, tbsize, and dither are supported. | |
31 | # Extra dfttest parameters may be passed via dfttest_params. | |
32 | # MVTools2 pel, thSCD, thSAD, blksize, overlap, dct, search, and | |
33 | # searchparam are also supported. | |
34 | # | |
35 | # sigma is the main control of dfttest strength. | |
36 | # tbsize should not be set higher than mc * 2 + 1. | |
37 | ||
38 | function dfttestMC(clip input, clip "pp", int "mc", bool "mdg", bool "Y", bool "U", bool "V", float "sigma", int "sbsize", int "sosize", int "tbsize", int "dither", bool "lsb",bool "lsb_in",bool "pp_lsb_in",int "super_filter", | |
39 | \ string "dfttest_params",float "rStr",float "Amp", int "mdgSAD", int "thSAD", int "thSCD1", int "thSCD2", bool "recalculate", bool "truemotion", int "pel", int "blksize", int "search", int "searchparam", int "overlap", | |
40 | \ int "dct", bool "slices", bool "luma_rebuild", string "nstring", string "sstring", string "ssx", string "ssy", string "sst", bool "mdg_domask", string "mdg_mask", clip "ppsuper", clip "super", clip "exmcclip", bool "hd", clip "input8") | |
41 | { | |
42 | # Set default options. Most external parameters are passed valueless. | |
43 | ||
44 | exmc = defined(exmcclip) | |
45 | mc = default(mc, 2).min(5) | |
46 | Y = default(Y, true) | |
47 | U = default(U, true) | |
48 | V = default(V, true) | |
49 | mdg = default(mdg, false) | |
50 | lsb = default(lsb, false) | |
51 | lsb_in = default(lsb_in, false) | |
52 | input8 = defined(input8) ? input8 : lsb_in ? input.ditherpost(mode=7,slice=slices,y=y ? 3 : 1,u=u ? 3 : 1,v=v ? 3 : 1) : input | |
53 | super_filter = default(super_filter,4) | |
54 | pp_enabled = defined(pp) | |
55 | pp_lsb_in = default(pp_lsb_in,(pp_enabled ? lsb_in ? (height(input) == height(pp)) ? true : false : false : false )) | |
56 | lsb_enable = false | |
57 | truemotion = default(truemotion,true) | |
58 | tbsize = default(tbsize, mc * 2 + 1) | |
59 | dfttest_params = default(dfttest_params, "") | |
60 | ox = defined(HD) ? nop() : input8.width() | |
61 | oy = defined(HD) ? nop() : input8.height() | |
62 | HD = defined(HD) ? HD : (ox > 1099 || oy > 599) | |
63 | pel = default( pel, HD ? 1 : 2 ) | |
64 | blksize = default(blksize,HD ? 16:8) | |
65 | blksize2 = int(blksize/2) + (int(blksize/2)%2) | |
66 | search = default(search, HD ? 4 : 5) | |
67 | overlap = default(overlap,blksize2) | |
68 | overlap2 = int(overlap/2) + (int(overlap/2)%2) | |
69 | recalculate = default(recalculate,mdg) | |
70 | mdgSAD = default(mdgSAD, 400) | |
71 | mdgSAD2= mdgSAD/2 | |
72 | thSAD = default(thSAD , mdgSAD) | |
73 | rStr = default( rStr, 1.0 ) | |
74 | Amp = default( Amp, 0.0625 ) | |
75 | slices = default(slices, true) | |
76 | luma_rebuild = default(luma_rebuild, true) | |
77 | mdg_domask = default(mdg_domask, mdg) | |
78 | ||
79 | avs26 = VersionNumber() < 2.60 ? false : true | |
80 | ||
81 | # Set chroma parameters. | |
82 | chroma = U || V | |
83 | plane = U && !Y && !V ? 1 : V && !Y && !U ? 2 : chroma && !Y ? 3 : Y && chroma ? 4 : 0 | |
84 | ||
85 | # Prepare supersampled clips. | |
86 | !exmc || mdg ? eval(""" | |
87 | pp = (pp_enabled) && !defined(ppsuper) ? luma_rebuild ? pp.dither_luma_rebuild(S0=rStr,c=Amp,slice=slices,lsb_in=pp_lsb_in,lsb_out=false,uv=((U&&v)?3:1)) : pp : nop() | |
88 | pp_super = defined(ppsuper) ? ppsuper : exmc ? nop() : pp_enabled ? MSuper(pp, pel=pel, chroma=chroma,rfilter=super_filter) : MSuper(input8, pel=pel, chroma=chroma) | |
89 | super = defined(super) ? super : pp_enabled ? input8.MSuper(pel=pel, levels=1, chroma=chroma) : pp_super | |
90 | recalc_sup = recalculate && pp_enabled ? MSuper(pp,pel=pel, levels=1, chroma=chroma) : pp_super | |
91 | ||
92 | # Motion vector search. | |
93 | b5vec = mc == 5 ? MAnalyse(pp_super, delta=5, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
94 | b4vec = mc > 3 ? MAnalyse(pp_super, delta=4, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
95 | b3vec = mc > 2 ? MAnalyse(pp_super, delta=3, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
96 | b2vec = mc > 1 ? MAnalyse(pp_super, delta=2, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
97 | b1vec = MAnalyse(pp_super, delta=1, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) | |
98 | f1vec = MAnalyse(pp_super, delta=1, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) | |
99 | f2vec = mc > 1 ? MAnalyse(pp_super, delta=2, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
100 | f3vec = mc > 2 ? MAnalyse(pp_super, delta=3, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
101 | f4vec = mc > 3 ? MAnalyse(pp_super, delta=4, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
102 | f5vec = mc == 5 ? MAnalyse(pp_super, delta=5, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
103 | """) : nop() | |
104 | ||
105 | ||
106 | recalculate ? Eval(""" | |
107 | b5vec = mc == 5 ? MRecalculate(recalc_sup,b5vec , chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
108 | b4vec = mc > 3 ? MRecalculate(recalc_sup,b4vec , chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
109 | b3vec = mc > 2 ? MRecalculate(recalc_sup,b3vec , chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
110 | b2vec = mc > 1 ? MRecalculate(recalc_sup,b2vec , chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
111 | b1vec = MRecalculate(recalc_sup,b1vec , chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) | |
112 | f1vec = MRecalculate(recalc_sup,f1vec, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) | |
113 | f2vec = mc > 1 ? MRecalculate(recalc_sup,f2vec, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
114 | f3vec = mc > 2 ? MRecalculate(recalc_sup,f3vec, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
115 | f4vec = mc > 3 ? MRecalculate(recalc_sup,f4vec, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
116 | f5vec = mc == 5 ? MRecalculate(recalc_sup,f5vec, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap2, blksize=blksize2, dct=dct,thSAD=mdgSAD2,truemotion=truemotion) : nop() | |
117 | """) : nop() | |
118 | ||
119 | # Optional MDegrain. | |
120 | Eval(""" | |
121 | try { | |
122 | degrained = lsb || lsb_in ? mc == 5 && mdg ? MDeGrain5(input8, super, b1vec, f1vec, b2vec, f2vec, b3vec, f3vec, b4vec, f4vec, b5vec, f5vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2, lsb=true) : | |
123 | \ mc == 4 && mdg ? MDeGrain4(input8, super, b1vec, f1vec, b2vec, f2vec, b3vec, f3vec, b4vec, f4vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2, lsb=true) : | |
124 | \ mc == 3 && mdg ? MDeGrain3(input8, super, b1vec, f1vec, b2vec, f2vec, b3vec, f3vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2, lsb=true) : | |
125 | \ mc == 2 && mdg ? MDeGrain2(input8, super, b1vec, f1vec, b2vec, f2vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2, lsb=true) : | |
126 | \ mdg ? MDeGrain1(input8, super, b1vec, f1vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2, lsb=true) : lsb_in ? input : errmsggonext : | |
127 | \ errmsggonext | |
128 | degrained = mdg_domask && mdg ? defined(mdg_mask) ? eval(mdg_mask) : DarkPreserve_function(degrained,input,lsb_in=lsb_in) : degrained | |
129 | degrained8 = lsb ? degrained.dither_get_msb() : degrained.ditherpost(mode=7,slice=slices,y=y ? 3 : 1,u=u ? 3 : 1,v=v ? 3 : 1) | |
130 | lsb_enable = true | |
131 | } catch(err_msg) | |
132 | { | |
133 | degrained8 = avs26 && mc == 5 && mdg ? MDeGrain5(input8, super, b1vec, f1vec, b2vec, f2vec, b3vec, f3vec, b4vec, f4vec, b5vec, f5vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2) : | |
134 | \ avs26 && mc == 4 && mdg ? MDeGrain4(input8, super, b1vec, f1vec, b2vec, f2vec, b3vec, f3vec, b4vec, f4vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2) : | |
135 | \ mc >= 3 && mdg ? MDeGrain3(input8, super, b1vec, f1vec, b2vec, f2vec, b3vec, f3vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2) : | |
136 | \ mc == 2 && mdg ? MDeGrain2(input8, super, b1vec, f1vec, b2vec, f2vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2) : | |
137 | \ mdg ? MDeGrain1(input8, super, b1vec, f1vec, thSAD=mdgSAD, plane=plane, thSCD1=thSCD1, thSCD2=thSCD2) : input8 | |
138 | degrained8 = mdg_domask && mdg ? defined(mdg_mask) ? eval(mdg_mask) : DarkPreserve_function(degrained8,input,lsb_in=lsb_in) : degrained8 | |
139 | lsb_enable = false | |
140 | } | |
141 | """) | |
142 | !exmc ? eval(""" | |
143 | degrained_super = mdg ? MSuper(degrained8, pel=pel, levels=1, chroma=chroma) : super | |
144 | b5clip = mc == 5 ? MCompensate(degrained8, degrained_super, b5vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
145 | b4clip = mc > 3 ? MCompensate(degrained8, degrained_super, b4vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
146 | b3clip = mc > 2 ? MCompensate(degrained8, degrained_super, b3vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
147 | b2clip = mc > 1 ? MCompensate(degrained8, degrained_super, b2vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
148 | b1clip = MCompensate(degrained8, degrained_super, b1vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) | |
149 | f1clip = MCompensate(degrained8, degrained_super, f1vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) | |
150 | f2clip = mc > 1 ? MCompensate(degrained8, degrained_super, f2vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
151 | f3clip = mc > 2 ? MCompensate(degrained8, degrained_super, f3vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
152 | f4clip = mc > 3 ? MCompensate(degrained8, degrained_super, f4vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
153 | f5clip = mc == 5 ? MCompensate(degrained8, degrained_super, f5vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
154 | """) : nop() | |
155 | ||
156 | # Create compensated clip. | |
157 | interleaved = !exmc && mc == 5 ? Interleave(f5clip, f4clip, f3clip, f2clip, f1clip, degrained8, b1clip, b2clip, b3clip, b4clip, b5clip) : | |
158 | \ !exmc && mc == 4 ? Interleave(f4clip, f3clip, f2clip, f1clip, degrained8, b1clip, b2clip, b3clip, b4clip) : | |
159 | \ !exmc && mc == 3 ? Interleave(f3clip, f2clip, f1clip, degrained8, b1clip, b2clip, b3clip) : | |
160 | \ !exmc && mc == 2 ? Interleave(f2clip, f1clip, degrained8, b1clip, b2clip) : | |
161 | \ !exmc ? Interleave(f1clip, degrained8, b1clip) : exmcclip | |
162 | ||
163 | degrained = lsb_enable ? lsb_in && mdg ? input.Dither_limit_dif16(degrained, thr=1.0, elast=2.0) : degrained : nop() | |
164 | degrained = lsb_enable ? degrained : lsb_in ? input.Dither_limit_dif16(degrained8.dither_convert_8_to_16(), thr=1.0, elast=2.0) : nop() | |
165 | ||
166 | degrained16mc = lsb_enable || lsb_in ? degrained.changefps(interleaved,linear=true) : nop() | |
167 | ||
168 | mask = lsb_enable || lsb_in ? mt_logic(interleaved,degrained16mc.dither_get_msb(), "xor",y=y ? 3 : 1,u=u ? 3 : 1,v=v ? 3 : 1).mt_binarize(0,y=y ? 3 : 1,u=u ? 3 : 1,v=v ? 3 : 1) : nop() | |
169 | ||
170 | interleaved16 = lsb_enable || lsb_in ? Dither_merge16_8(degrained16mc,interleaved.dither_convert_8_to_16(),mask,u=u ? 3 : 1,v=v ? 3 : 1) : interleaved | |
171 | ||
172 | # Perform dfttest. Exception handling required for official dfttest. | |
173 | Eval(""" | |
174 | try { | |
175 | filtered = Eval("dfttest(interleaved16, Y=Y, U=U, V=V, sigma=sigma, sbsize=sbsize, sosize=sosize, tbsize=tbsize, dither=dither, lsb=lsb,lsb_in=lsb_enable || lsb_in, nstring=nstring, sstring=sstring, ssx=ssx, ssy=ssy, sst=sst" + dfttest_params + ")") | |
176 | } catch(err_msg) | |
177 | { | |
178 | filtered = Eval("dfttest(interleaved, Y=Y, U=U, V=V, sigma=sigma, sbsize=sbsize, sosize=sosize, tbsize=tbsize, dither=dither, nstring=nstring, sstring=sstring, ssx=ssx, ssy=ssy, sst=sst" + dfttest_params + ")") | |
179 | } | |
180 | """) | |
181 | ||
182 | return selectEvery(filtered, mc * 2 + 1, mc) | |
183 | } | |
184 | ||
185 | ||
186 | function sMCclips(clip input, clip pp_super, clip super, int "mc", | |
187 | \ int "thSAD", int "thSCD1", int "thSCD2", bool "truemotion", bool "chroma", int "blksize", int "search", int "searchparam", int "overlap", | |
188 | \ int "dct", bool "HD") | |
189 | { | |
190 | mc = default(mc, 2).min(5) | |
191 | HD = default(HD, false) | |
192 | truemotion = default(truemotion,true) | |
193 | blksize = default(blksize,HD ? 16:8) | |
194 | blksize2 = int(blksize/2) + (int(blksize/2)%2) | |
195 | search = default(search, HD ? 4 : 5) | |
196 | overlap = default(overlap,blksize2) | |
197 | thSAD = default(thSAD , 400) | |
198 | chroma = default(chroma, true) | |
199 | ||
200 | # Motion vector search. | |
201 | b5vec = mc == 5 ? MAnalyse(pp_super, delta=5, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
202 | b4vec = mc > 3 ? MAnalyse(pp_super, delta=4, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
203 | b3vec = mc > 2 ? MAnalyse(pp_super, delta=3, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
204 | b2vec = mc > 1 ? MAnalyse(pp_super, delta=2, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
205 | b1vec = MAnalyse(pp_super, delta=1, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) | |
206 | f1vec = MAnalyse(pp_super, delta=1, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) | |
207 | f2vec = mc > 1 ? MAnalyse(pp_super, delta=2, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
208 | f3vec = mc > 2 ? MAnalyse(pp_super, delta=3, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
209 | f4vec = mc > 3 ? MAnalyse(pp_super, delta=4, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
210 | f5vec = mc == 5 ? MAnalyse(pp_super, delta=5, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct,truemotion=truemotion) : nop() | |
211 | ||
212 | eval(""" | |
213 | b5clip = mc == 5 ? MCompensate(input, super, b5vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
214 | b4clip = mc > 3 ? MCompensate(input, super, b4vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
215 | b3clip = mc > 2 ? MCompensate(input, super, b3vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
216 | b2clip = mc > 1 ? MCompensate(input, super, b2vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
217 | b1clip = MCompensate(input, super, b1vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) | |
218 | f1clip = MCompensate(input, super, f1vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) | |
219 | f2clip = mc > 1 ? MCompensate(input, super, f2vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
220 | f3clip = mc > 2 ? MCompensate(input, super, f3vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
221 | f4clip = mc > 3 ? MCompensate(input, super, f4vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
222 | f5clip = mc == 5 ? MCompensate(input, super, f5vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2) : nop() | |
223 | """) | |
224 | ||
225 | # Create compensated clip. | |
226 | interleaved = mc == 5 ? Interleave(f5clip, f4clip, f3clip, f2clip, f1clip, input, b1clip, b2clip, b3clip, b4clip, b5clip) : | |
227 | \ mc == 4 ? Interleave(f4clip, f3clip, f2clip, f1clip, input, b1clip, b2clip, b3clip, b4clip) : | |
228 | \ mc == 3 ? Interleave(f3clip, f2clip, f1clip, input, b1clip, b2clip, b3clip) : | |
229 | \ mc == 2 ? Interleave(f2clip, f1clip, input, b1clip, b2clip) : | |
230 | \ Interleave(f1clip, input, b1clip) | |
231 | ||
232 | return interleaved | |
233 | } | |
234 | ||
235 | ||
236 | function spp_super(clip input, clip "pp", int "dither", bool "lsb",bool "lsb_in",bool "pp_lsb_in",int "super_filter", | |
237 | \ float "rStr",float "Amp", int "pel", bool "Y", bool "U", bool "V", | |
238 | \ bool "slices", bool "luma_rebuild", bool "HD") | |
239 | { | |
240 | Y = default(Y, true) | |
241 | U = default(U, true) | |
242 | V = default(V, true) | |
243 | HD = default(HD, false) | |
244 | lsb_in = default(lsb_in, false) | |
245 | input8 = lsb_in ? input.ditherpost(mode=7,slice=slices,y=y ? 3 : 1,u=u ? 3 : 1,v=v ? 3 : 1) : input | |
246 | super_filter = default(super_filter,4) | |
247 | pp_enabled = defined(pp) | |
248 | pp_lsb_in = default(pp_lsb_in,(pp_enabled ? lsb_in ? (height(input) == height(pp)) ? true : false : false : false )) | |
249 | pel = default( pel, HD ? 1 : 2 ) | |
250 | rStr = default( rStr, 1.0 ) | |
251 | Amp = default( Amp, 0.0625 ) | |
252 | slices = default(slices, true) | |
253 | luma_rebuild = default(luma_rebuild, true) | |
254 | ||
255 | # Set chroma parameters. | |
256 | chroma = U || V | |
257 | ||
258 | # Prepare supersampled clips. | |
259 | pp = (pp_enabled) ? luma_rebuild ? pp.dither_luma_rebuild(S0=rStr,c=Amp,slice=slices,lsb_in=pp_lsb_in,lsb_out=false,uv=((U&&v)?3:1)) : pp : nop() | |
260 | pp_super = pp_enabled ? MSuper(pp, pel=pel, chroma=chroma,rfilter=super_filter) : MSuper(input8, pel=pel, chroma=chroma) | |
261 | ||
262 | return pp_super | |
263 | } |