FFmpeg
vf_chromaber_vulkan.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/random_seed.h"
20 #include "libavutil/opt.h"
21 #include "vulkan_filter.h"
22 #include "internal.h"
23 
24 #define CGROUPS (int [3]){ 32, 32, 1 }
25 
28 
33 
34  /* Shader updators, must be in the main filter struct */
35  VkDescriptorImageInfo input_images[3];
36  VkDescriptorImageInfo output_images[3];
37 
38  /* Push constants / options */
39  struct {
40  float dist[2];
41  } opts;
43 
44 static const char distort_chroma_kernel[] = {
45  C(0, void distort_rgb(ivec2 size, ivec2 pos) )
46  C(0, { )
47  C(1, const vec2 p = ((vec2(pos)/vec2(size)) - 0.5f)*2.0f; )
48  C(1, const vec2 o = p * (dist - 1.0f); )
49  C(0, )
50  C(1, vec4 res; )
51  C(1, res.r = texture(input_img[0], ((p - o)/2.0f) + 0.5f).r; )
52  C(1, res.g = texture(input_img[0], ((p )/2.0f) + 0.5f).g; )
53  C(1, res.b = texture(input_img[0], ((p + o)/2.0f) + 0.5f).b; )
54  C(1, res.a = texture(input_img[0], ((p )/2.0f) + 0.5f).a; )
55  C(1, imageStore(output_img[0], pos, res); )
56  C(0, } )
57  C(0, )
58  C(0, void distort_chroma(int idx, ivec2 size, ivec2 pos) )
59  C(0, { )
60  C(1, vec2 p = ((vec2(pos)/vec2(size)) - 0.5f)*2.0f; )
61  C(1, float d = sqrt(p.x*p.x + p.y*p.y); )
62  C(1, p *= d / (d* dist); )
63  C(1, vec4 res = texture(input_img[idx], (p/2.0f) + 0.5f); )
64  C(1, imageStore(output_img[idx], pos, res); )
65  C(0, } )
66 };
67 
69 {
70  int err;
71  FFVkSampler *sampler;
73  FFVulkanContext *vkctx = &s->vkctx;
74  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
75 
76  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT, 0);
77 
78  /* Create a sampler */
79  sampler = ff_vk_init_sampler(vkctx, 0, VK_FILTER_LINEAR);
80  if (!sampler)
81  return AVERROR_EXTERNAL;
82 
83  s->pl = ff_vk_create_pipeline(vkctx, &s->qf);
84  if (!s->pl)
85  return AVERROR(ENOMEM);
86 
87  /* Normalize options */
88  s->opts.dist[0] = (s->opts.dist[0] / 100.0f) + 1.0f;
89  s->opts.dist[1] = (s->opts.dist[1] / 100.0f) + 1.0f;
90 
91  { /* Create the shader */
92  FFVulkanDescriptorSetBinding desc_i[2] = {
93  {
94  .name = "input_img",
95  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
96  .dimensions = 2,
97  .elems = planes,
98  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
99  .updater = s->input_images,
100  .sampler = sampler,
101  },
102  {
103  .name = "output_img",
104  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
105  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
106  .mem_quali = "writeonly",
107  .dimensions = 2,
108  .elems = planes,
109  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
110  .updater = s->output_images,
111  },
112  };
113 
114  FFVkSPIRVShader *shd = ff_vk_init_shader(s->pl, "chromaber_compute",
115  VK_SHADER_STAGE_COMPUTE_BIT);
116  if (!shd)
117  return AVERROR(ENOMEM);
118 
120 
121  GLSLC(0, layout(push_constant, std430) uniform pushConstants { );
122  GLSLC(1, vec2 dist; );
123  GLSLC(0, }; );
124  GLSLC(0, );
125 
126  ff_vk_add_push_constant(s->pl, 0, sizeof(s->opts),
127  VK_SHADER_STAGE_COMPUTE_BIT);
128 
129  RET(ff_vk_add_descriptor_set(vkctx, s->pl, shd, desc_i, FF_ARRAY_ELEMS(desc_i), 0)); /* set 0 */
130 
132  GLSLC(0, void main() );
133  GLSLC(0, { );
134  GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
135  if (planes == 1) {
136  GLSLC(1, distort_rgb(imageSize(output_img[0]), pos); );
137  } else {
138  GLSLC(1, ivec2 size = imageSize(output_img[0]); );
139  GLSLC(1, vec2 npos = vec2(pos)/vec2(size); );
140  GLSLC(1, vec4 res = texture(input_img[0], npos); );
141  GLSLC(1, imageStore(output_img[0], pos, res); );
142  for (int i = 1; i < planes; i++) {
143  GLSLC(0, );
144  GLSLF(1, size = imageSize(output_img[%i]); ,i);
145  GLSLC(1, if (IS_WITHIN(pos, size)) { );
146  GLSLF(2, distort_chroma(%i, size, pos); ,i);
147  GLSLC(1, } else { );
148  GLSLC(2, npos = vec2(pos)/vec2(size); );
149  GLSLF(2, res = texture(input_img[%i], npos); ,i);
150  GLSLF(2, imageStore(output_img[%i], pos, res); ,i);
151  GLSLC(1, } );
152  }
153  }
154  GLSLC(0, } );
155 
156  RET(ff_vk_compile_shader(vkctx, shd, "main"));
157  }
158 
159  RET(ff_vk_init_pipeline_layout(vkctx, s->pl));
160  RET(ff_vk_init_compute_pipeline(vkctx, s->pl));
161 
162  /* Execution context */
163  RET(ff_vk_create_exec_ctx(vkctx, &s->exec, &s->qf));
164 
165  s->initialized = 1;
166 
167  return 0;
168 
169 fail:
170  return err;
171 }
172 
173 static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *in_f)
174 {
175  int err = 0;
176  VkCommandBuffer cmd_buf;
178  FFVulkanContext *vkctx = &s->vkctx;
179  FFVulkanFunctions *vk = &vkctx->vkfn;
180  AVVkFrame *in = (AVVkFrame *)in_f->data[0];
181  AVVkFrame *out = (AVVkFrame *)out_f->data[0];
182  int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
183  const VkFormat *input_formats = av_vkfmt_from_pixfmt(s->vkctx.input_format);
184  const VkFormat *ouput_formats = av_vkfmt_from_pixfmt(s->vkctx.output_format);
185 
186  /* Update descriptors and init the exec context */
187  ff_vk_start_exec_recording(vkctx, s->exec);
188  cmd_buf = ff_vk_get_exec_buf(s->exec);
189 
190  for (int i = 0; i < planes; i++) {
191  RET(ff_vk_create_imageview(vkctx, s->exec,
192  &s->input_images[i].imageView, in->img[i],
193  input_formats[i],
195 
196  RET(ff_vk_create_imageview(vkctx, s->exec,
197  &s->output_images[i].imageView, out->img[i],
198  ouput_formats[i],
200 
201  s->input_images[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
202  s->output_images[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
203  }
204 
205  ff_vk_update_descriptor_set(vkctx, s->pl, 0);
206 
207  for (int i = 0; i < planes; i++) {
208  VkImageMemoryBarrier bar[2] = {
209  {
210  .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
211  .srcAccessMask = 0,
212  .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
213  .oldLayout = in->layout[i],
214  .newLayout = s->input_images[i].imageLayout,
215  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
216  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
217  .image = in->img[i],
218  .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
219  .subresourceRange.levelCount = 1,
220  .subresourceRange.layerCount = 1,
221  },
222  {
223  .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
224  .srcAccessMask = 0,
225  .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
226  .oldLayout = out->layout[i],
227  .newLayout = s->output_images[i].imageLayout,
228  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
229  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
230  .image = out->img[i],
231  .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
232  .subresourceRange.levelCount = 1,
233  .subresourceRange.layerCount = 1,
234  },
235  };
236 
237  vk->CmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
238  VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0,
239  0, NULL, 0, NULL, FF_ARRAY_ELEMS(bar), bar);
240 
241  in->layout[i] = bar[0].newLayout;
242  in->access[i] = bar[0].dstAccessMask;
243 
244  out->layout[i] = bar[1].newLayout;
245  out->access[i] = bar[1].dstAccessMask;
246  }
247 
248  ff_vk_bind_pipeline_exec(vkctx, s->exec, s->pl);
249 
250  ff_vk_update_push_exec(vkctx, s->exec, VK_SHADER_STAGE_COMPUTE_BIT,
251  0, sizeof(s->opts), &s->opts);
252 
253  vk->CmdDispatch(cmd_buf,
254  FFALIGN(s->vkctx.output_width, CGROUPS[0])/CGROUPS[0],
255  FFALIGN(s->vkctx.output_height, CGROUPS[1])/CGROUPS[1], 1);
256 
257  ff_vk_add_exec_dep(vkctx, s->exec, in_f, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
258  ff_vk_add_exec_dep(vkctx, s->exec, out_f, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
259 
260  err = ff_vk_submit_exec_queue(vkctx, s->exec);
261  if (err)
262  return err;
263 
264  ff_vk_qf_rotate(&s->qf);
265 
266  return err;
267 
268 fail:
269  ff_vk_discard_exec_deps(s->exec);
270  return err;
271 }
272 
274 {
275  int err;
276  AVFilterContext *ctx = link->dst;
278  AVFilterLink *outlink = ctx->outputs[0];
279 
280  AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
281  if (!out) {
282  err = AVERROR(ENOMEM);
283  goto fail;
284  }
285 
286  if (!s->initialized)
287  RET(init_filter(ctx, in));
288 
289  RET(process_frames(ctx, out, in));
290 
291  err = av_frame_copy_props(out, in);
292  if (err < 0)
293  goto fail;
294 
295  av_frame_free(&in);
296 
297  return ff_filter_frame(outlink, out);
298 
299 fail:
300  av_frame_free(&in);
301  av_frame_free(&out);
302  return err;
303 }
304 
306 {
308 
309  ff_vk_uninit(&s->vkctx);
310 
311  s->initialized = 0;
312 }
313 
314 #define OFFSET(x) offsetof(ChromaticAberrationVulkanContext, x)
315 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
317  { "dist_x", "Set horizontal distortion amount", OFFSET(opts.dist[0]), AV_OPT_TYPE_FLOAT, {.dbl = 0.0f}, -10.0f, 10.0f, .flags = FLAGS },
318  { "dist_y", "Set vertical distortion amount", OFFSET(opts.dist[1]), AV_OPT_TYPE_FLOAT, {.dbl = 0.0f}, -10.0f, 10.0f, .flags = FLAGS },
319  { NULL },
320 };
321 
322 AVFILTER_DEFINE_CLASS(chromaber_vulkan);
323 
325  {
326  .name = "default",
327  .type = AVMEDIA_TYPE_VIDEO,
328  .filter_frame = &chromaber_vulkan_filter_frame,
329  .config_props = &ff_vk_filter_config_input,
330  },
331 };
332 
334  {
335  .name = "default",
336  .type = AVMEDIA_TYPE_VIDEO,
337  .config_props = &ff_vk_filter_config_output,
338  },
339 };
340 
342  .name = "chromaber_vulkan",
343  .description = NULL_IF_CONFIG_SMALL("Offset chroma of input video (chromatic aberration)"),
344  .priv_size = sizeof(ChromaticAberrationVulkanContext),
350  .priv_class = &chromaber_vulkan_class,
351  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
352 };
ChromaticAberrationVulkanContext::pl
FFVulkanPipeline * pl
Definition: vf_chromaber_vulkan.c:32
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:101
planes
static const struct @346 planes[]
r
const char * r
Definition: vf_curves.c:126
AVERROR
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
opt.h
ff_comp_identity_map
const VkComponentMapping ff_comp_identity_map
Definition: vulkan.c:51
out
FILE * out
Definition: movenc.c:54
ChromaticAberrationVulkanContext::dist
float dist[2]
Definition: vf_chromaber_vulkan.c:40
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:374
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:969
ff_vk_bind_pipeline_exec
void ff_vk_bind_pipeline_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
Definition: vulkan.c:1264
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:99
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
chromaber_vulkan_uninit
static void chromaber_vulkan_uninit(AVFilterContext *avctx)
Definition: vf_chromaber_vulkan.c:305
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:184
OFFSET
#define OFFSET(x)
Definition: vf_chromaber_vulkan.c:314
AVOption
AVOption.
Definition: opt.h:251
b
#define b
Definition: input.c:41
ff_vk_compile_shader
int ff_vk_compile_shader(FFVulkanContext *s, FFVkSPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
Definition: vulkan.c:849
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees the main Vulkan context.
Definition: vulkan.c:1379
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:165
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
FFVkSampler
Definition: vulkan.h:74
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:351
ff_vk_add_exec_dep
int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.
Definition: vulkan.c:509
ff_vk_get_exec_buf
VkCommandBuffer ff_vk_get_exec_buf(FFVkExecContext *e)
Gets the command buffer to use for this submission from the exe context.
Definition: vulkan.c:504
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2928
ff_vk_add_push_constant
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Define a push constant for a given stage into a pipeline.
Definition: vulkan.c:364
AVVkFrame::img
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
Definition: hwcontext_vulkan.h:217
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:407
fail
#define fail()
Definition: checkasm.h:134
vulkan_filter.h
ChromaticAberrationVulkanContext
Definition: vf_chromaber_vulkan.c:26
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
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
ff_vk_qf_init
void ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family, int nb_queues)
Initialize a queue family with a specific number of queues.
Definition: vulkan.c:96
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
ff_vk_create_imageview
int ff_vk_create_imageview(FFVulkanContext *s, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.
Definition: vulkan.c:742
FLAGS
#define FLAGS
Definition: vf_chromaber_vulkan.c:315
ff_vf_chromaber_vulkan
const AVFilter ff_vf_chromaber_vulkan
Definition: vf_chromaber_vulkan.c:341
s
#define s(width, name)
Definition: cbs_vp9.c:256
g
const char * g
Definition: vf_curves.c:127
ChromaticAberrationVulkanContext::opts
struct ChromaticAberrationVulkanContext::@238 opts
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
ff_vk_init_shader
FFVkSPIRVShader * ff_vk_init_shader(FFVulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.
Definition: vulkan.c:795
chromaber_vulkan_options
static const AVOption chromaber_vulkan_options[]
Definition: vf_chromaber_vulkan.c:316
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ChromaticAberrationVulkanContext::input_images
VkDescriptorImageInfo input_images[3]
Definition: vf_chromaber_vulkan.c:35
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
link
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 link
Definition: filter_design.txt:23
ff_vk_update_descriptor_set
void ff_vk_update_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
Definition: vulkan.c:1080
ff_vk_start_exec_recording
int ff_vk_start_exec_recording(FFVulkanContext *s, FFVkExecContext *e)
Begin recording to the command buffer.
Definition: vulkan.c:463
opts
AVDictionary * opts
Definition: movenc.c:50
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:594
GLSLD
#define GLSLD(D)
Definition: vulkan.h:47
ff_vk_update_push_exec
void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Updates push constants.
Definition: vulkan.c:1106
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(chromaber_vulkan)
ff_vk_create_exec_ctx
int ff_vk_create_exec_ctx(FFVulkanContext *s, FFVkExecContext **ctx, FFVkQueueFamilyCtx *qf)
Init an execution context for command recording and queue submission.
Definition: vulkan.c:385
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:133
ff_vk_qf_rotate
void ff_vk_qf_rotate(FFVkQueueFamilyCtx *qf)
Rotate through the queues in a queue family.
Definition: vulkan.c:132
FFVulkanContext
Definition: vulkan.h:188
FFVulkanPipeline
Definition: vulkan.h:104
chromaber_vulkan_outputs
static const AVFilterPad chromaber_vulkan_outputs[]
Definition: vf_chromaber_vulkan.c:333
ff_vk_discard_exec_deps
void ff_vk_discard_exec_deps(FFVkExecContext *e)
Discards all queue dependencies.
Definition: vulkan.c:447
main
int main(int argc, char **argv)
Definition: avio_http_serve_files.c:99
init_filter
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
Definition: vf_chromaber_vulkan.c:68
f
f
Definition: af_crystalizer.c:122
AVVkFrame::access
VkAccessFlagBits access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
Definition: hwcontext_vulkan.h:240
FFVulkanDescriptorSetBinding
Definition: vulkan.h:78
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
AVVkFrame
Definition: hwcontext_vulkan.h:213
CGROUPS
#define CGROUPS
Definition: vf_chromaber_vulkan.c:24
ff_vk_init_pipeline_layout
int ff_vk_init_pipeline_layout(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
Definition: vulkan.c:1116
size
int size
Definition: twinvq_data.h:10344
FFVkQueueFamilyCtx
Definition: vulkan.h:97
process_frames
static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *in_f)
Definition: vf_chromaber_vulkan.c:173
chromaber_vulkan_filter_frame
static int chromaber_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_chromaber_vulkan.c:273
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
ff_vk_submit_exec_queue
int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e)
Submits a command buffer to the queue for execution.
Definition: vulkan.c:590
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVkExecContext
Definition: vulkan.h:154
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:79
ChromaticAberrationVulkanContext::exec
FFVkExecContext * exec
Definition: vf_chromaber_vulkan.c:31
internal.h
av_vkfmt_from_pixfmt
const VkFormat * av_vkfmt_from_pixfmt(enum AVPixelFormat p)
Returns the format of each image up to the number of planes for a given sw_format.
Definition: hwcontext_stub.c:30
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
ChromaticAberrationVulkanContext::output_images
VkDescriptorImageInfo output_images[3]
Definition: vf_chromaber_vulkan.c:36
layout
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 layout
Definition: filter_design.txt:18
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:184
ChromaticAberrationVulkanContext::initialized
int initialized
Definition: vf_chromaber_vulkan.c:29
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes a compute pipeline.
Definition: vulkan.c:1229
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
VkFormat
enum VkFormat VkFormat
Definition: hwcontext_stub.c:25
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Gets the glsl format string for a pixel format.
Definition: vulkan.c:721
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:46
ff_vk_create_pipeline
FFVulkanPipeline * ff_vk_create_pipeline(FFVulkanContext *s, FFVkQueueFamilyCtx *qf)
Inits a pipeline.
Definition: vulkan.c:1220
ChromaticAberrationVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_chromaber_vulkan.c:27
AVFilter
Filter definition.
Definition: avfilter.h:161
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:191
pos
unsigned int pos
Definition: spdifenc.c:413
ff_vk_add_descriptor_set
int ff_vk_add_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int num, int only_print_to_shader)
Adds a descriptor set to the shader and registers them in the pipeline.
Definition: vulkan.c:923
random_seed.h
FFVkSPIRVShader
Definition: vulkan.h:58
ff_vk_init_sampler
FFVkSampler * ff_vk_init_sampler(FFVulkanContext *s, int unnorm_coords, VkFilter filt)
Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
Definition: vulkan.c:670
AVFilterContext
An instance of a filter.
Definition: avfilter.h:392
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:44
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
AVVkFrame::layout
VkImageLayout layout[AV_NUM_DATA_POINTERS]
Definition: hwcontext_vulkan.h:241
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
ff_vk_set_compute_shader_sizes
void ff_vk_set_compute_shader_sizes(FFVkSPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
Definition: vulkan.c:816
d
d
Definition: ffmpeg_filter.c:156
distort_chroma_kernel
static const char distort_chroma_kernel[]
Definition: vf_chromaber_vulkan.c:44
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:285
chromaber_vulkan_inputs
static const AVFilterPad chromaber_vulkan_inputs[]
Definition: vf_chromaber_vulkan.c:324
RET
#define RET(x)
Definition: vulkan.h:52
FFVulkanFunctions
Definition: vulkan_functions.h:175
ChromaticAberrationVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_chromaber_vulkan.c:30