Guest User

AnimeIVTC 2 mod

a guest
Apr 15th, 2015
394
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # AnimeIVTC() by thetoof
  2. # v2.00 2015-4-15 mod
  3. # last update by AmjadSONY was:- make "precision=1" use "nnedi3" only for "Toriko Anime" by using it like this:- AnimeIVTC(1, precision=1)
  4. # add mode22 bool to use it in mode 2 for Spatial field-blend (field-blend in a part of the picture), ex:- AnimeIVTC(2, bbob=1, mode22=true)
  5. # TC file now will out in V2 ;) , add ediext clip to use it with QTGMC and add bob4p to change QTGMC Preset , add extbob clip to use an External bobber with bbob/cbob=5 , chrfix in mode 1 and other things fixed by doom9 member
  6. # make chrfix work. add dchr bool, can help chrfix with some source, add palf bool for no decimate in mode 1 and make fps 24 instead of 25 for mode 2 in pal source, add tcfv1 bool to made TC file v1 and make it true by default
  7. # add nvfr bool for VFR noisy sources, add real30p bool to not use daa with 30p, and some fix in for PAL cases and other things
  8. # add TFM (mode, cthresh, blockx, blocky, MI) and some fix
  9. # add extbobf string to use external bob function, old external bob clip (extbob) still exist, and if you use both the old extbob will win
  10.  
  11. # Read the documentation for all the required info to know how to use this function, With note that there are some things have changed in this MOD
  12.  
  13. function AnimeIVTC (clip i, int "mode", int "aa", int "precision", int "killcomb", int "cache", bool "ifade", float "sfthr", bool "sfshow"\
  14.         , bool "chrfix"\
  15.         , bool "blend"\  
  16.         , bool "normconv"\
  17.         , int "pattern"\
  18.         , int "pass", bool "rendering" \
  19.         , int "bbob", int "cbob", string "edimode", int "degrain", int "omode", int "cthresh", int "blockx", int "blocky", int "MI", int "tfmm"\
  20.         , int "i1", int "i2", int "e1", int "e2", int "e3", int "p1", int "p2", bool "dchr", bool "palf", bool "tcfv1", bool "nvfr", bool "real30p" \
  21.         , int "overlap", int "pel", int "search", bool "nnedi3pel", string "credconv", bool "mode22", clip "ediext", string "bob4p", clip "extbob", string "extbobf"\
  22.         , float "dark", int "thin", int "sharp", int "smooth", bool "stabilize", int "tradius", int "aapel", int "aaov", int "aablk", string "aatype"){
  23.  
  24. ###General arguments###
  25. Assert(defined(mode), "Specify a mode... please read the documentation.")
  26.  
  27. #Highest quality by default
  28. precision   = default ( precision,        3 )
  29.  
  30. #change pal fps
  31. palf    = default ( palf,         false )
  32.  
  33. #VFR default optional
  34. tcfv1   = default ( tcfv1,        true  )
  35. nvfr    = default ( nvfr,         false )
  36.  
  37. #boolean "creds" is set to true if any of the i/p arguments are defined (i.e. if there's a 30i or 30p section to process)
  38. creds = defined(i1) ? true : false
  39. creds = defined(i2) ? true : creds
  40. creds = defined(p1) ? true : creds
  41. creds = defined(p2) ? true : creds
  42. creds = defined(e1) ? true : creds
  43. creds = defined(e2) ? true : creds
  44. creds = defined(e3) ? true : creds
  45.  
  46. # real30p
  47. real30p  = default( real30p,        false)
  48.  
  49. ###Framerate preparation###
  50. normconv = default( normconv, false)
  51. #Determine source region by analysing framerate
  52. Ifrate  = round(framerate(i))==30 ? 1 : framerate(i)==25 ? 2 : 3
  53. assert(ifrate!=3, "What is your input clip?? It's not 30fps NTSC nor 25fps PAL... maybe you're using the function for a purpose it was not meant to. Please post in the AnimeIVTC thread.")
  54.  
  55. #Set the output to the other region if normconv (norm-conversion) is set to true, use same as input if not
  56. Ofrate  = Ifrate==1 && normconv ? 2 : Ifrate==2 && normconv ? 1 : Ifrate
  57.  
  58. #prepare arguments for srestore and tdecimate based on user settings (as seen previously)
  59. frate   = Ofrate==1 ? 23.976 : palf ? 24 : 25
  60. tnum    = Ofrate==1 ? (mode==1 && palf) ? 30000 : 24000 : (mode==2 && palf) ? 24 : ((mode==1 && palf) || mode==2) ? 25 : 20
  61. tden    = Ofrate==1 ? 1001 : 1
  62.  
  63.  
  64.  
  65. #Set pattern=0 (tdecimate) for DHT (safest)
  66. pattern     = default ( pattern,          0 )
  67.  
  68. #Set defaults of bobbing filters to use to general optimal quality
  69. bbob        = default ( bbob,             3 )
  70. cbob        = default ( cbob,             4 )
  71. bob4p       = default ( bob4p,     "Slower" )
  72. bob5_with_extbob= (cbob >= 5 || bbob >= 5) ? (defined(extbobf) || defined(extbob)) ? 1 : 0 : 2
  73. Assert(bob5_with_extbob!=0 , "please specify extbobf or extbob if you use bbob=5 or cbob=5.")
  74.  
  75. #Sets output mode to 1 (23.976fps for NTSC and 25fps for PAL) when no 30i or 30p sections are specified and sets it to 0 to use NOP() for every operation where it needs to be specified by the user
  76. omode = (creds==false && mode!=4) || ofrate==2 || normconv ? 1 : default (omode, 0)
  77. Assert(omode!=0, "Specify an output mode (omode)... please read the documentation.")
  78. normconv ? assert(mode==2, "Why would you use normconv=true with a telecined source?") : nop()
  79.  
  80. ###Framerate conversion arguments###
  81. bs      = (i.width>1100) ? 16 : 8
  82. overlap     = default ( overlap,           bs/2 )
  83. pel         = default ( pel,          2 )
  84. search      = default ( search,           4 )
  85. assert(search >= 2, "Using a lower search than 2 will most probably lead to weird artifacts")
  86. nnedi3pel   = default ( nnedi3pel,        false )
  87. credconv    = default ( credconv,       omode==2 ? "a" : "blah" )
  88. creds ? assert(credconv!= "blah", "Please specify credconv. Check in the docs to see which is more appropriate to your source.") : nop()
  89.  
  90. #VFR - If this is pass=2 and that the user made a rendering pass out of pass=1, use input directly for decimation instead of recomputing everything
  91. pass        = default (pass,          1 )
  92. rendering   = default ( rendering,        false )
  93.  
  94. #Ask if hard telecine (mode=1) is actually blend telecine (patter = 3 clean frames followed by 2 blended ones)
  95. blend       = default ( blend,        false )
  96.  
  97. #Ask if double chroma blend removal is needed (see guide for more info about this problem)
  98. chrfix  = default ( chrfix,       false )
  99. dchr    = default ( dchr,       false )
  100.  
  101. #mode22 for Spatial field-blend
  102. mode22  = default ( mode22,       false )
  103.  
  104. #Set cache to 10 frames for all functions using scriptclip to prevent seeking issues + frame order mess-up with temporal filters
  105. cache       = default ( cache,       10 )
  106.  
  107. #Let the user decide which edimode (optimal varies greatly depending on source) and degrain (++ affects quality vs speed) settings to use in qTGMC
  108. edimode     = default ( edimode,       "nnedi3" )
  109. degrain     = default ( degrain,          1 )
  110.  
  111. #Set decombing and antialiasing filters to off by default
  112. killcomb    = default ( killcomb,         0 )
  113. aa      = default ( aa,           0 )
  114. aa = killcomb==3 && aa==2 ? 0 : aa
  115.  
  116. #Set interlaced fade ins detection (and correction to off by default)
  117. ifade       = default ( ifade,         false )
  118. #Also turn it off if aa=2 (use daa()), since it applies the same operation on the whole clip as ifade would have had selectively)
  119. ifade       = aa==2 || killcomb==3 ? false : ifade
  120. sfthr   = default ( sfthr,  0.4 )
  121. sfshow = default ( sfshow, false )
  122.  
  123. ###Alright, let's start doing something :p ###
  124.  
  125.  
  126. #########
  127. #Bobbing#
  128. #########
  129.  
  130. #Assign clip to prevent double computation
  131. edeint= i.nnedi3(-2)
  132. emask = i.tmm(1)
  133.  
  134. #For later NOP() use if blendbob is not needed
  135. usebbob = chrfix && blend || mode==2
  136.  
  137.  
  138. #Use non-motion-compensated bobber for blended clips since blends have a negative impact on motion detection (if blends are averaged with frames, they can be harder to detect/remove) (mode=2 and mode=1 with blend and chrfix because blend telecine... well has a lot of blends)
  139. blendbob    = usebbob ? bbob<=0 ? i.tdeint(1)                                       :
  140. \               bbob==1 ? i.tdeint(1,       edeint=edeint   )                       :
  141. \               bbob==2 ? i.tdeint(1,       edeint=edeint,emask=emask)              :
  142. \               bbob==3 ? i.yadifmod(mode=1,    edeint=edeint)                      :
  143. \               bbob==4 ? i.QTGMC(Preset=bob4p,edimode=edimode,tr2=degrain,ediext=ediext)   :
  144. \                         defined(extbob) ? extbob : Eval("i." + extbobf)                       : NOP()
  145.  
  146. #For later NOP() use if clearbob is not needed
  147. usecbob = mode==3 || defined(i1) || chrfix && blend==false
  148.  
  149. #Allow usage of mo-comp bobber (TempGaussMC) when source is not blended. Highly recommended for stability. (mode=3, interlaced credits, used in chrfix because impact is minimal compared to bob flicker on the whole clip)
  150. clearbob    = usecbob ? cbob<=0 ? i.tdeint(1)                                       :
  151. \               cbob==1 ? i.tdeint(1,       edeint=edeint)                          :
  152. \               cbob==2 ? i.tdeint(1,       edeint=edeint,emask=emask)                  :
  153. \               cbob==3 ? i.yadifmod(mode=1,    edeint=edeint)                          :
  154. \                   cbob==4 ? i.QTGMC(Preset=bob4p,edimode=edimode,tr2=degrain,ediext=ediext)   :
  155. \                         defined(extbob) ? extbob : Eval("i." + extbobf)                       : NOP()
  156.  
  157. ############################
  158. #Chroma swap between fields# chrfix
  159. ############################
  160.  
  161. #Repair double chroma blending if requested by user using xbob depending on source (known by the mode)
  162. chrdeb = chrfix ? blend || mode==2 ? dchr ? blendbob.chroma_rep2(cache) : blendbob.chroma_rep(cache) : dchr ? clearbob.chroma_rep2(cache) : clearbob.chroma_rep(cache) : nop()
  163.  
  164. #Remove duplicates (like a safe selecteven/odd) for further processing before final decimation (hybrid decimation (except blend decimation to prevent having 2 calls of tdecimate) or blend telecine IVTC)
  165. #Once bobbed, in mode=1 (tdecimate(1,3,5), in mode=1 + blend = back to 30fps for further deblending, in mode=2 srestore will do the job, in mode=3 tdecimate(1,3,5), in mode 4 VFR needs 30, CFR can do it (personal notes)
  166. debprep = chrfix ? mode==1 && blend || mode==4 && omode==2 ? chrdeb.tdecimate(1,1,2) : chrdeb : i
  167.  
  168. ################
  169. #Field matching# MODE=1 AND 4
  170. ################
  171.  
  172. #Field match for mode 1, pass 2 of mode 4 (hybrid without tfm.txt output) or mode=4 with blend decimation (no need for txt file) or mode=4 with interlaced credits (txt file unusable)
  173. usefm = mode==1 || (mode==4 && (pass==2 || creds || omode==1))
  174.  
  175. #field match for hard telecine or blend telecine restoration for mode==1
  176. fm =    (precision==0 && usefm) ? blend ? debprep.srestore(omode="pp0") : i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI) :
  177. \   (precision==1 && usefm) ? blend ? debprep.srestore(omode="pp1") : i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI,clip2=i.nnedi3) :
  178. \   (precision==2 && usefm) ? blend ? debprep.srestore(omode="pp2") : i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI,clip2=i.tdeint(2,edeint=edeint)) :
  179. \   (precision==3 && usefm) ? blend ? debprep.srestore(omode="pp3") : i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI,clip2=i.tdeint(2,edeint=edeint,emask=emask)) :
  180. \   nop()
  181. fm = usefm ? ifade ? fm.smartfademod(sfthr, sfshow, cache) : fm : nop()
  182.  
  183. #Field match + tfm.txt output for VFR clips (mode=4, pass=1)
  184. usehfm = mode==4 && pass==1 && usefm==false
  185.  
  186. hybridfm =  (usehfm && precision==0) ? i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI, output="tfm.txt") :
  187. \       (usehfm && precision==1) ? i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI, output="tfm.txt",clip2=i.nnedi3) :
  188. \       (usehfm && precision==2) ? i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI, output="tfm.txt",clip2=i.tdeint(2,edeint=edeint)) :
  189. \       (usehfm && precision==3) ? i.tfm(slow=2,mode=tfmm,cthresh=cthresh,blockx=blockx,blocky=blocky,MI=MI, output="tfm.txt",clip2=i.tdeint(2,edeint=edeint,emask=emask)) :
  190. \       nop()
  191. hybridfm = usehfm ? ifade ? hybridfm.smartfademod(sfthr, sfshow, cache) : hybridfm : nop()
  192.  
  193. ###############        ######################
  194. #Field blended# MODE=2 #Double hard telecine# MODE=3
  195. ###############        ######################
  196.  
  197. #Since during double chroma blend removal it was checked whether to use blendbob or clearbob depending on the source (blendbob was used for field blended and clearbob was used for double hard telecine), use chrbob when chrfix=true, else use the appropriate one
  198.  
  199. fbbob = mode==2 ? chrfix ? debprep : blendbob : nop()
  200.  
  201. dhtbob = mode==3 ? chrfix ? debprep : clearbob : nop()
  202.  
  203. ################
  204. #CFR decimation# OMODE=1
  205. ################
  206.  
  207. #HT decimation (mode=1), remove 3 frames out of 5 when chrfix=true since the clip has been bobbed to 60fps
  208. fmdecim = mode==1 ? chrfix ? debprep.tdecimate(1,3,5) : palf ? fm : fm.tdecimate()                                          : nop()
  209.  
  210. #Field blended blend removal & decimation (mode=2) No need to check for chrfix since it was done in the previous step
  211. fbdecim = mode==2 ? mode22 ? chrfix ? fbbob.srestore(omode=2, mode=4, thresh=44, cache=cache, dclip=fbbob.crop(10,0,-10,0)).srestore(frate=frate, mode=4, speed=-4, cache=cache) :  fbbob.srestore(omode=2, mode=4, thresh=44, cache=cache, dclip=fbbob.crop(10,0,-10,0)).srestore(frate=frate, mode=-4, speed=-4, cache=cache)     :
  212. \chrfix ? fbbob.srestore(frate=frate, cache=cache) :    fbbob.srestore(frate=frate, cache=cache, dclip=i.bob(-0.2,0.6).reduceflicker(strength=1))   : nop()
  213.  
  214. #Pattern finding and decimation for double hard telecine (mode=3) No need to check for chrfix since it was done in the previous step
  215. a= mode==3 && (pattern==1 || pattern==-1) ? dhtbob.selectevery(5,0,3) : NOP()
  216. b= mode==3 && (pattern==2 || pattern==-1) ? dhtbob.selectevery(5,1,4) : NOP()
  217. c= mode==3 && (pattern==3 || pattern==-1) ? dhtbob.selectevery(5,0,2) : NOP()
  218. d= mode==3 && (pattern==4 || pattern==-1) ? dhtbob.selectevery(5,1,3) : NOP()
  219. e= mode==3 && (pattern==5 || pattern==-1) ? dhtbob.selectevery(5,2,4) : NOP()
  220. dhtdecim = mode==3 ?            pattern==-1 ? stackvertical(stackhorizontal(a.subtitle("pattern=1"),b.subtitle("pattern=2"),c.subtitle("pattern=3")),stackhorizontal(d.subtitle("pattern=4"),e.subtitle("pattern=5"),e.blackness())) :
  221. \                   pattern==1 ? a :
  222. \                   pattern==2 ? b :
  223. \                   pattern==3 ? c :
  224. \                   pattern==4 ? d :
  225. \                   pattern==5 ? e :
  226. \                   dhtbob.tdecimate(1,3,5) : nop()
  227.  
  228. #Hybrid CFR blend decimation of 30p into 24p
  229. blenddecim = (mode==4 && omode==1) ? chrfix ? debprep.tdecimate(1,3,5,hybrid=1) :   fm.tdecimate(hybrid=1)              : nop()
  230.  
  231. #########
  232. #Credits# CREDS=TRUE (USER SPECIFIES I1, I2, P1, P2, E1, E2 OR E3)
  233. #########
  234.  
  235. #Interlaced : use the same smart-bobbed clip as before; we don't care if the background is blended or not since it is unrecoverable anyways (at least for now... see developments about using masking to isolate creds from background)
  236. credbob = defined(i1) ? clearbob.selecteven() : nop()
  237.  
  238. #Progressive : Blend deinterlace the 24t background while doing minimal damage on the 30p credits
  239. blendbg= defined(p1) ? real30p ? i : i.daa3() : nop()
  240.  
  241. ###CFR conversion###
  242. #######################
  243. ###Framerate conversion (recommended for static or low-motion backgrounds since it is prone artifacts... it reduces framerate/motion based on motion vectors)
  244.  
  245. ####Convert the framerate of the interlaced credits
  246. #Determine if usage of the following conversion is required
  247. usemocompi = defined(i1) && credconv=="mocomp"
  248.  
  249. #External pelclip on source with nnedi, if requested
  250. upsi =      nnedi3pel && usemocompi ?   credbob.    nnedi3_rpow2(rfactor=pel,cshift="spline36resize")        : nop()
  251.  
  252. #Prepare super clip for the interlaced credits
  253. credbobsuper    = usemocompi ?          credbob.    MSuper(pel=pel, levels=0)                    : nop()
  254. credbobupsuper  = usemocompi && nnedi3pel ?     credbob.    MSuper(pel=pel, levels=0, pelclip=upsi)              : nop()
  255.  
  256. #Calculate vectors
  257. bvi =       usemocompi ? nnedi3pel ?    credbobupsuper. MAnalyse(isb = true,search=search, blksize=bs, overlap=overlap)  :
  258. \                       credbobsuper.   MAnalyse(isb = true,search=search, blksize=bs, overlap=overlap)  : nop()
  259.  
  260. fvi =       usemocompi ? nnedi3pel ?    credbobupsuper. MAnalyse(isb = false,search=search, blksize=bs, overlap=overlap) :
  261. \                       credbobsuper.   MAnalyse(isb = false,search=search, blksize=bs, overlap=overlap) : nop()
  262.  
  263. #Apply framerate conversion
  264. fpsconvi =      usemocompi ? nnedi3pel ?    credbob.    MFlowFps(credbobupsuper,bvi, fvi, tnum, tden)            :
  265. \                       credbob.    MFlowFps(credbobsuper,  bvi, fvi, tnum, tden)            : nop()
  266.  
  267. ###Convert the framerate of the progressive credits
  268. #Determine if usage of the following conversion is required
  269. usemocompp = defined(p1) && credconv=="mocomp"
  270.  
  271. #External pelclip on source with nnedi, if requested
  272. upsp =      nnedi3pel && usemocompp ?   blendbg.    nnedi3_rpow2(rfactor=pel,cshift="spline36resize")        : nop()
  273.  
  274. #Prepare super clip for the progressive credits
  275. blendbgsuper    = usemocompp ?          blendbg.MSuper(pel=pel, levels=0)                        : nop()
  276. blendbgsuperup  = usemocompp && nnedi3pel ?     blendbg.MSuper(pel=pel, levels=0, pelclip=upsp)                  : nop()
  277.  
  278. #Calculate vectors
  279. bvp =       usemocompp ? nnedi3pel ?    blendbgsuperup. MAnalyse(isb = true,search=search, blksize=bs, overlap=overlap)  :
  280. \                       blendbgsuper.   MAnalyse(isb = true,search=search, blksize=bs, overlap=overlap)  : nop()
  281.  
  282. fvp =       usemocompp ? nnedi3pel ?    blendbgsuperup. MAnalyse(isb = false,search=search, blksize=bs, overlap=overlap) :
  283. \                       blendbgsuper.   MAnalyse(isb = false,search=search, blksize=bs, overlap=overlap) : nop()
  284.  
  285. #Apply framerate conversion
  286. fpsconvp =  usemocompp ? nnedi3pel ?    blendbg.MFlowFps(blendbgsuperup,bvp, fvp, tnum, tden)                :
  287. \                       blendbg.MFlowFps(blendbgsuper,  bvp, fvp, tnum, tden)                : nop()
  288.  
  289. #######################
  290. ###Blend 30p creds into 24t (ugly and fast, but can lead to less disturbing artifacts when you have a high motion background)
  291. blendi = defined(i1) && credconv=="blend" ? credbob.convertfps(tnum,tden) : nop()
  292.  
  293. blendp = defined(p1) && credconv=="blend" ? blendbg.convertfps(tnum,tden) : nop()
  294.  
  295. #######################
  296. ###Drop frames 30p creds into 24t (ugly and fast, will lead to stuttery motion)
  297. drop_credconv = (credconv=="drop" && normconv) ? 1 : 0
  298.  
  299. assert(drop_credconv!=1, "Please choose another credconv. drop not compatible with normconv=true.")
  300.  
  301. dropi = defined(i1) && credconv=="drop" ? (mode==1 && palf) ? credbob : credbob.tdecimate(1) : nop()
  302.  
  303. dropp = defined(p1) && credconv=="drop" ? (mode==1 && palf) ? blendbg : blendbg.tdecimate(1) : nop()
  304.  
  305. ########
  306. #SPLICE# CREDS=TRUE (USER SPECIFIES I1, I2, P1, P2, E1, E2 OR E3)
  307. ########
  308.  
  309. #Determine the "mix" mode (how the different sections (30i, 24t, 30p) are spliced together)
  310. #Also check for user error when entering the frame numbers
  311.  
  312. mix22a17    = defined(e1) && defined(e2) && defined(e3) && defined(i1) && defined(p1)   ? true : false
  313. mix7        = defined(e1) && defined(e2) && defined(e3) && defined(i1) && defined(i2)   ? true : false
  314. mix14       = defined(e1) && defined(e2) && defined(e3) && defined(p1) && defined(p2)   ? true : false
  315.  
  316. mix21a20a16a15  = defined(e1) && defined(e2) && defined(i1) && defined(p1) && mix22a17==false   ? true : false
  317. mix6a3      = defined(e1) && defined(e2) && defined(i1) && defined(i2) && mix7==false   ? true : false
  318. mix13a10    = defined(e1) && defined(e2) && defined(p1) && defined(p2) && mix14==false  ? true : false
  319.  
  320. mix19a18    = defined(e1) && defined(p1) && defined(i1) && mix21a20a16a15==false    ? true : false
  321. mix9        = defined(e1) && defined(p1) && defined(p2) && mix13a10==false      ? true : false
  322. mix2        = defined(e1) && defined(i1) && defined(i2) && mix6a3==false        ? true : false
  323. mix4        = defined(e1) && defined(e2) && defined(i1) && mix21a20a16a15==false && mix6a3==false   ? true : false
  324. mix11       = defined(e1) && defined(e2) && defined(p1) && mix21a20a16a15==false && mix13a10==false ? true : false
  325.  
  326. mix1a5  = defined(e1) && defined(i1) && mix19a18==false && mix2==false && mix4==false       ? true : false
  327. mix8a12 = defined(e1) && defined(p1) && mix19a18==false && mix11==false && mix9==false      ? true : false
  328.  
  329.  
  330. #Getting the "mix" mode based on user input
  331. mix = 0
  332. mix = mix1a5        && i1<e1        ? 1 : mix
  333. mix = mix2      && i1<e1<i2         ? 2 : mix
  334. mix = mix6a3        && i1<e1<i2<e2      ? 3 : mix
  335. mix = mix4      && e1<i1<e2         ? 4 : mix
  336. mix = mix1a5        && e1<i1        ? 5 : mix
  337. mix = mix6a3        && e1<i1<e2<i2      ? 6 : mix
  338. mix = mix7      && e1<i1<e2<i2<e3   ? 7 : mix
  339. mix = mix8a12       && p1<e1        ? 8 : mix
  340. mix = mix9      && p1<e1<p2         ? 9 : mix
  341. mix = mix13a10      && p1<e1<p2<e2      ? 10 : mix
  342. mix = mix11         && e1<p1<e2         ? 11 : mix
  343. mix = mix8a12       && e1<p1        ? 12 : mix
  344. mix = mix13a10      && e1<p1<e2<p2      ? 13 : mix
  345. mix = mix14         && e1<p1<e2<p2<e3   ? 14 : mix
  346. mix = mix21a20a16a15    && e1<i1<e2<p1      ? 15 : mix
  347. mix = mix21a20a16a15    && i1<e1<p1<e2      ? 16 : mix
  348. mix = mix22a17      && e1<i1<e2<p1<e3   ? 17 : mix
  349. mix = mix19a18      && i1<e1<p1         ? 18 : mix
  350. mix = mix19a18      && p1<e1<i1         ? 19 : mix
  351. mix = mix21a20a16a15    && e1<p1<e2<i1      ? 20 : mix
  352. mix = mix21a20a16a15    && p1<e1<i1<e2      ? 21 : mix
  353. mix = mix22a17      && e1<p1<e2<i1<e3   ? 22 : mix
  354. mix = defined(i2) && defined(i1)==false ? 0 : mix
  355. mix = defined(p2) && defined(p1)==false ? 0 : mix
  356. mix = defined(e2) && defined(e1)==false ? 0 : mix
  357. mix = defined(e3) && defined(e2)==false ? 0 : mix
  358. mix = defined(e3) && defined(e1)==false ? 0 : mix
  359. mix = defined(i1) && defined(e1)==false ? 0 : mix
  360. mix = defined(p1) && defined(e1)==false ? 0 : mix
  361. creds ? assert(mix!=0, "Mistake in entering i1, e1.... parameters. Please check.") : nop()
  362.  
  363. #Determine frame numbers based on mix mode and user input of i/p/e1/2/3
  364. istart1=mix==1 || mix==2 || mix==3 || mix==16 || mix==18                    ? 0     : \
  365.     mix==4 || mix==5 || mix==6 || mix==7 || mix==15 || mix==17 || mix==19 || mix==21    ? e1+1  : \
  366.     mix==20 || mix==22                                  ? e2+1  : nop()
  367.  
  368. istart2=mix==2 || mix==3 ? e1+1 : mix==6 || mix==7 ? e2+1 : nop()
  369.  
  370. pstart1=mix==8 || mix==9 || mix==10 || mix==19 || mix==21                   ? 0     : \
  371.     mix==11 || mix==12 || mix==13 || mix==14 || mix==16 || mix==18 || mix==20 || mix==22    ? e1+1  : \
  372.     mix==15 || mix==17                                  ? e2+1  : nop()
  373.  
  374. pstart2=mix==9 || mix==10 ? e1+1 : mix==13 || mix==14 ? e2+1 : nop()
  375.  
  376. estart1=mix==4 || mix==5 || mix==6 || mix==7 || mix==11 || mix==12 || mix==13 || mix==14 || mix==15 || mix==17 || mix==20 || mix==22    ? 0     : \
  377.     mix==1 || mix==2 || mix==3 || mix==16 || mix==18                                        ? i1+1  : \
  378.     mix==8 || mix==9 || mix==10 || mix==19 || mix==21                                       ? p1+1  : nop()
  379.  
  380. estart2=mix==4 || mix==6 || mix==7 || mix==15 || mix==17 || mix==21     ? i1+1  : \
  381.     mix==3                              ? i2+1  : \
  382.     mix==11 || mix==13 || mix==14 || mix==16 || mix==20 || mix==22  ? p1+1  : \
  383.     mix==10                             ? p2+1  : nop()
  384.  
  385. estart3=mix==7 ? i2+1 : mix==14 ? p2+1 : mix==17 ? p1+1 : mix==22 ? i1+1 : nop()
  386.  
  387. maxfps = defined(i1) ? framerate(i) : defined(p1) ? framerate(i) : nop()
  388.  
  389. #Final 24fps ivtced clip and deinterlaced + framerate converted for CFR (omode=1)
  390. tocfrfinalt = omode==1 ? (mode==1) ? fmdecim : (mode==2) ? fbdecim : (mode==3) ? dhtdecim : (mode==4 && omode==1) ? blenddecim : nop() : nop()
  391. tocfrfinali = omode==1 && creds ? (credconv=="mocomp") ? fpsconvi : (credconv=="blend") ? blendi : credconv=="drop" ? dropi : nop() : nop()
  392. tocfrfinalp = omode==1 && creds ? (credconv=="mocomp") ? fpsconvp : (credconv=="blend") ? blendp : credconv=="drop" ? dropp : nop() : nop()
  393.  
  394. #Final 30fps clips (prepare for hybrid decimation, make everything 30fps) for hybrid use fm since it will be spliced (txt file will be useless) (used when creds=true)
  395. tovfrfinalt = omode==2 && creds ? (mode==1) ? fm : (mode==2) ? fbdecim.changefps(maxfps) : (mode==3) ? dhtdecim.changefps(maxfps) : (mode==4 && omode==2) ? fm : nop() : nop()
  396. tovfrfinali = omode==2 && creds ? credbob : nop()
  397. tovfrfinalp = omode==2 && creds ? blendbg : nop()
  398.  
  399. #Final clip to splice
  400. spliceprept = mix!=0 ? omode==1 ? tocfrfinalt : omode==2 ? tovfrfinalt : nop() : nop()
  401. spliceprepi = mix!=0 ? omode==1 ? tocfrfinali : omode==2 ? tovfrfinali : nop() : nop()
  402. spliceprepp = mix!=0 ? omode==1 ? tocfrfinalp : omode==2 ? tovfrfinalp : nop() : nop()
  403.  
  404. #######################
  405. ###Trim
  406. #Factor to get the proper trim values after decimating
  407. factor = omode==1 ? defined(i1) ? float(framerate(tocfrfinali)/framerate(i)) : defined(p1) ? float(framerate(tocfrfinalp)/framerate(i)) : nop() : nop()
  408.  
  409. et1 =   defined(e1) ? omode==2 ? spliceprept.trim(estart1,e1) : spliceprept.trim(int(estart1*factor),int(e1*factor)) : nop()
  410. et2 =   defined(e2) ? omode==2 ? spliceprept.trim(estart2,e2) : spliceprept.trim(int(estart2*factor),int(e2*factor)) : nop()
  411. et3 =   defined(e3) ? omode==2 ? spliceprept.trim(estart3,e3) : spliceprept.trim(int(estart3*factor),int(e3*factor)) : nop()
  412.  
  413. ci1 =   defined(i1) ? omode==2 ? spliceprepi.trim(istart1,i1) : spliceprepi.trim(int(istart1*factor),int(i1*factor)) : nop()
  414. ci2 =   defined(i2) ? omode==2 ? spliceprepi.trim(istart2,i2) : spliceprepi.trim(int(istart2*factor),int(i2*factor)) : nop()
  415.  
  416. #Prepare 30p sections for splicing
  417. cp1 =   defined(p1) ? omode==2 ? spliceprepp.trim(pstart1,p1) : spliceprepp.trim(int(pstart1*factor),int(p1*factor)) : nop()
  418. cp2 =   defined(p2) ? omode==2 ? spliceprepp.trim(pstart2,p2) : spliceprepp.trim(int(pstart2*factor),int(p2*factor)) : nop()
  419.  
  420. spliced=(mix==1) ?  ci1 +   et1 : \
  421.     (mix==2) ?  ci1 +   et1 +   ci2 : \
  422.     (mix==3) ?  ci1 +   et1 +   ci2 +   et2 : \
  423.     (mix==4) ?  et1 +   ci1 +   et2 : \
  424.     (mix==5) ?  et1 +   ci1 : \
  425.     (mix==6) ?  et1 +   ci1 +   et2 +   ci2 : \
  426.     (mix==7) ?  et1 +   ci1 +   et2 +   ci2 +   et3 : \
  427.     (mix==8) ?  cp1 +   et1 : \
  428.     (mix==9) ?  cp1 +   et1 +   cp2 : \
  429.     (mix==10) ?     cp1 +   et1 +   cp2 +   et2 : \
  430.     (mix==11) ?     et1 +   cp1 +   et2 : \
  431.     (mix==12) ?     et1 +   cp1 : \
  432.     (mix==13) ?     et1 +   cp1 +   et2 +   cp2 : \
  433.     (mix==14) ?     et1 +   cp1 +   et2 +   cp2 +   et3 : \
  434.     (mix==15) ?     et1 +   ci1 +   et2 +   cp1 : \
  435.     (mix==16) ?     ci1 +   et1 +   cp1 +   et2 : \
  436.     (mix==17) ? et1 +   ci1 +   et2 +   cp1 +   et3 : \
  437.     (mix==18) ?     ci1 +   et1 +   cp1 : \
  438.     (mix==19) ?     cp1 +   et1 +   ci1 : \
  439.     (mix==20) ?     et1 +   cp1 +   et2 +   ci1 : \
  440.     (mix==21) ?     cp1 +   et1 +   ci1 +   et2 : \
  441.     (mix==22) ?     et1 +   cp1 +   et2 +   ci1 +   et3 : \
  442.     NOP()
  443.  
  444. finalcfr =  omode==1 ? creds ? spliced : tocfrfinalt : nop()
  445. tovfrdec1 = omode==2 ? creds ? spliced : chrfix ? debprep : hybridfm : nop()
  446. tovfrdec2 = omode==2 ? rendering ? i : creds ? spliced : chrfix ? debprep : fm : nop()
  447.  
  448. finalvfr =  omode==2 && pass==1 ? nvfr ? tovfrdec1.TDecimate(4, output="stats.txt",denoise=true,vidThresh=0.8,dupThresh=0.9) : tovfrdec1.TDecimate(4, output="stats.txt") :
  449. \       omode==2 && pass==2 ? nvfr ? tovfrdec2.TDecimate(5,hybrid=2,tfmin=creds ? "" : "tfm.txt",input="stats.txt",mkvout="timecodes.txt",tcfv1=tcfv1,batch=true,vidThresh=0.4,dupThresh=0.6) : tovfrdec2.TDecimate(5,hybrid=2,tfmin=creds ? "" : "tfm.txt",input="stats.txt",mkvout="timecodes.txt",tcfv1=tcfv1,batch=true) : nop()
  450.  
  451. topp = omode==1 ? finalcfr : omode==2 ? finalvfr : nop()
  452.  
  453. #Kill combing depending on user settings
  454. dec =   killcomb==0 ? topp :
  455. \   killcomb==1 ? topp.vinverse() :
  456. \   killcomb==2 ? topp.vinverseD() :
  457. \   killcomb==3 ? topp.daa3() :
  458. \       interleave( topp.        subtitle("killcomb=0",align=9),
  459. \               topp.vinverse(). subtitle("killcomb=1",align=9),
  460. \               topp.vinverseD().subtitle("killcomb=2",align=9),
  461. \               topp.daa3().subtitle("killcomb=3",align=9))
  462.  
  463. aaed =  aa==0 ? dec :
  464. \   aa==1 ? dec.ediaa() :
  465. \   aa==2 ? dec.daa3() :
  466. \   aa==3 ? dec.maa() :
  467. \   aa==4 ? dec.sharpaamcmod(dark,thin,sharp,smooth,stabilize,tradius,aapel,aaov,aablk,aatype) :
  468. \           interleave( dec.        subtitle("aa=0",align=9),
  469. \                   dec.ediaa().    subtitle("aa=1",align=9),
  470. \                   dec.daa3(). subtitle("aa=2",align=9),
  471. \                   dec.maa().  subtitle("aa=3",align=9),
  472. \                   dec.sharpaamcmod(dark,thin,sharp,smooth,stabilize,tradius,aapel,aaov,aablk,aatype).subtitle("aa=4",align=9))
  473.  
  474. return omode==2 && pass==1 ? finalvfr : aaed
  475. }
  476.  
  477.  
  478. function chroma_rep(clip source, int "cache")
  479. {
  480. ###### parameters & other necessary vars ######
  481.     cache   = default(cache,-1)
  482.  
  483.  
  484. ###### source preparation & lut ######
  485. global  out1    = source
  486. global  out2    = mergechroma(source,mt_adddiff(source.trim(1,0),mt_makediff(source.trim(1,0),source.trim(2,0),y=1,u=3,v=3),y=1,u=3,v=3).blur(1))
  487.  
  488.  
  489. ###### initialise variables ######
  490. global  alfr     = -100
  491.  
  492.  
  493. ###### evaluation call & output calculation ######
  494. scriptclip( source, """
  495.  
  496. ### preparation ###
  497.        cfr = current_frame
  498.        ajmp = alfr+1==cfr
  499.        
  500.    global  alfr = cfr
  501.  
  502.        al_v = LumaDifference(out1.trim(1,0),out1.trim(2,0))
  503.        ac_v = ChromaUDifference(out1.trim(1,0),out1.trim(2,0)) + ChromaVDifference(out1.trim(1,0),out1.trim(2,0))
  504.  
  505.  ## luma value shifting ##
  506.    l10 = ajmp ? l01 : al_v
  507. global      l01 = ajmp ? l12 : al_v
  508. global      l12 = al_v
  509.  
  510.  ## chroma value shifting ##
  511.    c10 = ajmp ? c01 : ac_v
  512. global      c01 = ajmp ? c12 : ac_v
  513. global      c12 = ac_v
  514.    
  515. ### condition ###
  516.    change  = l12*3<l01 && c01*1.5<c12
  517.    chango  = l01*3<l10 && c10*1.5<c01
  518.    
  519.    change ? out2 : chango ? out1.trim(1,0) : out1
  520.  
  521. """)
  522.  
  523.  
  524. ###### final decimation & caching ######
  525. cache<0 ? last : last.RequestLinear(8, cache, 5, false, false)
  526.  
  527. return last
  528. }
  529.  
  530.  
  531. function chroma_rep2(clip source, int "cache")
  532. {
  533. ###### parameters & other necessary vars ######
  534.     cache   = default(cache,-1)
  535.  
  536.  
  537. ###### source preparation & lut ######
  538. global  out1    = source
  539. global  out2    = mergechroma(source,mt_adddiff(source.trim(1,0),mt_makediff(source.trim(1,0),source.trim(2,0),y=1,u=3,v=3),y=1,u=3,v=3).blur(1))
  540.  
  541.  
  542. ###### initialise variables ######
  543. global  alfr     = -100
  544.  
  545.  
  546. ###### evaluation call & output calculation ######
  547. chrixout = scriptclip( source, """
  548.  
  549. ### preparation ###
  550.        cfr = current_frame
  551.        ajmp = alfr+1==cfr
  552.        
  553.    global  alfr = cfr
  554.  
  555.        al_v = LumaDifference(out1,out1.trim(1,0))
  556.        ac_v = ChromaUDifference(out1,out1.trim(1,0)) + ChromaVDifference(out1,out1.trim(1,0))
  557.  
  558.  ## luma value shifting ##
  559.    l10 = ajmp ? l01 : al_v
  560. global      l01 = ajmp ? l12 : al_v
  561. global      l12 = al_v
  562.  
  563.  ## chroma value shifting ##
  564.    c10 = ajmp ? c01 : ac_v
  565. global      c01 = ajmp ? c12 : ac_v
  566. global      c12 = ac_v
  567.    
  568. ### condition ###
  569.    change  = l12*3<l01 && c01*1.5<c12
  570.    chango  = l01*3<l10 && c10*1.5<c01
  571.    
  572.    change ? out2 : chango ? out1.trim(1,0) : out1
  573.  
  574. """)
  575.  
  576.  
  577. ###### final decimation & caching ######
  578. chrixout2 = cache<0 ? source.mergechroma(chrixout) : source.mergechroma(chrixout).RequestLinear(8, cache, 5, false, false)
  579.  
  580. return chrixout2
  581. }
  582.  
  583.  
  584. #based on smartfade v0.2 by martino - Aimed at removing interlaced fades in anime. Uses luma difference between two fields as activation threshold.
  585. #mod by thetoof : removed degrainmedian post-processing,
  586. #       changed how the fields are blended together (average of 2 nnedi interpolations + contra-sharpening to retain more detail) and
  587. #       added cache parameter to forward the setting of animeivtc to this function
  588. #       renamed global parameter to something less general than "threshold"
  589.  
  590. function smartfademod(clip c, float "sfthr", bool "sfshow", int "cache") {
  591.    
  592. global sfthr    = default ( sfthr,  0.4 ) # Threshold for fade detection.
  593. show        = default ( sfshow, false ) # Displays luma difference between fields without processing anything.
  594. cache       = default ( cache,   10 ) # Cache the frames to help seeking and other functions requesting many frames
  595.  
  596. show ? scriptclip(c, "subtitle(string(abs(    separatefields().selectodd().averageluma() \
  597.                             - separatefields().selecteven().averageluma())))") : \
  598.        scriptclip(c, "sep = separatefields() \
  599.       avg = sep.selectodd().averageluma() - sep.selecteven().averageluma() \
  600.       abs(avg) > sfthr ? interleave(sep.selecteven(),sep.selectodd()).weave().daa3() : last")
  601.  
  602. cache<0 ? last : last.RequestLinear(8, cache, 5, false, false)
  603.  
  604.     return last
  605.  
  606. }
  607.  
  608. #Suggested by Mystery Keeper in "Denoise of tv-anime" thread
  609. function ediaa(clip a) {return a.EEDI2(field=1).TurnRight().EEDI2(field=1).TurnLeft().spline36resize(a.width,a.height,-0.5,-0.5)}
  610.  
  611. #Anti-aliasing with contra-sharpening by Didée
  612. function daa(clip c) {
  613. nn  = c.nnedi2(field=-2)
  614. dbl     = mt_average(selecteven(nn),selectodd(nn),U=3,V=3)
  615. dblD    = mt_makediff(c,dbl,U=3,V=3)
  616. shrpD   = mt_makediff(dbl,dbl.removegrain((width(c)>1100) ? 20 : 11),U=3,V=3)
  617. DD  = shrpD.repair(dblD,13)
  618. return dbl.mt_adddiff(DD,U=3,V=3) }
  619.  
  620. #Anti-aliasing with edge masking by martino, mask using "sobel" taken from Kintaro's useless filterscripts and modded by thetoof for spline36
  621. function maa(clip input, int "mask") {
  622. mask = input.mt_edge("sobel",7,7,5,5).mt_inflate()
  623. aa_clip=input.spline36Resize(width(input)*2,height(input)*2).TurnLeft().SangNom().TurnRight().SangNom().spline36Resize(width(input),height(input)).MergeChroma(input)
  624. return mt_merge(input,aa_clip,mask) }
  625.  
  626. #Developped in the "fine anime antialiasing thread"
  627. function SharpAAMCmod(clip orig, float "dark", int "thin", int "sharp", int "smooth", bool "stabilize", int "tradius", int "aapel", int "aaov", int "aablk", string "aatype")
  628. {
  629. dark    = default ( dark,     0.2 ) # strokes darkening strength
  630. thin    = default ( thin,      10 ) # Presharpening
  631. sharp   = default ( sharp,    150 ) # Postsharpening
  632. smooth  = default ( smooth,    -1 ) # Postsmoothing
  633. stabilize= default ( stabilize,false ) # Use post stabilization with Motion Compensation
  634. Tradius = default ( Tradius,    2 ) # 2 = MDegrain2 / 3 = MDegrain3
  635. aapel   = default ( aapel,      1 ) # accuracy of the motion estimation (Value can only be 1, 2 or 4. 1 means a precision to the pixel. 2 means a precision to half a pixel, 4 means a precision to quarter a pixel, produced by spatial interpolation (better but slower).)
  636. aaov    = default ( aaov,       (orig.width>1100) ? 8 : 4 ) # block overlap value (horizontal). Must be even and less than block size. (Higher = more precise & slower)
  637. aablk   = default ( aablk,      (orig.width>1100) ? 16 : 8 ) # Size of a block (horizontal). It's either 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.
  638. aatype  = default ( aatype, "Sangnom" ) # Use Sangnom() or EEDI2() for anti-aliasing
  639.  
  640. w=width(orig)
  641. h=height(orig)
  642. m=mt_logic( orig.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=4,Y=3,U=3,V=3)
  643.  \       ,orig.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=4,Y=3,U=3,V=3)
  644.  \       ,"max").mt_lut("x 128 / 0.86 ^ 255 *")
  645. preaa=(thin==0 && dark==0) ? orig : (thin==0) ? orig.Toon(dark) : (dark==0) ? orig.awarpsharp2(depth=thin) : orig.Toon(dark).awarpsharp2(depth=thin)
  646. aa= (aatype=="Sangnom") ? preaa.spline36resize(w*2,h*2).TurnLeft().SangNom().TurnRight().SangNom().spline36resize(w,h) : (aatype=="EEDI2") ? preaa.ediaa() : blankclip(pixel_type="YV12").subtitle("Please use Sangnom or EEDI2 for aatype")
  647. postsh=(sharp==0 && smooth==0) ? aa : aa.lsfmod(edgemode=1,strength=sharp,overshoot=1,soft=smooth)
  648. merged=mt_merge(orig,postsh,m,Y=3,U=3,V=3)
  649.  
  650. sD=mt_makediff(orig,merged)
  651.  
  652. origsuper= orig.MSuper(pel=aapel)
  653. sDsuper  = sD.  MSuper(pel=aapel, levels=1)
  654.  
  655.  
  656. fv3 = tradius==3 ? origsuper.MAnalyse(isb=false,delta=3,overlap=aaov,blksize=aablk) : nop()
  657. fv2 = tradius>=2 ? origsuper.MAnalyse(isb=false,delta=2,overlap=aaov,blksize=aablk) : nop()
  658. fv1 = tradius>=1 ? origsuper.MAnalyse(isb=false,delta=1,overlap=aaov,blksize=aablk) : nop()
  659. bv1 = tradius>=1 ? origsuper.MAnalyse(isb=true, delta=1,overlap=aaov,blksize=aablk) : nop()
  660. bv2 = tradius>=2 ? origsuper.MAnalyse(isb=true, delta=2,overlap=aaov,blksize=aablk) : nop()
  661. bv3 = tradius==3 ? origsuper.MAnalyse(isb=true, delta=3,overlap=aaov,blksize=aablk) : nop()
  662. sDD = tradius==1 ? sD.MDegrain1(sDsuper,bv1,fv1) : tradius==2 ? sD.MDegrain2(sDsuper,bv1,fv1,bv2,fv2) : sD.MDegrain3(sDsuper,bv1,fv1,bv2,fv2,bv3,fv3)
  663.  
  664. reduc = 0.4
  665. sDD = mt_lutxy(sD,sDD,"x 128 - abs y 128 - abs < x y ?").mergeluma(sDD,1.0-reduc)
  666.  
  667. return stabilize ? orig.mt_makediff(sDD,U=2,V=2) : merged
  668. }
  669.  
  670. # Kill Combing Function from mcbob
  671. function VinverseD(clip clp, float "sstr", int "amnt", int "uv")
  672. {
  673. uv   = default(uv,3)
  674. sstr = default(sstr,2.7)
  675. amnt = default(amnt,255)
  676. uv2  = (uv==2) ? 1 : uv
  677. STR  = string(sstr)
  678. AMN  = string(amnt)
  679. vblur  = clp.mt_convolution("1","50 99 50",U=uv,V=uv)
  680. vblurD = mt_makediff(clp,vblur,U=uv2,V=uv2)
  681. Vshrp  = mt_lutxy(vblur,vblur.mt_convolution("1","1 4 6 4 1",U=uv2,V=uv2),expr="x x y - "+STR+" * +",U=uv2,V=uv2)
  682. VshrpD = mt_makediff(Vshrp,vblur,U=uv2,V=uv2)
  683. VlimD  = mt_lutxy(VshrpD,VblurD,expr="x 128 - y 128 - * 0 < x 128 - abs y 128 - abs < x y ? 128 - 0.25 * 128 + x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
  684. mt_adddiff(Vblur,VlimD,U=uv,V=uv)
  685. (amnt>254) ? last : (amnt==0) ? clp : mt_lutxy(clp,last,expr="x "+AMN+" + y < x "+AMN+" + x "+AMN+" - y > x "+AMN+" - y ? ?",U=uv,V=uv)
  686. return(last)
  687. }
RAW Paste Data