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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4883>
This commit is contained in:
He Junyan 2023-06-18 14:30:14 +08:00 committed by GStreamer Marge Bot
parent e92dea5ce6
commit 6accb7a1f5
3 changed files with 18 additions and 9 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -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)