Log in

View Full Version : possible Overlay() optimisation?


Mug Funky
27th September 2006, 09:46
hi all.

i'm using this script to make scrolling credits:
function credits (clip c, string image, int inframe, int outframe)
{
global cr_c = c
global cr_image40 = imagesource(image,end=0).converttorgb32()
global cr_image31 = cr_image40.generalconvolution(matrix="0 0 0 0 3 0 0 1 0")
global cr_image22 = cr_image40.generalconvolution(matrix="0 0 0 0 2 0 0 2 0")
global cr_image13 = cr_image40.generalconvolution(matrix="0 0 0 0 1 0 0 3 0")

global cr_flat = cr_image40.blankclip(color=$ffffff)

global cr_in = inframe
global cr_out = outframe

cr_evaluate1 = c.scriptclip(""" overlay(cr_c,cr_flat,mask=cr_image,y=int(off_y) ) """)
cr_evaluate2 = frameevaluate(cr_evaluate1,""" global cr_image = 4-(4*(off_y-int(off_y)))+.5 < 1 ? cr_image40 :
\ 4-(4*(off_y-int(off_y)))+.5 < 2 ? cr_image31 :
\ 4-(4*(off_y-int(off_y)))+.5 < 3 ? cr_image22 : cr_image13""")
frameevaluate(cr_evaluate2,""" off_y = (576 + cr_in*(cr_image40.height/float(cr_out - cr_in)))
\ - current_frame*(cr_image40.height/float(cr_out - cr_in)) """)
}

and it's kinda slow.

i'm loading a very large .png file, and this script is scrolling it up according to the in and out points.

the only problem is it's very slow. i'm guessing that overlay is rendering all 13858 lines of my png every frame.

is it possible for overlay to be modified so it only works with what's inside the frame size of the input clip?

Didée
27th September 2006, 10:15
Why aren't you using Animate() + Resize(crop-only) ?

Mug Funky
27th September 2006, 11:13
aah. i could probably do that. that'll give more subpel accuracy as well (provided i use latest avisynth).

looks like it's back to the old drawing board :)

however, is it possible for the cropresize stuff to go entirely off the screen (ie. not just repeat the edge pixels)? that can be desirable sometimes.

sh0dan
27th September 2006, 18:03
Well - overlay converts the image to yv24 before it applies clipping, but it will only convert the mask, if any part of the image is visible.

Convert your images to YV12. The YV12 -> YV24 is much faster - especially for the mask.

If you need to maintain chroma, use v2.6, as you can use YV24 natively.