videoparsers: Clear user data explicitly in _reset_frame

This fits better with the model used by the parser elements. It also
properly resets the data when the parser is reset.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5450>
This commit is contained in:
Jan Alexander Steffens (heftig) 2023-10-10 08:34:29 +02:00 committed by GStreamer Marge Bot
parent b3c03cec8d
commit 3577fdec51
5 changed files with 29 additions and 36 deletions

View file

@ -262,6 +262,7 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse)
h264parse->have_pps_in_frame = FALSE; h264parse->have_pps_in_frame = FALSE;
h264parse->have_aud_in_frame = FALSE; h264parse->have_aud_in_frame = FALSE;
gst_adapter_clear (h264parse->frame_out); gst_adapter_clear (h264parse->frame_out);
gst_video_clear_user_data (&h264parse->user_data);
} }
static void static void

View file

@ -207,6 +207,7 @@ gst_h265_parse_reset_frame (GstH265Parse * h265parse)
h265parse->have_sps_in_frame = FALSE; h265parse->have_sps_in_frame = FALSE;
h265parse->have_pps_in_frame = FALSE; h265parse->have_pps_in_frame = FALSE;
gst_adapter_clear (h265parse->frame_out); gst_adapter_clear (h265parse->frame_out);
gst_video_clear_user_data (&h265parse->user_data);
} }
static void static void

View file

@ -196,6 +196,7 @@ gst_mpegv_parse_reset_frame (GstMpegvParse * mpvparse)
mpvparse->ext_count = 0; mpvparse->ext_count = 0;
mpvparse->slice_count = 0; mpvparse->slice_count = 0;
mpvparse->slice_offset = 0; mpvparse->slice_offset = 0;
gst_video_clear_user_data (&mpvparse->user_data);
} }
static void static void

View file

