[FFmpeg-devel] [PATCH] lavu/eval: add ifzero() and ifnonzero() expression

Michael Niedermayer michaelni at gmx.at
Mon Jan 16 00:37:35 CET 2012


On Sun, Jan 15, 2012 at 11:08:55PM +0100, Stefano Sabatini wrote:
> They allow to implement the if/then/else logic, which cannot be
> implemented otherwise.
> 
> For example the expression:
> A*B + not(A)*C
> 
> always evaluates to NaN if B is NaN, even in the case where A is 0.
> ---
>  doc/eval.texi    |   19 ++++++++++++-------
>  libavutil/eval.c |    8 ++++++++
>  2 files changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/doc/eval.texi b/doc/eval.texi
> index b325b37..4cc8ec9 100644
> --- a/doc/eval.texi
> +++ b/doc/eval.texi
> @@ -100,6 +100,14 @@ Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and
>  @var{y} are 0 or either or both are less than zero then behavior is undefined.
>  @end table
>  
> + at item ifzero(x, y)
> +Evaluate @var{x}, and if the result is zero return the result of the
> +evaluation of @var{y}, return 0 otherwise.
> +
> + at item ifnonzero(x, y)
> +Evaluate @var{x}, and if the result is non-zero return the result of
> +the evaluation of @var{y}, return 0 otherwise.

i suggest

if(x,y)
Evaluates y when x is non zero
returns the value of y if evaluated otherwise 0

then
if(not(x),y)
would give the other case

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120116/09b81e87/attachment.asc>


More information about the ffmpeg-devel mailing list