Go to the documentation of this file.
32 .queue_flags = VK_QUEUE_COMPUTE_BIT,
95 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
96 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT));
101 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
103 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
104 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
129 if (slices_buf && slices_buf->host_ref && !pp->
slice_num)
137 if (!slices_buf || !slices_buf->host_ref) {
164 VkBufferMemoryBarrier2 buf_bar[2];
165 int nb_img_bar = 0, nb_buf_bar = 0, nb_imgs,
i, err;
179 .slice_data = slice_data->address,
182 .width = avctx->
width,
189 .log2_chroma_w = pix_desc->log2_chroma_w,
195 memcpy(pd.qmat_luma, pr->
qmat_luma,
sizeof(pd.qmat_luma ));
196 memcpy(pd.qmat_chroma, pr->
qmat_chroma,
sizeof(pd.qmat_chroma));
203 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
204 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
214 vkf->
layout[0] = VK_IMAGE_LAYOUT_UNDEFINED;
215 vkf->
access[0] = VK_ACCESS_2_NONE;
222 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
223 VK_PIPELINE_STAGE_2_CLEAR_BIT,
224 VK_ACCESS_2_TRANSFER_WRITE_BIT,
225 VK_IMAGE_LAYOUT_GENERAL,
226 VK_QUEUE_FAMILY_IGNORED);
228 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
229 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
230 .pBufferMemoryBarriers = buf_bar,
231 .bufferMemoryBarrierCount = nb_buf_bar,
232 .pImageMemoryBarriers = img_bar,
233 .imageMemoryBarrierCount = nb_img_bar,
235 nb_img_bar = nb_buf_bar = 0;
238 for (
i = 0;
i <
FFMIN(nb_imgs, 3); ++
i) {
239 vk->CmdClearColorImage(exec->
buf, vkf->
img[
i],
240 VK_IMAGE_LAYOUT_GENERAL,
241 &((VkClearColorValue) { 0 }),
242 1, &((VkImageSubresourceRange) {
243 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
252 pr->
first_field ? VK_PIPELINE_STAGE_2_CLEAR_BIT : VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
253 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
254 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
255 VK_IMAGE_LAYOUT_GENERAL,
256 VK_QUEUE_FAMILY_IGNORED);
258 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
259 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
261 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
263 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
264 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
265 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
270 metadata->stage = buf_bar[0].dstStageMask;
271 metadata->access = buf_bar[0].dstAccessMask;
273 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
274 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
275 .pBufferMemoryBarriers = buf_bar,
276 .bufferMemoryBarrierCount = nb_buf_bar,
277 .pImageMemoryBarriers = img_bar,
278 .imageMemoryBarrierCount = nb_img_bar,
280 nb_img_bar = nb_buf_bar = 0;
287 VK_FORMAT_UNDEFINED);
292 VK_FORMAT_UNDEFINED);
296 VK_IMAGE_LAYOUT_GENERAL,
301 VK_SHADER_STAGE_COMPUTE_BIT,
309 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
310 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
311 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
312 VK_IMAGE_LAYOUT_GENERAL,
313 VK_QUEUE_FAMILY_IGNORED);
315 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
316 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
318 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
320 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT,
321 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
322 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
327 metadata->stage = buf_bar[0].dstStageMask;
328 metadata->access = buf_bar[0].dstAccessMask;
330 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
331 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
332 .pBufferMemoryBarriers = buf_bar,
333 .bufferMemoryBarrierCount = nb_buf_bar,
334 .pImageMemoryBarriers = img_bar,
335 .imageMemoryBarrierCount = nb_img_bar,
337 nb_img_bar = nb_buf_bar = 0;
344 VK_FORMAT_UNDEFINED);
348 VK_IMAGE_LAYOUT_GENERAL,
353 VK_SHADER_STAGE_COMPUTE_BIT,
366 GLSLC(0,
layout(push_constant, scalar) uniform pushConstants { );
367 GLSLC(1, u8buf slice_data; );
368 GLSLC(1, uint bitstream_size; );
372 GLSLC(1, uint16_t mb_width; );
373 GLSLC(1, uint16_t mb_height; );
374 GLSLC(1, uint16_t slice_width; );
375 GLSLC(1, uint16_t slice_height; );
376 GLSLC(1, uint8_t log2_slice_width; );
377 GLSLC(1, uint8_t log2_chroma_w; );
378 GLSLC(1, uint8_t depth; );
379 GLSLC(1, uint8_t alpha_info; );
380 GLSLC(1, uint8_t bottom_field; );
382 GLSLC(1, uint8_t qmat_luma [8*8]; );
383 GLSLC(1, uint8_t qmat_chroma[8*8]; );
387 VK_SHADER_STAGE_COMPUTE_BIT);
398 void *spv_opaque =
NULL;
402 VK_SHADER_STAGE_COMPUTE_BIT,
403 (
const char *[]) {
"GL_EXT_buffer_reference",
404 "GL_EXT_buffer_reference2" }, 2,
405 local_size >> 16 & 0xff, local_size >> 8 & 0xff, local_size >> 0 & 0xff,
459 int max_num_mbs, err;
463 spv = ff_vk_spirv_init();
486 .
name =
"slice_offsets_buf",
487 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
488 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
489 .mem_quali =
"readonly",
490 .buf_content =
"uint32_t slice_offsets",
491 .buf_elems = max_num_mbs + 1,
494 .name =
"quant_idx_buf",
495 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
496 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
497 .mem_quali =
"writeonly",
498 .buf_content =
"uint8_t quant_idx",
499 .buf_elems = max_num_mbs,
503 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
507 .mem_quali =
"writeonly",
509 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
513 "prores_dec_vld",
"main", desc_set, 3,
518 .
name =
"quant_idx_buf",
519 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
520 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
521 .mem_quali =
"readonly",
522 .buf_content =
"uint8_t quant_idx",
523 .buf_elems = max_num_mbs,
527 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
532 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
536 "prores_dec_idct",
"main", desc_set, 2,
558 .
p.
name =
"prores_vulkan",
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
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_vk_shader_init(FFVulkanContext *s, FFVulkanShader *shd, const char *name, VkPipelineStageFlags stage, const char *extensions[], int nb_extensions, int lg_x, int lg_y, int lg_z, uint32_t required_subgroup_size)
Initialize a shader object, with a specific set of extensions, type+bind, local group size,...
int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, enum FFVkShaderRepFormat rep_fmt, int alloc_dpb)
Software-defined decoder version of ff_vk_decode_prepare_frame.
void * hwaccel_picture_private
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
FFVulkanDecodeShared * shared_ctx
RefStruct is an API for creating reference-counted objects with minimal overhead.
AVHWAccel p
The public AVHWAccel.
This structure describes decoded (raw) audio or video data.
static void vk_prores_free_frame_priv(AVRefStructOpaque _hwctx, void *data)
static int vk_prores_end_frame(AVCodecContext *avctx)
const char * ff_source_prores_vld_comp
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
int slice_count
number of slices in the current picture
@ 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)
unsigned slice_mb_width
maximum width of a slice in mb
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
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)
#define HWACCEL_CAP_THREAD_SAFE
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
int ff_vk_host_map_buffer(FFVulkanContext *s, AVBufferRef **dst, uint8_t *src_data, const AVBufferRef *src_buf, VkBufferUsageFlags usage)
Maps a system RAM buffer into a Vulkan buffer.
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int vk_prores_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *dst, uint64_t *dst_val, AVFrame *f)
#define AV_CEIL_RSHIFT(a, b)
struct FFVulkanDecodePicture::@326 view
static int vk_prores_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
Execution dependency management.
static int vk_decode_prores_init(AVCodecContext *avctx)
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pix_fmt, enum FFVkShaderRepFormat rep_fmt)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture *vp)
Free a frame and its state.
struct AVCodecInternal * internal
Private context used for internal data.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
void(* flush)(AVBSFContext *ctx)
int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Initialize hw_frames_ctx with the parameters needed to decode the stream using the parameters from av...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a source
int(* init)(AVBSFContext *ctx)
VkAccessFlagBits access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
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.
uint32_t slice_offsets_sz
void * hwaccel_priv_data
hwaccel-specific private data
#define AV_NUM_DATA_POINTERS
int(* compile_shader)(FFVulkanContext *s, struct FFVkSPIRVCompiler *ctx, FFVulkanShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
#define AVERROR_EXTERNAL
Generic error in an external library.
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.
const FFHWAccel ff_prores_vulkan_hwaccel
const char * name
Name of the hardware accelerated codec.
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
unsigned mb_width
width of the current picture in mb
#define FF_VK_EXT_EXTERNAL_HOST_MEMORY
static void uninit(AVBSFContext *ctx)
VkImageView out[AV_NUM_DATA_POINTERS]
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
#define i(width, name, range_min, range_max)
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, uint8_t *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd)
Bind a shader.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
This struct describes a set or pool of "hardware" frames (i.e.
void ff_vk_decode_flush(AVCodecContext *avctx)
Flush decoder.
const char * ff_source_common_comp
const FFVulkanDecodeDescriptor ff_vk_dec_prores_desc
int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, const uint8_t *data, size_t size, int add_startcode, uint32_t *nb_slices, const uint32_t **offsets)
Add slice data to frame.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
int frame_type
0 = progressive, 1 = tff, 2 = bff
main external API structure.
static int add_push_data(FFVulkanShader *shd)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. Use ff_thread_get_buffer()(or ff_progress_frame_get_buffer() in case you have inter-frame dependencies and use the ProgressFrame API) to allocate frame buffers. Call ff_progress_frame_report() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
int ff_vk_params_invalidate(AVCodecContext *avctx, int t, const uint8_t *b, uint32_t s)
Removes current session parameters to recreate them.
AVBufferRef * metadata_buf
int ff_vk_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Synchronize the contexts between 2 threads.
int coded_width
Bitstream width / height, may be different from width/height e.g.
VkImageLayout layout[AV_NUM_DATA_POINTERS]
A reference to a data buffer.
const char * ff_source_prores_idct_comp
AVBufferPool * metadata_pool
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int ff_vk_count_images(AVVkFrame *f)
VkDeviceAddress slice_data
int width
picture width / height.
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
static int init_shader(AVCodecContext *avctx, FFVulkanContext *s, FFVkExecPool *pool, FFVkSPIRVCompiler *spv, FFVulkanShader *shd, const char *name, const char *entrypoint, FFVulkanDescriptorSetBinding *descs, int num_descs, const char *source, int local_size, int interlaced)
static void vk_decode_prores_uninit(FFVulkanDecodeShared *ctx)
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.
unsigned mb_height
height of the current picture in mb