View Full Version : New Pre Pre Alpha upsizer, almost usably fast
*.mp4 guy
5th May 2007, 06:55
Script:
function autotap3(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 1)
thresh = default(thresh, 256)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=5)
t6 = lanczosresize(clp, dx, dy, taps=9)
t7 = lanczosresize(clp, dx, dy, taps=36)
m1 = yv12lutxy(clp, lanczosresize(t1, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m2 = yv12lutxy(clp, lanczosresize(t2, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m3 = yv12lutxy(clp, lanczosresize(t3, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m4 = yv12lutxy(clp, lanczosresize(t4, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m5 = yv12lutxy(clp, lanczosresize(t5, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m6 = yv12lutxy(clp, lanczosresize(t6, clp.width, clp.height, taps=3), "x y - abs", u=3, v=3)
m7 = yv12lutxy(clp, lanczosresize(t7, clp.width, clp.height, taps=6), "x y - abs", u=3, v=3)
cp1 = maskedmerge(t1.blur(1.42), t2, lanczosresize(yv12lutxy(m1, m2, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m100 = yv12lutxy(clp, bilinearresize(cp1, clp.width, clp.height), "x y - abs", u=3, v=3)
cp2 = maskedmerge(cp1, t3, lanczosresize(yv12lutxy(m100, m3, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m101 = yv12lutxy(clp, bilinearresize(cp2, clp.width, clp.height), "x y - abs", u=3, v=3)
cp3 = maskedmerge(cp2, t4, lanczosresize(yv12lutxy(m101, m4, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m102 = yv12lutxy(clp, bilinearresize(cp3, clp.width, clp.height), "x y - abs", u=3, v=3)
cp4 = maskedmerge(cp3, t5, lanczosresize(yv12lutxy(m102, m5, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m103 = yv12lutxy(clp, bilinearresize(cp4, clp.width, clp.height), "x y - abs", u=3, v=3)
cp5 = maskedmerge(cp4, t6, lanczosresize(yv12lutxy(m103, m6, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m104 = yv12lutxy(clp, bilinearresize(cp5, clp.width, clp.height), "x y - abs", u=3, v=3)
cp6 = maskedmerge(cp5, t7, lanczosresize(yv12lutxy(m104, m7, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m105 = yv12lutxy(clp, bilinearresize(cp6, clp.width, clp.height), "x y - abs", u=3, v=3)
return(mergechroma(cp6, spline36resize(clp, dx, dy), 1))}
###
###
###
function Lanczosplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 1)
sharp2 = default(sharp2, 4)
blur1 = default(blur1, 0.33)
blur2 = default(blur2, 1.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.autotap3( ((c.width/16)*8 >= 144 ? (c.width/16)*8 : 144), ((c.height/16)*8 >= 144 ? (c.height/16)*8 : 144), mtaps3=mtaps3, thresh=athresh).autotap3( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), (c.width/16)*8, (c.height/16)*8, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? maskedmerge(c, fre2, m1) : c
d2 = d.autotap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = autotap3(autotap3(d, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
d2.width, d2.height, mtaps3=mtaps3, thresh=athresh)
d4 = maskedmerge( yv12lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
yv12lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.autotap3(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = maskedmerge(d5, c, m1).autotap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, ((e.width*(dx/c.width))/16)*16, ((e.height*(dy/c.height))/16)*16, taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = autotap3(autotap3(e, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
e.width, e.height, mtaps3=mtaps3, thresh=athresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = maskedmerge( yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
maskedmerge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
I know the code is almost completely unreadable, and probably slower then it has to be, but I don't have as much time to work on this stuff as I used to, hopefully Ill have time to fix it up in a few days. comments, are always welcome.
The basic premise is to.
1 - detect areas that will cause ringing in other areas
2 - make a mask of those areas, lowpas them, and replace them
3 - upsize using the "ringing resistent" clip, using hgh taps, but avoiding ringing
4 - upsize the original input clip, then use the mask from step 2 to replace the lowpassed areas in the upsized clip, since the lowpassed areas don't exhibit ringing themselves, but cause it in other areas, this doesn't cause much ringing, but brings back a lot of sharpness
There is other stuff happening, but it isn't anything interesting. I'll make things more transparent later. Lanczos is used for speed reasons, I was tempted to use a better base resizer, but it ended up to slow, even for me.
[edit] new version, sharper, slower
[edit] new version, explanation of functionality no longer completely relevant.
Pookie
5th May 2007, 09:11
I like it. Results look pretty natural on the couple of test clips I threw at it. Thx.
How can I use it? :confused:
*.mp4 guy
7th May 2007, 16:09
The same way you would use limitedsharpen. It doesn't have any parameters yet, so you would just put: Lanczosplus()
Is there a parameter for output h/v size? Or is it only output in predefined upscale size such as 2x?
regards,
Li On
*.mp4 guy
8th May 2007, 03:34
Right now it only does predefined 2X upsampling (because that is easy), It should be possible to do arbitrary resizing without too much more work, though.
edit: new version can be used for arbitrary upsizing, quality will probably be slightly reduced (only when upsizing by a factor that isn't 2), also added better antialiasing, and made the threshold paramteters exposed, though they shouldn't need to be tweaked.
edit2:internal parameters updated, a little faster and sharper now.
function Lanczosplus(clip c, int "dx", int "dy", int "thresh", int "thresh2"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
c
s = c
s
fd1 = lanczosresize(c, dx, dy, taps=3)
fre1 = fd1.lanczosresize( c.width, c.height, taps=3)
fre2 = fre1.lanczosresize( c.width/2, c.height/2, taps=3).lanczosresize( c.width, c.height, taps=3)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
d = maskedmerge(c, fre2, m1)
d2 = d.lanczosresize(dx, dy, taps=4)
d3= lanczosresize(lanczosresize(d, (c.width)-(width/2), (c.height)-(height/2), taps=5), d2.width, d2.height, taps=5)
m2 = lanczosresize(lanczosresize(frfun7(degrainmedian(m1, mode=1), 2.01, 256, 256), c.width/2, c.height/2, taps=16), d2.width, d2.height, taps=16)
#
d4 = maskedmerge(yv12lutxy(d2, d3 , "x y - 0.5 * x +" , u=3, v=3), yv12lutxy(d2, d3 , "y x - 0.5 * x +" , u=3, v=3), m2)
d5 = d4.lanczosresize(d.width, d.height, taps=12)
#
e = maskedmerge(d5, c, m1).lanczosresize(dx, dy, taps=12).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1)
fd12 = lanczosresize(e, e.width*(dx/c.width), e.height*(dy/c.height), taps=2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=2)
fre22 = fre12.lanczosresize( e.width/2, e.height/2, taps=2).lanczosresize( e.width, e.height, taps=2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3).lanczosresize( e.width/2, e.height/2, taps=2).lanczosresize( e.width, e.height, taps=2)
e2= lanczosresize(lanczosresize(e, (c.width)-(width/2), (c.height)-(height/2), taps=12), e.width, e.height, taps=11).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1)#yv12lutxy(e, e2 , "x y - 0.75 * x +" , u=3, v=3)
e3 = maskedmerge(yv12lutxy(e, e2 , "y x - 0.33 * x +" , u=3, v=3), yv12lutxy(e, e2 , "x y - 1 * x +" , u=3, v=3), m12).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1).awarpsharp(depth=6, cm=0, blurlevel=1)
maskedmerge(d4, e3, m2)
return(last)}
*.mp4 guy
14th May 2007, 18:39
new version, script cleaned up a bit more, better defaults, slightly improved quality, more options to play with.
function Lanczosplus(clip c, int "dx", int "dy", int "thresh", int "thresh2", float "sharp1", float "sharp2", float "blur1", float "blur2", int "mtaps1"
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 0.33)
sharp2 = default(sharp2, 1)
blur1 = default(blur1, 1)
blur2 = default(blur2, 0.33)
mtaps1 = default(mtaps1, 2)
mtaps2 = default(mtaps2, 2)
ttaps = default(ttaps, 12)
ltaps = default(ltaps, 12)
depth = default(depth, 2)
wthresh = default(wthresh, 0.99)
wblur = default(wblur, 2)
c
s = c
s
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.lanczosresize( c.width/2, c.height/2, taps=mtaps1).lanczosresize( c.width, c.height, taps=mtaps1)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), c.width/2, c.height/2, taps=ttaps), dx, dy, taps=ttaps)
d = maskedmerge(c, fre2, m2.lanczosresize(c.width, c.height))
d2 = d.lanczosresize(dx, dy, taps=ttaps)
d3= lanczosresize(lanczosresize(d, (c.width)-(width/2), (c.height)-(height/2), taps=ttaps), d2.width, d2.height, taps=ttaps)
d4 = maskedmerge(yv12lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), yv12lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.lanczosresize(d.width, d.height, taps=ttaps)
e = maskedmerge(d5, c, m1).lanczosresize(dx, dy, taps=ltaps).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, e.width*(dx/c.width), e.height*(dy/c.height), taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3).lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2= lanczosresize(lanczosresize(e, (c.width)-(width/2), (c.height)-(height/2), taps=ltaps), e.width, e.height, taps=ltaps).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = maskedmerge(yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), m12).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh).awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
maskedmerge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
Edit: acript fixed, thanks buzzqw
buzzqw
14th May 2007, 19:47
i think script is truncated
BHH
@*.mp4 guy,
Do you know about the Avisynth "\" continuation character. It's use can make excessivly wide scripts so much more readable.
*.mp4 guy
15th May 2007, 05:15
@*.mp4 guy,
Do you know about the Avisynth "\" continuation character. It's use can make excessivly wide scripts so much more readable.
I know about it, but I never really liked it, imo it doesn't improve readability, but it does reduce scrolling. If it is considered proper "grammar" I'll start putting it in.
buzzqw
15th May 2007, 07:56
the script is broken again... the line 1 is too long.. is doubled
BHH
buzzqw
15th May 2007, 08:21
ok, i manually fixed it...
just one question: is impossibile to downsize with this script
i got this error (from 720*576 source to 640*480)
Resize: Width must be bigger than or equal to 4.
(c:\xxx\LanczosPlus.avsi, line 41)
BHH
*.mp4 guy
15th May 2007, 08:41
No, it is not possible to downsize.
buzzqw
15th May 2007, 08:45
ok thanks! :)
BHH
buzzqw
15th May 2007, 10:57
Hi !
another question: could i add the LanczosPlus to list of resizers included in AutoMKV ?
i will also add all reference to this thread and Author in changelog and in license.txt
thanks
BHH
You might want to wait until it comes out of "Pre Pre Alpha" mode. Or maybe it is ready to roll right now, I haven't tested it yet.
buzzqw
15th May 2007, 14:39
yup.. could be true... but from my little test .. this filter is already beta.. not alpha ! :)
BHH
*.mp4 guy
15th May 2007, 19:28
You might want to wait until it comes out of "Pre Pre Alpha" mode. Or maybe it is ready to roll right now, I haven't tested it yet.
I wouldn't call it finnished yet, but its no longer pre pre alpha.
Hi !
another question: could i add the LanczosPlus to list of resizers included in AutoMKV ?
i will also add all reference to this thread and Author in changelog and in license.txt
thanks
BHH
Sure, just don't ask me to explain what all the little widgets do yet :devil:
I'm not fussy about attribution, etc. aslong as you don't try to give credit to someone else, you can do whatever you want.
also, changed masking a little (reverted a previous change, that turned out to be bad), updated defaults aswell, new version is in the first post.
Alain2
15th May 2007, 20:28
Correction of the parameters definition (truncated in your first post) and introduction of some \ ^^ (hope you don't mind)
function Lanczosplus( clip c, int "dx", int "dy", int "thresh", int "thresh2",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps",
\ int "depth", float "wthresh", float "wblur")
{
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 0.33)
sharp2 = default(sharp2, 2)
blur1 = default(blur1, 0.066)
blur2 = default(blur2, 0.25)
mtaps1 = default(mtaps1, 2)
mtaps2 = default(mtaps2, 2)
ttaps = default(ttaps, 4)
ltaps = default(ltaps, 5)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.lanczosresize( c.width/2, c.height/2, taps=mtaps1).lanczosresize( c.width, c.height, taps=mtaps1)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), c.width/2, c.height/2, taps=ttaps), \
dx, dy, taps=ttaps)
d = maskedmerge(c, fre2, m1)
d2 = d.lanczosresize(dx, dy, taps=ttaps)
d3 = lanczosresize(lanczosresize(d, (c.width)-(width/2), (c.height)-(height/2), taps=ttaps), \
d2.width, d2.height, taps=ttaps)
d4 = maskedmerge( yv12lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
yv12lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.lanczosresize(d.width, d.height, taps=ttaps)
e = maskedmerge(d5, c, m1).lanczosresize(dx, dy, taps=ltaps)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, e.width*(dx/c.width), e.height*(dy/c.height), taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = lanczosresize(lanczosresize(e, (c.width)-(width/2), (c.height)-(height/2), taps=ltaps), \
e.width, e.height, taps=ltaps)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = maskedmerge( yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
maskedmerge(d4, e3, m2)
mergechroma(spline36resize(c, dx, dy), 1)
}
Any particular reason you use masktools v1 and not using v2 ?
Oh btw I noticed you create new clip names one after the other, like fd1 > fre1 > fre2 ; is there a reason ? Is it faster than assigning on the same clip name ? (in that case the mods I did for e/e2/e3 may be slower)
*.mp4 guy
15th May 2007, 20:37
Correction of the parameters definition (truncated in your first post) and introduction of some \ ^^ (hope you don't mind)
Thanks, I should really stop procrastinating and buy a new mouse (my current one is a bit unreliable in its clicking, as some may have noticed).
Any particular reason you use masktools v1 and not using v2 ?
is there a reason to use masktools 2 for this, are its equivelant functions faster?
Oh btw I noticed you create new clip names one after the other, like fd1 > fre1 > fre2 ; is there a reason ? Is it faster than assigning on the same clip name ? (in that case the mods I did for e/e2/e3 may be slower)
I do that to keep things discrete, that is it keeps things simple, so If I make any drastic changes to the script it is easy to reorganize.
[edit] hope you don't mind, but I put your version in the first post.
Alain2
16th May 2007, 20:35
is there a reason to use masktools 2 for this, are its equivelant functions faster?
I think most or all of v2 functions are supposed to be a bit faster than v1, even though I understood that the ones that really get a speed increase are the inpand/expand. As v2 has been around for a while without bug reports and is designed to replace v1 (and has some additional/improved functions as well), I personnaly always script with v2 now, but I am not bothered if you use v1. I was just wandering if you had any preference for the v1 over v2 equivalent functions and why, that's now cleared from your question :)
*.mp4 guy
22nd May 2007, 11:48
New version, ringing further reduced, resizing to anything but a multiple of the input resulution is now broken (quality will be BAD), but there is a workaround, it would reduce quality so I have to make it switchable, which might take a while for me to do. The reduced ringing will probably lead to increased sharpness in a later version, once I sort through the good and bad ways to leverage it.
function autotap(clip clp, int "dx", int "dy"){
c = clp
#dx = c.width*2
#dy = c.height*2
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
#n1 = NEDIC(clp)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=6)
t6 = lanczosresize(clp, dx, dy, taps=8)
t7 = lanczosresize(clp, dx, dy, taps=11)
t8 = lanczosresize(clp, dx, dy, taps=16)
t9 = lanczosresize(clp, dx, dy, taps=22)
t10 = lanczosresize(clp, dx, dy, taps=32)
t11 = lanczosresize(clp, dx, dy, taps=45)
#nm1 = yv12lutxy(clp, lanczosresize(n1, clp.width, clp.height, taps=1, taps=7), "x y - abs", u=3, v=3)
m1 = yv12lutxy(clp, lanczosresize(t1, clp.width, clp.height, taps=0), "x y - abs", u=3, v=3)
m2 = yv12lutxy(clp, lanczosresize(t2, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m3 = yv12lutxy(clp, lanczosresize(t3, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m4 = yv12lutxy(clp, lanczosresize(t4, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m5 = yv12lutxy(clp, lanczosresize(t5, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m6 = yv12lutxy(clp, lanczosresize(t6, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m7 = yv12lutxy(clp, lanczosresize(t7, clp.width, clp.height, taps=3), "x y - abs", u=3, v=3)
m8 = yv12lutxy(clp, lanczosresize(t8, clp.width, clp.height, taps=4), "x y - abs", u=3, v=3)
m9 = yv12lutxy(clp, lanczosresize(t9, clp.width, clp.height, taps=4), "x y - abs", u=3, v=3)
m10 = yv12lutxy(clp, lanczosresize(t10, clp.width, clp.height, taps=6), "x y - abs", u=3, v=3)
m11 = yv12lutxy(clp, lanczosresize(t11, clp.width, clp.height, taps=7), "x y - abs", u=3, v=3)
cp1 = maskedmerge(t1.blur(1.42), t2, lanczosresize(yv12lutxy(m1, m2, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m12 = yv12lutxy(clp, bilinearresize(cp1, clp.width, clp.height), "x y - abs", u=3, v=3)
cp2 = maskedmerge(cp1, t3, lanczosresize(yv12lutxy(m12, m3, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m13 = yv12lutxy(clp, bilinearresize(cp2, clp.width, clp.height), "x y - abs", u=3, v=3)
cp3 = maskedmerge(cp2, t4, lanczosresize(yv12lutxy(m13, m4, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m14 = yv12lutxy(clp, bilinearresize(cp3, clp.width, clp.height), "x y - abs", u=3, v=3)
cp4 = maskedmerge(cp3, t5, lanczosresize(yv12lutxy(m14, m5, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m15 = yv12lutxy(clp, bilinearresize(cp4, clp.width, clp.height), "x y - abs", u=3, v=3)
cp5 = maskedmerge(cp4, t6, lanczosresize(yv12lutxy(m15, m6, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m16 = yv12lutxy(clp, bilinearresize(cp5, clp.width, clp.height), "x y - abs", u=3, v=3)
cp6 = maskedmerge(cp5, t7, lanczosresize(yv12lutxy(m16, m7, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m17 = yv12lutxy(clp, bilinearresize(cp6, clp.width, clp.height), "x y - abs", u=3, v=3)
cp7 = maskedmerge(cp6, t8, lanczosresize(yv12lutxy(m17, m8, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m18 = yv12lutxy(clp, bilinearresize(cp7, clp.width, clp.height), "x y - abs", u=3, v=3)
cp8 = maskedmerge(cp7, t9, lanczosresize(yv12lutxy(m18, m9, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m19 = yv12lutxy(clp, bilinearresize(cp8, clp.width, clp.height), "x y - abs", u=3, v=3)
cp9 = maskedmerge(cp8, t10, lanczosresize(yv12lutxy(m19, m10, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m20 = yv12lutxy(clp, bilinearresize(cp9, clp.width, clp.height), "x y - abs", u=3, v=3)
cp10 = maskedmerge(cp9, t11, lanczosresize(yv12lutxy(m20, m11, "x y - 256 *", u=3, v=3), dx, dy, taps=0))
m21 = yv12lutxy(clp, bilinearresize(cp10, clp.width, clp.height), "x y - abs", u=3, v=3)
#cp11 = maskedmerge(cp10, n1, lanczosresize(yv12lutxy(m21, m1, "x y - 256 *", u=3, v=3), dx, dy, taps=5))
#m22 = yv12lutxy(clp, lanczosresize(cp11, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
#cp12 = maskedmerge(cp11, t3, lanczosresize(yv12lutxy(m22, m1, "x y - 256 *", u=3, v=3), dx, dy, taps=5))
#m23 = yv12lutxy(clp, lanczosresize(cp12, clp.width, clp.height, taps=1, taps=3), "x y - abs", u=3, v=3)
#cp13 = maskedmerge(cp12, t2, lanczosresize(yv12lutxy(m23, m1, "x y - 256 *", u=3, v=3), dx, dy, taps=5))
#m24 = yv12lutxy(clp, lanczosresize(cp13, clp.width, clp.height, taps=1, taps=3), "x y - abs", u=3, v=3)
return(mergechroma(cp10, spline36resize(clp, dx, dy), 1))}
function Lanczosplus( clip c, int "dx", int "dy", int "thresh", int "thresh2",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps",
\ int "depth", float "wthresh", float "wblur"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 0.33)
sharp2 = default(sharp2, 2)
blur1 = default(blur1, 0.066)
blur2 = default(blur2, 0.25)
mtaps1 = default(mtaps1, 2)
mtaps2 = default(mtaps2, 2)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.lanczosresize( c.width/2, c.height/2, taps=mtaps1).lanczosresize( c.width, c.height, taps=mtaps1)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), c.width/2, c.height/2, taps=ttaps), \
dx, dy, taps=ttaps)
d = c#maskedmerge(c, fre2, m1)
d2 = d.autotap(dx, dy)
d3 = lanczosresize(lanczosresize(d, (c.width)-(width/2), (c.height)-(height/2), taps=ttaps), \
d2.width, d2.height, taps=ttaps)
d4 = maskedmerge( yv12lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
yv12lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.lanczosresize(d.width, d.height, taps=ttaps)
e = maskedmerge(d5, c, m1).autotap(dx, dy)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, e.width*(dx/c.width), e.height*(dy/c.height), taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = lanczosresize(lanczosresize(e, (c.width)-(width/2), (c.height)-(height/2), taps=ltaps), \
e.width, e.height, taps=ltaps)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = maskedmerge( yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
maskedmerge(d4, e3, m2)
mergechroma(spline36resize(c, dx, dy), 1)}
*.mp4 guy
23rd May 2007, 02:59
new verion, fixed output resolution limitation, improved prebluring, prebluring is now toggleable, and off by default, better defaults (much sharper now).
function autotap(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
#dx = c.width*2
#dy = c.height*2
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 0)
thresh = default(thresh, 256)
#n1 = NEDIC(clp)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=6)
t6 = lanczosresize(clp, dx, dy, taps=8)
t7 = lanczosresize(clp, dx, dy, taps=11)
t8 = lanczosresize(clp, dx, dy, taps=16)
t9 = lanczosresize(clp, dx, dy, taps=22)
t10 = lanczosresize(clp, dx, dy, taps=32)
t11 = lanczosresize(clp, dx, dy, taps=45)
#nm1 = yv12lutxy(clp, lanczosresize(n1, clp.width, clp.height, taps=1, taps=7), "x y - abs", u=3, v=3)
m1 = yv12lutxy(clp, lanczosresize(t1, clp.width, clp.height, taps=mtaps3), "x y - abs", u=3, v=3)
m2 = yv12lutxy(clp, lanczosresize(t2, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m3 = yv12lutxy(clp, lanczosresize(t3, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m4 = yv12lutxy(clp, lanczosresize(t4, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m5 = yv12lutxy(clp, lanczosresize(t5, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m6 = yv12lutxy(clp, lanczosresize(t6, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m7 = yv12lutxy(clp, lanczosresize(t7, clp.width, clp.height, taps=3), "x y - abs", u=3, v=3)
m8 = yv12lutxy(clp, lanczosresize(t8, clp.width, clp.height, taps=4), "x y - abs", u=3, v=3)
m9 = yv12lutxy(clp, lanczosresize(t9, clp.width, clp.height, taps=4), "x y - abs", u=3, v=3)
m10 = yv12lutxy(clp, lanczosresize(t10, clp.width, clp.height, taps=6), "x y - abs", u=3, v=3)
m11 = yv12lutxy(clp, lanczosresize(t11, clp.width, clp.height, taps=7), "x y - abs", u=3, v=3)
cp1 = maskedmerge(t1.blur(1.42), t2, lanczosresize(yv12lutxy(m1, m2, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m12 = yv12lutxy(clp, bilinearresize(cp1, clp.width, clp.height), "x y - abs", u=3, v=3)
cp2 = maskedmerge(cp1, t3, lanczosresize(yv12lutxy(m12, m3, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m13 = yv12lutxy(clp, bilinearresize(cp2, clp.width, clp.height), "x y - abs", u=3, v=3)
cp3 = maskedmerge(cp2, t4, lanczosresize(yv12lutxy(m13, m4, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m14 = yv12lutxy(clp, bilinearresize(cp3, clp.width, clp.height), "x y - abs", u=3, v=3)
cp4 = maskedmerge(cp3, t5, lanczosresize(yv12lutxy(m14, m5, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m15 = yv12lutxy(clp, bilinearresize(cp4, clp.width, clp.height), "x y - abs", u=3, v=3)
cp5 = maskedmerge(cp4, t6, lanczosresize(yv12lutxy(m15, m6, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m16 = yv12lutxy(clp, bilinearresize(cp5, clp.width, clp.height), "x y - abs", u=3, v=3)
cp6 = maskedmerge(cp5, t7, lanczosresize(yv12lutxy(m16, m7, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m17 = yv12lutxy(clp, bilinearresize(cp6, clp.width, clp.height), "x y - abs", u=3, v=3)
cp7 = maskedmerge(cp6, t8, lanczosresize(yv12lutxy(m17, m8, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m18 = yv12lutxy(clp, bilinearresize(cp7, clp.width, clp.height), "x y - abs", u=3, v=3)
cp8 = maskedmerge(cp7, t9, lanczosresize(yv12lutxy(m18, m9, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m19 = yv12lutxy(clp, bilinearresize(cp8, clp.width, clp.height), "x y - abs", u=3, v=3)
cp9 = maskedmerge(cp8, t10, lanczosresize(yv12lutxy(m19, m10, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m20 = yv12lutxy(clp, bilinearresize(cp9, clp.width, clp.height), "x y - abs", u=3, v=3)
cp10 = maskedmerge(cp9, t11, lanczosresize(yv12lutxy(m20, m11, "x y - 256 *", u=3, v=3), dx, dy, taps=mtaps3))
m21 = yv12lutxy(clp, bilinearresize(cp10, clp.width, clp.height), "x y - abs", u=3, v=3)
#cp11 = maskedmerge(cp10, n1, lanczosresize(yv12lutxy(m21, m1, "x y - 256 *", u=3, v=3), dx, dy, taps=5))
#m22 = yv12lutxy(clp, lanczosresize(cp11, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
#cp12 = maskedmerge(cp11, t3, lanczosresize(yv12lutxy(m22, m1, "x y - 256 *", u=3, v=3), dx, dy, taps=5))
#m23 = yv12lutxy(clp, lanczosresize(cp12, clp.width, clp.height, taps=1, taps=3), "x y - abs", u=3, v=3)
#cp13 = maskedmerge(cp12, t2, lanczosresize(yv12lutxy(m23, m1, "x y - 256 *", u=3, v=3), dx, dy, taps=5))
#m24 = yv12lutxy(clp, lanczosresize(cp13, clp.width, clp.height, taps=1, taps=3), "x y - abs", u=3, v=3)
return(mergechroma(cp10, spline36resize(clp, dx, dy), 1))}
###
###
###
function Lanczosplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 0.33)
sharp2 = default(sharp2, 2)
blur1 = default(blur1, 0.066)
blur2 = default(blur2, 0.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.autotap( c.width/2, c.height/2, mtaps3=mtaps3, thresh=athresh).autotap( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), c.width/2, c.height/2, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? maskedmerge(c, fre2, m1) : c
d2 = d.autotap(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = autotap(autotap(d, (c.width)-(width/2), (c.height)-(height/2), mtaps3=mtaps3, thresh=athresh), \
d2.width, d2.height, mtaps3=mtaps3, thresh=athresh)
d4 = maskedmerge( yv12lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
yv12lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.autotap(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = maskedmerge(d5, c, m1).autotap(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, e.width*(dx/c.width), e.height*(dy/c.height), taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( e.width/2, e.height/2, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = autotap(autotap(e, (c.width)-(width/2), (c.height)-(height/2), mtaps3=mtaps3, thresh=athresh), \
e.width, e.height, mtaps3=mtaps3, thresh=athresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = maskedmerge( yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
maskedmerge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
*.mp4 guy
25th May 2007, 04:41
New version, shouldn't crash on smallish images all the time anymore, a bit faster.
function autotap3(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 1)
thresh = default(thresh, 256)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=5)
t6 = lanczosresize(clp, dx, dy, taps=9)
t7 = lanczosresize(clp, dx, dy, taps=36)
m1 = yv12lutxy(clp, lanczosresize(t1, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m2 = yv12lutxy(clp, lanczosresize(t2, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m3 = yv12lutxy(clp, lanczosresize(t3, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m4 = yv12lutxy(clp, lanczosresize(t4, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m5 = yv12lutxy(clp, lanczosresize(t5, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m6 = yv12lutxy(clp, lanczosresize(t6, clp.width, clp.height, taps=3), "x y - abs", u=3, v=3)
m7 = yv12lutxy(clp, lanczosresize(t7, clp.width, clp.height, taps=6), "x y - abs", u=3, v=3)
cp1 = maskedmerge(t1.blur(1.42), t2, lanczosresize(yv12lutxy(m1, m2, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m100 = yv12lutxy(clp, bilinearresize(cp1, clp.width, clp.height), "x y - abs", u=3, v=3)
cp2 = maskedmerge(cp1, t3, lanczosresize(yv12lutxy(m100, m3, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m101 = yv12lutxy(clp, bilinearresize(cp2, clp.width, clp.height), "x y - abs", u=3, v=3)
cp3 = maskedmerge(cp2, t4, lanczosresize(yv12lutxy(m101, m4, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m102 = yv12lutxy(clp, bilinearresize(cp3, clp.width, clp.height), "x y - abs", u=3, v=3)
cp4 = maskedmerge(cp3, t5, lanczosresize(yv12lutxy(m102, m5, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m103 = yv12lutxy(clp, bilinearresize(cp4, clp.width, clp.height), "x y - abs", u=3, v=3)
cp5 = maskedmerge(cp4, t6, lanczosresize(yv12lutxy(m103, m6, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m104 = yv12lutxy(clp, bilinearresize(cp5, clp.width, clp.height), "x y - abs", u=3, v=3)
cp6 = maskedmerge(cp5, t7, lanczosresize(yv12lutxy(m104, m7, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m105 = yv12lutxy(clp, bilinearresize(cp6, clp.width, clp.height), "x y - abs", u=3, v=3)
return(mergechroma(cp6, spline36resize(clp, dx, dy), 1))}
###
###
###
function Lanczosplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 1)
sharp2 = default(sharp2, 4)
blur1 = default(blur1, 0.33)
blur2 = default(blur2, 1.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.autotap3( ((c.width/16)*8 >= 144 ? (c.width/16)*8 : 144), ((c.height/16)*8 >= 144 ? (c.height/16)*8 : 144), mtaps3=mtaps3, thresh=athresh).autotap3( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), (c.width/16)*8, (c.height/16)*8, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? maskedmerge(c, fre2, m1) : c
d2 = d.autotap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = autotap3(autotap3(d, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
d2.width, d2.height, mtaps3=mtaps3, thresh=athresh)
d4 = maskedmerge( yv12lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
yv12lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.autotap3(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = maskedmerge(d5, c, m1).autotap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, ((e.width*(dx/c.width))/16)*16, ((e.height*(dy/c.height))/16)*16, taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = autotap3(autotap3(e, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
e.width, e.height, mtaps3=mtaps3, thresh=athresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = maskedmerge( yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
maskedmerge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
burfadel
25th May 2007, 10:07
Now that avisynth v2.8 is available (as a test version I know) are you going to include a version for that too? The main thing you can change is replacing the lanczosresize with the blackmanresize functions. This particular blackmanresize, as you can see in documentation, is just an improved version of the lanczosresize function. The syntax is EXACTLY the same except replacing the word lanczos with blackman (but will only run on avisynth v2.58 or later).
The other thing is splin64resize has been introduced. There's mixed feelings about this, some say its better some say its not than spline36resize but I have personally found it to be a bit better.
I think the inclusion of these two functions as an alternative Avisynth v2.58 version would be great!
I think the inclusion of these two functions as an alternative Avisynth v2.58 version would be great!
Have you considered using the "Find and replace" function of your favourite text editor?
foxyshadis
26th May 2007, 03:43
Now that avisynth v2.8 is available (as a test version I know) are you going to include a version for that too? The main thing you can change is replacing the lanczosresize with the blackmanresize functions. This particular blackmanresize, as you can see in documentation, is just an improved version of the lanczosresize function. The syntax is EXACTLY the same except replacing the word lanczos with blackman (but will only run on avisynth v2.58 or later).
The other thing is splin64resize has been introduced. There's mixed feelings about this, some say its better some say its not than spline36resize but I have personally found it to be a bit better.
I think the inclusion of these two functions as an alternative Avisynth v2.58 version would be great!
You don't even need that; if mp4 guy found them to work better he could just distribute or point to the externally compiled versions of those functions, so they'd work on 2.57 and below.
TheRyuu
26th May 2007, 06:12
You don't even need that; if mp4 guy found them to work better he could just distribute or point to the externally compiled versions of those functions, so they'd work on 2.57 and below.
You mean like this? (http://forum.doom9.org/showpost.php?p=958662&postcount=73) :p
(despite it being just "compiled and not crashed" it works very well, I'm experimenting with blackman and spline64).
Anyway, I would use Lanczos Plus like this right:
LanczosPlus(dest_x, dest_y, other stuff...) #or is it still just 2xwidth/height?
Also, would having the "Pruned" version of awarpsharp affect anything? And what does the autotap3() thing do (is it used in conjunction with Lanczos Plus?)
Anyway, I'll definitely be playing around with this one. Been looking for a new "resizer". Been getting board of the years old Lanczos and Spline36. :D
Thanks :)
BTW, 5 minutes of work for burfadel (it's about the same speed, too lazy to wait for it to finish, got about .31fps with SetMTMode(2, 2) on dual core Opty@2.5ghz)
Replaced all "LanczosResize" with "blackmanresize" and spline36 with spline64. Wonder how the quality is affected anyway since Blackman is suppose to "ring" less.
#BlackManPlus :D
#modified LanczosPlus using Blackmanresize and Spline64 from the new filters dll compiled by foxyshadis
#LanczosPlus made by mp4 guy
LoadPlugin("newresize.dll")
function autotap3b(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 1)
thresh = default(thresh, 256)
t1 = blackmanresize(clp, dx, dy, taps=1)
t2 = blackmanresize(clp, dx, dy, taps=2)
t3 = blackmanresize(clp, dx, dy, taps=3)
t4 = blackmanresize(clp, dx, dy, taps=4)
t5 = blackmanresize(clp, dx, dy, taps=5)
t6 = blackmanresize(clp, dx, dy, taps=9)
t7 = blackmanresize(clp, dx, dy, taps=36)
m1 = yv12lutxy(clp, blackmanresize(t1, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m2 = yv12lutxy(clp, blackmanresize(t2, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m3 = yv12lutxy(clp, blackmanresize(t3, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m4 = yv12lutxy(clp, blackmanresize(t4, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m5 = yv12lutxy(clp, blackmanresize(t5, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m6 = yv12lutxy(clp, blackmanresize(t6, clp.width, clp.height, taps=3), "x y - abs", u=3, v=3)
m7 = yv12lutxy(clp, blackmanresize(t7, clp.width, clp.height, taps=6), "x y - abs", u=3, v=3)
cp1 = maskedmerge(t1.blur(1.42), t2, blackmanresize(yv12lutxy(m1, m2, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m100 = yv12lutxy(clp, bilinearresize(cp1, clp.width, clp.height), "x y - abs", u=3, v=3)
cp2 = maskedmerge(cp1, t3, blackmanresize(yv12lutxy(m100, m3, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m101 = yv12lutxy(clp, bilinearresize(cp2, clp.width, clp.height), "x y - abs", u=3, v=3)
cp3 = maskedmerge(cp2, t4, blackmanresize(yv12lutxy(m101, m4, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m102 = yv12lutxy(clp, bilinearresize(cp3, clp.width, clp.height), "x y - abs", u=3, v=3)
cp4 = maskedmerge(cp3, t5, blackmanresize(yv12lutxy(m102, m5, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m103 = yv12lutxy(clp, bilinearresize(cp4, clp.width, clp.height), "x y - abs", u=3, v=3)
cp5 = maskedmerge(cp4, t6, blackmanresize(yv12lutxy(m103, m6, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m104 = yv12lutxy(clp, bilinearresize(cp5, clp.width, clp.height), "x y - abs", u=3, v=3)
cp6 = maskedmerge(cp5, t7, blackmanresize(yv12lutxy(m104, m7, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m105 = yv12lutxy(clp, bilinearresize(cp6, clp.width, clp.height), "x y - abs", u=3, v=3)
return(mergechroma(cp6, spline64resize(clp, dx, dy), 1))}
###
###
###
function Blackmanplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 1)
sharp2 = default(sharp2, 4)
blur1 = default(blur1, 0.33)
blur2 = default(blur2, 1.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = blackmanresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.blackmanresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.autotap3b( ((c.width/16)*8 >= 144 ? (c.width/16)*8 : 144), ((c.height/16)*8 >= 144 ? (c.height/16)*8 : 144), mtaps3=mtaps3, thresh=athresh).autotap3b( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = yv12lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = blackmanresize(blackmanresize(frfun7(m1, 2.01, 256, 256), (c.width/16)*8, (c.height/16)*8, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? maskedmerge(c, fre2, m1) : c
d2 = d.autotap3b(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = autotap3b(autotap3b(d, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
d2.width, d2.height, mtaps3=mtaps3, thresh=athresh)
d4 = maskedmerge( yv12lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
yv12lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.autotap3b(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = maskedmerge(d5, c, m1).autotap3b(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = blackmanresize(e, ((e.width*(dx/c.width))/16)*16, ((e.height*(dy/c.height))/16)*16, taps=mtaps2)
fre12 = fd12.blackmanresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.blackmanresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).blackmanresize( e.width, e.height, taps=mtaps2)
m12 = yv12lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.blackmanresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).blackmanresize( e.width, e.height, taps=mtaps2)
e2 = autotap3b(autotap3b(e, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
e.width, e.height, mtaps3=mtaps3, thresh=athresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = maskedmerge( yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
maskedmerge(d4, e3, m2)
return(last.mergechroma(spline64resize(c, dx, dy), 1))}
*.mp4 guy
26th May 2007, 08:46
Anyway, I would use Lanczos Plus like this right:
LanczosPlus(dest_x, dest_y, other stuff...) #or is it still just 2xwidth/height?
Also, would having the "Pruned" version of awarpsharp affect anything? And what does the autotap3() thing do (is it used in conjunction with Lanczos Plus?)
Anyway, I'll definitely be playing around with this one. Been looking for a new "resizer". Been getting board of the years old Lanczos and Spline36. :D
Thanks :)
BTW, 5 minutes of work for burfadel (it's about the same speed, too lazy to wait for it to finish, got about .31fps with SetMTMode(2, 2) on dual core Opty@2.5ghz)
Replaced all "LanczosResize" with "blackmanresize" and spline36 with spline64. Wonder how the quality is affected anyway since Blackman is suppose to "ring" less.
[/CODE]
1- Yes, thats how you would use lanczosplus, it works fine at any resolution that is greater then the input resolution, aslong as the input resolution is greater then 144 (less then 144*144 will cause problems due to high order taps)
2-No idea about awarpsharp, probably not.
3- Quality will be very very similar, all that is necessary for ****plus to work is a high quality base linear resizing algorithm, that supports various window sizes. If blackman rings less, it might actually be worse then lanczos, since less ringing=less detail (when considering windowing functions), the best base resizer (probably) would be a "square" windowed sinc function, but I don't think avisynth has one.
I would like to know if lanczos(or blackman)plus does anything interesting, thanks for changing the script for burfadel.
burfadel
26th May 2007, 09:09
I didn't want to show the replacement myself as I don't use the resizer! It wouldn't be right to suggest something is better if you haven't even tried the original one (I have no need to try the resizer!). The only reason why I suggested it is because the blackmanresize function is an update of the lanczosresize filter designed to reduce the exact artifacts you were referring to!
Anyway, has anyone tried with the blackman and spline 64 resizers? I am curious to know if the result was any different!
Manao
26th May 2007, 10:21
*.mp4 guy : Why do you still use masktools 1.5 ? v2.0 provides the same capabilities, but faster, with less bug and almost the same syntax.
Fizick
26th May 2007, 11:07
Manao,
please see your signature:
v1.5.8 is 'stable'
v2.0 is 'alpha'
IMO it is confusing for many people. When you will release 'more stable' 2.0 'beta' or 'RC' of final?
Manao
26th May 2007, 11:22
Fair enough.
I consider 2.0a30 stable since I haven't had a bug report on that version, and it has been out there long enough.
But I think *.mp4 guy knows that and so he may have another reason, which interests me since it's potentially a bug / a missing functionality i haven't seen.
krieger2005
26th May 2007, 11:53
It's a force of habit for me. It think for *.mp4 guy also. If i don't want to look the new syntax or function-names of masktools v2 i just use v1.
*.mp4 guy
26th May 2007, 11:53
No, it is laziness on my part, I thought the only difference was a (modest) speed increase, and the stuff I usually end up with is so slow, I never consider masktools to be an important factor in how fast they run. I have had some stability issues, however, which may or may not be related to masktools, which is a much more compelling reason to use V2. I'm not aware of any missing functionality in V2.
[edit] krieger2005 beat me to it, I have all of the masktools v1.5 function syntax memorized, so when I am writing something I never think to use anything else, and after the fact, simple replacement is not particularly apealing.
Manao
26th May 2007, 11:57
Ok, thanks for the precision, and sorry for the slight hijacking of the thread.
TheRyuu
26th May 2007, 15:35
No, it is laziness on my part, I thought the only difference was a (modest) speed increase, and the stuff I usually end up with is so slow, I never consider masktools to be an important factor in how fast they run. I have had some stability issues, however, which may or may not be related to masktools, which is a much more compelling reason to use V2. I'm not aware of any missing functionality in V2.
[edit] krieger2005 beat me to it, I have all of the masktools v1.5 function syntax memorized, so when I am writing something I never think to use anything else, and after the fact, simple replacement is not particularly apealing.
Why isn't simple replacement appealing?
Anyway, how about I just replace it for ya :) (honestly, I have no idea what any of it means or what I was doing, I just opened up the mt_masktools webpage and looked up the similar function names)
Just to try it out (had pretty much not idea what I was doing), I replaced all the masktools v1 with mt_masktools v2 functions and came up with whats below. According to what I could see it was .05-.10fps faster. Which if you do the math is something like 30% faster. This is from what I could see running a quick test. And I also have no idea if quality was affected at all.
Not sure if this is "real" real world performance here.
Just ran it real quick through x264 on a 1 pass fast with setmtmode(2,2). LanczosPlus got about ~.30fps, Lanczosmtplus got ~.37-.40.
#modified LanczosPlus using Masktools 2.0
#LanczosPlus is now LanczosmtPlus
#autotap3 is now automttap3
#should be ~30% increase in speed, although it may vary from computer to computer
#original lanczosplus created by *.mp4 guy. :)
function automttap3(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 1)
thresh = default(thresh, 256)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=5)
t6 = lanczosresize(clp, dx, dy, taps=9)
t7 = lanczosresize(clp, dx, dy, taps=36)
m1 = mt_lutxy(clp, lanczosresize(t1, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m2 = mt_lutxy(clp, lanczosresize(t2, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m3 = mt_lutxy(clp, lanczosresize(t3, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m4 = mt_lutxy(clp, lanczosresize(t4, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m5 = mt_lutxy(clp, lanczosresize(t5, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m6 = mt_lutxy(clp, lanczosresize(t6, clp.width, clp.height, taps=3), "x y - abs", u=3, v=3)
m7 = mt_lutxy(clp, lanczosresize(t7, clp.width, clp.height, taps=6), "x y - abs", u=3, v=3)
cp1 = mt_merge(t1.blur(1.42), t2, lanczosresize(yv12lutxy(m1, m2, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m100 = mt_lutxy(clp, bilinearresize(cp1, clp.width, clp.height), "x y - abs", u=3, v=3)
cp2 = mt_merge(cp1, t3, lanczosresize(yv12lutxy(m100, m3, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m101 = mt_lutxy(clp, bilinearresize(cp2, clp.width, clp.height), "x y - abs", u=3, v=3)
cp3 = mt_merge(cp2, t4, lanczosresize(yv12lutxy(m101, m4, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m102 = mt_lutxy(clp, bilinearresize(cp3, clp.width, clp.height), "x y - abs", u=3, v=3)
cp4 = mt_merge(cp3, t5, lanczosresize(yv12lutxy(m102, m5, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m103 = mt_lutxy(clp, bilinearresize(cp4, clp.width, clp.height), "x y - abs", u=3, v=3)
cp5 = mt_merge(cp4, t6, lanczosresize(yv12lutxy(m103, m6, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m104 = mt_lutxy(clp, bilinearresize(cp5, clp.width, clp.height), "x y - abs", u=3, v=3)
cp6 = mt_merge(cp5, t7, lanczosresize(yv12lutxy(m104, m7, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m105 = mt_lutxy(clp, bilinearresize(cp6, clp.width, clp.height), "x y - abs", u=3, v=3)
return(mergechroma(cp6, spline36resize(clp, dx, dy), 1))}
###
###
###
function Lanczosmtplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 1)
sharp2 = default(sharp2, 4)
blur1 = default(blur1, 0.33)
blur2 = default(blur2, 1.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.automttap3( ((c.width/16)*8 >= 144 ? (c.width/16)*8 : 144), ((c.height/16)*8 >= 144 ? (c.height/16)*8 : 144), mtaps3=mtaps3, thresh=athresh).automttap3( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = mt_lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), (c.width/16)*8, (c.height/16)*8, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? mt_merge(c, fre2, m1) : c
d2 = d.automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = automttap3(automttap3(d, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
d2.width, d2.height, mtaps3=mtaps3, thresh=athresh)
d4 = mt_merge( mt_lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
mt_lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.automttap3(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = mt_merge(d5, c, m1).automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, ((e.width*(dx/c.width))/16)*16, ((e.height*(dy/c.height))/16)*16, taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = mt_lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = automttap3(autotap3(e, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
e.width, e.height, mtaps3=mtaps3, thresh=athresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = mt_merge( yv12lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
yv12lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
mt_merge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
Did a little more testing with speed and I think I can safely say that using mt_masktools is anywhere between not faster at all, and ~.8-.10fps faster (or ~30% on my computer). Varies a lot, IMO.
Anyway, See ya :)
canuckerfan
26th May 2007, 22:51
hmm... i read through the posts and what I could understand of the script... but couldn't figure out what's the different between normal lanczos and lanczosplus. could anyone elaborate?
*.mp4 guy
27th May 2007, 04:02
@wizboy11
Heh, If I knew it was that easy I would have done it a lot sooner, thanks for enlihtening me; I was sure the syntax had changed and I would have to retype a lot of stuff.
@canuckerfan
The easiest way to find out the answer to your question is to test it out yourself, I could try to tell you what it does, but its always best to see for youself.
Quick question
wizboy11, why not update the "yv12lutxy" function, as seen for example in the automttap3 function? Like use mt_lutxy instead?
TheRyuu
27th May 2007, 17:24
Quick question
wizboy11, why not update the "yv12lutxy" function, as seen for example in the automttap3 function? Like use mt_lutxy instead?
lol, I think I missed a few :p
Edit:
#modified LanczosPlus using Masktools 2.0
#LanczosPlus is now LanczosmtPlus()
#autotap3 is now automttap3
#I just replaced the original Masktools v1 with mt_masktools v2 commands. I have no idea if this at all changes
#any functionality of this script or the quality.
#original lanczosplus created by *.mp4 guy. :)
function automttap3(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 1)
thresh = default(thresh, 256)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=5)
t6 = lanczosresize(clp, dx, dy, taps=9)
t7 = lanczosresize(clp, dx, dy, taps=36)
m1 = mt_lutxy(clp, lanczosresize(t1, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m2 = mt_lutxy(clp, lanczosresize(t2, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m3 = mt_lutxy(clp, lanczosresize(t3, clp.width, clp.height, taps=1), "x y - abs", u=3, v=3)
m4 = mt_lutxy(clp, lanczosresize(t4, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m5 = mt_lutxy(clp, lanczosresize(t5, clp.width, clp.height, taps=2), "x y - abs", u=3, v=3)
m6 = mt_lutxy(clp, lanczosresize(t6, clp.width, clp.height, taps=3), "x y - abs", u=3, v=3)
m7 = mt_lutxy(clp, lanczosresize(t7, clp.width, clp.height, taps=6), "x y - abs", u=3, v=3)
cp1 = mt_merge(t1.blur(1.42), t2, lanczosresize(mt_lutxy(m1, m2, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m100 = mt_lutxy(clp, bilinearresize(cp1, clp.width, clp.height), "x y - abs", u=3, v=3)
cp2 = mt_merge(cp1, t3, lanczosresize(mt_lutxy(m100, m3, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m101 = mt_lutxy(clp, bilinearresize(cp2, clp.width, clp.height), "x y - abs", u=3, v=3)
cp3 = mt_merge(cp2, t4, lanczosresize(mt_lutxy(m101, m4, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m102 = mt_lutxy(clp, bilinearresize(cp3, clp.width, clp.height), "x y - abs", u=3, v=3)
cp4 = mt_merge(cp3, t5, lanczosresize(mt_lutxy(m102, m5, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m103 = mt_lutxy(clp, bilinearresize(cp4, clp.width, clp.height), "x y - abs", u=3, v=3)
cp5 = mt_merge(cp4, t6, lanczosresize(mt_lutxy(m103, m6, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m104 = mt_lutxy(clp, bilinearresize(cp5, clp.width, clp.height), "x y - abs", u=3, v=3)
cp6 = mt_merge(cp5, t7, lanczosresize(mt_lutxy(m104, m7, "x y - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m105 = mt_lutxy(clp, bilinearresize(cp6, clp.width, clp.height), "x y - abs", u=3, v=3)
return(mergechroma(cp6, spline36resize(clp, dx, dy), 1))}
###
###
###
function Lanczosmtplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 1)
sharp2 = default(sharp2, 4)
blur1 = default(blur1, 0.33)
blur2 = default(blur2, 1.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.automttap3( ((c.width/16)*8 >= 144 ? (c.width/16)*8 : 144), ((c.height/16)*8 >= 144 ? (c.height/16)*8 : 144), mtaps3=mtaps3, thresh=athresh).automttap3( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = mt_lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), (c.width/16)*8, (c.height/16)*8, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? mt_merge(c, fre2, m1) : c
d2 = d.automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = automttap3(automttap3(d, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
d2.width, d2.height, mtaps3=mtaps3, thresh=athresh)
d4 = mt_merge( mt_lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
mt_lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.automttap3(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = mt_merge(d5, c, m1).automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, ((e.width*(dx/c.width))/16)*16, ((e.height*(dy/c.height))/16)*16, taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = mt_lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = automttap3(automttap3(e, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
e.width, e.height, mtaps3=mtaps3, thresh=athresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = mt_merge( mt_lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
mt_lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
mt_merge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
Hope I got'em all.
This one is faster then ever. A whopping .42fps I got on it.
Didée
27th May 2007, 17:55
It would be possible to squeeze even a bit more. Half of all mt_LutXY's could be replaced by mt_MakeDiff. The abs'ing of the differences can be incorporated in the subsequent mt_LutXY's. This a) loads the script faster because less lookup tables have to be filled, and b) mt_MakeDiff generally runs faster than doing it manually by mt_LutXY.
Theorertically there's a loss in precision (abs(+/-255) vs. abs(+/-128)) - but that's no issue here, since the actually used diff's are much smaller (with thresh=255, it's only +/-1 that is really used.)
@wizboy11
Thanks, I was just pointing out an inconsistency. Thanks for updating the script.
@All
Anyone know how to do what Dideé just suggested? I would, but I hardly know how, or where to start.
Didée
27th May 2007, 19:06
>> Anyone know how to do what Dideé just suggested?
By replacing
>> mt_lutxy( this, that, "x y - abs", u=3, v=3)
with
>> mt_makediff( this, that, u=3, v=3)
and, consequently,
this
>> mt_lutxy(m1, m2, "x y - "
with
>> mt_lutxy(m1, m2, "x y 128 - abs - "
That's all.
BTW1, @ wizboy11:
You forgot one time "autotap3" -> "automttap3"
(in line 114, actually.) ;)
BTW2: There is even more speed loss for Lanczos(mt)Plus.
In Auto(mt)tap3, all chroma planes are fully processed.
But then, Lanczos(mt)Plus calls Auto(mt)tap3 many times, hence the chroma planes are fully processed several times - - and in the very end, Lanczos(mt)Plus uses nothing but a simple resize of the original input:
function Lanczosmtplus( clip c, ... ) {
.. ..
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
Plenty of all the work goes into the chroma planes, and is not used in the end.
Script with just the lutxy/makediff optimization (but not the chroma thing):
#modified LanczosPlus using Masktools 2.0
#LanczosPlus is now LanczosmtPlus()
#autotap3 is now automttap3
#I just replaced the original Masktools v1 with mt_masktools v2 commands. I have no idea if this at all changes
#any functionality of this script or the quality.
#original lanczosplus created by *.mp4 guy. :)
function automttap3(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 1)
thresh = default(thresh, 256)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=5)
t6 = lanczosresize(clp, dx, dy, taps=9)
t7 = lanczosresize(clp, dx, dy, taps=36)
m1 = mt_makediff(clp, lanczosresize(t1, clp.width, clp.height, taps=1), u=3, v=3)
m2 = mt_makediff(clp, lanczosresize(t2, clp.width, clp.height, taps=1), u=3, v=3)
m3 = mt_makediff(clp, lanczosresize(t3, clp.width, clp.height, taps=1), u=3, v=3)
m4 = mt_makediff(clp, lanczosresize(t4, clp.width, clp.height, taps=2), u=3, v=3)
m5 = mt_makediff(clp, lanczosresize(t5, clp.width, clp.height, taps=2), u=3, v=3)
m6 = mt_makediff(clp, lanczosresize(t6, clp.width, clp.height, taps=3), u=3, v=3)
m7 = mt_makediff(clp, lanczosresize(t7, clp.width, clp.height, taps=6), u=3, v=3)
cp1 = mt_merge(t1.blur(1.42), t2, lanczosresize(mt_lutxy(m1, m2, "x y 128 - abs - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m100 = mt_makediff(clp, bilinearresize(cp1, clp.width, clp.height), u=3, v=3)
cp2 = mt_merge(cp1, t3, lanczosresize(mt_lutxy(m100, m3, "x y 128 - abs - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m101 = mt_makediff(clp, bilinearresize(cp2, clp.width, clp.height), u=3, v=3)
cp3 = mt_merge(cp2, t4, lanczosresize(mt_lutxy(m101, m4, "x y 128 - abs - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m102 = mt_makediff(clp, bilinearresize(cp3, clp.width, clp.height), u=3, v=3)
cp4 = mt_merge(cp3, t5, lanczosresize(mt_lutxy(m102, m5, "x y 128 - abs - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m103 = mt_makediff(clp, bilinearresize(cp4, clp.width, clp.height), u=3, v=3)
cp5 = mt_merge(cp4, t6, lanczosresize(mt_lutxy(m103, m6, "x y 128 - abs - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m104 = mt_makediff(clp, bilinearresize(cp5, clp.width, clp.height), u=3, v=3)
cp6 = mt_merge(cp5, t7, lanczosresize(mt_lutxy(m104, m7, "x y 128 - abs - "+string(thresh)+" *", u=3, v=3), dx, dy, taps=mtaps3))
m105 = mt_makediff(clp, bilinearresize(cp6, clp.width, clp.height), u=3, v=3)
return(mergechroma(cp6, spline36resize(clp, dx, dy), 1))}
###
###
###
function Lanczosmtplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 1)
sharp2 = default(sharp2, 4)
blur1 = default(blur1, 0.33)
blur2 = default(blur2, 1.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 3)
ltaps = default(ltaps, 3)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.automttap3( ((c.width/16)*8 >= 144 ? (c.width/16)*8 : 144), ((c.height/16)*8 >= 144 ? (c.height/16)*8 : 144), mtaps3=mtaps3, thresh=athresh).automttap3( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = mt_lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=3, v=3)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), (c.width/16)*8, (c.height/16)*8, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? mt_merge(c, fre2, m1) : c
d2 = d.automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = automttap3(automttap3(d, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
d2.width, d2.height, mtaps3=mtaps3, thresh=athresh)
d4 = mt_merge( mt_lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=3, v=3), \
mt_lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=3, v=3), m2)
d5 = d4.automttap3(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = mt_merge(d5, c, m1).automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, ((e.width*(dx/c.width))/16)*16, ((e.height*(dy/c.height))/16)*16, taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = mt_lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=3, v=3)
m12 = m12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = automttap3(automttap3(e, c.width, c.height, mtaps3=mtaps3, thresh=athresh), \
e.width, e.height, mtaps3=mtaps3, thresh=athresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = mt_merge( mt_lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=3, v=3), \
mt_lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=3, v=3), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
mt_merge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
canuckerfan
27th May 2007, 19:49
@canuckerfan
The easiest way to find out the answer to your question is to test it out yourself, I could try to tell you what it does, but its always best to see for youself.
i will experiment. thank you. hopefully, it will create less ringing. already I can tell it's slower...:)
*.mp4 guy
27th May 2007, 21:20
>> Anyone know how to do what Dideé just suggested?
BTW2: There is even more speed loss for Lanczos(mt)Plus.
In Auto(mt)tap3, all chroma planes are fully processed.
But then, Lanczos(mt)Plus calls Auto(mt)tap3 many times, hence the chroma planes are fully processed several times - - and in the very end, Lanczos(mt)Plus uses nothing but a simple resize of the original input
Do you know of a way to process the luminance channel only? I know there is a speed hit for processing the chroma planes, but I've never known how to get around it.
@wizboy11, @Didée
Thanks for the optimizations, it may just become almost usably fast, again.
Didée
27th May 2007, 21:41
Old story ... in masktools,
y|u|v = 3 will actually process that plane.
y|u|v = 2 will pipe that plane through untouched
y|u|v = 1 will trash that plane (slightly faster than '2')
Practical example of a function where chroma handling can be chosen by the user:
# Nifty Gauss/Median combination
function MinBlur(clip clp, int r, int "uv")
{
uv = default(uv,3)
uv2 = (uv==2) ? 1 : uv
rg4 = (uv==3) ? 4 : -1
rg11 = (uv==3) ? 11 : -1
rg20 = (uv==3) ? 20 : -1
medf = (uv==3) ? 1 : -200
RG11D = (r==1) ? mt_makediff(clp,clp.removegrain(11,rg11),U=uv2,V=uv2)
\ : (r==2) ? mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20),U=uv2,V=uv2)
\ : mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20).removegrain(20,rg20),U=uv2,V=uv2)
RG4D = (r==1) ? mt_makediff(clp,clp.removegrain(4,rg4),U=uv2,V=uv2)
\ : (r==2) ? mt_makediff(clp,clp.medianblur(2,2*medf,2*medf),U=uv2,V=uv2)
\ : mt_makediff(clp,clp.medianblur(3,3*medf,3*medf),U=uv2,V=uv2)
DD = mt_lutxy(RG11D,RG4D,"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
clp.mt_makediff(DD,U=uv,V=uv)
return(last)
}
(Lazily, this doesn't offer full flexibility (u|v separation, y exclusion) or maximum optimization (intermediately, 2->1 could be used), but it gets the major part of the cake.)
Terranigma
27th May 2007, 23:16
Didée, with all these speed improvements you're busting out with for various scripts, think you can think of ways to speed up my fav avs scripts, maybe by .5fps (Seesaw and Mcbob)? =P
*.mp4 guy
28th May 2007, 08:10
@Didée
Yeah, I see whats happening. If y8<->yv12 conversion works correctly I should also be able to speed up the resampling steps.
[edit] didn't realise that y8 isn't supported in anything less then 2.6, so it might be a while before it can be used as an optimisation.
[edit] some of the mt_lutxy equations were wrong, now fixed, reverted a non-beneficial change from a previous version, chroma planes are no longer processed during masktools operations, but are otherwise still processed.
#modified LanczosPlus using Masktools 2.0
#LanczosPlus is now LanczosmtPlus()
#autotap3 is now automttap3
# Optimisations by: wizboy11 and Didée
function automttap3(clip clp, int "dx", int "dy", int "mtaps3", int "thresh"){
c = clp
#g = clp.converttoy8()
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
mtaps3 = default(mtaps3, 1)
thresh = default(thresh, 256)
t1 = lanczosresize(clp, dx, dy, taps=1)
t2 = lanczosresize(clp, dx, dy, taps=2)
t3 = lanczosresize(clp, dx, dy, taps=3)
t4 = lanczosresize(clp, dx, dy, taps=4)
t5 = lanczosresize(clp, dx, dy, taps=5)
t6 = lanczosresize(clp, dx, dy, taps=9)
t7 = lanczosresize(clp, dx, dy, taps=36)
m1 = mt_makediff(clp, lanczosresize(t1, clp.width, clp.height, taps=1), u=1, v=1)
m2 = mt_makediff(clp, lanczosresize(t2, clp.width, clp.height, taps=1), u=1, v=1)
m3 = mt_makediff(clp, lanczosresize(t3, clp.width, clp.height, taps=1), u=1, v=1)
m4 = mt_makediff(clp, lanczosresize(t4, clp.width, clp.height, taps=2), u=1, v=1)
m5 = mt_makediff(clp, lanczosresize(t5, clp.width, clp.height, taps=2), u=1, v=1)
m6 = mt_makediff(clp, lanczosresize(t6, clp.width, clp.height, taps=3), u=1, v=1)
m7 = mt_makediff(clp, lanczosresize(t7, clp.width, clp.height, taps=6), u=1, v=1)
cp1 = mt_merge(t1.blur(1.42), t2, lanczosresize(mt_lutxy(m1, m2, "x 128 - abs y 128 - abs - "+string(thresh)+" *", u=1, v=1), dx, dy, taps=mtaps3))
m100 = mt_makediff(clp, bilinearresize(cp1, clp.width, clp.height), u=3, v=3)
cp2 = mt_merge(cp1, t3, lanczosresize(mt_lutxy(m100, m3, "x 128 - abs y 128 - abs - "+string(thresh)+" *", u=1, v=1), dx, dy, taps=mtaps3))
m101 = mt_makediff(clp, bilinearresize(cp2, clp.width, clp.height), u=3, v=3)
cp3 = mt_merge(cp2, t4, lanczosresize(mt_lutxy(m101, m4, "x 128 - abs y 128 - abs - "+string(thresh)+" *", u=1, v=1), dx, dy, taps=mtaps3))
m102 = mt_makediff(clp, bilinearresize(cp3, clp.width, clp.height), u=3, v=3)
cp4 = mt_merge(cp3, t5, lanczosresize(mt_lutxy(m102, m5, "x 128 - abs y 128 - abs - "+string(thresh)+" *", u=1, v=1), dx, dy, taps=mtaps3))
m103 = mt_makediff(clp, bilinearresize(cp4, clp.width, clp.height), u=3, v=3)
cp5 = mt_merge(cp4, t6, lanczosresize(mt_lutxy(m103, m6, "x 128 - abs y 128 - abs - "+string(thresh)+" *", u=1, v=1), dx, dy, taps=mtaps3))
m104 = mt_makediff(clp, bilinearresize(cp5, clp.width, clp.height), u=3, v=3)
cp6 = mt_merge(cp5, t7, lanczosresize(mt_lutxy(m104, m7, "x 128 - abs y 128 - abs - "+string(thresh)+" *", u=1, v=1), dx, dy, taps=mtaps3))
m105 = mt_makediff(clp, bilinearresize(cp6, clp.width, clp.height), u=3, v=3)
return(mergechroma(cp6, spline36resize(clp, dx, dy), 1))}
###
###
###
function Lanczosmtplus( clip c, int "dx", int "dy", int "thresh", int "thresh2", int "athresh",
\ float "sharp1", float "sharp2", float "blur1", float "blur2",
\ int "mtaps1", int "mtaps2", int "ttaps", int "ltaps", bool "preblur",
\ int "depth", float "wthresh", float "wblur", int "mtaps3"){
dx = default(dx, c.width*2)
dy = default(dy, c.height*2)
thresh = default(thresh, 0)
thresh2 = Default(thresh2, ((thresh+1)*(thresh+1))*64/(thresh+1))
sharp1 = default(sharp1, 1)
sharp2 = default(sharp2, 4)
blur1 = default(blur1, 0.33)
blur2 = default(blur2, 1.25)
mtaps1 = default(mtaps1, 1)
mtaps2 = default(mtaps2, 1)
ttaps = default(ttaps, 1)
ltaps = default(ltaps, 1)
depth = default(depth, 2)
wthresh = default(wthresh, 0.90)
wblur = default(wblur, 2)
mtaps3 = default(mtaps3, 1)
preblur = default(preblur, false)
athresh = default(athresh, 256)
c
s = c
fd1 = lanczosresize(c, dx, dy, taps=mtaps1)
fre1 = fd1.lanczosresize( c.width, c.height, taps=mtaps1)
fre2 = fre1.automttap3( ((c.width/16)*8 >= 144 ? (c.width/16)*8 : 144), ((c.height/16)*8 >= 144 ? (c.height/16)*8 : 144), \
mtaps3=mtaps3, thresh=athresh).automttap3( c.width, c.height, mtaps3=mtaps3, thresh=athresh)
m1 = mt_lutxy(fre1, s, "x y - abs "+string(thresh)+" - "+string(thresh2)+" *", u=1, v=1)
m2 = lanczosresize(lanczosresize(frfun7(m1, 2.01, 256, 256), (c.width/16)*8, (c.height/16)*8, taps=ttaps), \
dx, dy, taps=ttaps)
d = preblur ? mt_merge(c, fre2, m1) : c
d2 = d.automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
d3 = lanczosresize(lanczosresize(d, c.width, c.height, taps=ttaps), \
d2.width, d2.height, taps=ttaps)
d4 = mt_merge( mt_lutxy(d2, d3 , "x y - "+string(sharp1)+" * x +" , u=1, v=1), \
mt_lutxy(d2, d3 , "y x - "+string(blur1)+" * x +" , u=1, v=1), m2)
d5 = d4.automttap3(d.width, d.height, mtaps3=mtaps3, thresh=athresh)
e = mt_merge(d5, c, m1).automttap3(dx, dy, mtaps3=mtaps3, thresh=athresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e = e.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
fd12 = lanczosresize(e, ((e.width*(dx/c.width))/16)*16, ((e.height*(dy/c.height))/16)*16, taps=mtaps2)
fre12 = fd12.lanczosresize( e.width, e.height, taps=mtaps2)
fre22 = fre12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
m12 = mt_lutxy(fre12, e, "x y - abs "+string(thresh)+" - "+string(thresh2*1)+" *", u=1, v=1)
m12 = m12.lanczosresize( (e.width/16)*8, (e.height/16)*8, taps=mtaps2).lanczosresize( e.width, e.height, taps=mtaps2)
e2 = lanczosresize(lanczosresize(e, c.width, c.height, taps=ltaps), \
e.width, e.height, taps=ltaps)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e2 = e2.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = mt_merge( mt_lutxy(e, e2 , "y x - "+string(blur2)+" * x +" , u=1, v=1), \
mt_lutxy(e, e2 , "x y - "+string(sharp2)+" * x +" , u=1, v=1), \
m12)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
e3 = e3.awarpsharp(depth=depth, cm=0, blurlevel=wblur, thresh=wthresh)
mt_merge(d4, e3, m2)
return(last.mergechroma(spline36resize(c, dx, dy), 1))}
Didée
28th May 2007, 11:24
some of the mt_lutxy equations were wrong,
Uh-oh, that was my fault ... didn't see that in lutxy(m1,m2) both clips are difference clips. :o
Hard cheese, sorry. ;)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.