View Full Version : Motion compensated filtering script extremely slow and resource hungry!
ChrisBeringB
18th January 2011, 16:22
Hi all!
I started using Avisynth a couple months ago. There's a lot to learn - particularly separating the wheat from the chaff in the custom filter/script department. Even builtin functions vary somewhat in quality.
In the end I started writing my own noise removal script, using filters everyone seems to use; MVTools2, Masktools2, NEEdi3 and FFT3DFilter.
My little project has since morphed and grown as I learned more about the filters - MVTools2 in particular is anything but easy to get good results from. Infact, most of the script is about masking artefacts away.
In the end, the script has become extremely slow.
Processing 704x480 video on my mobile 2GHz Core Duo yields 0.16 fps - ie ~6 seconds per frame!!!
I also have to use a SetMemoryMax(1260) statement to avoid Avisynth grinding to an almost complete halt.
I know temporal filtering is slow, but this is ridiculous. I'm assuming this is much, much worse than what is achieved by the various other temporal filters out there.
So, I must be doing something wrong.
Are there any performance pitfalls, that newbies should be aware of?
I know Avisynth has an internal frame buffering system, that prevents calculating intermediate results more than once.
But over 1.2GB memory usage?
Is there a way to guide Avisynth to only buffer the neccesary variables, instead of buffering everything?
I tried splitting the 3 main filtering stages into separate functions, thinking that all local variables in each stage would then be buffered less, as they become local in scope.
As Avisynth can't pass arguments as references, I chose for performance reasons to just make the handful of global variables, well, global.
This gave no change in either speed or memory requirements - so maybe my understanding of how Avisynth works is flawed, or maybe something else is eating the memory.
Any advice will be appreciated.
Chris.
Gser
18th January 2011, 16:28
Yup, that's the way it is.
ChrisBeringB
18th January 2011, 16:55
I was after general directions/good practice in Avisynth scripting and usage of the filters I employ.
I could post my script after some cleaning up, but even then, would anyone here bother to wade through it? - It's not small.
Gavino
18th January 2011, 17:11
Is there a way to guide Avisynth to only buffer the neccesary variables, instead of buffering everything?
It's not variables that are buffered (cf Stephen's comments), it's rendered video frames. In principle though, once the cache fills up, it should adjust itself heuristically so that it it only keeps the bits it needs (or is likely to need).
If you want to cache less, you should reduce the SetMemoryMax value. This makes more memory available to the filters themselves, and potentially to other processes (eg the encoder).
ChrisBeringB
18th January 2011, 19:23
What I said was "I know Avisynth has an internal frame buffering system, that prevents calculating intermediate results more than once". This is correctly understood, right?
How is lowering SetMemoryMax(), going to speed anything up?
If I lower it to ~1GB, fps drops to 0.01.
It seems to me the filters and the encoder (I use x264) grabs the memory they need - no matter what. The total memory usage is ~1.7GB.
Didée
18th January 2011, 19:42
We all would like to help, but can't.
Post. Your. Script.
ChrisBeringB
19th January 2011, 00:21
Here it is - cleaned a tiny bit.
# Experimental Avisynth script written by Christian Bering.
#
# It expects an interlaced YV12 clip as input.
# The output is deinterlaced, resolution and frame doubled, temporally denoised and sharpened.
# Uses filter plugins MVTools2, Masktools2, NNEdi3 and FFT3DFilter.
# The current settings are good for a very noisy 704x480x30 clip being cleaned,cropped and resized to 1080x720x60.
SetMemoryMax(1260)
Global clip=UnAlignedSplice(FFmpegSource2("D:\Temp\VTS_02_1.VOB", atrack=-1, colorspace="YV12"), FFmpegSource2("D:\Temp\VTS_02_2.VOB", atrack=-1, colorspace="YV12")).Crop(6, 0, -10, -0)
Global u=clip.UToY
Global v=clip.VToY
Global clip=StackVertical(clip.Crop(0, 0, -0, 2), clip, clip.Crop(0, Height(clip)-2, -0, 2))
Global clip=StackHorizontal(clip.PointResize(2, Height(clip), 0, 0, 1, -0), clip, clip.PointResize(2, Height(clip), Width(clip)-1, 0, 1, -0)).NNEdi3(field=-2, nsize=6, nns=4, qual=2, u=false, v=false, fapprox=7).AssumeFrameBased
Global prefiltered=clip.Crop(2, 2, -2, -2).fft3dfilter(sigma=6.0, sigma2=10.0, sigma3=7.0, sigma4=6.0, plane=0, bt=4, bw=64, bh=64, ow=32, oh=32, interlaced=false, wintype=2)
#Global prefiltered=clip.Crop(2, 2, -2, -2).fft3dgpu(sigma=6.0, sigma2=10.0, sigma3=7.0, sigma4=6.0, plane=0, bt=4, bw=64, bh=64, ow=32, oh=32, interlaced=false, wintype=2, precision=2)
Global clip=clip.TurnRight.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnLeft.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).Crop(4, 4, -4, -4)
Global prefiltered=StackVertical(prefiltered.PointResize(Width(prefiltered), 4, 0, 0, -0, 1).Crop(0, 0, -0, 2), prefiltered, prefiltered.PointResize(Width(prefiltered), 4, 0, Height(prefiltered)-1, -0, 1).Crop(0, 0, -0, 2))
Global prefiltered=StackHorizontal(prefiltered.PointResize(2, Height(prefiltered), 0, 0, 1, -0), prefiltered, prefiltered.PointResize(2, Height(prefiltered), Width(prefiltered)-1, 0, 1, -0)).TurnRight.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnLeft.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).Crop(4, 4, -4, -4)
UXShift=0
VXShift=0
UEvenYShift=0
VEvenYShift=0
UOddYShift=0
VOddYShift=0
Global u=StackVertical(u.Crop(0, 0, -0, 2), u, u.Crop(0, Height(u)-2, -0, 2))
Global u=StackHorizontal(u.PointResize(2, Height(u), 0, 0, 1, -0), u, u.PointResize(2, Height(u), Width(u)-1, 0, 1, -0)).NNEdi3(field=-2, nsize=6, nns=4, qual=2, u=false, v=false, fapprox=7).AssumeFrameBased.TurnRight.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnLeft.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnRight.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnLeft.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7)
Global u=Interleave(u.SelectEven.PointResize(Width(u)-16, Height(u)-16, 8-UXShift, 6-UEvenYShift, -8-UXShift, -10-UEvenYShift), u.SelectOdd.PointResize(Width(u)-16, Height(u)-16, 8-UXShift, 8-UOddYShift, -8-UXShift, -8-UOddYShift))
Global v=StackVertical(v.Crop(0, 0, -0, 2), v, v.Crop(0, Height(v)-2, -0, 2))
Global v=StackHorizontal(v.PointResize(2, Height(v), 0, 0, 1, -0), v, v.PointResize(2, Height(v), Width(v)-1, 0, 1, -0)).NNEdi3(field=-2, nsize=6, nns=4, qual=2, u=false, v=false, fapprox=7).AssumeFrameBased.TurnRight.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnLeft.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnRight.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7).TurnLeft.NNEdi3(field=1, dh=true, nsize=0, nns=4, qual=2, u=false, v=false, fapprox=7)
Global v=Interleave(v.SelectEven.PointResize(Width(v)-16, Height(v)-16, 8-VXShift, 6-VEvenYShift, -8-VXShift, -10-VEvenYShift), v.SelectOdd.PointResize(Width(v)-16, Height(v)-16, 8-VXShift, 8-VOddYShift, -8-VXShift, -8-VOddYShift))
Global done=stage1y
Global doneu=stage1u
Global donev=stage1v
Global done2=stage2y
Global done2u=stage2u
Global done2v=stage2v
Global done3=stage3y
Global done3u=stage3u
Global done3v=stage3v
strength=1.5
noisereject=0.5
th=MT_Lutxy(done3, done3.MT_Deflate, yexpr=String(1-noisereject) + " x * " + String(noisereject) + " y * +")
square=th.MT_Expand
both=th.MT_Expand(mode="both")
doneh=MT_Lutxy(both, square, yexpr="74.9807 x * 181.0193 y * + 256 /")
donehh=MT_Lutxy(both.MT_Expand(mode="both"), MT_Lutxy(both.MT_Expand, square.MT_Expand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
tl=MT_Lutxy(done3, done3.MT_Inflate, yexpr=String(1-noisereject) + " x * " + String(noisereject) + " y * +")
square=tl.MT_Inpand
both=tl.MT_Inpand(mode="both")
donel=MT_Lutxy(both, square, yexpr="74.9807 x * 181.0193 y * + 256 /")
donell=MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, square.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
dones=MT_Merge(donel, doneh, MT_Lutxy(MT_Makediff(tl, donell), MT_Makediff(donehh, th), yexpr="x 128 - " + String(strength) + " ^ x 128 - " + String(strength) + " ^ y 128 - " + String(strength) + " ^ + 1 max / 256 *"), u=1, v=1)
cropx=1392
cropy=928
centerx=0
centery=0
newwidth=1080
newheight=720
cl=0.5*(Width(done3)-cropx)+centerx
cr=0.5*(Width(done3)-cropx)-centerx
ct=0.5*(Height(done3)-cropy)+centery
cb=0.5*(Height(done3)-cropy)-centery
coff=(0.5*cropx)/newwidth
#final=YToUV(done2u.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), done2v.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), done3.BilinearResize(newwidth, newheight, cl, ct, -cr, -cb))
#final=YToUV(done2u.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), done2v.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), done3.BicubicResize(newwidth, newheight, 1./3., 1./3., cl, ct, -cr, -cb))
#finals=YToUV(done2u.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), done2v.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), dones.BilinearResize(newwidth, newheight, cl, ct, -cr, -cb))
finals=YToUV(done2u.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), done2v.BilinearResize(newwidth/2, newheight/2, cl-coff, ct, -cr-coff, -cb), dones.BicubicResize(newwidth, newheight, 1./3., 1./3., cl, ct, -cr, -cb))
return finals
#return Interleave(final, finals)
ChrisBeringB
19th January 2011, 00:22
Function stage1y()
{
clipsr=StackHorizontal(clip.PointResize(4, Height(clip)-4, 0, 0, 1, -4), clip.Crop(0, 0, -4, -4))
clipsr=StackVertical(clipsr.PointResize(Width(clipsr), 4, 0, 0, -0, 1), clipsr).Turn180
prefilteredsr=StackHorizontal(prefiltered.PointResize(4, Height(prefiltered)-4, 0, 0, 1, -4), prefiltered.Crop(0, 0, -4, -4))
prefilteredsr=StackVertical(prefilteredsr.PointResize(Width(prefilteredsr), 4, 0, 0, -0, 1), prefilteredsr).Turn180
superclip=MSuper(clip, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superclipsr=MSuper(clipsr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superpre=MSuper(prefiltered, hpad=16, vpad=16, pel=1, levels=5, chroma=true, sharp=2, rfilter=2)
superpresr=MSuper(prefilteredsr, hpad=16, vpad=16, pel=1, levels=5, chroma=true, sharp=2, rfilter=2)
Global vf1=MRecalculate(superpre, MRecalculate(superpre, MAnalyse(superpre,
\ blksize=16, levels=5, search=3, searchparam=6, pelsearch=1, isb=false, chroma=false, delta=1, truemotion=true, lambda=12000, lsad=1000, pnew=0, plevel=0, global=true, pzero=0, overlap=8, dct=8, divide=0),
\ thSAD=200, smooth=0, blksize=16, search=5, searchparam=16, chroma=false, truemotion=true, lambda=4000, pnew=0, overlap=8, dct=8, divide=0),
\ thSAD=0, smooth=0, blksize=16, search=5, searchparam=8, chroma=false, truemotion=true, lambda=8000, pnew=0, overlap=8, dct=8, divide=0)
Global vb1=MRecalculate(superpre, MRecalculate(superpre, MAnalyse(superpre,
\ blksize=16, levels=5, search=3, searchparam=6, pelsearch=1, isb=true, chroma=false, delta=1, truemotion=true, lambda=12000, lsad=1000, pnew=0, plevel=0, global=true, pzero=0, overlap=8, dct=8, divide=0),
\ thSAD=200, smooth=0, blksize=16, search=5, searchparam=16, chroma=false, truemotion=true, lambda=4000, pnew=0, overlap=8, dct=8, divide=0),
\ thSAD=0, smooth=0, blksize=16, search=5, searchparam=8, chroma=false, truemotion=true, lambda=8000, pnew=0, overlap=8, dct=8, divide=0)
Global vf1sr=MRecalculate(superpresr, MRecalculate(superpresr, MAnalyse(superpresr,
\ blksize=16, levels=5, search=3, searchparam=6, pelsearch=1, isb=false, chroma=false, delta=1, truemotion=true, lambda=12000, lsad=1000, pnew=0, plevel=0, global=true, pzero=0, overlap=8, dct=8, divide=0),
\ thSAD=200, smooth=0, blksize=16, search=5, searchparam=16, chroma=false, truemotion=true, lambda=4000, pnew=0, overlap=8, dct=8, divide=0),
\ thSAD=0, smooth=0, blksize=16, search=5, searchparam=8, chroma=false, truemotion=true, lambda=8000, pnew=0, overlap=8, dct=8, divide=0)
Global vb1sr=MRecalculate(superpresr, MRecalculate(superpresr, MAnalyse(superpresr,
\ blksize=16, levels=5, search=3, searchparam=6, pelsearch=1, isb=true, chroma=false, delta=1, truemotion=true, lambda=12000, lsad=1000, pnew=0, plevel=0, global=true, pzero=0, overlap=8, dct=8, divide=0),
\ thSAD=200, smooth=0, blksize=16, search=5, searchparam=16, chroma=false, truemotion=true, lambda=4000, pnew=0, overlap=8, dct=8, divide=0),
\ thSAD=0, smooth=0, blksize=16, search=5, searchparam=8, chroma=false, truemotion=true, lambda=8000, pnew=0, overlap=8, dct=8, divide=0)
Global scenechange=MSCDetection(prefiltered, vb1, thSCD1=500, thSCD2=85).Crop(0, 0, 16, 4, align=true)
#Global scenechange=BlankClip(clip, width=16, height=4, color_yuv=0)
transitionwindow=2
transitionlinearity=2
diff=MT_Makediff(MCompensate(prefiltered, superpre, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), prefiltered)
diffsr=MT_Makediff(MCompensate(prefilteredsr, superpresr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), prefiltered)
Global maska=MT_Lutxy(diff, diffsr, yexpr="x 128 - abs y 128 - abs - -1 max 1 min x 128 - abs y 128 - abs - abs " + String(transitionwindow+1) + " min " + String(transitionlinearity) + " ^ * " + String(Pow(transitionwindow+1, transitionlinearity)) + " + " + String(Pow(transitionwindow+1, transitionlinearity)) + " / 128 *")
frame2=MT_Merge(MCompensate(clip, superclip, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(clipsr, superclipsr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
mask2=MT_Lut(MT_Merge(diff, diffsr, maska, u=1, v=1), yexpr="x 128 - 4 * 128 +")
mask2=MT_Lutxy(mask2.MT_Inflate.MT_Inflate.MT_Deflate.MT_Deflate, mask2.MT_Deflate.MT_Deflate.MT_Inflate.MT_Inflate, yexpr="x 128 - abs y 128 - abs - 0.5 + 1 min 0 max y * y 128 - abs x 128 - abs - 0.5 + 1 min 0 max x * +")
both=mask2.MT_Inpand(mode="both")
over=MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, mask2.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
t=MT_Lut(mask2, yexpr="256 x -")
both=t.MT_Inpand(mode="both")
t=MT_Logic(over, MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, t.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), mode="max")
t=MT_Lutxy(t.MT_Inpand(mode="both"), t.MT_Inpand, yexpr="74.9807 x * 181.0193 y * + 256 /")
t=MT_Lutxy(t.MT_Expand(mode="both"), t.MT_Expand, yexpr="74.9807 x * 181.0193 y * + 256 /")
both=t.MT_Expand(mode="both")
t=MT_Lutxy(mask2, MT_Lutxy(both.MT_Expand(mode="both"), MT_Lutxy(both.MT_Expand, t.MT_Expand.MT_Expand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), yexpr="128 x 128 - -0.25 max 0.25 min y 128.125 - 0 max * -")
frame2=MT_Adddiff(frame2, t)
mask2=MT_Adddiff(mask2, MT_Lut(t, yexpr="x 128 - 4 * 128 +"))
diff=MT_Makediff(MCompensate(prefiltered, superpre, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), prefiltered)
diffsr=MT_Makediff(MCompensate(prefilteredsr, superpresr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), prefiltered)
Global maskb=MT_Lutxy(diff, diffsr, yexpr="x 128 - abs y 128 - abs - -1 max 1 min x 128 - abs y 128 - abs - abs " + String(transitionwindow+1) + " min " + String(transitionlinearity) + " ^ * " + String(Pow(transitionwindow+1, transitionlinearity)) + " + " + String(Pow(transitionwindow+1, transitionlinearity)) + " / 128 *")
frame4=MT_Merge(MCompensate(clip, superclip, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(clipsr, superclipsr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
mask4=MT_Lut(MT_Merge(diff, diffsr, maskb, u=1, v=1), yexpr="x 128 - 4 * 128 +")
mask4=MT_Lutxy(mask4.MT_Inflate.MT_Inflate.MT_Deflate.MT_Deflate, mask4.MT_Deflate.MT_Deflate.MT_Inflate.MT_Inflate, yexpr="x 128 - abs y 128 - abs - 0.5 + 1 min 0 max y * y 128 - abs x 128 - abs - 0.5 + 1 min 0 max x * +")
both=mask4.MT_Inpand(mode="both")
over=MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, mask4.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
t=MT_Lut(mask4, yexpr="256 x -")
both=t.MT_Inpand(mode="both")
t=MT_Logic(over, MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, t.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), mode="max")
t=MT_Lutxy(t.MT_Inpand(mode="both"), t.MT_Inpand, yexpr="74.9807 x * 181.0193 y * + 256 /")
t=MT_Lutxy(t.MT_Expand(mode="both"), t.MT_Expand, yexpr="74.9807 x * 181.0193 y * + 256 /")
both=t.MT_Expand(mode="both")
t=MT_Lutxy(mask4, MT_Lutxy(both.MT_Expand(mode="both"), MT_Lutxy(both.MT_Expand, t.MT_Expand.MT_Expand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), yexpr="128 x 128 - -0.25 max 0.25 min y 128.125 - 0 max * -")
frame4=MT_Adddiff(frame4, t)
mask4=MT_Adddiff(mask4, MT_Lut(t, yexpr="x 128 - 4 * 128 +"))
frame2=ConditionalFilter(scenechange.DuplicateFrame(0), frame2, frame4, "YPlaneMax", "=", "0")
frame4=ConditionalFilter(scenechange, frame4, frame2, "YPlaneMax", "=", "0")
mask2=ConditionalFilter(scenechange.DuplicateFrame(0), mask2, mask4, "YPlaneMax", "=", "0")
mask4=ConditionalFilter(scenechange, mask4, mask2, "YPlaneMax", "=", "0")
goodpixel=3
badpixel=6
Global mask2b=MT_Lutxy(mask2, mask4, yexpr=String(Pow((badpixel-goodpixel)*1.25*4, 2)) + " y 128 - abs " + String(goodpixel*4) + " - 0 max " + String(badpixel-goodpixel) + " + 2 ^ - x 128 - abs " + String(goodpixel*4) + " - 0 max * 0.125 - " + String((Pow((badpixel-goodpixel)*1.25*4, 2)-Pow(badpixel-goodpixel, 2))*(badpixel-goodpixel)/64.0) + " /")
Global mask4b=MT_Lutxy(mask4, mask2, yexpr=String(Pow((badpixel-goodpixel)*1.25*4, 2)) + " y 128 - abs " + String(goodpixel*4) + " - 0 max " + String(badpixel-goodpixel) + " + 2 ^ - x 128 - abs " + String(goodpixel*4) + " - 0 max * 0.125 - " + String((Pow((badpixel-goodpixel)*1.25*4, 2)-Pow(badpixel-goodpixel, 2))*(badpixel-goodpixel)/64.0) + " /")
blendstrength1=170
Global mask24=MT_Lutxy(mask2, mask4, yexpr=String((badpixel-goodpixel)*4) + " x 128 - abs y 128 - abs min " + String(goodpixel*4) + " - 0 max - " + String(blendstrength1) + " * " + String((badpixel-goodpixel)*4) + " /")
done=ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(clip, MT_Average(MT_Merge(frame2, frame4, mask2b, u=1, v=1), MT_Merge(frame4, frame2, mask4b, u=1, v=1)), mask24, u=1, v=1), clip, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
blendstrength2=170
#Global mask24=MT_Lutxy(mask2, mask4, yexpr=String((badpixel-goodpixel)*4) + " x 128 - abs y 128 - abs min " + String(goodpixel*4) + " - 0 max - " + String(blendstrength2) + " * " + String((badpixel-goodpixel)*4) + " /")
Return done
}
Function stage1u()
{
usr=StackHorizontal(u.PointResize(4, Height(u)-4, 0, 0, 1, -4), u.Crop(0, 0, -4, -4))
usr=StackVertical(usr.PointResize(Width(usr), 4, 0, 0, -0, 1), usr).Turn180
superclipu=MSuper(u, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superclipusr=MSuper(usr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2u=MT_Merge(MCompensate(u, superclipu, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(usr, superclipusr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
frame4u=MT_Merge(MCompensate(u, superclipu, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(usr, superclipusr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
frame2u=ConditionalFilter(scenechange.DuplicateFrame(0), frame2u, frame4u, "YPlaneMax", "=", "0")
frame4u=ConditionalFilter(scenechange, frame4u, frame2u, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(u, MT_Average(MT_Merge(frame2u, frame4u, mask2b, u=1, v=1), MT_Merge(frame4u, frame2u, mask4b, u=1, v=1)), mask24, u=1, v=1), u, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
Function stage1v()
{
vsr=StackHorizontal(v.PointResize(4, Height(v)-4, 0, 0, 1, -4), v.Crop(0, 0, -4, -4))
vsr=StackVertical(vsr.PointResize(Width(vsr), 4, 0, 0, -0, 1), vsr).Turn180
superclipv=MSuper(v, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superclipvsr=MSuper(vsr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2v=MT_Merge(MCompensate(v, superclipv, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(vsr, superclipvsr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
frame4v=MT_Merge(MCompensate(v, superclipv, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(vsr, superclipvsr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
frame2v=ConditionalFilter(scenechange.DuplicateFrame(0), frame2v, frame4v, "YPlaneMax", "=", "0")
frame4v=ConditionalFilter(scenechange, frame4v, frame2v, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(v, MT_Average(MT_Merge(frame2v, frame4v, mask2b, u=1, v=1), MT_Merge(frame4v, frame2v, mask4b, u=1, v=1)), mask24, u=1, v=1), v, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
ChrisBeringB
19th January 2011, 00:23
Function stage2y()
{
donesr=StackHorizontal(done.PointResize(4, Height(done)-4, 0, 0, 1, -4), done.Crop(0, 0, -4, -4))
donesr=StackVertical(donesr.PointResize(Width(donesr), 4, 0, 0, -0, 1), donesr).Turn180
superdone=MSuper(done, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superdonesr=MSuper(donesr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2=MT_Merge(MCompensate(done, superdone, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(donesr, superdonesr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
mask2=MT_Lutxy(frame2, done, yexpr="x y - 4 * 128 +")
mask2=MT_Lutxy(mask2.MT_Inflate.MT_Deflate, mask2.MT_Deflate.MT_Inflate, yexpr="x 128 - abs y 128 - abs - 0.5 + 1 min 0 max y * y 128 - abs x 128 - abs - 0.5 + 1 min 0 max x * +")
both=mask2.MT_Inpand(mode="both")
over=MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, mask2.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
t=MT_Lut(mask2, yexpr="256 x -")
both=t.MT_Inpand(mode="both")
t=MT_Logic(over, MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, t.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), mode="max")
t=MT_Lutxy(t.MT_Inpand(mode="both"), t.MT_Inpand, yexpr="74.9807 x * 181.0193 y * + 256 /")
t=MT_Lutxy(t.MT_Expand(mode="both"), t.MT_Expand, yexpr="74.9807 x * 181.0193 y * + 256 /")
both=t.MT_Expand(mode="both")
frame2=MT_Adddiff(frame2, MT_Lutxy(mask2, MT_Lutxy(both.MT_Expand(mode="both"), MT_Lutxy(both.MT_Expand, t.MT_Expand.MT_Expand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), yexpr="128 x 128 - -0.25 max 0.25 min y 128.125 - 0 max * -"))
frame4=MT_Merge(MCompensate(done, superdone, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(donesr, superdonesr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
mask4=MT_Lutxy(frame4, done, yexpr="x y - 4 * 128 +")
mask4=MT_Lutxy(mask4.MT_Inflate.MT_Deflate, mask4.MT_Deflate.MT_Inflate, yexpr="x 128 - abs y 128 - abs - 0.5 + 1 min 0 max y * y 128 - abs x 128 - abs - 0.5 + 1 min 0 max x * +")
both=mask4.MT_Inpand(mode="both")
over=MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, mask4.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
t=MT_Lut(mask4, yexpr="256 x -")
both=t.MT_Inpand(mode="both")
t=MT_Logic(over, MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, t.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), mode="max")
t=MT_Lutxy(t.MT_Inpand(mode="both"), t.MT_Inpand, yexpr="74.9807 x * 181.0193 y * + 256 /")
t=MT_Lutxy(t.MT_Expand(mode="both"), t.MT_Expand, yexpr="74.9807 x * 181.0193 y * + 256 /")
both=t.MT_Expand(mode="both")
frame4=MT_Adddiff(frame4, MT_Lutxy(mask4, MT_Lutxy(both.MT_Expand(mode="both"), MT_Lutxy(both.MT_Expand, t.MT_Expand.MT_Expand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), yexpr="128 x 128 - -0.25 max 0.25 min y 128.125 - 0 max * -"))
frame2=ConditionalFilter(scenechange.DuplicateFrame(0), frame2, frame4, "YPlaneMax", "=", "0")
frame4=ConditionalFilter(scenechange, frame4, frame2, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(done, MT_Average(MT_Merge(frame2, frame4, mask2b, u=1, v=1), MT_Merge(frame4, frame2, mask4b, u=1, v=1)), mask24, u=1, v=1), done, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
Function stage2u()
{
doneusr=StackHorizontal(doneu.PointResize(4, Height(doneu)-4, 0, 0, 1, -4), doneu.Crop(0, 0, -4, -4))
doneusr=StackVertical(doneusr.PointResize(Width(doneusr), 4, 0, 0, -0, 1), doneusr).Turn180
superdoneu=MSuper(doneu, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superdoneusr=MSuper(doneusr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2u=MT_Merge(MCompensate(doneu, superdoneu, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(doneusr, superdoneusr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
frame4u=MT_Merge(MCompensate(doneu, superdoneu, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(doneusr, superdoneusr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
frame2u=ConditionalFilter(scenechange.DuplicateFrame(0), frame2u, frame4u, "YPlaneMax", "=", "0")
frame4u=ConditionalFilter(scenechange, frame4u, frame2u, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(doneu, MT_Average(MT_Merge(frame2u, frame4u, mask2b, u=1, v=1), MT_Merge(frame4u, frame2u, mask4b, u=1, v=1)), mask24, u=1, v=1), doneu, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
Function stage2v()
{
donevsr=StackHorizontal(donev.PointResize(4, Height(donev)-4, 0, 0, 1, -4), donev.Crop(0, 0, -4, -4))
donevsr=StackVertical(donevsr.PointResize(Width(donevsr), 4, 0, 0, -0, 1), donevsr).Turn180
superdonev=MSuper(donev, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superdonevsr=MSuper(donevsr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2v=MT_Merge(MCompensate(donev, superdonev, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(donevsr, superdonevsr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
frame4v=MT_Merge(MCompensate(donev, superdonev, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(donevsr, superdonevsr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
frame2v=ConditionalFilter(scenechange.DuplicateFrame(0), frame2v, frame4v, "YPlaneMax", "=", "0")
frame4v=ConditionalFilter(scenechange, frame4v, frame2v, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(donev, MT_Average(MT_Merge(frame2v, frame4v, mask2b, u=1, v=1), MT_Merge(frame4v, frame2v, mask4b, u=1, v=1)), mask24, u=1, v=1), donev, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
Function stage3y()
{
done2sr=StackHorizontal(done2.PointResize(4, Height(done2)-4, 0, 0, 1, -4), done2.Crop(0, 0, -4, -4))
done2sr=StackVertical(done2sr.PointResize(Width(done2sr), 4, 0, 0, -0, 1), done2sr).Turn180
superdone2=MSuper(done2, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superdone2sr=MSuper(done2sr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2=MT_Merge(MCompensate(done2, superdone2, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(done2sr, superdone2sr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
mask2=MT_Lutxy(frame2, done2, yexpr="x y - 4 * 128 +")
both=mask2.MT_Inpand(mode="both")
over=MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, mask2.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
t=MT_Lut(mask2, yexpr="256 x -")
both=t.MT_Inpand(mode="both")
t=MT_Logic(over, MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, t.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), mode="max")
t=MT_Lutxy(t.MT_Inpand(mode="both"), t.MT_Inpand, yexpr="74.9807 x * 181.0193 y * + 256 /")
t=MT_Lutxy(t.MT_Expand(mode="both"), t.MT_Expand, yexpr="74.9807 x * 181.0193 y * + 256 /")
both=t.MT_Expand(mode="both")
frame2=MT_Adddiff(frame2, MT_Lutxy(mask2, MT_Lutxy(both.MT_Expand(mode="both"), MT_Lutxy(both.MT_Expand, t.MT_Expand.MT_Expand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), yexpr="128 x 128 - -0.25 max 0.25 min y 128.125 - 0 max * -"))
frame4=MT_Merge(MCompensate(done2, superdone2, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(done2sr, superdone2sr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
mask4=MT_Lutxy(frame4, done2, yexpr="x y - 4 * 128 +")
both=mask4.MT_Inpand(mode="both")
over=MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, mask4.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /")
t=MT_Lut(mask4, yexpr="256 x -")
both=t.MT_Inpand(mode="both")
t=MT_Logic(over, MT_Lutxy(both.MT_Inpand(mode="both"), MT_Lutxy(both.MT_Inpand, t.MT_Inpand.MT_Inpand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), mode="max")
t=MT_Lutxy(t.MT_Inpand(mode="both"), t.MT_Inpand, yexpr="74.9807 x * 181.0193 y * + 256 /")
t=MT_Lutxy(t.MT_Expand(mode="both"), t.MT_Expand, yexpr="74.9807 x * 181.0193 y * + 256 /")
both=t.MT_Expand(mode="both")
frame4=MT_Adddiff(frame4, MT_Lutxy(mask4, MT_Lutxy(both.MT_Expand(mode="both"), MT_Lutxy(both.MT_Expand, t.MT_Expand.MT_Expand, yexpr="121.5789 x * 134.4211 y * + 256 /"), yexpr="54.0533 x * 201.9467 y * + 256 /"), yexpr="128 x 128 - -0.25 max 0.25 min y 128.125 - 0 max * -"))
frame2=ConditionalFilter(scenechange.DuplicateFrame(0), frame2, frame4, "YPlaneMax", "=", "0")
frame4=ConditionalFilter(scenechange, frame4, frame2, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(done2, MT_Average(MT_Merge(frame2, frame4, mask2b, u=1, v=1), MT_Merge(frame4, frame2, mask4b, u=1, v=1)), mask24, u=1, v=1), done2, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
Function stage3u()
{
done2usr=StackHorizontal(done2u.PointResize(4, Height(done2u)-4, 0, 0, 1, -4), done2u.Crop(0, 0, -4, -4))
done2usr=StackVertical(done2usr.PointResize(Width(done2usr), 4, 0, 0, -0, 1), done2usr).Turn180
superdone2u=MSuper(done2u, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superdone2usr=MSuper(done2usr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2u=MT_Merge(MCompensate(done2u, superdone2u, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(done2usr, superdone2usr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
frame4u=MT_Merge(MCompensate(done2u, superdone2u, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(done2usr, superdone2usr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
frame2u=ConditionalFilter(scenechange.DuplicateFrame(0), frame2u, frame4u, "YPlaneMax", "=", "0")
frame4u=ConditionalFilter(scenechange, frame4u, frame2u, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(done2u, MT_Average(MT_Merge(frame2u, frame4u, mask2b, u=1, v=1), MT_Merge(frame4u, frame2u, mask4b, u=1, v=1)), mask24, u=1, v=1), done2u, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
Function stage3v()
{
done2vsr=StackHorizontal(done2v.PointResize(4, Height(done2v)-4, 0, 0, 1, -4), done2v.Crop(0, 0, -4, -4))
done2vsr=StackVertical(done2vsr.PointResize(Width(done2vsr), 4, 0, 0, -0, 1), done2vsr).Turn180
superdone2v=MSuper(done2v, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
superdone2vsr=MSuper(done2vsr, hpad=16, vpad=16, pel=1, levels=1, chroma=true, sharp=2, rfilter=2)
frame2v=MT_Merge(MCompensate(done2v, superdone2v, vf1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(done2vsr, superdone2vsr, vf1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maska, u=1, v=1)
frame4v=MT_Merge(MCompensate(done2v, superdone2v, vb1, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255), MCompensate(done2vsr, superdone2vsr, vb1sr, thSAD=16383, scbehavior=false, thSCD1=16383, thSCD2=255).Crop(0, 0, -4, -4).Turn180.AddBorders(0, 0, 4, 4), maskb, u=1, v=1)
frame2v=ConditionalFilter(scenechange.DuplicateFrame(0), frame2v, frame4v, "YPlaneMax", "=", "0")
frame4v=ConditionalFilter(scenechange, frame4v, frame2v, "YPlaneMax", "=", "0")
Return ConditionalFilter(scenechange.DuplicateFrame(0), MT_Merge(done2v, MT_Average(MT_Merge(frame2v, frame4v, mask2b, u=1, v=1), MT_Merge(frame4v, frame2v, mask4b, u=1, v=1)), mask24, u=1, v=1), done2v, "YPlaneMax * YPlaneMax(scenechange)", "=", "0")
}
Stephen R. Savage
19th January 2011, 00:49
Your script is slow simply because you're doing too much. One of the most obvious wastes of memory and CPU is calling nnedi3 before everything else. Do things in this order:
1. Deinterlace
2. Denoise
3. Sharpen
4. Upscale
Moreover, I see a whole ton of wasted effort here. Why not just something like this:
MPEG2Source("in.d2v")
QTGMC()
MCTemporalDegrain()
LimitedSharpenFaster()
nnedi3_rpow2(rfactor=2)
Doubles framerate and resolution while denoising and sharpening! In a fraction of the lines!
ChrisBeringB
19th January 2011, 01:04
But doesn't those filters use NNEdi3 for upscaling too?
Didée
19th January 2011, 02:00
You write SUCH a script, and then wonder why it almost explodes?
ChrisBeringB
19th January 2011, 02:11
So, you're saying there's no hope?
I imagined, if I could get memory usage down, I could then optimize speed by making the script adaptive to scene complexity.
Undead Sega
19th January 2011, 04:39
Your script is slow simply because you're doing too much. One of the most obvious wastes of memory and CPU is calling nnedi3 before everything else. Do things in this order:
1. Deinterlace
2. Denoise
3. Sharpen
4. Upscale
Moreover, I see a whole ton of wasted effort here. Why not just something like this:
MPEG2Source("in.d2v")
QTGMC()
MCTemporalDegrain()
LimitedSharpenFaster()
nnedi3_rpow2(rfactor=2)
Doubles framerate and resolution while denoising and sharpening! In a fraction of the lines!
Hahahaaa...I was about to suggest almost the same script :D
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.