From 6accb7a1f5b1bb5d5a8d9e8de930ce4b78c4c42d Mon Sep 17 00:00:00 2001 From: He Junyan Date: Sun, 18 Jun 2023 14:30:14 +0800 Subject: [PATCH] va: Only change video format in gst_va_video_info_from_dma_info() The current way of using gst_video_info_set_format() will change all fields of the GstVideoInfo. We only need to change its format, stride and offset fields. In order to keep the consistency with th common drm API, we rename the gst_va_video_info_from_dma_info() into gst_va_dma_drm_info_to_video_info(). Part-of: --- .../gst-libs/gst/va/gstvavideoformat.c | 21 +++++++++++++------ .../gst-libs/gst/va/gstvavideoformat.h | 4 ++-- .../gst-plugins-bad/sys/va/gstvacaps.c | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.c index e173501ed1..cb737c0c64 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.c @@ -365,10 +365,12 @@ gst_va_video_surface_format_from_image_format (GstVideoFormat image_format, /* Convert the GstVideoInfoDmaDrm into a traditional GstVideoInfo with recognized format. */ gboolean -gst_va_video_info_from_dma_info (GstVideoInfo * info, - const GstVideoInfoDmaDrm * drm_info) +gst_va_dma_drm_info_to_video_info (const GstVideoInfoDmaDrm * drm_info, + GstVideoInfo * info) { GstVideoFormat video_format; + GstVideoInfo tmp_info; + guint i; g_return_val_if_fail (drm_info, FALSE); g_return_val_if_fail (info, FALSE); @@ -387,12 +389,19 @@ gst_va_video_info_from_dma_info (GstVideoInfo * info, if (video_format == GST_VIDEO_FORMAT_UNKNOWN) return FALSE; - *info = drm_info->vinfo; - - if (!gst_video_info_set_format (info, video_format, - GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info))) + if (!gst_video_info_set_format (&tmp_info, video_format, + GST_VIDEO_INFO_WIDTH (&drm_info->vinfo), + GST_VIDEO_INFO_HEIGHT (&drm_info->vinfo))) return FALSE; + *info = drm_info->vinfo; + info->finfo = tmp_info.finfo; + for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) + info->stride[i] = tmp_info.stride[i]; + for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) + info->offset[i] = tmp_info.offset[i]; + info->size = tmp_info.size; + return TRUE; } diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.h index 3d5712c63f..950f1e6730 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvavideoformat.h @@ -56,8 +56,8 @@ GstVideoFormat gst_va_video_surface_format_from_image_format (GstVideoFor GArray * surface_formats); GST_VA_API -gboolean gst_va_video_info_from_dma_info (GstVideoInfo * info, - const GstVideoInfoDmaDrm * drm_info); +gboolean gst_va_dma_drm_info_to_video_info (const GstVideoInfoDmaDrm * drm_info, + GstVideoInfo * info); GST_VA_API void gst_va_video_format_fix_map (VAImageFormat * image_formats, diff --git a/subprojects/gst-plugins-bad/sys/va/gstvacaps.c b/subprojects/gst-plugins-bad/sys/va/gstvacaps.c index a980a63254..0c91822b2a 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvacaps.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvacaps.c @@ -325,7 +325,7 @@ gst_va_video_info_from_caps (GstVideoInfo * info, guint64 * modifier, if (!gst_video_info_dma_drm_from_caps (&drm_info, caps)) return FALSE; - if (!gst_va_video_info_from_dma_info (info, &drm_info)) + if (!gst_va_dma_drm_info_to_video_info (&drm_info, info)) return FALSE; if (modifier)