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
961d6493
Commit
961d6493
authored
Oct 11, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil/eval: add sgn()
parent
72704cbf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
utils.texi
doc/utils.texi
+3
-0
eval.c
libavutil/eval.c
+4
-0
No files found.
doc/utils.texi
View file @
961d6493
...
...
@@ -920,6 +920,9 @@ corresponding input value will be returned.
@item round(expr)
Round the value of expression @var{expr} to the nearest integer. For example, "round(1.5)" is "2.0".
@item sgn(x)
Compute sign of @var{x}.
@item sin(x)
Compute sine of @var{x}.
...
...
libavutil/eval.c
View file @
961d6493
...
...
@@ -163,6 +163,7 @@ struct AVExpr {
e_last
,
e_st
,
e_while
,
e_taylor
,
e_root
,
e_floor
,
e_ceil
,
e_trunc
,
e_round
,
e_sqrt
,
e_not
,
e_random
,
e_hypot
,
e_gcd
,
e_if
,
e_ifnot
,
e_print
,
e_bitand
,
e_bitor
,
e_between
,
e_clip
,
e_atan2
,
e_lerp
,
e_sgn
,
}
type
;
double
value
;
// is sign in other types
union
{
...
...
@@ -197,6 +198,7 @@ static double eval_expr(Parser *p, AVExpr *e)
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_round
:
return
e
->
value
*
round
(
eval_expr
(
p
,
e
->
param
[
0
]));
case
e_sgn
:
return
e
->
value
*
FFDIFFSIGN
(
eval_expr
(
p
,
e
->
param
[
0
]),
0
);
case
e_sqrt
:
return
e
->
value
*
sqrt
(
eval_expr
(
p
,
e
->
param
[
0
]));
case
e_not
:
return
e
->
value
*
(
eval_expr
(
p
,
e
->
param
[
0
])
==
0
);
case
e_if
:
return
e
->
value
*
(
eval_expr
(
p
,
e
->
param
[
0
])
?
eval_expr
(
p
,
e
->
param
[
1
])
:
...
...
@@ -470,6 +472,7 @@ static int parse_primary(AVExpr **e, Parser *p)
else
if
(
strmatch
(
next
,
"clip"
))
d
->
type
=
e_clip
;
else
if
(
strmatch
(
next
,
"atan2"
))
d
->
type
=
e_atan2
;
else
if
(
strmatch
(
next
,
"lerp"
))
d
->
type
=
e_lerp
;
else
if
(
strmatch
(
next
,
"sgn"
))
d
->
type
=
e_sgn
;
else
{
for
(
i
=
0
;
p
->
func1_names
&&
p
->
func1_names
[
i
];
i
++
)
{
if
(
strmatch
(
next
,
p
->
func1_names
[
i
]))
{
...
...
@@ -657,6 +660,7 @@ static int verify_expr(AVExpr *e)
case
e_sqrt
:
case
e_not
:
case
e_random
:
case
e_sgn
:
return
verify_expr
(
e
->
param
[
0
])
&&
!
e
->
param
[
1
];
case
e_print
:
return
verify_expr
(
e
->
param
[
0
])
...
...
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