Log in

View Full Version : Optimalize script


koszopal
11th February 2004, 15:53
hi
here's my script
Problem is that this script witch i'm opening in VDM crashed every time when i wanna save seq. od images :(( in task manager (windows2000sp4 prof) i just see how VDM eating all memory (real 1GB) and then eating all pagefile memory (1GB) after that is crash :((
how to optimize this script to not crash ?
koszopal
...............
#
# http://gknot.doom9.org
#
# PLUGINS
LoadPlugin("D:\movie\Gordian Knot28.6\mpeg2dec3.dll")
#LoadPlugin("D:\movie\Gordian Knot28.6\WarpSharp.dll")
LoadPlugin("D:\movie\Gordian Knot28.6\Deen.dll")
#LoadPlugin("D:\movie\Gordian Knot28.6\undot.dll")
LoadPlugin("D:\movie\Gordian Knot28.6\unfilter.dll")
#LoadPlugin("D:\movie\Gordian Knot28.6\decomb.dll")
#LoadPlugin("D:\movie\Gordian Knot28.6\KernelDeInt.dll")
#LoadPlugin("D:\movie\Gordian Knot28.6\dgbob.dll")
LoadPlugin("D:\movie\Gordian Knot28.6\Convolution3d.dll")
#LoadPlugin("D:\movie\Gordian Knot28.6\FluxSmooth.dll")
LoadPlugin("D:\movie\Gordian Knot28.6\Msmooth.dll")
#Import("SharpTools-v0.3.avs")
# SOURCE
clip1=mpeg2source("D:\movie\movie\emma\emma_dvd2avi.d2v")
# sample
movie = clip1.Trim(29914,-1)+clip1.Trim(32525,-1)+ clip1.Trim(35412,-1) + clip1.Trim(37032,-1) + clip1.Trim(37828,-1) + clip1.Trim(76985,-1) + clip1.Trim(79893,-1)
clip1 = movie.Trim(0,-1)
#scena 1
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)


filtr1=filtruj(clip1)

clip1 = movie.Trim(1,-1)
#scena 2
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)

filtr = filtr1

filtr1=filtruj(clip1)

clip1 = movie.Trim(2,-1) # clip.Trim(35412,-1) + clip.Trim(37032,-1) + clip.Trim(37828,-1) + clip.Trim(76985,-1) + clip.Trim(79893,-1)
#scena 3
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)

filtr1=filtruj(clip1)

filtr = filtr + filtr1

clip1 = movie.Trim(3,-1) #+ clip.Trim(37032,-1) + clip.Trim(37828,-1) + clip.Trim(76985,-1) + clip.Trim(79893,-1)
#scena 4
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)

filtr1=filtruj(clip1)

filtr = filtr + filtr1
clip1 = movie.Trim(4,-1) #+ clip.Trim(37828,-1) + clip.Trim(76985,-1) + clip.Trim(79893,-1)
#scena 5
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)

filtr1=filtruj(clip1)

filtr = filtr + filtr1
clip1 = movie.Trim(5,-1) #+ clip.Trim(76985,-1) + clip.Trim(79893,-1)
#scena 6
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)

filtr1=filtruj(clip1)

filtr = filtr + filtr1
clip1 = movie.Trim(6,-1) #+ clip.Trim(79893,-1)
#scena 7
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)

filtr1=filtruj(clip1)

filtr = filtr + filtr1
clip1 = movie.Trim(7,-1)
#scena 8
clip1.crop(4,12,708,560)
clip1.LanczosResize(640,352)

filtr1=filtruj(clip1)

filtr = filtr + filtr1


return filtr.LanczosResize(640,352)


