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
f3e886c7
Commit
f3e886c7
authored
10 years ago
by
Stefano Sabatini
Browse files
Options
Downloads
Patches
Plain Diff
lavu/eval: add clip function
parent
7cd6d61d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/utils.texi
+3
-0
3 additions, 0 deletions
doc/utils.texi
libavutil/eval.c
+13
-1
13 additions, 1 deletion
libavutil/eval.c
libavutil/version.h
+1
-1
1 addition, 1 deletion
libavutil/version.h
tests/ref/fate/eval
+9
-0
9 additions, 0 deletions
tests/ref/fate/eval
with
26 additions
and
2 deletions
doc/utils.texi
+
3
−
0
View file @
f3e886c7
...
@@ -782,6 +782,9 @@ large numbers (usually 2^53 and larger).
...
@@ -782,6 +782,9 @@ large numbers (usually 2^53 and larger).
Round the value of expression @var{expr} upwards to the nearest
Round the value of expression @var{expr} upwards to the nearest
integer. For example, "ceil(1.5)" is "2.0".
integer. For example, "ceil(1.5)" is "2.0".
@item clip(x, min, max)
Return the value of @var{x} clipped between @var{min} and @var{max}.
@item cos(x)
@item cos(x)
Compute cosine of @var{x}.
Compute cosine of @var{x}.
...
...
This diff is collapsed.
Click to expand it.
libavutil/eval.c
+
13
−
1
View file @
f3e886c7
...
@@ -147,7 +147,7 @@ struct AVExpr {
...
@@ -147,7 +147,7 @@ struct AVExpr {
e_pow
,
e_mul
,
e_div
,
e_add
,
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_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_sqrt
,
e_not
,
e_random
,
e_hypot
,
e_gcd
,
e_if
,
e_ifnot
,
e_print
,
e_bitand
,
e_bitor
,
e_between
,
e_if
,
e_ifnot
,
e_print
,
e_bitand
,
e_bitor
,
e_between
,
e_clip
}
type
;
}
type
;
double
value
;
// is sign in other types
double
value
;
// is sign in other types
union
{
union
{
...
@@ -187,6 +187,13 @@ static double eval_expr(Parser *p, AVExpr *e)
...
@@ -187,6 +187,13 @@ static double eval_expr(Parser *p, AVExpr *e)
e
->
param
[
2
]
?
eval_expr
(
p
,
e
->
param
[
2
])
:
0
);
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
])
:
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
);
e
->
param
[
2
]
?
eval_expr
(
p
,
e
->
param
[
2
])
:
0
);
case
e_clip
:
{
double
x
=
eval_expr
(
p
,
e
->
param
[
0
]);
double
min
=
eval_expr
(
p
,
e
->
param
[
1
]),
max
=
eval_expr
(
p
,
e
->
param
[
2
]);
if
(
isnan
(
min
)
||
isnan
(
max
)
||
isnan
(
x
)
||
min
>
max
)
return
NAN
;
return
e
->
value
*
av_clipd
(
eval_expr
(
p
,
e
->
param
[
0
]),
min
,
max
);
}
case
e_between
:
{
case
e_between
:
{
double
d
=
eval_expr
(
p
,
e
->
param
[
0
]);
double
d
=
eval_expr
(
p
,
e
->
param
[
0
]);
return
e
->
value
*
(
d
>=
eval_expr
(
p
,
e
->
param
[
1
])
&&
return
e
->
value
*
(
d
>=
eval_expr
(
p
,
e
->
param
[
1
])
&&
...
@@ -436,6 +443,7 @@ static int parse_primary(AVExpr **e, Parser *p)
...
@@ -436,6 +443,7 @@ static int parse_primary(AVExpr **e, Parser *p)
else
if
(
strmatch
(
next
,
"bitand"
))
d
->
type
=
e_bitand
;
else
if
(
strmatch
(
next
,
"bitand"
))
d
->
type
=
e_bitand
;
else
if
(
strmatch
(
next
,
"bitor"
))
d
->
type
=
e_bitor
;
else
if
(
strmatch
(
next
,
"bitor"
))
d
->
type
=
e_bitor
;
else
if
(
strmatch
(
next
,
"between"
))
d
->
type
=
e_between
;
else
if
(
strmatch
(
next
,
"between"
))
d
->
type
=
e_between
;
else
if
(
strmatch
(
next
,
"clip"
))
d
->
type
=
e_clip
;
else
{
else
{
for
(
i
=
0
;
p
->
func1_names
&&
p
->
func1_names
[
i
];
i
++
)
{
for
(
i
=
0
;
p
->
func1_names
&&
p
->
func1_names
[
i
];
i
++
)
{
if
(
strmatch
(
next
,
p
->
func1_names
[
i
]))
{
if
(
strmatch
(
next
,
p
->
func1_names
[
i
]))
{
...
@@ -632,6 +640,7 @@ static int verify_expr(AVExpr *e)
...
@@ -632,6 +640,7 @@ static int verify_expr(AVExpr *e)
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
])
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
])
&&
(
!
e
->
param
[
2
]
||
verify_expr
(
e
->
param
[
2
]));
&&
(
!
e
->
param
[
2
]
||
verify_expr
(
e
->
param
[
2
]));
case
e_between
:
case
e_between
:
case
e_clip
:
return
verify_expr
(
e
->
param
[
0
])
&&
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
])
&&
verify_expr
(
e
->
param
[
1
])
&&
verify_expr
(
e
->
param
[
2
]);
verify_expr
(
e
->
param
[
2
]);
...
@@ -831,6 +840,9 @@ int main(int argc, char **argv)
...
@@ -831,6 +840,9 @@ int main(int argc, char **argv)
"between(10, -3, 10)"
,
"between(10, -3, 10)"
,
"between(-4, -2, -1)"
,
"between(-4, -2, -1)"
,
"between(1,2)"
,
"between(1,2)"
,
"clip(0, 2, 1)"
,
"clip(0/0, 1, 2)"
,
"clip(0, 0/0, 1)"
,
NULL
NULL
};
};
...
...
This diff is collapsed.
Click to expand it.
libavutil/version.h
+
1
−
1
View file @
f3e886c7
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
#define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 92
#define LIBAVUTIL_VERSION_MINOR 92
#define LIBAVUTIL_VERSION_MICRO 10
0
#define LIBAVUTIL_VERSION_MICRO 10
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, \
...
...
This diff is collapsed.
Click to expand it.
tests/ref/fate/eval
+
9
−
0
View file @
f3e886c7
...
@@ -268,5 +268,14 @@ Evaluating 'between(-4, -2, -1)'
...
@@ -268,5 +268,14 @@ Evaluating 'between(-4, -2, -1)'
Evaluating 'between(1,2)'
Evaluating 'between(1,2)'
'between(1,2)' -> nan
'between(1,2)' -> nan
Evaluating 'clip(0, 2, 1)'
'clip(0, 2, 1)' -> nan
Evaluating 'clip(0/0, 1, 2)'
'clip(0/0, 1, 2)' -> nan
Evaluating 'clip(0, 0/0, 1)'
'clip(0, 0/0, 1)' -> nan
12.700000 == 12.7
12.700000 == 12.7
0.931323 == 0.931322575
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