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
ac7cda9e
Commit
ac7cda9e
authored
Oct 08, 2011
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eval: add random()
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
8fd56f7b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
eval.c
libavutil/eval.c
+10
-1
No files found.
libavutil/eval.c
View file @
ac7cda9e
...
...
@@ -126,7 +126,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
,
e_not
,
e_sqrt
,
e_not
,
e_random
,
}
type
;
double
value
;
// is sign in other types
union
{
...
...
@@ -156,6 +156,13 @@ static double eval_expr(Parser *p, AVExpr *e)
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_not
:
return
e
->
value
*
eval_expr
(
p
,
e
->
param
[
0
])
==
0
;
case
e_random
:{
int
idx
=
av_clip
(
eval_expr
(
p
,
e
->
param
[
0
]),
0
,
VARS
-
1
);
uint64_t
r
=
isnan
(
p
->
var
[
idx
])
?
0
:
p
->
var
[
idx
];
r
=
r
*
1664525
+
1013904223
;
p
->
var
[
idx
]
=
r
;
return
e
->
value
*
(
r
*
(
1
.
0
/
UINT64_MAX
));
}
case
e_while
:
{
double
d
=
NAN
;
while
(
eval_expr
(
p
,
e
->
param
[
0
]))
...
...
@@ -294,6 +301,7 @@ static int parse_primary(AVExpr **e, Parser *p)
else
if
(
strmatch
(
next
,
"sqrt"
))
d
->
type
=
e_sqrt
;
else
if
(
strmatch
(
next
,
"not"
))
d
->
type
=
e_not
;
else
if
(
strmatch
(
next
,
"pow"
))
d
->
type
=
e_pow
;
else
if
(
strmatch
(
next
,
"random"
))
d
->
type
=
e_random
;
else
{
for
(
i
=
0
;
p
->
func1_names
&&
p
->
func1_names
[
i
];
i
++
)
{
if
(
strmatch
(
next
,
p
->
func1_names
[
i
]))
{
...
...
@@ -463,6 +471,7 @@ static int verify_expr(AVExpr *e)
case
e_trunc
:
case
e_sqrt
:
case
e_not
:
case
e_random
:
return
verify_expr
(
e
->
param
[
0
]);
default:
return
verify_expr
(
e
->
param
[
0
])
&&
verify_expr
(
e
->
param
[
1
]);
}
...
...
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