@ -123,10 +123,7 @@ gst_video_parse_user_data (GstElement * elt, GstVideoParseUserData * user_data,
user_data->afd_spec = GST_VIDEO_AFD_SPEC_ATSC_A53; user_data->afd_spec = GST_VIDEO_AFD_SPEC_ATSC_A53;
user_data->afd = temp; user_data->afd = temp;
user_data->active_format_flag = TRUE; user_data->active_format_flag = TRUE;
} else {
user_data->active_format_flag = FALSE;
} }
user_data->has_afd = TRUE;
user_data->field = field; user_data->field = field;
break; break;
case USER_DATA_ID_DIRECTV_CC: case USER_DATA_ID_DIRECTV_CC:
@ -223,7 +220,6 @@ gst_video_parse_user_data (GstElement * elt, GstVideoParseUserData * user_data,
break; break;
memcpy (user_data->bar_data, data, bar_size); memcpy (user_data->bar_data, data, bar_size);
user_data->bar_data_size = bar_size; user_data->bar_data_size = bar_size;
user_data->has_bar_data = TRUE;
user_data->field = field; user_data->field = field;
GST_DEBUG_OBJECT (elt, "Bar data, %u bytes", bar_size); GST_DEBUG_OBJECT (elt, "Bar data, %u bytes", bar_size);
break; break;
@ -265,13 +261,10 @@ gst_video_push_user_data (GstElement * elt, GstVideoParseUserData * user_data,
GST_DEBUG_OBJECT (elt, "Closed caption data already found on buffer, " GST_DEBUG_OBJECT (elt, "Closed caption data already found on buffer, "
"discarding to avoid duplication"); "discarding to avoid duplication");
} }
user_data->closedcaptions_type = GST_VIDEO_CAPTION_TYPE_UNKNOWN;
user_data->closedcaptions_size = 0;
} }
/* 2. handle AFD */ /* 2. handle AFD */
if (user_data->has_afd) { if (user_data->active_format_flag) {
GstVideoAFD afd; GstVideoAFD afd;
if (gst_video_parse_utils_parse_afd (user_data->afd, user_data->afd_spec, if (gst_video_parse_utils_parse_afd (user_data->afd, user_data->afd_spec,
user_data->field, &afd)) { user_data->field, &afd)) {
@ -279,16 +272,10 @@ gst_video_push_user_data (GstElement * elt, GstVideoParseUserData * user_data,
} else { } else {
GST_WARNING_OBJECT (elt, "Invalid AFD value %d", user_data->afd); GST_WARNING_OBJECT (elt, "Invalid AFD value %d", user_data->afd);
} }
} else if (user_data->active_format_flag) {
/* AFD was present, but now it is no longer present */
GST_DEBUG_OBJECT (elt,
"AFD was present in previous frame, now no longer present");
user_data->active_format_flag = 0;
} }
user_data->has_afd = FALSE;
/* 3. handle Bar data */ /* 3. handle Bar data */
if (user_data->has_bar_data) { if (user_data->bar_data_size) {
GstVideoBarData data; GstVideoBarData data;
if (gst_video_parse_utils_parse_bar (user_data->bar_data, if (gst_video_parse_utils_parse_bar (user_data->bar_data,
user_data->bar_data_size, user_data->field, &data)) { user_data->bar_data_size, user_data->field, &data)) {
@ -297,13 +284,7 @@ gst_video_push_user_data (GstElement * elt, GstVideoParseUserData * user_data,
} else { } else {
GST_WARNING_OBJECT (elt, "Invalid Bar data"); GST_WARNING_OBJECT (elt, "Invalid Bar data");
} }
} else if (user_data->bar_data_size) {
/* bar data was present, but now it is no longer present */
GST_DEBUG_OBJECT (elt,
"Bar data was present in previous frame, now no longer present");
user_data->bar_data_size = 0;
} }
user_data->has_bar_data = FALSE;
} }
/* /*
@ -456,6 +437,20 @@ gst_video_parse_utils_parse_afd (const guint8 data, GstVideoAFDSpec spec,
return TRUE; return TRUE;
} }
/*
* gst_video_clear_user_data:
* @user_data: #GstVideoParseUserData struct to hold parsed closed caption, bar and AFD data
*
* Clears the user data, resetting it for the next frame
*/
void
gst_video_clear_user_data (GstVideoParseUserData * user_data)
{
user_data->closedcaptions_size = 0;
user_data->bar_data_size = 0;
user_data->active_format_flag = 0;
}
/* /*
* gst_video_parse_user_data_unregistered: * gst_video_parse_user_data_unregistered:
* @elt: #GstElement that is parsing user data * @elt: #GstElement that is parsing user data

View file

@ -158,19 +158,11 @@ typedef struct
/* pending bar data */ /* pending bar data */
guint8 bar_data[GST_VIDEO_BAR_MAX_BYTES]; guint8 bar_data[GST_VIDEO_BAR_MAX_BYTES];
guint bar_data_size; guint bar_data_size;
gboolean has_bar_data;
/* parsed bar data */
GstVideoBarData bar_parsed;
/* pending AFD data */ /* pending AFD data */
guint8 afd; guint8 afd;
gboolean active_format_flag; gboolean active_format_flag;
GstVideoAFDSpec afd_spec; GstVideoAFDSpec afd_spec;
gboolean has_afd;
/* parsed afd data */
GstVideoAFD afd_parsed;
} GstVideoParseUserData; } GstVideoParseUserData;
@ -188,17 +180,20 @@ typedef struct
G_BEGIN_DECLS G_BEGIN_DECLS
void gst_video_parse_user_data(GstElement * elt, GstVideoParseUserData * user_data, void gst_video_parse_user_data (GstElement * elt,
GstByteReader * br, guint8 field, guint16 provider_code); GstVideoParseUserData * user_data,
GstByteReader * br,
guint8 field,
guint16 provider_code);
void gst_video_parse_user_data_unregistered(GstElement * elt, GstVideoParseUserDataUnregistered * user_data, void gst_video_push_user_data (GstElement * elt,
GstByteReader * br, guint8 uuid[16]); GstVideoParseUserData * user_data,
GstBuffer * buf);
void gst_video_clear_user_data (GstVideoParseUserData * user_data);
void gst_video_user_data_unregistered_clear(GstVideoParseUserDataUnregistered * user_data); void gst_video_user_data_unregistered_clear(GstVideoParseUserDataUnregistered * user_data);
void gst_video_push_user_data(GstElement * elt, GstVideoParseUserData * user_data,
GstBuffer * buf);
void gst_video_push_user_data_unregistered(GstElement * elt, GstVideoParseUserDataUnregistered * user_data, void gst_video_push_user_data_unregistered(GstElement * elt, GstVideoParseUserDataUnregistered * user_data,
GstBuffer * buf); GstBuffer * buf);