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
e5272e72
Commit
e5272e72
authored
May 03, 2011
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eval: add sqrt function for computing the square root
parent
5d2ce3a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
eval.texi
doc/eval.texi
+4
-0
avutil.h
libavutil/avutil.h
+1
-1
eval.c
libavutil/eval.c
+6
-0
No files found.
doc/eval.texi
View file @
e5272e72
...
...
@@ -72,6 +72,10 @@ integer. For example, "floor(-1.5)" is "-2.0".
@item trunc(expr)
Round the value of expression @var{expr} towards zero to the nearest
integer. For example, "trunc(-1.5)" is "-1.0".
@item sqrt(expr)
Compute the square root of @var{expr}. This is equivalent to
"(@var{expr})^.5".
@end table
Note that:
...
...
libavutil/avutil.h
View file @
e5272e72
...
...
@@ -41,7 +41,7 @@
#define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 2
#define LIBAVUTIL_VERSION_MICRO
0
#define LIBAVUTIL_VERSION_MICRO
1
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
...
...
libavutil/eval.c
View file @
e5272e72
...
...
@@ -122,6 +122,7 @@ struct AVExpr {
e_mod
,
e_max
,
e_min
,
e_eq
,
e_gt
,
e_gte
,
e_pow
,
e_mul
,
e_div
,
e_add
,
e_last
,
e_st
,
e_while
,
e_floor
,
e_ceil
,
e_trunc
,
e_sqrt
,
}
type
;
double
value
;
// is sign in other types
union
{
...
...
@@ -148,6 +149,7 @@ static double eval_expr(Parser *p, AVExpr *e)
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_trunc
:
return
e
->
value
*
trunc
(
eval_expr
(
p
,
e
->
param
[
0
]));
case
e_sqrt
:
return
e
->
value
*
sqrt
(
eval_expr
(
p
,
e
->
param
[
0
]));
case
e_while
:
{
double
d
=
NAN
;
while
(
eval_expr
(
p
,
e
->
param
[
0
]))
...
...
@@ -282,6 +284,7 @@ static int parse_primary(AVExpr **e, Parser *p)
else
if
(
strmatch
(
next
,
"floor"
))
d
->
type
=
e_floor
;
else
if
(
strmatch
(
next
,
"ceil"
))
d
->
type
=
e_ceil
;
else
if
(
strmatch
(
next
,
"trunc"
))
d
->
type
=
e_trunc
;
else
if
(
strmatch
(
next
,
"sqrt"
))
d
->
type
=
e_sqrt
;
else
{
for
(
i
=
0
;
p
->
func1_names
&&
p
->
func1_names
[
i
];
i
++
)
{
if
(
strmatch
(
next
,
p
->
func1_names
[
i
]))
{
...
...
@@ -449,6 +452,7 @@ static int verify_expr(AVExpr *e)
case
e_floor
:
case
e_ceil
:
case
e_trunc
:
case
e_sqrt
:
return
verify_expr
(
e
->
param
[
0
]);
default:
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
]);
}
...
...
@@ -628,6 +632,8 @@ int main(void)
"trunc(-123.123)"
,
"ceil(123.123)"
,
"ceil(-123.123)"
,
"sqrt(1764)"
,
"sqrt(-1)"
,
NULL
};
...
...
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