Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
f66ac83c
Commit
f66ac83c
authored
Apr 23, 2020
by
Lynne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
overlay_vulkan: add support for overlaying images with an alpha channel
parent
4e813243
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
vf_overlay_vulkan.c
libavfilter/vf_overlay_vulkan.c
+23
-2
No files found.
libavfilter/vf_overlay_vulkan.c
View file @
f66ac83c
...
@@ -59,11 +59,27 @@ static const char overlay_noalpha[] = {
...
@@ -59,11 +59,27 @@ static const char overlay_noalpha[] = {
C
(
0
,
}
)
C
(
0
,
}
)
};
};
static
const
char
overlay_alpha
[]
=
{
C
(
0
,
void
overlay_alpha_opaque
(
int
i
,
ivec2
pos
)
)
C
(
0
,
{
)
C
(
1
,
vec4
res
=
texture
(
main_img
[
i
],
pos
);
)
C
(
1
,
if
((
o_offset
[
i
].
x
<=
pos
.
x
)
&&
(
o_offset
[
i
].
y
<=
pos
.
y
)
&&
(
pos
.
x
<
(
o_offset
[
i
].
x
+
o_size
[
i
].
x
))
&&
(
pos
.
y
<
(
o_offset
[
i
].
y
+
o_size
[
i
].
y
)))
{
)
C
(
2
,
vec4
ovr
=
texture
(
overlay_img
[
i
],
pos
-
o_offset
[
i
]);
)
C
(
2
,
res
=
ovr
*
ovr
.
a
+
res
*
(
1
.
0
f
-
ovr
.
a
);
)
C
(
2
,
res
.
a
=
1
.
0
f
;
)
C
(
2
,
imageStore
(
output_img
[
i
],
pos
,
res
);
)
C
(
1
,
}
)
C
(
1
,
imageStore
(
output_img
[
i
],
pos
,
res
);
)
C
(
0
,
}
)
};
static
av_cold
int
init_filter
(
AVFilterContext
*
ctx
)
static
av_cold
int
init_filter
(
AVFilterContext
*
ctx
)
{
{
int
err
;
int
err
;
OverlayVulkanContext
*
s
=
ctx
->
priv
;
OverlayVulkanContext
*
s
=
ctx
->
priv
;
VkSampler
*
sampler
=
ff_vk_init_sampler
(
ctx
,
1
,
VK_FILTER_
LINEAR
);
VkSampler
*
sampler
=
ff_vk_init_sampler
(
ctx
,
1
,
VK_FILTER_
NEAREST
);
if
(
!
sampler
)
if
(
!
sampler
)
return
AVERROR_EXTERNAL
;
return
AVERROR_EXTERNAL
;
...
@@ -73,6 +89,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
...
@@ -73,6 +89,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
{
/* Create the shader */
{
/* Create the shader */
const
int
planes
=
av_pix_fmt_count_planes
(
s
->
vkctx
.
output_format
);
const
int
planes
=
av_pix_fmt_count_planes
(
s
->
vkctx
.
output_format
);
const
int
ialpha
=
av_pix_fmt_desc_get
(
s
->
vkctx
.
input_format
)
->
flags
&
AV_PIX_FMT_FLAG_ALPHA
;
VulkanDescriptorSetBinding
desc_i
[
3
]
=
{
VulkanDescriptorSetBinding
desc_i
[
3
]
=
{
{
{
...
@@ -126,12 +143,16 @@ static av_cold int init_filter(AVFilterContext *ctx)
...
@@ -126,12 +143,16 @@ static av_cold int init_filter(AVFilterContext *ctx)
RET
(
ff_vk_add_descriptor_set
(
ctx
,
s
->
pl
,
shd
,
&
desc_b
,
1
,
0
));
/* set 1 */
RET
(
ff_vk_add_descriptor_set
(
ctx
,
s
->
pl
,
shd
,
&
desc_b
,
1
,
0
));
/* set 1 */
GLSLD
(
overlay_noalpha
);
GLSLD
(
overlay_noalpha
);
GLSLD
(
overlay_alpha
);
GLSLC
(
0
,
void
main
()
);
GLSLC
(
0
,
void
main
()
);
GLSLC
(
0
,
{
);
GLSLC
(
0
,
{
);
GLSLC
(
1
,
ivec2
pos
=
ivec2
(
gl_GlobalInvocationID
.
xy
);
);
GLSLC
(
1
,
ivec2
pos
=
ivec2
(
gl_GlobalInvocationID
.
xy
);
);
GLSLF
(
1
,
int
planes
=
%
i
;
,
planes
);
GLSLF
(
1
,
int
planes
=
%
i
;
,
planes
);
GLSLC
(
1
,
for
(
int
i
=
0
;
i
<
planes
;
i
++
)
{
);
GLSLC
(
1
,
for
(
int
i
=
0
;
i
<
planes
;
i
++
)
{
);
GLSLC
(
2
,
overlay_noalpha
(
i
,
pos
);
);
if
(
ialpha
)
GLSLC
(
2
,
overlay_alpha_opaque
(
i
,
pos
);
);
else
GLSLC
(
2
,
overlay_noalpha
(
i
,
pos
);
);
GLSLC
(
1
,
}
);
GLSLC
(
1
,
}
);
GLSLC
(
0
,
}
);
GLSLC
(
0
,
}
);
...
...
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