PDA

View Full Version : using filter under conditional argument ( if <condition> then use this_filter


esby
28th December 2002, 03:38
I am wondering if this kind of scripting is possible in avs.
I have seen there is an ? identifier that can do the if
but i am wondering if there can be 'filters' (or dll)
that could return a boolean depending of the condition on the frame parsed.

eg : we know that picfix can have a problem with scene change,
introducing color ghosting ( in the best case) and bad macro blocks (in the common case).

if we could have something like that...

!IsSceneChange(clip) ? source = source.antiblink(...)

this function could desactivate the antiblink when it will create trash...


esby

Richard Berg
29th December 2002, 10:49
This sort of thing will require a major overhaul of the scripting language, but believe me such ideas are very much on my mind for the future (v3.0+, I should say, before I scare sh0dan too much ;)). Heck, just reading Ben's website the other day, I was reminded that even the nonlinear scripting we take for granted was a new (and incompatible) thing not too long ago.

AVISource "video.avi"
dup
Trim 2000,2500
swap
dup
Trim 3000,3500
swap
Trim 1000,1500
AlignedSplice
AlignedSplice

-- vs. --

AVISource("video.avi")
Trim(2000,2500) ++ Trim(3000,3500) ++ Trim(1000,1500)

:eek:

esby
29th December 2002, 14:07
I suppose the "Dup - Swap" code is quite old
(at least i hope to have figured out the example correctly),
Cause as far i remember using avisynth i never used these function.
One reason that make me thinking that too is the missing parenthesis.

To be serious, i don't think this kind of structure could be a big problem to code, i have been thinking about it.

What we need is :

Filters that returns a new structure( array of boolean ) made of boolean values for the clip(true=use the filter, false=dont use)

A new kind of function acting like a macro trim() ,
attached to this new structure,
applying or not the filter(clip) passed in parameter,
depending of the boolean value of the frame.

This could give something like that as syntax:

macroTrim( condition(source) , filter(source) )

condition(source) returning the array of boolean.
filter(source) being any filter you might want to use or not on the source.


Of course we could use optionnal syntax like :

condition(source).macroTrim( filter(source) )


but maybe i'm going to far in the future :devil: ...

esby

dividee
29th December 2002, 20:53
It might already be possible, as a function can already return an array, with this amended syntax (and renaming macroTrim to If :) )If(condition(source),filter(source),source)But there is one big problem: the whole array would need to be evaluated before frameserving can start and it might take a while...

Maybe better:If("condition",source,filter(source))In a way similar to Animate, the If filter would evaluate the condition for each frame. The condition function would return a single bool, and take as argument the source clip (second argument of If) and the frame number. The syntax could be extended to allow for condition functions with more parameters.

WarpEnterprises
29th December 2002, 22:23
Is this functionally more than playing with Layer to switch between two clips?
(Of course it would not calc both layers)

The way dividee described it would indeed be a big jump forward...