This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 73cc45ef0d5b3357d61e19d36624271d0fa3d81e
Author:     Lynne <[email protected]>
AuthorDate: Tue Aug 4 01:13:01 2026 +0900
Commit:     Lynne <[email protected]>
CommitDate: Wed Aug 5 16:04:37 2026 +0900

    vulkan_decode: manage session parameters with AVRefStruct
    
    Ditto.
---
 libavcodec/vulkan_av1.c    |  2 +-
 libavcodec/vulkan_decode.c | 41 ++++++++++++++++-------------------------
 libavcodec/vulkan_decode.h |  4 ++--
 libavcodec/vulkan_h264.c   |  2 +-
 libavcodec/vulkan_hevc.c   |  2 +-
 5 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c
index d2e1645a22..97a8b9816f 100644
--- a/libavcodec/vulkan_av1.c
+++ b/libavcodec/vulkan_av1.c
@@ -208,7 +208,7 @@ static void vk_av1_params_fill(AVCodecContext *avctx,
     };
 }
 
-static int vk_av1_create_params(AVCodecContext *avctx, AVBufferRef **buf,
+static int vk_av1_create_params(AVCodecContext *avctx, 
VkVideoSessionParametersKHR **buf,
                                 AV1VulkanDecodePicture *ap)
 {
     int err;
diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 781e71b5c5..8b29d81e3a 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -141,15 +141,12 @@ static const VkVideoProfileInfoKHR 
*get_video_profile(FFVulkanDecodeShared *ctx,
 
 int ff_vk_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
 {
-    int err;
     FFVulkanDecodeContext *src_ctx = src->internal->hwaccel_priv_data;
     FFVulkanDecodeContext *dst_ctx = dst->internal->hwaccel_priv_data;
 
     av_refstruct_replace(&dst_ctx->shared_ctx, src_ctx->shared_ctx);
 
-    err = av_buffer_replace(&dst_ctx->session_params, src_ctx->session_params);
-    if (err < 0)
-        return err;
+    av_refstruct_replace(&dst_ctx->session_params, src_ctx->session_params);
 
     dst_ctx->dedicated_dpb = src_ctx->dedicated_dpb;
     dst_ctx->external_fg = src_ctx->external_fg;
@@ -160,7 +157,7 @@ int ff_vk_update_thread_context(AVCodecContext *dst, const 
AVCodecContext *src)
 int ff_vk_params_invalidate(AVCodecContext *avctx, int t, const uint8_t *b, 
uint32_t s)
 {
     FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
-    av_buffer_unref(&dec->session_params);
+    av_refstruct_unref(&dec->session_params);
     return 0;
 }
 
@@ -461,8 +458,7 @@ int ff_vk_decode_frame(AVCodecContext *avctx,
         .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
         .videoSession = ctx->common.session,
         .videoSessionParameters = dec->session_params ?
-                                  *((VkVideoSessionParametersKHR 
*)dec->session_params->data) :
-                                  VK_NULL_HANDLE,
+                                  *dec->session_params : VK_NULL_HANDLE,
         .referenceSlotCount = vp->decode_info.referenceSlotCount,
         .pReferenceSlots = vp->decode_info.pReferenceSlots,
     };
@@ -517,10 +513,9 @@ int ff_vk_decode_frame(AVCodecContext *avctx,
     /* Slices; owned by the execution from now on */
     ff_vk_exec_move_dep_refstruct(&ctx->s, exec, &vp->slices_buf);
 
-    /* Parameters */
-    err = ff_vk_exec_add_dep_buf(&ctx->s, exec, &dec->session_params, 1, 1);
-    if (err < 0)
-        return err;
+    /* Parameters; unset when inline session parameters are used */
+    if (dec->session_params)
+        ff_vk_exec_add_dep_refstruct(&ctx->s, exec, dec->session_params);
 
     err = ff_vk_exec_add_dep_frame(&ctx->s, exec, pic,
                                    VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
@@ -1183,23 +1178,23 @@ int ff_vk_frame_params(AVCodecContext *avctx, 
AVBufferRef *hw_frames_ctx)
     return err;
 }
 
-static void vk_decode_free_params(void *opaque, uint8_t *data)
+static void vk_decode_free_params(AVRefStructOpaque opaque, void *obj)
 {
-    FFVulkanDecodeShared *ctx = opaque;
+    FFVulkanDecodeShared *ctx = opaque.nc;
     FFVulkanFunctions *vk = &ctx->s.vkfn;
-    VkVideoSessionParametersKHR *par = (VkVideoSessionParametersKHR *)data;
+    VkVideoSessionParametersKHR *par = obj;
     vk->DestroyVideoSessionParametersKHR(ctx->s.hwctx->act_dev, *par,
                                          ctx->s.hwctx->alloc);
-    av_free(par);
 }
 
-int ff_vk_decode_create_params(AVBufferRef **par_ref, void *logctx, 
FFVulkanDecodeShared *ctx,
+int ff_vk_decode_create_params(VkVideoSessionParametersKHR **par_ref, void 
*logctx, FFVulkanDecodeShared *ctx,
                                const VkVideoSessionParametersCreateInfoKHR 
*session_params_create)
 {
-    VkVideoSessionParametersKHR *par = av_malloc(sizeof(*par));
+    VkVideoSessionParametersKHR *par;
     const FFVulkanFunctions *vk = &ctx->s.vkfn;
     VkResult ret;
 
+    par = av_refstruct_alloc_ext(sizeof(*par), 0, ctx, vk_decode_free_params);
     if (!par)
         return AVERROR(ENOMEM);
 
@@ -1209,15 +1204,11 @@ int ff_vk_decode_create_params(AVBufferRef **par_ref, 
void *logctx, FFVulkanDeco
     if (ret != VK_SUCCESS) {
         av_log(logctx, AV_LOG_ERROR, "Unable to create Vulkan video session 
parameters: %s!\n",
                ff_vk_ret2str(ret));
-        av_free(par);
+        *par = VK_NULL_HANDLE;
+        av_refstruct_unref(&par);
         return AVERROR_EXTERNAL;
     }
-    *par_ref = av_buffer_create((uint8_t *)par, sizeof(*par),
-                                vk_decode_free_params, ctx, 0);
-    if (!*par_ref) {
-        vk_decode_free_params(ctx, (uint8_t *)par);
-        return AVERROR(ENOMEM);
-    }
+    *par_ref = par;
 
     return 0;
 }
@@ -1227,7 +1218,7 @@ int ff_vk_decode_uninit(AVCodecContext *avctx)
     FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
 
     av_freep(&dec->hevc_headers);
-    av_buffer_unref(&dec->session_params);
+    av_refstruct_unref(&dec->session_params);
     av_refstruct_unref(&dec->shared_ctx);
     av_freep(&dec->slice_off);
     return 0;
diff --git a/libavcodec/vulkan_decode.h b/libavcodec/vulkan_decode.h
index 8c6537194f..b2a5ab45b6 100644
--- a/libavcodec/vulkan_decode.h
+++ b/libavcodec/vulkan_decode.h
@@ -53,7 +53,7 @@ typedef struct FFVulkanDecodeShared {
 
 typedef struct FFVulkanDecodeContext {
     FFVulkanDecodeShared *shared_ctx;
-    AVBufferRef *session_params;
+    VkVideoSessionParametersKHR *session_params;
 
     int dedicated_dpb; /* Oddity  #1 - separate DPB images */
     int external_fg;   /* Oddity  #2 - hardware can't apply film grain */
@@ -158,7 +158,7 @@ void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, 
FFVulkanDecodePicture *
 /**
  * Create VkVideoSessionParametersKHR wrapped in an AVBufferRef.
  */
-int ff_vk_decode_create_params(AVBufferRef **par_ref, void *logctx, 
FFVulkanDecodeShared *ctx,
+int ff_vk_decode_create_params(VkVideoSessionParametersKHR **par_ref, void 
*logctx, FFVulkanDecodeShared *ctx,
                                const VkVideoSessionParametersCreateInfoKHR 
*session_params_create);
 
 /**
diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c
index 27f9a97102..61b7a14bb2 100644
--- a/libavcodec/vulkan_h264.c
+++ b/libavcodec/vulkan_h264.c
@@ -290,7 +290,7 @@ static void set_pps(const PPS *pps, const SPS *sps,
     };
 }
 
-static int vk_h264_create_params(AVCodecContext *avctx, AVBufferRef **buf)
+static int vk_h264_create_params(AVCodecContext *avctx, 
VkVideoSessionParametersKHR **buf)
 {
     int err;
     FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index 3a3df7d7c1..459ac75ee1 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -620,7 +620,7 @@ static void set_vps(const HEVCVPS *vps,
     };
 }
 
-static int vk_hevc_create_params(AVCodecContext *avctx, AVBufferRef **buf)
+static int vk_hevc_create_params(AVCodecContext *avctx, 
VkVideoSessionParametersKHR **buf)
 {
     int err;
     const HEVCContext *h = avctx->priv_data;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to