From b59b77a02ff6f06c87c4dd7abcbbf3d39f129450 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Wed, 22 Feb 2023 19:00:45 +0800 Subject: [PATCH] va: Add helper functions to convert GstVideoInfoDmaDrm into va video info The VA has its internal video format mapping(because different drivers may have different interpretation for the same format), so we should convert the info in GstVideoInfoDmaDrm into the according video info based on that mapping. Part-of: --- .../gst-plugins-bad/sys/va/gstvacaps.c | 35 +++++++++++++++++++ .../gst-plugins-bad/sys/va/gstvacaps.h | 5 +++ 2 files changed, 40 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvacaps.c b/subprojects/gst-plugins-bad/sys/va/gstvacaps.c index 0343a10a6d..a980a63254 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvacaps.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvacaps.c @@ -313,6 +313,41 @@ gst_va_create_raw_caps (GstVaDisplay * display, VAProfile profile, return caps; } +gboolean +gst_va_video_info_from_caps (GstVideoInfo * info, guint64 * modifier, + GstCaps * caps) +{ + GstVideoInfoDmaDrm drm_info; + + if (!gst_video_is_dma_drm_caps (caps)) + return gst_video_info_from_caps (info, caps); + + if (!gst_video_info_dma_drm_from_caps (&drm_info, caps)) + return FALSE; + + if (!gst_va_video_info_from_dma_info (info, &drm_info)) + return FALSE; + + if (modifier) + *modifier = drm_info.drm_modifier; + + return TRUE; +} + +GstCaps * +gst_va_video_info_to_dma_caps (GstVideoInfo * info, guint64 modifier) +{ + GstVideoInfoDmaDrm drm_info; + + gst_video_info_dma_drm_init (&drm_info); + drm_info.vinfo = *info; + drm_info.drm_fourcc = + gst_va_drm_fourcc_from_video_format (GST_VIDEO_INFO_FORMAT (info)); + drm_info.drm_modifier = modifier; + + return gst_video_info_dma_drm_to_caps (&drm_info); +} + /* the purpose of this function is to find broken configurations in * JPEG decoders: if the driver doesn't expose a pixel format for a * config with a specific sampling, that sampling is not valid */ diff --git a/subprojects/gst-plugins-bad/sys/va/gstvacaps.h b/subprojects/gst-plugins-bad/sys/va/gstvacaps.h index 65a7c11527..2ef8691b43 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvacaps.h +++ b/subprojects/gst-plugins-bad/sys/va/gstvacaps.h @@ -41,6 +41,11 @@ GstCaps * gst_va_create_coded_caps (GstVaDisplay * displa VAProfile profile, VAEntrypoint entrypoint, guint32 * rt_formats_ptr); +gboolean gst_va_video_info_from_caps (GstVideoInfo * info, + guint64 * modifier, + GstCaps * caps); +GstCaps * gst_va_video_info_to_dma_caps (GstVideoInfo * info, + guint64 modifier); gboolean gst_caps_set_format_array (GstCaps * caps, GArray * formats);