FFmpeg
Data Structures | Macros | Functions | Variables
vf_blend_vulkan.c File Reference
#include "libavutil/random_seed.h"
#include "libavutil/vulkan_spirv.h"
#include "libavutil/opt.h"
#include "vulkan_filter.h"
#include "filters.h"
#include "framesync.h"
#include "blend.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  FilterParamsVulkan
 
struct  BlendVulkanContext
 

Macros

#define IN_TOP   0
 
#define IN_BOTTOM   1
 
#define DEFINE_BLEND_MODE(MODE, EXPR)
 
#define A   top
 
#define B   bottom
 
#define FN(EXPR)   A + ((EXPR) - A) * opacity
 
#define CASE(MODE)
 
#define OFFSET(x)   offsetof(BlendVulkanContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static void init_blend_func (FilterParamsVulkan *param)
 
static int config_params (AVFilterContext *avctx)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
static av_cold int init_filter (AVFilterContext *avctx)
 
static int blend_frame (FFFrameSync *fs)
 
static av_cold int init (AVFilterContext *avctx)
 
static av_cold void uninit (AVFilterContext *avctx)
 
static int config_props_output (AVFilterLink *outlink)
 
static int activate (AVFilterContext *avctx)
 
 AVFILTER_DEFINE_CLASS (blend_vulkan)
 

Variables

static const AVOption blend_vulkan_options []
 
static const AVFilterPad blend_vulkan_inputs []
 
static const AVFilterPad blend_vulkan_outputs []
 
const AVFilter ff_vf_blend_vulkan
 

Macro Definition Documentation

◆ IN_TOP

#define IN_TOP   0

Definition at line 34 of file vf_blend_vulkan.c.

◆ IN_BOTTOM

#define IN_BOTTOM   1

Definition at line 35 of file vf_blend_vulkan.c.

◆ DEFINE_BLEND_MODE

#define DEFINE_BLEND_MODE (   MODE,
  EXPR 
)
Value:
static const char blend_##MODE[] = "blend_"#MODE; \
static const char blend_##MODE##_func[] = { \
C(0, vec4 blend_##MODE(vec4 top, vec4 bottom, float opacity) { ) \
C(1, vec4 dst = EXPR; ) \
C(1, return dst; ) \
C(0, } ) \
};

Definition at line 59 of file vf_blend_vulkan.c.

◆ A

#define A   top

Definition at line 68 of file vf_blend_vulkan.c.

◆ B

#define B   bottom

Definition at line 69 of file vf_blend_vulkan.c.

◆ FN

#define FN (   EXPR)    A + ((EXPR) - A) * opacity

Definition at line 71 of file vf_blend_vulkan.c.

◆ CASE

#define CASE (   MODE)
Value:
case BLEND_##MODE: \
param->blend = blend_##MODE;\
param->blend_func = blend_##MODE##_func; \
break;

◆ OFFSET

#define OFFSET (   x)    offsetof(BlendVulkanContext, x)

Definition at line 339 of file vf_blend_vulkan.c.

◆ FLAGS

Definition at line 340 of file vf_blend_vulkan.c.

Function Documentation

◆ init_blend_func()

static void init_blend_func ( FilterParamsVulkan param)
inlinestatic

Definition at line 76 of file vf_blend_vulkan.c.

Referenced by config_params().

◆ config_params()

static int config_params ( AVFilterContext avctx)
static

Definition at line 92 of file vf_blend_vulkan.c.

Referenced by config_props_output(), and process_command().

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 115 of file vf_blend_vulkan.c.

◆ init_filter()

static av_cold int init_filter ( AVFilterContext avctx)
static

Definition at line 125 of file vf_blend_vulkan.c.

Referenced by blend_frame().

◆ blend_frame()

static int blend_frame ( FFFrameSync fs)
static

Definition at line 228 of file vf_blend_vulkan.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext avctx)
static

Definition at line 270 of file vf_blend_vulkan.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext avctx)
static

Definition at line 279 of file vf_blend_vulkan.c.

◆ config_props_output()

static int config_props_output ( AVFilterLink outlink)
static

Definition at line 298 of file vf_blend_vulkan.c.

◆ activate()

static int activate ( AVFilterContext avctx)
static

Definition at line 333 of file vf_blend_vulkan.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( blend_vulkan  )

Variable Documentation

◆ blend_vulkan_options

const AVOption blend_vulkan_options[]
static
Initial value:
= {
{ "c0_mode", "set component #0 blend mode", OFFSET(params[0].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
{ "c1_mode", "set component #1 blend mode", OFFSET(params[1].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
{ "c2_mode", "set component #2 blend mode", OFFSET(params[2].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
{ "c3_mode", "set component #3 blend mode", OFFSET(params[3].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
{ "all_mode", "set blend mode for all components", OFFSET(all_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, BLEND_NB - 1, FLAGS, .unit = "mode" },
{ "normal", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_NORMAL }, 0, 0, FLAGS, .unit = "mode" },
{ "multiply", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_MULTIPLY }, 0, 0, FLAGS, .unit = "mode" },
{ "c0_opacity", "set color component #0 opacity", OFFSET(params[0].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
{ "c1_opacity", "set color component #1 opacity", OFFSET(params[1].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
{ "c2_opacity", "set color component #2 opacity", OFFSET(params[2].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
{ "c3_opacity", "set color component #3 opacity", OFFSET(params[3].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
{ "all_opacity", "set opacity for all color components", OFFSET(all_opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
{ NULL }
}

Definition at line 342 of file vf_blend_vulkan.c.

◆ blend_vulkan_inputs

const AVFilterPad blend_vulkan_inputs[]
static
Initial value:
= {
{
.name = "top",
.config_props = &ff_vk_filter_config_input,
},
{
.name = "bottom",
.config_props = &ff_vk_filter_config_input,
},
}

Definition at line 362 of file vf_blend_vulkan.c.

◆ blend_vulkan_outputs

const AVFilterPad blend_vulkan_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = &config_props_output,
}
}

Definition at line 376 of file vf_blend_vulkan.c.

◆ ff_vf_blend_vulkan

const AVFilter ff_vf_blend_vulkan
Initial value:
= {
.name = "blend_vulkan",
.description = NULL_IF_CONFIG_SMALL("Blend two video frames in Vulkan"),
.priv_size = sizeof(BlendVulkanContext),
.init = &init,
.priv_class = &blend_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.process_command = &process_command,
}

Definition at line 384 of file vf_blend_vulkan.c.

config_props_output
static int config_props_output(AVFilterLink *outlink)
Definition: vf_blend_vulkan.c:298
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
BLEND_NB
@ BLEND_NB
Definition: blend.h:69
init
static av_cold int init(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:270
blend_vulkan_outputs
static const AVFilterPad blend_vulkan_outputs[]
Definition: vf_blend_vulkan.c:376
OFFSET
#define OFFSET(x)
Definition: vf_blend_vulkan.c:339
C
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
Definition: writing_filters.txt:58
blend_vulkan_inputs
static const AVFilterPad blend_vulkan_inputs[]
Definition: vf_blend_vulkan.c:362
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition: opt.h:267
activate
static int activate(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:333
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
BLEND_MULTIPLY
@ BLEND_MULTIPLY
Definition: blend.h:42
BlendVulkanContext
Definition: vf_blend_vulkan.c:44
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: filters.h:206
FLAGS
#define FLAGS
Definition: vf_blend_vulkan.c:340
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:173
uninit
static av_cold void uninit(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:279
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_blend_vulkan.c:115
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:176
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
BLEND_NORMAL
@ BLEND_NORMAL
Definition: blend.h:29