Go to the documentation of this file.
79 (
int []) { 32, 32, 1 }, 0);
83 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
84 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
88 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
89 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
93 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
94 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
125 mafd = (
double) sad * 100.0 / count / (1ULL <<
desc->comp[0].depth);
141 VkImageMemoryBarrier2 img_bar[8];
164 VK_BUFFER_USAGE_TRANSFER_DST_BIT |
165 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
168 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
169 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
170 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT));
178 VK_PIPELINE_STAGE_2_NONE,
179 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
183 VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
186 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
187 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
188 VK_ACCESS_SHADER_READ_BIT,
189 VK_IMAGE_LAYOUT_GENERAL,
190 VK_QUEUE_FAMILY_IGNORED);
193 VK_PIPELINE_STAGE_2_NONE,
194 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
198 VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
201 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
202 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
203 VK_ACCESS_SHADER_READ_BIT,
204 VK_IMAGE_LAYOUT_GENERAL,
205 VK_QUEUE_FAMILY_IGNORED);
208 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
209 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
210 .pBufferMemoryBarriers = &(VkBufferMemoryBarrier2) {
211 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
212 .srcStageMask = VK_PIPELINE_STAGE_2_NONE,
213 .dstStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT,
214 .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
215 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
216 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
217 .buffer = buf_vk->buf,
218 .size = buf_vk->size,
221 .bufferMemoryBarrierCount = 1,
224 vk->CmdFillBuffer(exec->buf, buf_vk->buf, 0, buf_vk->size, 0x0);
226 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
227 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
228 .pImageMemoryBarriers = img_bar,
229 .imageMemoryBarrierCount = nb_img_bar,
230 .pBufferMemoryBarriers = &(VkBufferMemoryBarrier2) {
231 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
232 .srcStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT,
233 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
234 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
235 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
236 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
237 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
238 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
239 .buffer = buf_vk->buf,
240 .size = buf_vk->size,
243 .bufferMemoryBarrierCount = 1,
247 buf_vk, 0, buf_vk->size,
248 VK_FORMAT_UNDEFINED));
252 vk->CmdDispatch(exec->buf,
253 FFALIGN(in->width,
s->shd.lg_size[0]) /
s->shd.lg_size[0],
254 FFALIGN(in->height,
s->shd.lg_size[1]) /
s->shd.lg_size[1],
257 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
258 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
259 .pBufferMemoryBarriers = &(VkBufferMemoryBarrier2) {
260 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
261 .srcStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
262 .dstStageMask = VK_PIPELINE_STAGE_2_HOST_BIT,
263 .srcAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
264 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
265 .dstAccessMask = VK_ACCESS_HOST_READ_BIT,
266 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
267 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
268 .buffer = buf_vk->buf,
269 .size = buf_vk->size,
272 .bufferMemoryBarrierCount = 1,
280 snprintf(str,
sizeof(str),
"%0.3f",
s->prev_mafd);
281 av_dict_set(&in->metadata,
"lavfi.scd.mafd", str, 0);
282 snprintf(str,
sizeof(str),
"%0.3f", score);
283 av_dict_set(&in->metadata,
"lavfi.scd.score", str, 0);
285 if (score >=
s->threshold) {
293 if (!
s->sc_pass || score >=
s->threshold)
326 #define OFFSET(x) offsetof(SceneDetectVulkanContext, x)
327 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
356 .
p.
name =
"scdet_vulkan",
358 .p.priv_class = &scdet_vulkan_class,
AVBufferPool * det_buf_pool
static void scdet_vulkan_uninit(AVFilterContext *avctx)
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_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
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.
AVFILTER_DEFINE_CLASS(scdet_vulkan)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
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.
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
const unsigned int ff_scdet_comp_spv_len
static double evaluate(AVFilterContext *ctx, const SceneDetectBuf *buf)
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
#define SPEC_LIST_ADD(name, idx, val_bits, val)
const char * name
Filter name.
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
Bind a shader.
A link between two filters.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
void * priv
private data for use by the filter
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.
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)
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int scdet_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
#define FILTER_OUTPUTS(array)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
static AVFormatContext * ctx
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
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
static __device__ float fabs(float a)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
int ff_vk_filter_config_output(AVFilterLink *outlink)
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.
#define SPEC_LIST_CREATE(name, max_length, max_size)
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
uint32_t frame_sad[SLICES]
int(* init)(AVBSFContext *ctx)
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define i(width, name, range_min, range_max)
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
#define AV_NUM_DATA_POINTERS
AVRational time_base
Time base for the timestamps in this frame.
AVVulkanDeviceQueueFamily * qf
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
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.
#define AV_LOG_INFO
Standard information.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static void uninit(AVBSFContext *ctx)
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
const unsigned char ff_scdet_comp_spv_data[]
const char * name
Pad name.
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.
#define FILTER_INPUTS(array)
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
const FFFilter ff_vf_scdet_vulkan
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
static const AVFilterPad scdet_vulkan_outputs[]
static const AVOption scdet_vulkan_options[]
int ff_vk_filter_config_input(AVFilterLink *inlink)
AVFilter p
The public AVFilter.
A reference to a data buffer.
static av_cold int init_filter(AVFilterContext *ctx)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
static const AVFilterPad scdet_vulkan_inputs[]
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.
int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, AVBufferRef **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
Initialize a pool and create AVBufferRefs containing FFVkBuffer.