From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 12/23] avutil/hwcontext_vulkan: Allocate pub and priv frames hwctx together Date: Mon, 12 Feb 2024 01:03:24 +0100 Message-ID: <DU0P250MB07474E4BBA78A00629D7E87F8F482@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <DU0P250MB0747A90616DE3F93B906D8588F482@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM> This is possible because the lifetime of both coincide. Besides reducing the number of allocations this also simplifies access to VulkanFramesPriv as one no longer has to go through AVHWFramesInternal. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavutil/hwcontext_vulkan.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 3d591dedf9..449a6a2fef 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -129,6 +129,11 @@ typedef struct VulkanDevicePriv { } VulkanDevicePriv; typedef struct VulkanFramesPriv { + /** + * The public AVVulkanFramesContext. See hwcontext_vulkan.h for it. + */ + AVVulkanFramesContext p; + /* Image conversions */ FFVkExecPool compute_exec; @@ -2191,9 +2196,9 @@ static AVBufferRef *vulkan_pool_alloc(void *opaque, size_t size) AVVkFrame *f; AVBufferRef *avbuf = NULL; AVHWFramesContext *hwfc = opaque; - AVVulkanFramesContext *hwctx = hwfc->hwctx; VulkanDevicePriv *p = hwfc->device_ctx->hwctx; - VulkanFramesPriv *fp = hwfc->internal->priv; + VulkanFramesPriv *fp = hwfc->hwctx; + AVVulkanFramesContext *hwctx = &fp->p; VkExternalMemoryHandleTypeFlags e = 0x0; VkExportMemoryAllocateInfo eminfo[AV_NUM_DATA_POINTERS]; @@ -2264,7 +2269,7 @@ static void unlock_frame(AVHWFramesContext *fc, AVVkFrame *vkf) static void vulkan_frames_uninit(AVHWFramesContext *hwfc) { VulkanDevicePriv *p = hwfc->device_ctx->hwctx; - VulkanFramesPriv *fp = hwfc->internal->priv; + VulkanFramesPriv *fp = hwfc->hwctx; if (fp->modifier_info) { if (fp->modifier_info->pDrmFormatModifiers) @@ -2281,8 +2286,8 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc) { int err; AVVkFrame *f; - AVVulkanFramesContext *hwctx = hwfc->hwctx; - VulkanFramesPriv *fp = hwfc->internal->priv; + VulkanFramesPriv *fp = hwfc->hwctx; + AVVulkanFramesContext *hwctx = &fp->p; VulkanDevicePriv *p = hwfc->device_ctx->hwctx; VkImageUsageFlagBits supported_usage; const struct FFVkFormatEntry *fmt; @@ -2493,7 +2498,7 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f VulkanDevicePriv *p = ctx->hwctx; AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - VulkanFramesPriv *fp = hwfc->internal->priv; + VulkanFramesPriv *fp = hwfc->hwctx; const AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)src->data[0]; VkBindImageMemoryInfo bind_info[AV_DRM_MAX_PLANES]; VkBindImagePlaneMemoryInfo plane_info[AV_DRM_MAX_PLANES]; @@ -3004,7 +3009,7 @@ static int vulkan_transfer_data_from_cuda(AVHWFramesContext *hwfc, CUcontext dummy; AVVkFrame *dst_f; AVVkFrameInternal *dst_int; - VulkanFramesPriv *fp = hwfc->internal->priv; + VulkanFramesPriv *fp = hwfc->hwctx; const int planes = av_pix_fmt_count_planes(hwfc->sw_format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format); @@ -3146,8 +3151,8 @@ static int vulkan_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst, VulkanDevicePriv *p = hwfc->device_ctx->hwctx; AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - VulkanFramesPriv *fp = hwfc->internal->priv; - AVVulkanFramesContext *hwfctx = hwfc->hwctx; + VulkanFramesPriv *fp = hwfc->hwctx; + AVVulkanFramesContext *hwfctx = &fp->p; const int planes = av_pix_fmt_count_planes(hwfc->sw_format); VkImageDrmFormatModifierPropertiesEXT drm_mod = { .sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT, @@ -3317,7 +3322,7 @@ static int transfer_image_buf(AVHWFramesContext *hwfc, AVFrame *f, { int err; AVVkFrame *frame = (AVVkFrame *)f->data[0]; - VulkanFramesPriv *fp = hwfc->internal->priv; + VulkanFramesPriv *fp = hwfc->hwctx; VulkanDevicePriv *p = hwfc->device_ctx->hwctx; FFVulkanFunctions *vk = &p->vkctx.vkfn; VkImageMemoryBarrier2 img_bar[AV_NUM_DATA_POINTERS]; @@ -3580,7 +3585,7 @@ static int vulkan_transfer_data_to_cuda(AVHWFramesContext *hwfc, AVFrame *dst, CUcontext dummy; AVVkFrame *dst_f; AVVkFrameInternal *dst_int; - VulkanFramesPriv *fp = hwfc->internal->priv; + VulkanFramesPriv *fp = hwfc->hwctx; const int planes = av_pix_fmt_count_planes(hwfc->sw_format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format); @@ -3723,8 +3728,7 @@ const HWContextType ff_hwcontext_type_vulkan = { .name = "Vulkan", .device_hwctx_size = sizeof(VulkanDevicePriv), - .frames_hwctx_size = sizeof(AVVulkanFramesContext), - .frames_priv_size = sizeof(VulkanFramesPriv), + .frames_hwctx_size = sizeof(VulkanFramesPriv), .device_init = &vulkan_device_init, .device_uninit = &vulkan_device_uninit, -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-02-12 0:03 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-12 0:01 [FFmpeg-devel] [PATCH 01/23] avutil/hwcontext_opencl: Use proper OpenCLFramesContext Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 02/23] avutil/hwcontext: Don't check before av_buffer_unref() Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 03/23] avutil/hwcontext_vaapi: Allocate public and priv device hwctx together Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 04/23] avutil/hwcontext_vulkan: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 05/23] avutil/hwcontext_qsv: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 06/23] avutil/hwcontext_vdpau: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 07/23] avutil/hwcontext_opencl: Allocate pub " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 08/23] avutil/hwcontext_d3d12va: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 09/23] avutil/hwcontext: Remove unused AVHWDeviceInternal.priv Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 10/23] avutil/hwcontext: Allocate AVHWDevCtx jointly with its internals Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 11/23] avutil/hwcontext_vaapi: Allocate pub and priv frames hwctx together Andreas Rheinhardt 2024-02-12 0:03 ` Andreas Rheinhardt [this message] 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 13/23] avutil/hwcontext_videotoolbox: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 14/23] avutil/hwcontext_opencl: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 15/23] avutil/hwcontext_qsv: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 16/23] avutil/hwcontext_dxva2: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 17/23] avutil/hwcontext_d3d11va: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 18/23] avutil/hwcontext_d3d12va: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 19/23] avutil/hwcontext: Clarify documentation of AVHWFramesContext.hwctx Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 20/23] avutil/hwcontext_vdpau: Don't use AVHWFramesInternal.priv Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 21/23] avutil/hwcontext_cuda: " Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 22/23] avutil/hwcontext_internal: Remove unused AVHWFramesInternal.priv Andreas Rheinhardt 2024-02-12 0:03 ` [FFmpeg-devel] [PATCH 23/23] avutil/hwcontext: Allocate AVHWFramesCtx jointly with its internals Andreas Rheinhardt 2024-02-12 22:04 ` [FFmpeg-devel] [PATCH 01/23] avutil/hwcontext_opencl: Use proper OpenCLFramesContext Mark Thompson 2024-02-13 12:23 ` [FFmpeg-devel] [PATCH 24/24] avutil/hwcontext_cuda: Allocate public and internal device ctx jointly Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=DU0P250MB07474E4BBA78A00629D7E87F8F482@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git