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

Michael Niedermayer michaelni at gmx.at
Mon Jan 16 17:27:13 CET 2012


On Mon, Jan 16, 2012 at 12:07:57PM +0100, Stefano Sabatini wrote:
> On date Monday 2012-01-16 00:37:35 +0100, Michael Niedermayer encoded:
> > 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
> 
> Works for me, I'm keeping ifnot() since it slightly simplifies syntax
> (if(not(x),y) -> ifnot(x,y)).
> -- 
> FFmpeg = Fiendish and Faithful MultiPurpose Encoding/decoding Glue

>  doc/eval.texi    |   12 ++++++++++--
>  libavutil/eval.c |    8 ++++++++
>  2 files changed, 18 insertions(+), 2 deletions(-)
> 9c594bd012e0ecf60163403f617c774932528980  0003-lavu-eval-add-if-and-ifnot-eval-functions.patch
> From 85c2bcc557953516c09b9aead8eb9141a3d693f5 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Sun, 15 Jan 2012 22:59:42 +0100
> Subject: [PATCH] lavu/eval: add if() and ifnot() eval functions

ok with me

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- 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/8ff47b0c/attachment.asc>


More information about the ffmpeg-devel mailing list