Function filtruj(Clip clip){
DoDeen(clip,"c3d",0,2,10) ++ \
DoDeen(clip,"c3d",0,4,10) ++ \
DoDeen(clip,"c3d",0,6,10) ++ \
DoDeen(clip,"c3d",0,8,10) ++ \
DoDeen(clip,"c3d",0,12,15) ++ \
DoDeen(clip,"c3d",0,15,20) ++ \
DoDeen(clip,"a3d",1,2,10) ++ \
DoDeen(clip,"a3d",1,4,10) ++ \
DoDeen(clip,"a3d",1,6,10) ++ \
DoDeen(clip,"a3d",1,8,10) ++ \
DoDeen(clip,"a3d",1,10,12) ++ \
DoDeen(clip,"a3d",1,12,15) ++ \
DoDeen(clip,"a3d",1,15,20) ++ \
DoConv(clip,0,1,2,1,2,2.8,0) ++ \
DoConv(clip,0,2,4,2,3,2.8,0) ++ \
DoConv(clip,0,3,4,3,4,2.8,0) ++ \
DoConv(clip,0,4,6,4,6,2.8,0) ++ \
DoConv(clip,0,5,8,4,6,2.8,0) ++ \
DoConv(clip,0,6,10,6,8,2.8,0) ++ \
DoConv(clip,0,6,12,6,8,2.8,0) ++ \
DoUnFilter(clip,-1) ++ \
DoUnFilter(clip,-2) ++ \
DoUnFilter(clip,-3) ++ \
DoUnFilter(clip,-4) ++ \
DoUnFilter(clip,-5) ++ \
DoUnFilter(clip,-7) ++ \
DoUnFilter(clip,-10) ++ \
DoMsmooth(clip,5,1) ++ \
DoMsmooth(clip,10,1) ++ \
DoMsmooth(clip,15,1) ++ \
DoMsmooth(clip,20,1) ++ \
DoMsmooth(clip,30,1) ++ \
DoMsmooth(clip,40,1) ++ \
DoMsmooth(clip,50,1) ++ \
DoMsmooth(clip,5,2) ++ \
DoMsmooth(clip,10,2) ++ \
DoMsmooth(clip,15,2) ++ \
DoMsmooth(clip,20,2) ++ \
DoMsmooth(clip,30,2) ++ \
DoMsmooth(clip,40,2) ++ \
DoMsmooth(clip,50,2) ++ \
DoMsmooth(clip,5,3) ++ \
DoMsmooth(clip,10,3) ++ \
DoMsmooth(clip,15,3) ++ \
DoMsmooth(clip,20,3) ++ \
DoMsmooth(clip,30,3) ++ \
DoMsmooth(clip,40,3) ++ \
DoMsmooth(clip,50,3) ++ \
DoMsmooth(clip,10,1) ++ \
DoMsmooth(clip,10,2) ++ \
DoMsmooth(clip,10,3) ++ \
DoMsmooth(clip,10,4) ++ \
DoMsmooth(clip,10,5) ++ \
DoMsmooth(clip,10,6) ++ \
DoMsmooth(clip,10,7)
}



Function DoDeen(Clip Clip,String jaki,Float z,Float x,Float y) {
Return Clip.Deen(jaki,z,x,y).Subtitle("Deen("+jaki+"),"+String(z)+"," + String(x)+","+String(y)+")")
}

Function DoConv(Clip Clip,Float a,Float b,Float c,Float d,Float e,Float f,Float g) {
Return Clip.Convolution3D(a,b,c,d,e,f,g).Subtitle("Convolution3D("+String(a)+"," +String(b)+","+String(c)+","+String(d)+"," + String(e)+","+String(f)+","+String(g)+")")

}

Function DoUnFilter(Clip Clip,Int a) {
Return Clip.UnFilter(a,a).Subtitle("UnFilter("+String(a)+"," + String(a)+")")
}

Function DoMsmooth(Clip Clip,Int a,Int b) {
Return Clip.MSmooth(threshold=a,strength=b,debug=true).Subtitle("MSmooth(threshold="+String(a)+",strength=" + String(b)+",debug=true)")
}
...........

Soulhunter
11th February 2004, 20:12
... :eek:

koszopal
12th February 2004, 07:37
...
hehe what it's means ?
Any help ?
koszopal

Bidoche
12th February 2004, 10:09
You are using filters who use lots of memory.
The only way seems to decompose your filter chain in smaller parts and run them one at once.

Or to modify the filter code so they fold the buffers they allocate, but it may be not possible.

koszopal
12th February 2004, 11:30
@Bidoche
first option i know :) but for 2nd what u mean ? where could i start ?
koszopal

Bidoche
12th February 2004, 18:55
By filters folding their buffers, I mean that multiple instances (of the same filter) attempt to share them, thus saving memory.

It's not that easy to do, and it requires threading (or it will break when filters come from differents scripts running at once and try to use the buffers at the very same time).

And it's only possible if the buffers are not used to maintain data between frames.

FuPP
12th February 2004, 23:35
old versions of deen and fluxsmooth are known to eat memory. Use latest fluxsmooth modified by shodan and latest deen by Marcfd (search button...)

For other filters, I don't know.

Regards,
FuPP