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
0c913272
Commit
0c913272
authored
May 06, 2023
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vsrc_gradients: fix several issues with !rgba output
parent
722ff740
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
vsrc_gradients.c
libavfilter/vsrc_gradients.c
+20
-17
No files found.
libavfilter/vsrc_gradients.c
View file @
0c913272
...
...
@@ -111,13 +111,13 @@ static uint64_t lerp_color16(uint8_t c0[4], uint8_t c1[4], float x)
{
const
float
y
=
1
.
f
-
x
;
return
(
llrintf
((
c0
[
0
]
*
y
+
c1
[
0
]
*
x
)
*
256
))
<<
0
|
(
llrintf
((
c0
[
1
]
*
y
+
c1
[
1
]
*
x
)
*
256
))
<<
16
|
(
llrintf
((
c0
[
2
]
*
y
+
c1
[
2
]
*
x
)
*
256
))
<<
32
|
(
llrintf
((
c0
[
3
]
*
y
+
c1
[
3
]
*
x
)
*
256
))
<<
48
;
return
(
(
uint64_t
)
llrintf
((
c0
[
0
]
*
y
+
c1
[
0
]
*
x
)
*
256
))
<<
0
|
(
(
uint64_t
)
llrintf
((
c0
[
1
]
*
y
+
c1
[
1
]
*
x
)
*
256
))
<<
16
|
(
(
uint64_t
)
llrintf
((
c0
[
2
]
*
y
+
c1
[
2
]
*
x
)
*
256
))
<<
32
|
(
(
uint64_t
)
llrintf
((
c0
[
3
]
*
y
+
c1
[
3
]
*
x
)
*
256
))
<<
48
;
}
static
uint32_t
lerp_colors
(
uint8_t
arr
[
3
][
4
],
int
nb_colors
,
int
nb_wrap_colors
,
float
step
)
static
uint32_t
lerp_colors
(
uint8_t
arr
[
8
][
4
],
int
nb_colors
,
int
nb_wrap_colors
,
float
step
)
{
float
scl
;
int
i
,
j
;
...
...
@@ -140,7 +140,7 @@ static uint32_t lerp_colors(uint8_t arr[3][4], int nb_colors, int nb_wrap_colors
return
lerp_color
(
arr
[
i
],
arr
[
j
],
scl
-
i
);
}
static
uint64_t
lerp_colors16
(
uint8_t
arr
[
3
][
4
],
int
nb_colors
,
int
nb_wrap_colors
,
float
step
)
static
uint64_t
lerp_colors16
(
uint8_t
arr
[
8
][
4
],
int
nb_colors
,
int
nb_wrap_colors
,
float
step
)
{
float
scl
;
int
i
,
j
;
...
...
@@ -163,7 +163,7 @@ static uint64_t lerp_colors16(uint8_t arr[3][4], int nb_colors, int nb_wrap_colo
return
lerp_color16
(
arr
[
i
],
arr
[
j
],
scl
-
i
);
}
static
void
lerp_colors32
(
float
arr
[
3
][
4
],
int
nb_colors
,
static
void
lerp_colors32
(
float
arr
[
8
][
4
],
int
nb_colors
,
int
nb_wrap_colors
,
float
step
,
float
*
r
,
float
*
g
,
float
*
b
,
float
*
a
)
{
...
...
@@ -187,12 +187,12 @@ static void lerp_colors32(float arr[3][4], int nb_colors,
scl
=
step
*
(
nb_wrap_colors
-
1
);
i
=
floorf
(
scl
);
x
=
scl
-
i
;
j
=
i
+
1
;
if
(
i
>=
nb_colors
-
1
)
{
i
=
nb_colors
-
1
;
j
=
0
;
}
x
=
scl
-
i
;
*
r
=
lerpf
(
arr
[
i
][
0
],
arr
[
j
][
0
],
x
);
*
g
=
lerpf
(
arr
[
i
][
1
],
arr
[
j
][
1
],
x
);
...
...
@@ -253,11 +253,12 @@ static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb
const
int
end
=
(
height
*
(
job
+
1
))
/
nb_jobs
;
const
int
linesize
=
frame
->
linesize
[
0
]
/
4
;
uint32_t
*
dst
=
(
uint32_t
*
)
frame
->
data
[
0
]
+
start
*
linesize
;
const
int
type
=
s
->
type
;
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
,
s
->
type
);
dst
[
x
]
=
lerp_colors
(
s
->
color_rgba
,
s
->
nb_colors
,
s
->
nb_colors
+
(
s
->
type
>=
2
),
factor
);
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
,
type
);
dst
[
x
]
=
lerp_colors
(
s
->
color_rgba
,
s
->
nb_colors
,
s
->
nb_colors
+
(
type
>=
2
),
factor
);
}
dst
+=
linesize
;
...
...
@@ -276,11 +277,12 @@ static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int
const
int
end
=
(
height
*
(
job
+
1
))
/
nb_jobs
;
const
int
linesize
=
frame
->
linesize
[
0
]
/
8
;
uint64_t
*
dst
=
(
uint64_t
*
)
frame
->
data
[
0
]
+
start
*
linesize
;
const
int
type
=
s
->
type
;
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
,
s
->
type
);
dst
[
x
]
=
lerp_colors16
(
s
->
color_rgba
,
s
->
nb_colors
,
s
->
nb_colors
+
s
->
type
>=
2
,
factor
);
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
,
type
);
dst
[
x
]
=
lerp_colors16
(
s
->
color_rgba
,
s
->
nb_colors
,
s
->
nb_colors
+
(
type
>=
2
)
,
factor
);
}
dst
+=
linesize
;
...
...
@@ -302,14 +304,15 @@ static int draw_gradients_slice32_planar(AVFilterContext *ctx, void *arg, int jo
const
int
linesize_r
=
frame
->
linesize
[
2
]
/
4
;
const
int
linesize_a
=
frame
->
linesize
[
3
]
/
4
;
float
*
dst_g
=
(
float
*
)
frame
->
data
[
0
]
+
start
*
linesize_g
;
float
*
dst_b
=
(
float
*
)
frame
->
data
[
0
]
+
start
*
linesize_b
;
float
*
dst_r
=
(
float
*
)
frame
->
data
[
0
]
+
start
*
linesize_r
;
float
*
dst_a
=
(
float
*
)
frame
->
data
[
0
]
+
start
*
linesize_a
;
float
*
dst_b
=
(
float
*
)
frame
->
data
[
1
]
+
start
*
linesize_b
;
float
*
dst_r
=
(
float
*
)
frame
->
data
[
2
]
+
start
*
linesize_r
;
float
*
dst_a
=
(
float
*
)
frame
->
data
[
3
]
+
start
*
linesize_a
;
const
int
type
=
s
->
type
;
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
,
s
->
type
);
lerp_colors32
(
s
->
color_rgbaf
,
s
->
nb_colors
,
s
->
nb_colors
+
s
->
type
>=
2
,
factor
,
float
factor
=
project
(
s
->
fx0
,
s
->
fy0
,
s
->
fx1
,
s
->
fy1
,
x
,
y
,
type
);
lerp_colors32
(
s
->
color_rgbaf
,
s
->
nb_colors
,
s
->
nb_colors
+
(
type
>=
2
),
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