Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
77f60f00
Commit
77f60f00
authored
Mar 22, 2013
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavu/eval: add between() function.
parent
ac9b056d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
eval.texi
doc/eval.texi
+4
-0
eval.c
libavutil/eval.c
+14
-1
version.h
libavutil/version.h
+1
-1
eval
tests/ref/fate/eval
+9
-0
No files found.
doc/eval.texi
View file @
77f60f00
...
...
@@ -32,6 +32,10 @@ Compute arcsine of @var{x}.
@item atan(x)
Compute arctangent of @var{x}.
@item between(x, min, max)
Return 1 if @var{x} is greater than or equal to @var{min} and lesser than or
equal to @var{max}, 0 otherwise.
@item bitand(x, y)
@item bitor(x, y)
Compute bitwise and/or operation on @var{x} and @var{y}.
...
...
libavutil/eval.c
View file @
77f60f00
...
...
@@ -145,7 +145,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_if
,
e_ifnot
,
e_print
,
e_bitand
,
e_bitor
,
e_between
,
}
type
;
double
value
;
// is sign in other types
union
{
...
...
@@ -185,6 +185,11 @@ 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_between
:
{
double
d
=
eval_expr
(
p
,
e
->
param
[
0
]);
return
e
->
value
*
(
d
>=
eval_expr
(
p
,
e
->
param
[
1
])
&&
d
<=
eval_expr
(
p
,
e
->
param
[
2
]));
}
case
e_print
:
{
double
x
=
eval_expr
(
p
,
e
->
param
[
0
]);
int
level
=
e
->
param
[
1
]
?
av_clip
(
eval_expr
(
p
,
e
->
param
[
1
]),
INT_MIN
,
INT_MAX
)
:
AV_LOG_INFO
;
...
...
@@ -428,6 +433,7 @@ static int parse_primary(AVExpr **e, Parser *p)
else
if
(
strmatch
(
next
,
"ifnot"
))
d
->
type
=
e_ifnot
;
else
if
(
strmatch
(
next
,
"bitand"
))
d
->
type
=
e_bitand
;
else
if
(
strmatch
(
next
,
"bitor"
))
d
->
type
=
e_bitor
;
else
if
(
strmatch
(
next
,
"between"
))
d
->
type
=
e_between
;
else
{
for
(
i
=
0
;
p
->
func1_names
&&
p
->
func1_names
[
i
];
i
++
)
{
if
(
strmatch
(
next
,
p
->
func1_names
[
i
]))
{
...
...
@@ -623,6 +629,10 @@ static int verify_expr(AVExpr *e)
case
e_taylor
:
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
])
&&
(
!
e
->
param
[
2
]
||
verify_expr
(
e
->
param
[
2
]));
case
e_between
:
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
])
&&
verify_expr
(
e
->
param
[
2
]);
default:
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
])
&&
!
e
->
param
[
2
];
}
}
...
...
@@ -816,6 +826,9 @@ int main(int argc, char **argv)
"bitor(42, 12)"
,
"bitand(42, 12)"
,
"bitand(NAN, 1)"
,
"between(10, -3, 10)"
,
"between(-4, -2, -1)"
,
"between(1,2)"
,
NULL
};
...
...
libavutil/version.h
View file @
77f60f00
...
...
@@ -76,7 +76,7 @@
#define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 22
#define LIBAVUTIL_VERSION_MICRO 10
0
#define LIBAVUTIL_VERSION_MICRO 10
1
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
...
...
tests/ref/fate/eval
View file @
77f60f00
...
...
@@ -259,5 +259,14 @@ Evaluating 'bitand(42, 12)'
Evaluating 'bitand(NAN, 1)'
'bitand(NAN, 1)' -> nan
Evaluating 'between(10, -3, 10)'
'between(10, -3, 10)' -> 1.000000
Evaluating 'between(-4, -2, -1)'
'between(-4, -2, -1)' -> 0.000000
Evaluating 'between(1,2)'
'between(1,2)' -> nan
12.700000 == 12.7
0.931323 == 0.931322575
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment