This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 1512e52cb412b66be2d3c73eb57603df3227ddea Author: Niklas Haas <[email protected]> AuthorDate: Wed Mar 4 11:58:35 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Wed Mar 4 12:04:09 2026 +0100 swscale: switch to refstruct for hw_priv This is a bit more forward-facing than a bare allocation, and importantly, allows the `swscale/utils.c` code to remain agnostic about how to correctly uninit this struct. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <[email protected]> --- libswscale/swscale_internal.h | 2 +- libswscale/utils.c | 5 ++--- libswscale/vulkan/ops.c | 12 +++++------- libswscale/vulkan/ops.h | 1 - 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index d4102d7858..d9fb6d9297 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -696,7 +696,7 @@ struct SwsInternal { Half2FloatTables *h2f_tables; // Hardware specific private data - void *hw_priv; + void *hw_priv; /* refstruct */ }; //FIXME check init (where 0) diff --git a/libswscale/utils.c b/libswscale/utils.c index 4f50586e90..8a3462c4a3 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -50,6 +50,7 @@ #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/refstruct.h" #include "libavutil/slicethread.h" #include "libavutil/thread.h" #include "libavutil/aarch64/cpu.h" @@ -2248,9 +2249,7 @@ void sws_freeContext(SwsContext *sws) if (!c) return; -#if CONFIG_UNSTABLE && CONFIG_VULKAN - ff_sws_vk_uninit(sws); -#endif + av_refstruct_unref(&c->hw_priv); for (i = 0; i < FF_ARRAY_ELEMS(c->graph); i++) ff_sws_graph_free(&c->graph[i]); diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c index 64c9e3d45b..c3ebcbe529 100644 --- a/libswscale/vulkan/ops.c +++ b/libswscale/vulkan/ops.c @@ -21,14 +21,12 @@ #include "../ops_internal.h" #include "../swscale_internal.h" #include "libavutil/mem.h" +#include "libavutil/refstruct.h" #include "ops.h" -void ff_sws_vk_uninit(SwsContext *sws) +static void ff_sws_vk_uninit(AVRefStructOpaque opaque, void *obj) { - SwsInternal *c = sws_internal(sws); - FFVulkanOpsCtx *s = c->hw_priv; - if (!s) - return; + FFVulkanOpsCtx *s = obj; #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG if (s->spvc) @@ -36,7 +34,6 @@ void ff_sws_vk_uninit(SwsContext *sws) #endif ff_vk_exec_pool_free(&s->vkctx, &s->e); ff_vk_uninit(&s->vkctx); - av_freep(&c->hw_priv); } int ff_sws_vk_init(SwsContext *sws, AVBufferRef *dev_ref) @@ -45,7 +42,8 @@ int ff_sws_vk_init(SwsContext *sws, AVBufferRef *dev_ref) SwsInternal *c = sws_internal(sws); if (!c->hw_priv) { - c->hw_priv = av_mallocz(sizeof(FFVulkanOpsCtx)); + c->hw_priv = av_refstruct_alloc_ext(sizeof(FFVulkanOpsCtx), 0, NULL, + ff_sws_vk_uninit); if (!c->hw_priv) return AVERROR(ENOMEM); } diff --git a/libswscale/vulkan/ops.h b/libswscale/vulkan/ops.h index 73813bf4fa..9427ac0b73 100644 --- a/libswscale/vulkan/ops.h +++ b/libswscale/vulkan/ops.h @@ -38,6 +38,5 @@ typedef struct FFVulkanOpsCtx { } FFVulkanOpsCtx; int ff_sws_vk_init(SwsContext *sws, AVBufferRef *dev_ref); -void ff_sws_vk_uninit(SwsContext *sws); #endif /* SWSCALE_VULKAN_OPS_H */ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
