mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
eval: Add the isinf() function and tests for it
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
25accf93ad
commit
143f1e9203
@ -34,6 +34,8 @@ The following functions are available:
|
|||||||
@item abs(x)
|
@item abs(x)
|
||||||
@item squish(x)
|
@item squish(x)
|
||||||
@item gauss(x)
|
@item gauss(x)
|
||||||
|
@item isinf(x)
|
||||||
|
Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise.
|
||||||
@item isnan(x)
|
@item isnan(x)
|
||||||
Return 1.0 if @var{x} is NAN, 0.0 otherwise.
|
Return 1.0 if @var{x} is NAN, 0.0 otherwise.
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@
|
|||||||
|
|
||||||
#define LIBAVUTIL_VERSION_MAJOR 51
|
#define LIBAVUTIL_VERSION_MAJOR 51
|
||||||
#define LIBAVUTIL_VERSION_MINOR 34
|
#define LIBAVUTIL_VERSION_MINOR 34
|
||||||
#define LIBAVUTIL_VERSION_MICRO 0
|
#define LIBAVUTIL_VERSION_MICRO 1
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||||
LIBAVUTIL_VERSION_MINOR, \
|
LIBAVUTIL_VERSION_MINOR, \
|
||||||
|
@ -120,7 +120,7 @@ static int strmatch(const char *s, const char *prefix)
|
|||||||
struct AVExpr {
|
struct AVExpr {
|
||||||
enum {
|
enum {
|
||||||
e_value, e_const, e_func0, e_func1, e_func2,
|
e_value, e_const, e_func0, e_func1, e_func2,
|
||||||
e_squish, e_gauss, e_ld, e_isnan,
|
e_squish, e_gauss, e_ld, e_isnan, e_isinf,
|
||||||
e_mod, e_max, e_min, e_eq, e_gt, e_gte,
|
e_mod, e_max, e_min, e_eq, e_gt, e_gte,
|
||||||
e_pow, e_mul, e_div, e_add,
|
e_pow, e_mul, e_div, e_add,
|
||||||
e_last, e_st, e_while, e_floor, e_ceil, e_trunc,
|
e_last, e_st, e_while, e_floor, e_ceil, e_trunc,
|
||||||
@ -148,6 +148,7 @@ static double eval_expr(Parser *p, AVExpr *e)
|
|||||||
case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); }
|
case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); }
|
||||||
case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)];
|
case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)];
|
||||||
case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0]));
|
case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0]));
|
||||||
|
case e_isinf: return e->value * !!isinf(eval_expr(p, e->param[0]));
|
||||||
case e_floor: return e->value * floor(eval_expr(p, e->param[0]));
|
case e_floor: return e->value * floor(eval_expr(p, e->param[0]));
|
||||||
case e_ceil : return e->value * ceil (eval_expr(p, e->param[0]));
|
case e_ceil : return e->value * ceil (eval_expr(p, e->param[0]));
|
||||||
case e_trunc: return e->value * trunc(eval_expr(p, e->param[0]));
|
case e_trunc: return e->value * trunc(eval_expr(p, e->param[0]));
|
||||||
@ -282,6 +283,7 @@ static int parse_primary(AVExpr **e, Parser *p)
|
|||||||
else if (strmatch(next, "lt" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gte; }
|
else if (strmatch(next, "lt" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gte; }
|
||||||
else if (strmatch(next, "ld" )) d->type = e_ld;
|
else if (strmatch(next, "ld" )) d->type = e_ld;
|
||||||
else if (strmatch(next, "isnan" )) d->type = e_isnan;
|
else if (strmatch(next, "isnan" )) d->type = e_isnan;
|
||||||
|
else if (strmatch(next, "isinf" )) d->type = e_isinf;
|
||||||
else if (strmatch(next, "st" )) d->type = e_st;
|
else if (strmatch(next, "st" )) d->type = e_st;
|
||||||
else if (strmatch(next, "while" )) d->type = e_while;
|
else if (strmatch(next, "while" )) d->type = e_while;
|
||||||
else if (strmatch(next, "floor" )) d->type = e_floor;
|
else if (strmatch(next, "floor" )) d->type = e_floor;
|
||||||
@ -453,6 +455,7 @@ static int verify_expr(AVExpr *e)
|
|||||||
case e_ld:
|
case e_ld:
|
||||||
case e_gauss:
|
case e_gauss:
|
||||||
case e_isnan:
|
case e_isnan:
|
||||||
|
case e_isinf:
|
||||||
case e_floor:
|
case e_floor:
|
||||||
case e_ceil:
|
case e_ceil:
|
||||||
case e_trunc:
|
case e_trunc:
|
||||||
@ -601,6 +604,10 @@ int main(int argc, char **argv)
|
|||||||
"st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))",
|
"st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))",
|
||||||
"isnan(1)",
|
"isnan(1)",
|
||||||
"isnan(NAN)",
|
"isnan(NAN)",
|
||||||
|
"isnan(INF)",
|
||||||
|
"isinf(1)",
|
||||||
|
"isinf(NAN)",
|
||||||
|
"isinf(INF)",
|
||||||
"floor(NAN)",
|
"floor(NAN)",
|
||||||
"floor(123.123)",
|
"floor(123.123)",
|
||||||
"floor(-123.123)",
|
"floor(-123.123)",
|
||||||
|
@ -112,6 +112,18 @@ Evaluating 'isnan(1)'
|
|||||||
Evaluating 'isnan(NAN)'
|
Evaluating 'isnan(NAN)'
|
||||||
'isnan(NAN)' -> 1.000000
|
'isnan(NAN)' -> 1.000000
|
||||||
|
|
||||||
|
Evaluating 'isnan(INF)'
|
||||||
|
'isnan(INF)' -> 0.000000
|
||||||
|
|
||||||
|
Evaluating 'isinf(1)'
|
||||||
|
'isinf(1)' -> 0.000000
|
||||||
|
|
||||||
|
Evaluating 'isinf(NAN)'
|
||||||
|
'isinf(NAN)' -> 0.000000
|
||||||
|
|
||||||
|
Evaluating 'isinf(INF)'
|
||||||
|
'isinf(INF)' -> 1.000000
|
||||||
|
|
||||||
Evaluating 'floor(NAN)'
|
Evaluating 'floor(NAN)'
|
||||||
'floor(NAN)' -> nan
|
'floor(NAN)' -> nan
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user