Avisynth: Conditional User Defined Functions?
How can I execute conditional user defined functions like:
c = (x==y) ? userdefined1() : userdefined2() where userdefined1 and userdefined2 results, are clips of not equal resolution. |
The direct way :
Code:
u1=userdefined1() Code:
u = (x==y) ? "userdefined1()" : "userdefined2()" |
Maybe what you want is something like this :?:
x==y ? c=userdefined1() : c=userdefined2() -kwag |
And if the "then" way will "do nothing" I remember still this was
x==y ? c=userdefined1() : NOP |
Let's go for an other wzy to do all that :
Code:
(x==y) ? userdefined1() : userdefined2() |
Quote:
Either userdefined1() or userdefined2() will ALWAYS evaluate, so "c" will always have the value of the true or false condition. So c=last is redundant, because it's already assigned once in either userdefined1() or in userdefined2() ;) But then, we can get really obfuscated here, don't we :lol: -kwag |
Re: Conditional User Defined Functions
As I can see
Quote:
Quote:
Quote:
In Dialhot example, he asign the userdefined functions 1 an 2 to two variables and later (translation) wright the conditional statement same like mine one. In Kwag example, he define his condition and later asign the results at c. It is like say "If x = y, then c=udf1, if not c=udf2", and my way, "c=udf1 if x = y,c=udf2 if not". But what is the correct way? or all are the right ones? |
Re: Conditional User Defined Functions
Quote:
The statement: c = (x==y) ? u1 : u2 assigns true or false ( 1 or 0 ) to c, depending on the value of x and y. The statement: x==y ? c=userdefined1() : c=userdefined2() assigns the correct value, depending on the condition that evaluates to true or false. -kwag |
Ohh!, I understand, thank you, Kwag.
And thanks to all. Another question: When I use the NOP statement, the script will continue beyond the conditional evaluation: For example: x==y ? c=userdefined1() : NOP bicubicresize()... In this case, resize will be applied whatever would be the condition? (I hope you understand my english!!!) |
Quote:
:arrow: == (comparison) is not the same as :arrow: = (assignment) ;) -kwag |
Sorry, I had edit my previous post and you don't saw the last question.
|
Re: Conditional User Defined Functions
Quote:
Actually this statement set c to u1 is the condition is true, u2 if not. And actually u1 is equal to the result of userdefined1 and u2 the result of userdefined2. So that is EXACTLY what wee need to have. Quote:
So it's more efficient (as I told in my first post !) :arrow: but it will work only if avisynth grammar accepts non constant lvalues with ":" operator :!: Avisynth is not C language. |
removed stupid question
|
Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.