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();
148 VK_SHADER_STAGE_COMPUTE_BIT, 0));
154 .name =
"top_images",
155 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
158 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
162 .name =
"bottom_images",
163 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
166 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
170 .name =
"output_images",
171 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
173 .mem_quali =
"writeonly",
176 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
182 for (
int i = 0, j = 0;
i <
planes;
i++) {
183 for (j = 0; j <
i; j++)
184 if (
s->params[
i].blend_func ==
s->params[j].blend_func)
188 GLSLD(
s->params[
i].blend_func);
195 GLSLC(1,
const ivec2
pos = ivec2(gl_GlobalInvocationID.xy); );
200 GLSLF(2,
const vec4 top = texture(top_images[%
i],
pos); ,
i);
201 GLSLF(2,
const vec4 bottom = texture(bottom_images[%
i],
pos); ,
i);
202 GLSLF(2,
const float opacity = %
f; ,
s->params[
i].opacity);
203 GLSLF(2, vec4 dst = %
s(top, bottom, opacity); ,
s->params[
i].blend);
205 GLSLF(2, imageStore(output_images[%
i],
pos, dst); ,
i);
247 if (!
s->initialized) {
250 if (top_fc->
sw_format != bottom_fc->sw_format) {
252 "Currently the sw format of the bottom video need to match the top!\n");
261 s->sampler,
NULL, 0));
307 if (toplink->
w != bottomlink->
w || toplink->
h != bottomlink->
h) {
309 "(size %dx%d) do not match the corresponding "
310 "second input link %s parameters (size %dx%d)\n",
338 #define OFFSET(x) offsetof(BlendVulkanContext, x)
339 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
384 .
name =
"blend_vulkan",
393 .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
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
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_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
#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_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
uint8_t * data
The data buffer.
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)
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family)
Chooses a QF and loads it into a context.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
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.
int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, AVFrame *out, AVFrame *in[], int nb_in, VkSampler sampler, void *push_src, size_t push_size)
Up to 16 inputs, one output.
int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, uint8_t *spirv, size_t spirv_size, const char *entrypoint)
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
const char * name
Filter name.
int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int read_only, int print_to_shader_only)
Add descriptor to a pipeline.
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
A link between two filters.
#define MULTIPLY(var, const)
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
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[]
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[]
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
static int activate(AVFilterContext *avctx)
static av_cold int init_filter(AVFilterContext *avctx)
int(* compile_shader)(struct FFVkSPIRVCompiler *ctx, void *avctx, struct FFVkSPIRVShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
#define FILTER_INPUTS(array)
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[]
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *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_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, VkShaderStageFlags stage, uint32_t required_subgroup_size)
Shader management.
int main(int argc, char **argv)
#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)
#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.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Returns the format to use for images in shaders.
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.
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
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.
static const struct @386 planes[]
#define FILTER_OUTPUTS(array)
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanPipeline *pl)
Register a pipeline with an exec pool.
#define flags(name, subs,...)
AVFILTER_DEFINE_CLASS(blend_vulkan)
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
AVFilterLink ** outputs
array of pointers to output links