Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
6f231664
Commit
6f231664
authored
Mar 06, 2022
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vsrc_gradients: add radial gradients
parent
7c23c9df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
filters.texi
doc/filters.texi
+3
-0
vsrc_gradients.c
libavfilter/vsrc_gradients.c
+13
-9
No files found.
doc/filters.texi
View file @
6f231664
...
...
@@ -25269,6 +25269,9 @@ supposed to be generated forever.
@item speed
Set speed of gradients rotation.
@item type, t
Set type of gradients, can be @code{linear} or @code{radial}.
@end table
...
...
libavfilter/vsrc_gradients.c
View file @
6f231664
...
...
@@ -76,9 +76,13 @@ static const AVOption gradients_options[] = {
{
"nb_colors"
,
"set the number of colors"
,
OFFSET
(
nb_colors
),
AV_OPT_TYPE_INT
,
{.
i64
=
2
},
2
,
8
,
FLAGS
},
{
"n"
,
"set the number of colors"
,
OFFSET
(
nb_colors
),
AV_OPT_TYPE_INT
,
{.
i64
=
2
},
2
,
8
,
FLAGS
},
{
"seed"
,
"set the seed"
,
OFFSET
(
seed
),
AV_OPT_TYPE_INT64
,
{.
i64
=-
1
},
-
1
,
UINT32_MAX
,
FLAGS
},
{
"duration"
,
"set video duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
\
{
"d"
,
"set video duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
\
{
"speed"
,
"set gradients rotation speed"
,
OFFSET
(
speed
),
AV_OPT_TYPE_FLOAT
,{.
dbl
=
0
.
01
},
0
.
00001
,
1
,
FLAGS
},
\
{
"duration"
,
"set video duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
{
"d"
,
"set video duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
{
"speed"
,
"set gradients rotation speed"
,
OFFSET
(
speed
),
AV_OPT_TYPE_FLOAT
,{.
dbl
=
0
.
01
},
0
.
00001
,
1
,
FLAGS
},
{
"type"
,
"set gradient type"
,
OFFSET
(
type
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"type"
},
{
"t"
,
"set gradient type"
,
OFFSET
(
type
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"type"
},
{
"linear"
,
"set gradient type"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
FLAGS
,
"type"
},
{
"radial"
,
"set gradient type"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
FLAGS
,
"type"
},
{
NULL
},
};
...
...
@@ -180,19 +184,19 @@ static void lerp_colors32(float arr[3][4], int nb_colors, float step,
static
float
project
(
float
origin_x
,
float
origin_y
,
float
dest_x
,
float
dest_y
,
int
point_x
,
int
point_y
)
int
point_x
,
int
point_y
,
int
type
)
{
// Rise and run of line.
float
od_x
=
dest_x
-
origin_x
;
float
od_y
=
dest_y
-
origin_y
;
// Distance-squared of line.
float
od_s_q
=
od_x
*
od_x
+
od_y
*
od_y
;
float
od_s_q
=
type
?
sqrtf
(
od_x
*
od_x
+
od_y
*
od_y
)
:
od_x
*
od_x
+
od_y
*
od_y
;
// Rise and run of projection.
float
op_x
=
point_x
-
origin_x
;
float
op_y
=
point_y
-
origin_y
;
float
op_x_od
=
op_x
*
od_x
+
op_y
*
od_y
;
float
op_x_od
=
type
?
sqrtf
(
op_x
*
op_x
+
op_y
*
op_y
)
:
op_x
*
od_x
+
op_y
*
od_y
;
// Normalize and clamp range.
return
av_clipf
(
op_x_od
/
od_s_q
,
0
.
f
,
1
.
f
);
...
...
@@ -211,7 +215,7 @@ static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb
for
(
int
y
=
start
;
y
<
end
;
y
++
)
{
for
(
int
x
=
0
;
x
<
width
;
x
++
)
{
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
);
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
,
s
->
type
);
dst
[
x
]
=
lerp_colors
(
s
->
color_rgba
,
s
->
nb_colors
,
factor
);
}
...
...
@@ -234,7 +238,7 @@ static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int
for
(
int
y
=
start
;
y
<
end
;
y
++
)
{
for
(
int
x
=
0
;
x
<
width
;
x
++
)
{
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
);
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
,
s
->
type
);
dst
[
x
]
=
lerp_colors16
(
s
->
color_rgba
,
s
->
nb_colors
,
factor
);
}
...
...
@@ -263,7 +267,7 @@ static int draw_gradients_slice32_planar(AVFilterContext *ctx, void *arg, int jo
for
(
int
y
=
start
;
y
<
end
;
y
++
)
{
for
(
int
x
=
0
;
x
<
width
;
x
++
)
{
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
);
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
,
s
->
type
);
lerp_colors32
(
s
->
color_rgbaf
,
s
->
nb_colors
,
factor
,
&
dst_r
[
x
],
&
dst_g
[
x
],
&
dst_b
[
x
],
&
dst_a
[
x
]);
}
...
...
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