FFmpeg
Data Structures | Macros | Functions | Variables
vf_gblur_vulkan.c File Reference
#include "libavutil/random_seed.h"
#include "libavutil/opt.h"
#include "vulkan_filter.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  GBlurVulkanContext
 

Macros

#define CGS   32
 
#define GBLUR_MAX_KERNEL_SIZE   127
 
#define OFFSET(x)   offsetof(GBlurVulkanContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static float gaussian (float sigma, float x)
 
static float gaussian_simpson_integration (float sigma, float a, float b)
 
static void init_gaussian_kernel (float *kernel, float sigma, float kernel_size)
 
static void init_kernel_size (GBlurVulkanContext *s, int *out_size)
 
static av_cold void init_gaussian_params (GBlurVulkanContext *s)
 
static int init_gblur_pipeline (GBlurVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVkBuffer *params_buf, VkDescriptorBufferInfo *params_desc, int ksize, float sigma)
 
static av_cold int init_filter (AVFilterContext *ctx, AVFrame *in)
 
static av_cold void gblur_vulkan_uninit (AVFilterContext *avctx)
 
static int process_frames (AVFilterContext *avctx, AVFrame *outframe, AVFrame *inframe)
 
static int gblur_vulkan_filter_frame (AVFilterLink *link, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (gblur_vulkan)
 

Variables

static const char gblur_func []
 
static const AVOption gblur_vulkan_options []
 
static const AVFilterPad gblur_vulkan_inputs []
 
static const AVFilterPad gblur_vulkan_outputs []
 
const AVFilter ff_vf_gblur_vulkan
 

Macro Definition Documentation

◆ CGS

#define CGS   32

Definition at line 25 of file vf_gblur_vulkan.c.

◆ GBLUR_MAX_KERNEL_SIZE

#define GBLUR_MAX_KERNEL_SIZE   127

Definition at line 26 of file vf_gblur_vulkan.c.

◆ OFFSET

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

Definition at line 465 of file vf_gblur_vulkan.c.

◆ FLAGS

Definition at line 466 of file vf_gblur_vulkan.c.

Function Documentation

◆ gaussian()

static float gaussian ( float  sigma,
float  x 
)
inlinestatic

Definition at line 66 of file vf_gblur_vulkan.c.

Referenced by gaussian_simpson_integration().

◆ gaussian_simpson_integration()

static float gaussian_simpson_integration ( float  sigma,
float  a,
float  b 
)
inlinestatic

Definition at line 72 of file vf_gblur_vulkan.c.

Referenced by init_gaussian_kernel().

◆ init_gaussian_kernel()

static void init_gaussian_kernel ( float kernel,
float  sigma,
float  kernel_size 
)
static

Definition at line 78 of file vf_gblur_vulkan.c.

Referenced by init_gblur_pipeline().

◆ init_kernel_size()

static void init_kernel_size ( GBlurVulkanContext s,
int out_size 
)
inlinestatic

Definition at line 98 of file vf_gblur_vulkan.c.

Referenced by init_gaussian_params().

◆ init_gaussian_params()

static av_cold void init_gaussian_params ( GBlurVulkanContext s)
static

Definition at line 110 of file vf_gblur_vulkan.c.

Referenced by init_filter().

◆ init_gblur_pipeline()

static int init_gblur_pipeline ( GBlurVulkanContext s,
FFVulkanPipeline pl,
FFVkSPIRVShader shd,
FFVkBuffer params_buf,
VkDescriptorBufferInfo *  params_desc,
int  ksize,
float  sigma 
)
static

Definition at line 125 of file vf_gblur_vulkan.c.

Referenced by init_filter().

◆ init_filter()

static av_cold int init_filter ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 195 of file vf_gblur_vulkan.c.

Referenced by gblur_vulkan_filter_frame().

◆ gblur_vulkan_uninit()

static av_cold void gblur_vulkan_uninit ( AVFilterContext avctx)
static

Definition at line 287 of file vf_gblur_vulkan.c.

◆ process_frames()

static int process_frames ( AVFilterContext avctx,
AVFrame outframe,
AVFrame inframe 
)
static

Definition at line 300 of file vf_gblur_vulkan.c.

Referenced by gblur_vulkan_filter_frame().

◆ gblur_vulkan_filter_frame()

static int gblur_vulkan_filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 426 of file vf_gblur_vulkan.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( gblur_vulkan  )

Variable Documentation

◆ gblur_func

const char gblur_func[]
static
Initial value:
= {
C(0, void gblur(const ivec2 pos, const int index) )
C(0, { )
C(1, vec4 sum = texture(input_images[index], pos) * kernel[0]; )
C(0, )
C(1, for(int i = 1; i < kernel.length(); i++) { )
C(2, sum += texture(input_images[index], pos + OFFSET) * kernel[i]; )
C(2, sum += texture(input_images[index], pos - OFFSET) * kernel[i]; )
C(1, } )
C(0, )
C(1, imageStore(output_images[index], pos, sum); )
C(0, } )
}

Definition at line 52 of file vf_gblur_vulkan.c.

Referenced by init_gblur_pipeline().

◆ gblur_vulkan_options

const AVOption gblur_vulkan_options[]
static
Initial value:
= {
{ "sigma", "Set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, { .dbl = 0.5 }, 0.01, 1024.0, FLAGS },
{ "sigmaV", "Set vertical sigma", OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0.0, 1024.0, FLAGS },
{ "planes", "Set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, { .i64 = 0xF }, 0, 0xF, FLAGS },
{ "size", "Set kernel size", OFFSET(size), AV_OPT_TYPE_INT, { .i64 = 19 }, 1, GBLUR_MAX_KERNEL_SIZE, FLAGS },
{ "sizeV", "Set vertical kernel size", OFFSET(sizeV), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, GBLUR_MAX_KERNEL_SIZE, FLAGS },
{ NULL },
}

Definition at line 467 of file vf_gblur_vulkan.c.

◆ gblur_vulkan_inputs

const AVFilterPad gblur_vulkan_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = &gblur_vulkan_filter_frame,
.config_props = &ff_vk_filter_config_input,
}
}

Definition at line 478 of file vf_gblur_vulkan.c.

◆ gblur_vulkan_outputs

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

Definition at line 487 of file vf_gblur_vulkan.c.

◆ ff_vf_gblur_vulkan

const AVFilter ff_vf_gblur_vulkan
Initial value:
= {
.name = "gblur_vulkan",
.description = NULL_IF_CONFIG_SMALL("Gaussian Blur in Vulkan"),
.priv_size = sizeof(GBlurVulkanContext),
.priv_class = &gblur_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 495 of file vf_gblur_vulkan.c.

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: internal.h:370
FLAGS
#define FLAGS
Definition: vf_gblur_vulkan.c:466
OFFSET
#define OFFSET(x)
Definition: vf_gblur_vulkan.c:465
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:184
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
gblur_vulkan_inputs
static const AVFilterPad gblur_vulkan_inputs[]
Definition: vf_gblur_vulkan.c:478
gblur_vulkan_outputs
static const AVFilterPad gblur_vulkan_outputs[]
Definition: vf_gblur_vulkan.c:487
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
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
NULL
#define NULL
Definition: coverity.c:32
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:133
GBLUR_MAX_KERNEL_SIZE
#define GBLUR_MAX_KERNEL_SIZE
Definition: vf_gblur_vulkan.c:26
index
int index
Definition: gxfenc.c:89
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:115
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
size
int size
Definition: twinvq_data.h:10344
GBlurVulkanContext
Definition: vf_gblur_vulkan.c:28
gblur_vulkan_uninit
static av_cold void gblur_vulkan_uninit(AVFilterContext *avctx)
Definition: vf_gblur_vulkan.c:287
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:180
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
pos
unsigned int pos
Definition: spdifenc.c:412
gblur_vulkan_filter_frame
static int gblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_gblur_vulkan.c:426
planes
static const struct @347 planes[]
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:52
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:285