Log in

View Full Version : Standardizing behaviors for filters


poptones
9th August 2002, 21:34
While developing methods for creating scripts from python for doing more complex NLE, one thing has quickly become apparent to me: much of the efficiency can be lost quickly through layers and layers of filters that do nothing 99% of the time.

Consider this example.

clip1.blur(0,0)

Seems pretty harmless, right? But here's the thing: let's say at some point in the clip we want to make the frame blur. Not a lot, just a couple of frames. Let's say we have Brad Pitt telling us about clowns and snowflakes and we want to flash to a motion blur a couple of times - ok?

Now, we can do that by adding dozens of clips together - ie:

notblurclip + kindablurclip + reallyblurclip + notblurclip + ...

You get the idea. Or we can add animations in the "blur" clips and add'em up like this:

notblurclip + animatedblur + notblurclip + animatedblur + ...

But the way that makes most sense would just be to add the blur right at the start, and then animate it when we need it - right?

So our clip definition looks nice and neat like this:

clip1=AVISource("notasnowflake.avi").blur(0,0)

Followed, when we need it, by

clip1.animate(... etc ...)
clip1.animate(... etc ...)
clip1.animate(... etc ...)

Makes sense, no?

Except now we have that blur() being applied to every single frame whether we need it or not.

Now, blur is one case where zeroes actually count. Last time I looked at the source zeros meant "return clip" and that was about it. But lots of others (layer included) don't.

So what I would like to posit is the establishment of a minimum of expected behaviors. And the first one (with an eye on the future) is to make sure calling a filter that doesn't actually do anything will result in a quick return of that value. For example, layer() can easily be modified to return either the bottom or top layer depending on whether the "amount" is a full 0 or 1. RGBAdjust can quickly return the source clip if all the variables passed to it equal one.

I think this will help us all create more useful and efficient avs macros for our tool boxes. It will also make things a lot easier for newbies, since we could build one "general purpose" avs macro that has all the basic filters and can be invoked from one call. Of course, that also makes it a LOT easier to animate complex changes.

Can anyone think of other things that would increase efficiency under such conditions? Or see any pitfalls I overlooked?

dividee
15th August 2002, 01:02
I agree.
This can be done even more efficiently in the Create function of the filter: it would check for such null-ops and just returns the clip itself (usually args[0]) instead of a filter object. In other terms, it doesn't even insert the filter in the graph.

poptones
15th August 2002, 08:57
Cool. And I had forgotten all about this one.

Might as well link to this (http://mississippi.is.dreaming.org) then...

Keep in mind it's all just notes to myself. If you have anything to add, feel free.