h265parser: Compare upstream profile with in SPS.
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 14 Dec 2021 18:56:48 +0000 (19:56 +0100)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Thu, 16 Dec 2021 16:08:30 +0000 (17:08 +0100)
Compare if upstream profile in caps is the same as the one parsed in
the SPS. If they are different use the bigger for simplicity and
more chances to decode it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1440>

subprojects/gst-plugins-bad/gst/videoparsers/gsth265parse.c

index 2122e81..2eb902d 100644 (file)
@@ -2356,8 +2356,24 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps)
       GstH265Profile p;
 
       p = gst_h265_get_profile_from_sps (sps);
-
       profile = gst_h265_profile_to_string (p);
+
+      if (s && gst_structure_has_field (s, "profile")) {
+        const gchar *profile_sink = gst_structure_get_string (s, "profile");
+        GstH265Profile p_sink = gst_h265_profile_from_string (profile_sink);
+
+        if (p != p_sink) {
+          const gchar *profile_src;
+
+          p = MAX (p, p_sink);
+          profile_src = (p == p_sink) ? profile_sink : profile;
+          GST_INFO_OBJECT (h265parse,
+              "Upstream profile (%s) is different than in SPS (%s). "
+              "Using %s.", profile_sink, profile, profile_src);
+          profile = profile_src;
+        }
+      }
+
       if (profile != NULL)
         gst_caps_set_simple (caps, "profile", G_TYPE_STRING, profile, NULL);