FFmpeg
Loading...
Searching...
No Matches
vf_blackdetect_vulkan.c
Go to the documentation of this file.
1/*
2 * Copyright 2025 (c) Niklas Haas
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <float.h>
22#include "libavutil/opt.h"
23#include "libavutil/timestamp.h"
24#include "vulkan_filter.h"
25
26#include "filters.h"
27
28extern const unsigned char ff_blackdetect_comp_spv_data[];
29extern const unsigned int ff_blackdetect_comp_spv_len;
30
33
39
42 int alpha;
43
44 int64_t black_start; ///< pts start time of the first black picture
45 int64_t last_pts; ///< pts of the last filtered frame
46 double black_min_duration_time; ///< minimum duration of detected black, in seconds
47 int64_t black_min_duration; ///< minimum duration of detected black, expressed in timebase units
50
54
55typedef struct BlackDetectBuf {
56#define SLICES 16
57 uint32_t slice_sum[SLICES];
59
61{
62 int err;
64 FFVulkanContext *vkctx = &s->vkctx;
65 const AVFilterLink *inlink = ctx->inputs[0];
66 const int plane = s->alpha ? 3 : 0;
67
68 const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(s->vkctx.input_format);
69 if (pixdesc->flags & AV_PIX_FMT_FLAG_RGB) {
70 av_log(ctx, AV_LOG_ERROR, "RGB inputs are not supported\n");
71 return AVERROR(ENOTSUP);
72 }
73
74 s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
75 if (!s->qf) {
76 av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
77 err = AVERROR(ENOTSUP);
78 goto fail;
79 }
80
81 RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, FF_VK_DEFAULT_EXEC_CONTEXTS, 0, 0, 0, NULL));
82
83 SPEC_LIST_CREATE(sl, 2, 2*sizeof(uint32_t))
84 SPEC_LIST_ADD(sl, 0, 32, plane);
85 SPEC_LIST_ADD(sl, 1, 32, SLICES);
86
87 ff_vk_shader_load(&s->shd, VK_SHADER_STAGE_COMPUTE_BIT, sl,
88 (int []) { 32, 32, 1 }, 0);
89
91 VK_SHADER_STAGE_COMPUTE_BIT);
92
94 { /* input_img */
95 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
96 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
97 .elems = av_pix_fmt_count_planes(s->vkctx.input_format),
98 },
99 { /* sum_buffer */
100 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
101 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
102 }
103 };
104 ff_vk_shader_add_descriptor_set(vkctx, &s->shd, desc, 2, 0);
105
106 RET(ff_vk_shader_link(vkctx, &s->shd,
109
110 RET(ff_vk_shader_register_exec(vkctx, &s->e, &s->shd));
111
112 s->time_base = inlink->time_base;
113 s->black_min_duration = s->black_min_duration_time / av_q2d(s->time_base);
114 s->black_start = AV_NOPTS_VALUE;
115 s->initialized = 1;
116
117fail:
118 return err;
119}
120
122{
124
125 if (s->black_start == AV_NOPTS_VALUE)
126 return;
127
128 if ((black_end - s->black_start) >= s->black_min_duration) {
130 "black_start:%s black_end:%s black_duration:%s\n",
131 av_ts2timestr(s->black_start, &s->time_base),
132 av_ts2timestr(black_end, &s->time_base),
133 av_ts2timestr(black_end - s->black_start, &s->time_base));
134 }
135}
136
137static void evaluate(AVFilterLink *link, AVFrame *in,
138 const BlackDetectBuf *sum)
139{
140 AVFilterContext *ctx = link->dst;
142 FilterLink *inl = ff_filter_link(link);
143 uint64_t nb_black_pixels = 0;
144 double ratio;
145
146 for (int i = 0; i < FF_ARRAY_ELEMS(sum->slice_sum); i++)
147 nb_black_pixels += sum->slice_sum[i];
148
149 ratio = (double) nb_black_pixels / (link->w * link->h);
150
152 "frame:%"PRId64" picture_black_ratio:%f pts:%s t:%s type:%c\n",
153 inl->frame_count_out, ratio,
154 av_ts2str(in->pts), av_ts2timestr(in->pts, &in->time_base),
156
157 if (ratio >= s->picture_black_ratio_th) {
158 if (s->black_start == AV_NOPTS_VALUE) {
159 s->black_start = in->pts;
160 av_dict_set(&in->metadata, "lavfi.black_start",
161 av_ts2timestr(in->pts, &in->time_base), 0);
162 }
163 } else if (s->black_start != AV_NOPTS_VALUE) {
165 av_dict_set(&in->metadata, "lavfi.black_end",
166 av_ts2timestr(in->pts, &in->time_base), 0);
167 s->black_start = AV_NOPTS_VALUE;
168 }
169}
170
172{
173 int err;
174 AVFilterContext *ctx = link->dst;
176 AVFilterLink *outlink = ctx->outputs[0];
177
178 VkImageView in_views[AV_NUM_DATA_POINTERS];
179 VkImageMemoryBarrier2 img_bar[4];
180 int nb_img_bar = 0;
181
182 FFVulkanContext *vkctx = &s->vkctx;
183 FFVulkanFunctions *vk = &vkctx->vkfn;
184 FFVkExecContext *exec = NULL;
185 FFVkBuffer *sum_vk = NULL;
186
187 BlackDetectBuf *sum;
188 BlackDetectPushData push_data;
189
190 if (in->color_range == AVCOL_RANGE_JPEG || s->alpha) {
191 push_data.threshold = s->pixel_black_th;
192 } else {
194 const int depth = desc->comp[0].depth;
195 const int ymin = 16 << (depth - 8);
196 const int ymax = 235 << (depth - 8);
197 const int imax = (1 << depth) - 1;
198 push_data.threshold = (s->pixel_black_th * (ymax - ymin) + ymin) / imax;
199 }
200
201 if (!s->initialized)
203
204 err = ff_vk_get_pooled_buffer(vkctx, &s->sum_buf_pool, &sum_vk,
205 VK_BUFFER_USAGE_TRANSFER_DST_BIT |
206 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
207 NULL,
208 sizeof(BlackDetectBuf),
209 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
210 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
211 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
212 if (err < 0)
213 return err;
214 sum = (BlackDetectBuf *) sum_vk->mapped_mem;
215
216 exec = ff_vk_exec_get(vkctx, &s->e);
217 ff_vk_exec_start(vkctx, exec);
218
219 RET(ff_vk_exec_add_dep_frame(vkctx, exec, in,
220 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
221 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
222 RET(ff_vk_create_imageviews(vkctx, exec, in_views, in, FF_VK_REP_FLOAT));
223
224 ff_vk_shader_update_img_array(vkctx, exec, &s->shd, in, in_views, 0, 0,
225 VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
226
227 ff_vk_frame_barrier(vkctx, exec, in, img_bar, &nb_img_bar,
228 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
229 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
230 VK_ACCESS_SHADER_READ_BIT,
231 VK_IMAGE_LAYOUT_GENERAL,
232 VK_QUEUE_FAMILY_IGNORED);
233
234 /* zero sum buffer */
235 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
236 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
237 .pBufferMemoryBarriers = &(VkBufferMemoryBarrier2) {
238 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
239 .srcStageMask = VK_PIPELINE_STAGE_2_NONE,
240 .dstStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT,
241 .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
242 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
243 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
244 .buffer = sum_vk->buf,
245 .size = sum_vk->size,
246 .offset = 0,
247 },
248 .bufferMemoryBarrierCount = 1,
249 });
250
251 vk->CmdFillBuffer(exec->buf, sum_vk->buf, 0, sum_vk->size, 0x0);
252
253 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
254 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
255 .pImageMemoryBarriers = img_bar,
256 .imageMemoryBarrierCount = nb_img_bar,
257 .pBufferMemoryBarriers = &(VkBufferMemoryBarrier2) {
258 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
259 .srcStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT,
260 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
261 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
262 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
263 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
264 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
265 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
266 .buffer = sum_vk->buf,
267 .size = sum_vk->size,
268 .offset = 0,
269 },
270 .bufferMemoryBarrierCount = 1,
271 });
272
273 RET(ff_vk_shader_update_desc_buffer(&s->vkctx, exec, &s->shd, 0, 1, 0,
274 sum_vk, 0, sum_vk->size,
275 VK_FORMAT_UNDEFINED));
276
277 ff_vk_exec_bind_shader(vkctx, exec, &s->shd);
278 ff_vk_shader_update_push_const(vkctx, exec, &s->shd, VK_SHADER_STAGE_COMPUTE_BIT,
279 0, sizeof(push_data), &push_data);
280
281 vk->CmdDispatch(exec->buf,
282 FFALIGN(in->width, s->shd.lg_size[0]) / s->shd.lg_size[0],
283 FFALIGN(in->height, s->shd.lg_size[1]) / s->shd.lg_size[1],
284 s->shd.lg_size[2]);
285
286 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
287 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
288 .pBufferMemoryBarriers = &(VkBufferMemoryBarrier2) {
289 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
290 .srcStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
291 .dstStageMask = VK_PIPELINE_STAGE_2_HOST_BIT,
292 .srcAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
293 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
294 .dstAccessMask = VK_ACCESS_HOST_READ_BIT,
295 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
296 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
297 .buffer = sum_vk->buf,
298 .size = sum_vk->size,
299 .offset = 0,
300 },
301 .bufferMemoryBarrierCount = 1,
302 });
303
304 RET(ff_vk_exec_submit(vkctx, exec));
305 ff_vk_exec_wait(vkctx, exec);
306 evaluate(link, in, sum);
307 s->last_pts = in->pts;
308
309 av_refstruct_unref(&sum_vk);
310 return ff_filter_frame(outlink, in);
311
312fail:
313 if (exec)
314 ff_vk_exec_discard_deps(&s->vkctx, exec);
315 av_frame_free(&in);
316 av_refstruct_unref(&sum_vk);
317 return err;
318}
319
321{
323 FFVulkanContext *vkctx = &s->vkctx;
324
325 /* the input link may be gone here: during graph teardown the upstream
326 * filter can be freed first. Use the cached pts of the last frame */
327 if (s->initialized)
328 report_black_region(avctx, s->last_pts);
329
330 ff_vk_exec_pool_free(vkctx, &s->e);
331 ff_vk_shader_free(vkctx, &s->shd);
332
333 av_refstruct_pool_uninit(&s->sum_buf_pool);
334
335 ff_vk_uninit(&s->vkctx);
336
337 s->initialized = 0;
338}
339
340static int config_output(AVFilterLink *outlink)
341{
342 AVFilterContext *ctx = outlink->src;
344 FFVulkanContext *vkctx = &s->vkctx;
346
347 if (s->alpha && !(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) {
348 av_log(ctx, AV_LOG_ERROR, "Input format %s does not have an alpha channel\n",
350 return AVERROR(EINVAL);
351 }
352
354 !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) {
355 av_log(ctx, AV_LOG_ERROR, "Input format %s is not planar YUV\n",
357 return AVERROR(EINVAL);
358 }
359
360 return ff_vk_filter_config_output(outlink);
361}
362
363#define OFFSET(x) offsetof(BlackDetectVulkanContext, x)
364#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
366 { "d", "set minimum detected black duration in seconds", OFFSET(black_min_duration_time), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 0, DBL_MAX, FLAGS },
367 { "black_min_duration", "set minimum detected black duration in seconds", OFFSET(black_min_duration_time), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 0, DBL_MAX, FLAGS },
368 { "picture_black_ratio_th", "set the picture black ratio threshold", OFFSET(picture_black_ratio_th), AV_OPT_TYPE_DOUBLE, {.dbl=.98}, 0, 1, FLAGS },
369 { "pic_th", "set the picture black ratio threshold", OFFSET(picture_black_ratio_th), AV_OPT_TYPE_DOUBLE, {.dbl=.98}, 0, 1, FLAGS },
370 { "pixel_black_th", "set the pixel black threshold", OFFSET(pixel_black_th), AV_OPT_TYPE_DOUBLE, {.dbl=.10}, 0, 1, FLAGS },
371 { "pix_th", "set the pixel black threshold", OFFSET(pixel_black_th), AV_OPT_TYPE_DOUBLE, {.dbl=.10}, 0, 1, FLAGS },
372 { "alpha", "check alpha instead of luma", OFFSET(alpha), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
373 { NULL }
374};
375
376AVFILTER_DEFINE_CLASS(blackdetect_vulkan);
377
379 {
380 .name = "default",
381 .type = AVMEDIA_TYPE_VIDEO,
382 .filter_frame = &blackdetect_vulkan_filter_frame,
383 .config_props = &ff_vk_filter_config_input,
384 },
385};
386
388 {
389 .name = "default",
390 .type = AVMEDIA_TYPE_VIDEO,
391 .config_props = &config_output,
392 },
393};
394
396 .p.name = "blackdetect_vulkan",
397 .p.description = NULL_IF_CONFIG_SMALL("Detect video intervals that are (almost) black."),
398 .p.priv_class = &blackdetect_vulkan_class,
399 .p.flags = AVFILTER_FLAG_HWDEVICE,
400 .priv_size = sizeof(BlackDetectVulkanContext),
406 .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
407};
const FFFilter ff_vf_blackdetect_vulkan
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AV_NUM_DATA_POINTERS
Definition frame.h:473
#define fail
Definition test.h:479
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition avfilter.h:187
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:86
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition rational.h:104
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
Definition utils.c:40
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
static const int16_t alpha[]
Definition ilbcdata.h:55
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#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:208
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition filters.h:254
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
void ff_vk_shader_update_img_array(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
Update a descriptor in a buffer with an image array.
Definition vulkan.c:2542
int ff_vk_shader_load(FFVulkanShader *shd, VkPipelineStageFlags stage, VkSpecializationInfo *spec, uint32_t wg_size[3], uint32_t required_subgroup_size)
Initialize a shader object.
Definition vulkan.c:2070
void ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
Add descriptor to a shader.
Definition vulkan.c:2373
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition vulkan.c:310
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.
Definition vulkan.c:357
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
Definition vulkan.c:590
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
Definition vulkan.c:1443
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition vulkan.c:2638
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags2 src_stage, VkPipelineStageFlags2 dst_stage, VkAccessFlagBits2 new_access, VkImageLayout new_layout, uint32_t new_qf)
Definition vulkan.c:2027
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition vulkan.c:599
int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
Create an imageview and add it as a dependency to an execution.
Definition vulkan.c:1958
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition vulkan.c:2614
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
Definition vulkan.c:2407
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition vulkan.c:571
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition vulkan.c:881
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
Bind a shader.
Definition vulkan.c:2591
int ff_vk_shader_update_desc_buffer(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, int bind, int elem, FFVkBuffer *buf, VkDeviceSize offset, VkDeviceSize len, VkFormat fmt)
Update a descriptor in a buffer with a buffer.
Definition vulkan.c:2555
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
Definition vulkan.c:297
int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVRefStructPool **buf_pool, FFVkBuffer **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
Initialize a pool and create AVBufferRefs containing FFVkBuffer.
Definition vulkan.c:1256
void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e)
Definition vulkan.c:636
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, const char *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
Definition vulkan.c:2267
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
Definition vulkan.c:777
void ff_vk_shader_update_push_const(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Update push constant in a shader.
Definition vulkan.c:2581
const char * desc
Definition libsvtav1.c:83
#define FFALIGN(x, a)
Definition macros.h:78
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3500
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition pixdesc.c:3380
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition pixdesc.h:147
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition pixdesc.h:136
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition pixdesc.h:132
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
Definition pixdesc.h:163
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:783
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition pixfmt.h:379
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition refstruct.c:120
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
Definition refstruct.h:292
#define FF_ARRAY_ELEMS(a)
An instance of a filter.
Definition avfilter.h:273
void * priv
private data for use by the filter
Definition avfilter.h:288
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:574
AVRational time_base
Time base for the timestamps in this frame.
Definition frame.h:589
AVDictionary * metadata
metadata.
Definition frame.h:750
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition frame.h:723
enum AVPictureType pict_type
Picture type of the frame.
Definition frame.h:564
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
uint64_t flags
Combination of AV_PIX_FMT_FLAG_... flags.
Definition pixdesc.h:94
Rational number (pair of numerator and denominator).
Definition rational.h:58
AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
Definition refstruct.c:183
uint32_t slice_sum[SLICES]
int64_t black_start
pts start time of the first black picture
int64_t last_pts
pts of the last filtered frame
AVVulkanDeviceQueueFamily * qf
double black_min_duration_time
minimum duration of detected black, in seconds
int64_t black_min_duration
minimum duration of detected black, expressed in timebase units
uint8_t * mapped_mem
Definition vulkan.h:103
VkCommandBuffer buf
Definition vulkan.h:139
enum AVPixelFormat input_format
Definition vulkan.h:343
FFVulkanFunctions vkfn
Definition vulkan.h:294
#define av_log(a,...)
static int imax(const int a, const int b)
Definition internal.h:177
static AVFormatContext * ctx
Definition movenc.c:49
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:54
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:83
static const AVFilterPad blackdetect_vulkan_inputs[]
const unsigned int ff_blackdetect_comp_spv_len
static av_cold int init_filter(AVFilterContext *ctx)
static const AVFilterPad blackdetect_vulkan_outputs[]
static void report_black_region(AVFilterContext *ctx, int64_t black_end)
#define SLICES
static const AVOption blackdetect_vulkan_options[]
static void evaluate(AVFilterLink *link, AVFrame *in, const BlackDetectBuf *sum)
static int blackdetect_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
static void blackdetect_vulkan_uninit(AVFilterContext *avctx)
#define OFFSET(x)
static int config_output(AVFilterLink *outlink)
const unsigned char ff_blackdetect_comp_spv_data[]
@ FF_VK_REP_FLOAT
Definition vulkan.h:431
#define FF_VK_DEFAULT_EXEC_CONTEXTS
Definition vulkan.h:121
#define RET(x)
Definition vulkan.h:37
#define SPEC_LIST_ADD(name, idx, val_bits, val)
Definition vulkan.h:55
#define SPEC_LIST_CREATE(name, max_length, max_size)
Definition vulkan.h:45
int ff_vk_filter_config_input(AVFilterLink *inlink)
int ff_vk_filter_config_output(AVFilterLink *outlink)
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.