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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4674>
This commit is contained in:
He Junyan 2023-05-19 15:20:16 +08:00 committed by GStreamer Marge Bot
parent fa8fbab0f7
commit 1e9e976268

View file

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