View Single Post
Old 20th September 2009, 17:04   #18  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
tin3tin - Looking at this more closely, I think the overhead is due to the repeated use of StackVertical. For an image height of 576, you have 576 instances of StackVertical, each copying an average of 288 lines, so that's over 150000 lines being copied!

A faster way would be to directly use a resizer as the interpolator instead of the Spline function. Try these alternative versions which should produce similar results to yours (I believe identical in the non-spline case).
Code:
function Gradient2(int gwidth, int gheight, int ared, int agreen, int ablue,
\          int bred, int bgreen, int bblue, int cred, int cgreen, int cblue)
{
  c1 = BlankClip(1, gwidth, 3, color=ared*65536 + agreen*256 + ablue)
  c2 = BlankClip(1, gwidth, 1, color=bred*65536 + bgreen*256 + bblue)
  c3 = BlankClip(1, gwidth, 3, color=cred*65536 + cgreen*256 + cblue)
  StackVertical(c1, c2, c3)
  Spline16Resize(gwidth, gheight, 0, 2.5, 0, -2.5)
}

function GradientNoSpline2(int gwidth, int gheight, int ared, int agreen, int ablue,
\          int bred, int bgreen, int bblue, int cred, int cgreen, int cblue)
{
  c1 = BlankClip(1, gwidth, 2, color=ared*65536 + agreen*256 + ablue)
  c2 = BlankClip(1, gwidth, 1, color=bred*65536 + bgreen*256 + bblue)
  c3 = BlankClip(1, gwidth, 2, color=cred*65536 + cgreen*256 + cblue)
  StackVertical(c1, c2, c3)
  BilinearResize(gwidth, gheight, 0, 1.5, 0, -1.5)
}
Here, GScript is no longer required, but I think it is fair to say that the problem lay not with GScript itself but with the method you used.

(BTW there was another bug in your original code, where 720 was used in place of gwidth in the BlankClips.)
Gavino is offline   Reply With Quote