[FFmpeg-cvslog] hwcontext_vaapi: don't use the generic mapping struct for DRM/VAAPI
Lynne
git at videolan.org
Sat Nov 13 16:14:25 EET 2021
ffmpeg | branch: master | Lynne <dev at lynne.ee> | Sat Nov 13 15:13:03 2021 +0100| [7f6dc9b3868626f6d37ec747d84df973842d5d50] | committer: Lynne
hwcontext_vaapi: don't use the generic mapping struct for DRM/VAAPI
Avoids a per-frame allocation since we don't need the flag field.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f6dc9b3868626f6d37ec747d84df973842d5d50
---
libavutil/hwcontext_vulkan.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 7c70fac30f..d40b1e5de0 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2210,9 +2210,9 @@ fail:
}
#if CONFIG_LIBDRM
-static void vulkan_unmap_from(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
+static void vulkan_unmap_from_drm(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
{
- VulkanMapping *map = hwmap->priv;
+ AVVkFrame *f = hwmap->priv;
AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
@@ -2221,21 +2221,22 @@ static void vulkan_unmap_from(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
VkSemaphoreWaitInfo wait_info = {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
.flags = 0x0,
- .pSemaphores = map->frame->sem,
- .pValues = map->frame->sem_value,
+ .pSemaphores = f->sem,
+ .pValues = f->sem_value,
.semaphoreCount = planes,
};
vk->WaitSemaphores(hwctx->act_dev, &wait_info, UINT64_MAX);
+ vulkan_free_internal(f);
+
for (int i = 0; i < planes; i++) {
- vk->DestroyImage(hwctx->act_dev, map->frame->img[i], hwctx->alloc);
- vk->FreeMemory(hwctx->act_dev, map->frame->mem[i], hwctx->alloc);
- vk->DestroySemaphore(hwctx->act_dev, map->frame->sem[i], hwctx->alloc);
+ vk->DestroyImage(hwctx->act_dev, f->img[i], hwctx->alloc);
+ vk->FreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc);
+ vk->DestroySemaphore(hwctx->act_dev, f->sem[i], hwctx->alloc);
}
- av_freep(&map->frame);
- av_free(map);
+ av_free(f);
}
static const struct {
@@ -2540,7 +2541,6 @@ static int vulkan_map_from_drm(AVHWFramesContext *hwfc, AVFrame *dst,
{
int err = 0;
AVVkFrame *f;
- VulkanMapping *map = NULL;
if ((err = vulkan_map_from_drm_frame_desc(hwfc, &f, src)))
return err;
@@ -2550,15 +2550,8 @@ static int vulkan_map_from_drm(AVHWFramesContext *hwfc, AVFrame *dst,
dst->width = src->width;
dst->height = src->height;
- map = av_mallocz(sizeof(VulkanMapping));
- if (!map)
- goto fail;
-
- map->frame = f;
- map->flags = flags;
-
err = ff_hwframe_map_create(dst->hw_frames_ctx, dst, src,
- &vulkan_unmap_from, map);
+ &vulkan_unmap_from_drm, f);
if (err < 0)
goto fail;
@@ -2568,7 +2561,6 @@ static int vulkan_map_from_drm(AVHWFramesContext *hwfc, AVFrame *dst,
fail:
vulkan_frame_free(hwfc->device_ctx->hwctx, (uint8_t *)f);
- av_free(map);
return err;
}
More information about the ffmpeg-cvslog
mailing list