vp9parse: Add video codec tag to the tag list

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8156>
This commit is contained in:
Sebastian Dröge 2024-12-16 11:39:10 +02:00 committed by GStreamer Marge Bot
parent f590e815fe
commit 9f79d39b1b

View file

@ -23,6 +23,7 @@
#include <gst/codecparsers/gstvp9parser.h> #include <gst/codecparsers/gstvp9parser.h>
#include <gst/video/video.h> #include <gst/video/video.h>
#include <gst/pbutils/pbutils.h>
#include "gstvideoparserselements.h" #include "gstvideoparserselements.h"
#include "gstvp9parse.h" #include "gstvp9parse.h"
@ -42,6 +43,8 @@ struct _GstVp9Parse
{ {
GstBaseParse parent; GstBaseParse parent;
gboolean first_frame;
/* parsed from the last keyframe */ /* parsed from the last keyframe */
gint width; gint width;
gint height; gint height;
@ -151,6 +154,7 @@ gst_vp9_parse_reset (GstVp9Parse * self)
self->profile = GST_VP9_PROFILE_UNDEFINED; self->profile = GST_VP9_PROFILE_UNDEFINED;
self->bit_depth = (GstVp9BitDepth) 0; self->bit_depth = (GstVp9BitDepth) 0;
self->codec_alpha = FALSE; self->codec_alpha = FALSE;
self->first_frame = TRUE;
gst_vp9_parse_reset_super_frame (self); gst_vp9_parse_reset_super_frame (self);
} }
@ -442,6 +446,34 @@ gst_vp9_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
if (!frame->buffer) if (!frame->buffer)
return GST_FLOW_OK; 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;
}
/* The super frame may contain more than one frames inside its buffer. /* The super frame may contain more than one frames inside its buffer.
When splitting a super frame into frames, the base parse class only When splitting a super frame into frames, the base parse class only
assign the PTS to the first frame and leave the others' PTS invalid. assign the PTS to the first frame and leave the others' PTS invalid.