From 1e9e976268330c88f6b07b4ecd84ef50e89ecba1 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 19 May 2023 15:20:16 +0800 Subject: [PATCH] videometa: Only validate the alignment only when it contains some info When the alignment contains nothing, all its fields are 0 and always can be satisfied. So there is no need to validate it in this case. And there are a lot of places just setting this alignment to default all zero value, this validation generates lots of warnings. Part-of: --- .../gst-libs/gst/video/gstvideometa.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideometa.c b/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideometa.c index 50113fad9e..f9f1a156a0 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideometa.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideometa.c @@ -394,6 +394,25 @@ gst_video_meta_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info) return meta->unmap (meta, plane, info); } +static gboolean +gst_video_meta_is_alignment_valid (GstVideoAlignment * align) +{ + gint i; + + g_return_val_if_fail (align != NULL, FALSE); + + if (align->padding_top != 0 || align->padding_bottom != 0 || + align->padding_left != 0 || align->padding_right != 0) + return TRUE; + + for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) { + if (align->stride_align[i] != 0) + return TRUE; + } + + return FALSE; +} + static gboolean gst_video_meta_validate_alignment (GstVideoMeta * meta, gsize plane_size[GST_VIDEO_MAX_PLANES]) @@ -401,6 +420,15 @@ gst_video_meta_validate_alignment (GstVideoMeta * meta, GstVideoInfo info; guint i; + if (!gst_video_meta_is_alignment_valid (&meta->alignment)) { + GST_LOG ("Set alignment on meta to all zero"); + + /* When alignment is invalid, no further check is needed, + unless user wants to calculate the pitch for each plane. */ + if (!plane_size) + return TRUE; + } + gst_video_info_init (&info); gst_video_info_set_format (&info, meta->format, meta->width, meta->height);