vulkan/prores: use cached bitstream reader

Speedup is around 75% on NVIDIA 3050, 20% on AMD 6700XT, 5% on Intel TigerLake.
This commit is contained in:
averne
2025-11-29 22:33:45 +01:00
parent fd2fd3828c
commit 1d1643b42a

View File

@@ -21,7 +21,6 @@
#include "hwaccel_internal.h" #include "hwaccel_internal.h"
#include "libavutil/mem.h" #include "libavutil/mem.h"
#include "libavutil/vulkan.h" #include "libavutil/vulkan.h"
#include "libavutil/vulkan_loader.h"
#include "libavutil/vulkan_spirv.h" #include "libavutil/vulkan_spirv.h"
extern const char *ff_source_common_comp; extern const char *ff_source_common_comp;
@@ -207,14 +206,12 @@ static int vk_prores_end_frame(AVCodecContext *avctx)
RET(ff_vk_exec_mirror_sem_value(&ctx->s, exec, &vp->sem, &vp->sem_value, RET(ff_vk_exec_mirror_sem_value(&ctx->s, exec, &vp->sem, &vp->sem_value,
pr->frame)); pr->frame));
/* Transfer ownership to the exec context */
RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &vp->slices_buf, 1, 0)); RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &vp->slices_buf, 1, 0));
vp->slices_buf = NULL; vp->slices_buf = NULL;
RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &pp->metadata_buf, 1, 0)); RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &pp->metadata_buf, 1, 0));
pp->metadata_buf = NULL; pp->metadata_buf = NULL;
/* Transfer ownership to the exec context */
vp->slices_buf = pp->metadata_buf = NULL;
/* Input barrier */ /* Input barrier */
ff_vk_frame_barrier(&ctx->s, exec, pr->frame, img_bar, &nb_img_bar, ff_vk_frame_barrier(&ctx->s, exec, pr->frame, img_bar, &nb_img_bar,
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
@@ -404,6 +401,11 @@ static int init_shader(AVCodecContext *avctx, FFVulkanContext *s,
local_size >> 16 & 0xff, local_size >> 8 & 0xff, local_size >> 0 & 0xff, local_size >> 16 & 0xff, local_size >> 8 & 0xff, local_size >> 0 & 0xff,
0)); 0));
av_bprintf(&shd->src, "#define GET_BITS_SMEM\n");
if (interlaced)
av_bprintf(&shd->src, "#define INTERLACED\n");
/* Common code */ /* Common code */
GLSLD(ff_source_common_comp); GLSLD(ff_source_common_comp);
@@ -412,9 +414,6 @@ static int init_shader(AVCodecContext *avctx, FFVulkanContext *s,
RET(ff_vk_shader_add_descriptor_set(s, shd, descs, num_descs, 0, 0)); RET(ff_vk_shader_add_descriptor_set(s, shd, descs, num_descs, 0, 0));
if (interlaced)
av_bprintf(&shd->src, "#define INTERLACED\n");
/* Main code */ /* Main code */
GLSLD(source); GLSLD(source);
@@ -494,6 +493,7 @@ static int vk_decode_prores_init(AVCodecContext *avctx)
RET(init_shader(avctx, &ctx->s, &ctx->exec_pool, spv, &pv->reset, RET(init_shader(avctx, &ctx->s, &ctx->exec_pool, spv, &pv->reset,
"prores_dec_reset", "main", desc_set, 1, "prores_dec_reset", "main", desc_set, 1,
ff_source_prores_reset_comp, 0x080801, pr->frame_type != 0)); ff_source_prores_reset_comp, 0x080801, pr->frame_type != 0));
desc_set = (FFVulkanDescriptorSetBinding []) { desc_set = (FFVulkanDescriptorSetBinding []) {
{ {
.name = "slice_offsets_buf", .name = "slice_offsets_buf",