Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
9bc39390
Commit
9bc39390
authored
13 years ago
by
Stefano Sabatini
Committed by
Anton Khirnov
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
eval: add sqrt function for computing the square root
parent
3e033da8
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/eval.texi
+4
-0
4 additions, 0 deletions
doc/eval.texi
libavutil/avutil.h
+1
-1
1 addition, 1 deletion
libavutil/avutil.h
libavutil/eval.c
+6
-0
6 additions, 0 deletions
libavutil/eval.c
tests/ref/fate/eval
+6
-0
6 additions, 0 deletions
tests/ref/fate/eval
with
17 additions
and
1 deletion
doc/eval.texi
+
4
−
0
View file @
9bc39390
...
...
@@ -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:
...
...
This diff is collapsed.
Click to expand it.
libavutil/avutil.h
+
1
−
1
View file @
9bc39390
...
...
@@ -41,7 +41,7 @@
#define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 10
#define LIBAVUTIL_VERSION_MICRO
0
#define LIBAVUTIL_VERSION_MICRO
1
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
...
...
This diff is collapsed.
Click to expand it.
libavutil/eval.c
+
6
−
0
View file @
9bc39390
...
...
@@ -123,6 +123,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
{
...
...
@@ -149,6 +150,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
]))
...
...
@@ -283,6 +285,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
]))
{
...
...
@@ -450,6 +453,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
]);
}
...
...
@@ -600,6 +604,8 @@ int main(int argc, char **argv)
"trunc(-123.123)"
,
"ceil(123.123)"
,
"ceil(-123.123)"
,
"sqrt(1764)"
,
"sqrt(-1)"
,
NULL
};
...
...
This diff is collapsed.
Click to expand it.
tests/ref/fate/eval
+
6
−
0
View file @
9bc39390
...
...
@@ -133,5 +133,11 @@ Evaluating 'ceil(123.123)'
Evaluating 'ceil(-123.123)'
'ceil(-123.123)' -> -123.000000
Evaluating 'sqrt(1764)'
'sqrt(1764)' -> 42.000000
Evaluating 'sqrt(-1)'
'sqrt(-1)' -> -nan
12.700000 == 12.7
0.931323 == 0.931322575
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment