[FFmpeg-devel] [PATCH] lavu/eval: add ifzero() and ifnonzero() expression
Stefano Sabatini
stefasab at gmail.com
Mon Jan 16 12:07:57 CET 2012
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-lavu-eval-add-if-and-ifnot-eval-functions.patch
Type: text/x-diff
Size: 3298 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120116/dfa5d2dd/attachment.bin>
More information about the ffmpeg-devel
mailing list