diff --git a/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c b/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c index eeb48117a8..0ebe42cdfe 100644 --- a/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c +++ b/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c @@ -73,6 +73,7 @@ #include #include #include +#include #include "gstvideoparserselements.h" #include "gstav1parse.h" @@ -101,6 +102,8 @@ struct _GstAV1Parse { GstBaseParse parent; + gboolean first_frame; + gint width; gint height; gint subsampling_x; @@ -329,6 +332,7 @@ gst_av1_parse_reset (GstAV1Parse * self) self->show_frame = FALSE; self->last_parsed_offset = 0; self->highest_spatial_id = 0; + self->first_frame = TRUE; gst_av1_parse_reset_obu_data_state (self); g_clear_pointer (&self->colorimetry, g_free); g_clear_pointer (&self->parser, gst_av1_parser_free); @@ -2286,6 +2290,34 @@ gst_av1_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) if (!frame->buffer) return GST_FLOW_OK; + if (self->first_frame) { + GstTagList *taglist; + GstCaps *caps; + + /* codec tag */ + caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (caps == NULL) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (self))) { + GST_INFO_OBJECT (self, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (self, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); + gst_pb_utils_add_codec_description_to_tag_list (taglist, + GST_TAG_VIDEO_CODEC, caps); + gst_caps_unref (caps); + + gst_base_parse_merge_tags (parse, taglist, GST_TAG_MERGE_REPLACE); + gst_tag_list_unref (taglist); + + /* also signals the end of first-frame processing */ + self->first_frame = FALSE; + } + if (self->align == GST_AV1_PARSE_ALIGN_FRAME) { /* Input buffers may may contain more than one frames inside its buffer. When splitting a TU into frames, the base parse class only assign the