Go to the documentation of this file.
59 #define DEFINE_BLEND_MODE(MODE, EXPR) \
60 static const char blend_##MODE[] = "blend_"#MODE; \
61 static const char blend_##MODE##_func[] = { \
62 C(0, vec4 blend_##MODE(vec4 top, vec4 bottom, float opacity) { ) \
63 C(1, vec4 dst = EXPR; ) \
71 #define FN(EXPR) A + ((EXPR) - A) * opacity
78 #define CASE(MODE) case BLEND_##MODE: \
79 param->blend = blend_##MODE;\
80 param->blend_func = blend_##MODE##_func; \
83 switch (param->mode) {
86 default: param->blend =
NULL;
break;
100 param->
mode =
s->all_mode;
101 if (
s->all_opacity < 1)
107 "Currently the blend mode specified is not supported yet.\n");
116 char *res,
int res_len,
int flags)
130 void *spv_opaque =
NULL;
138 spv = ff_vk_spirv_init();
154 VK_SHADER_STAGE_COMPUTE_BIT,
161 .name =
"top_images",
162 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
165 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
169 .name =
"bottom_images",
170 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
173 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
177 .name =
"output_images",
178 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
180 .mem_quali =
"writeonly",
183 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
189 for (
int i = 0, j = 0;
i <
planes;
i++) {
190 for (j = 0; j <
i; j++)
191 if (
s->params[
i].blend_func ==
s->params[j].blend_func)
195 GLSLD(
s->params[
i].blend_func);
202 GLSLC(1,
const ivec2
pos = ivec2(gl_GlobalInvocationID.xy); );
207 GLSLF(2,
const vec4 top = texture(top_images[%
i],
pos); ,
i);
208 GLSLF(2,
const vec4 bottom = texture(bottom_images[%
i],
pos); ,
i);
209 GLSLF(2,
const float opacity = %
f; ,
s->params[
i].opacity);
210 GLSLF(2, vec4
dst = %
s(top, bottom, opacity); ,
s->params[
i].blend);
253 if (!
s->initialized) {
256 if (top_fc->
sw_format != bottom_fc->sw_format) {
258 "Currently the sw format of the bottom video need to match the top!\n");
267 s->sampler,
NULL, 0));
314 if (toplink->
w != bottomlink->
w || toplink->
h != bottomlink->
h) {
316 "(size %dx%d) do not match the corresponding "
317 "second input link %s parameters (size %dx%d)\n",
345 #define OFFSET(x) offsetof(BlendVulkanContext, x)
346 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
391 .
name =
"blend_vulkan",
400 .priv_class = &blend_vulkan_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
const AVFilter ff_vf_blend_vulkan
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
int ff_vk_shader_init(FFVulkanContext *s, FFVulkanShader *shd, const char *name, VkPipelineStageFlags stage, const char *extensions[], int nb_extensions, int lg_x, int lg_y, int lg_z, uint32_t required_subgroup_size)
Initialize a shader object, with a specific set of extensions, type+bind, local group size,...
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
uint8_t * data
The data buffer.
int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf, FFVkExecPool *pool, int nb_contexts, int nb_queries, VkQueryType query_type, int query_64bit, const void *query_create_pnext)
Allocates/frees an execution pool.
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
static int config_props_output(AVFilterLink *outlink)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
static void init_blend_func(FilterParamsVulkan *param)
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
const char * name
Filter name.
A link between two filters.
#define MULTIPLY(var, const)
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Link properties exposed to filter code, but not external callers.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
void * priv
private data for use by the filter
static av_cold int init(AVFilterContext *avctx)
FilterParamsVulkan params[4]
static const AVFilterPad blend_vulkan_outputs[]
static const struct @469 planes[]
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
A filter pad used for either input or output.
AVFilterPad * input_pads
array of input pads
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static const AVFilterPad blend_vulkan_inputs[]
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static int activate(AVFilterContext *avctx)
static av_cold int init_filter(AVFilterContext *avctx)
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
#define FILTER_OUTPUTS(array)
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pix_fmt, enum FFVkShaderRepFormat rep_fmt)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define fs(width, name, subs,...)
AVFilterLink ** inputs
array of pointers to input links
int ff_vk_filter_config_output(AVFilterLink *outlink)
static int config_params(AVFilterContext *avctx)
static const AVOption blend_vulkan_options[]
AVVulkanDeviceQueueFamily * qf
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanShader *shd, AVFrame *out, AVFrame *in[], int nb_in, VkSampler sampler, void *push_src, size_t push_size)
Up to 16 inputs, one output.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
static int blend_frame(FFFrameSync *fs)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
AVFilterContext * src
source filter
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
int(* compile_shader)(FFVulkanContext *s, struct FFVkSPIRVCompiler *ctx, FFVulkanShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
#define AVERROR_EXTERNAL
Generic error in an external library.
#define i(width, name, range_min, range_max)
int w
agreed upon image width
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, uint8_t *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
const char * name
Pad name.
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
This struct describes a set or pool of "hardware" frames (i.e.
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
static av_cold void uninit(AVFilterContext *avctx)
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
#define DEFINE_BLEND_MODE(MODE, EXPR)
int ff_vk_filter_config_input(AVFilterLink *inlink)
AVVulkanDeviceContext * hwctx
VkDevice act_dev
Active device.
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
#define flags(name, subs,...)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
AVFILTER_DEFINE_CLASS(blend_vulkan)
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
AVFilterLink ** outputs
array of pointers to output links