videoparseutils: Don't double-attach AFD, Bar or unregistered data

We already did this for captions. We also need to do it for the other
meta types to ensure our parsers are idempotent and don't attach
duplicates.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5450>
This commit is contained in:
Jan Alexander Steffens (heftig) 2023-10-11 12:30:31 +02:00 committed by GStreamer Marge Bot
parent 92017b983e
commit 9426eaae6a

View file

@ -253,40 +253,40 @@ void
gst_video_push_user_data (GstElement * elt, GstVideoParseUserData * user_data, gst_video_push_user_data (GstElement * elt, GstVideoParseUserData * user_data,
GstBuffer * buf) GstBuffer * buf)
{ {
GstVideoAFD afd;
GstVideoBarData bar;
/* 1. handle closed captions */ if (user_data->closedcaptions_size == 0) {
if (user_data->closedcaptions_size > 0) { GST_TRACE_OBJECT (elt, "No closed caption data to attach");
if (!gst_buffer_get_meta (buf, GST_VIDEO_CAPTION_META_API_TYPE)) { } else if (gst_buffer_get_meta (buf, GST_VIDEO_CAPTION_META_API_TYPE)) {
gst_buffer_add_video_caption_meta (buf, GST_DEBUG_OBJECT (elt, "Buffer already has closed caption meta");
user_data->closedcaptions_type, user_data->closedcaptions, } else {
user_data->closedcaptions_size); gst_buffer_add_video_caption_meta (buf,
} else { user_data->closedcaptions_type, user_data->closedcaptions,
GST_DEBUG_OBJECT (elt, "Closed caption data already found on buffer, " user_data->closedcaptions_size);
"discarding to avoid duplication");
}
} }
/* 2. handle AFD */ if (!user_data->active_format_flag) {
if (user_data->active_format_flag) { GST_TRACE_OBJECT (elt, "No AFD to attach");
GstVideoAFD afd; } else if (gst_buffer_get_meta (buf, GST_VIDEO_AFD_META_API_TYPE)) {
if (gst_video_parse_utils_parse_afd (user_data->afd, user_data->afd_spec, GST_DEBUG_OBJECT (elt, "Buffer already has AFD meta");
user_data->field, &afd)) { } else if (!gst_video_parse_utils_parse_afd (user_data->afd,
gst_buffer_add_video_afd_meta (buf, afd.field, afd.spec, afd.afd); user_data->afd_spec, user_data->field, &afd)) {
} else { GST_WARNING_OBJECT (elt, "Invalid AFD value %d", user_data->afd);
GST_WARNING_OBJECT (elt, "Invalid AFD value %d", user_data->afd); } else {
} gst_buffer_add_video_afd_meta (buf, afd.field, afd.spec, afd.afd);
} }
/* 3. handle Bar data */ if (!user_data->bar_data_size) {
if (user_data->bar_data_size) { GST_TRACE_OBJECT (elt, "No Bar data to attach");
GstVideoBarData data; } else if (gst_buffer_get_meta (buf, GST_VIDEO_BAR_META_API_TYPE)) {
if (gst_video_parse_utils_parse_bar (user_data->bar_data, GST_DEBUG_OBJECT (elt, "Buffer already has Bar meta");
user_data->bar_data_size, user_data->field, &data)) { } else if (!gst_video_parse_utils_parse_bar (user_data->bar_data,
gst_buffer_add_video_bar_meta (buf, data.field, data.is_letterbox, user_data->bar_data_size, user_data->field, &bar)) {
data.bar_data[0], data.bar_data[1]); GST_WARNING_OBJECT (elt, "Invalid Bar data");
} else { } else {
GST_WARNING_OBJECT (elt, "Invalid Bar data"); gst_buffer_add_video_bar_meta (buf, bar.field, bar.is_letterbox,
} bar.bar_data[0], bar.bar_data[1]);
} }
} }
@ -503,8 +503,16 @@ gst_video_push_user_data_unregistered (GstElement * elt,
GArray *messages = user_data->messages; GArray *messages = user_data->messages;
guint i; guint i;
if (messages == NULL) if (messages == NULL || messages->len == 0) {
GST_TRACE_OBJECT (elt, "No unregistered user data to attach");
return; return;
}
if (gst_buffer_get_meta (buf,
GST_VIDEO_SEI_USER_DATA_UNREGISTERED_META_API_TYPE)) {
GST_DEBUG_OBJECT (elt, "Buffer already has unregistered meta");
return;
}
for (i = 0; i < messages->len; i++) { for (i = 0; i < messages->len; i++) {
GstVideoUnregisteredMessage *msg = GstVideoUnregisteredMessage *msg =