[FFmpeg-devel] [PATCH] lavu/eval: add clip function
Stefano Sabatini
stefasab at gmail.com
Thu Jul 17 13:28:10 CEST 2014
On date Monday 2014-07-07 20:58:50 +0200, Michael Niedermayer encoded:
> On Fri, Jul 04, 2014 at 04:40:50PM +0200, Stefano Sabatini wrote:
[...]
> > Subject: [PATCH] lavu/eval: add clip function
> >
> > TODO: bump micro
> > ---
> > doc/utils.texi | 3 +++
> > libavutil/eval.c | 14 +++++++++++++-
> > tests/ref/fate/eval | 9 +++++++++
> > 3 files changed, 25 insertions(+), 1 deletion(-)
> >
> > diff --git a/doc/utils.texi b/doc/utils.texi
> > index 5abfb0c..b92691f 100644
> > --- a/doc/utils.texi
> > +++ b/doc/utils.texi
> > @@ -782,6 +782,9 @@ large numbers (usually 2^53 and larger).
> > Round the value of expression @var{expr} upwards to the nearest
> > integer. For example, "ceil(1.5)" is "2.0".
> >
> > + at item clip(x, min, max)
> > +Return the value of @var{x} clipped between @var{min} and @var{max}.
> > +
> > @item cos(x)
> > Compute cosine of @var{x}.
> >
> > diff --git a/libavutil/eval.c b/libavutil/eval.c
> > index 4a313bf..1c53b79 100644
> > --- a/libavutil/eval.c
> > +++ b/libavutil/eval.c
> > @@ -147,7 +147,7 @@ struct AVExpr {
> > e_pow, e_mul, e_div, e_add,
> > e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc,
> > e_sqrt, e_not, e_random, e_hypot, e_gcd,
> > - e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between,
> > + e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip
> > } type;
> > double value; // is sign in other types
> > union {
> > @@ -187,6 +187,13 @@ static double eval_expr(Parser *p, AVExpr *e)
> > e->param[2] ? eval_expr(p, e->param[2]) : 0);
> > case e_ifnot: return e->value * (!eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) :
> > e->param[2] ? eval_expr(p, e->param[2]) : 0);
> > + case e_clip: {
> > + double x = eval_expr(p, e->param[0]);
> > + double min = eval_expr(p, e->param[1]), max = eval_expr(p, e->param[2]);
> > + if (isnan(min) || isnan(max) || isnan(x) || min > max)
> > + return NAN;
>
> > + return e->value * av_clip(eval_expr(p, e->param[0]), min, max);
>
> this should be av_clipd()
>
> should be ok otherwise
Applied, thanks.
--
FFmpeg = Frenzy & Fantastic Meaningful Plastic Ephemeral Game
More information about the ffmpeg-devel
mailing list