vaapih264enc: intersect the new proposed caps
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 17 Jan 2020 12:07:04 +0000 (13:07 +0100)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Sun, 19 Jan 2020 12:54:02 +0000 (12:54 +0000)
Instead of just leave to keep the proposed caps, with the best profile
in the allowed caps, is its intersected again.

gst/vaapi/gstvaapiencode_h264.c

index 1c84094..987f72c 100644 (file)
@@ -274,6 +274,8 @@ gst_vaapiencode_h264_set_config (GstVaapiEncode * base_encode)
       goto fail;
 
     if (!gst_caps_can_intersect (allowed_caps, available_caps)) {
+      GstCaps *tmp_caps;
+
       GST_INFO_OBJECT (encode, "downstream may have requested an unsupported "
           "profile. Encoder will try to output a compatible one");
 
@@ -283,9 +285,15 @@ gst_vaapiencode_h264_set_config (GstVaapiEncode * base_encode)
       if (profile == GST_VAAPI_PROFILE_UNKNOWN)
         goto fail;
 
-      profile_caps = gst_caps_from_string (GST_CODEC_CAPS);
-      gst_caps_set_simple (profile_caps, "profile", G_TYPE_STRING,
+      tmp_caps = gst_caps_from_string (GST_CODEC_CAPS);
+      gst_caps_set_simple (tmp_caps, "profile", G_TYPE_STRING,
           gst_vaapi_profile_get_name (profile), NULL);
+      profile_caps = gst_caps_intersect (available_caps, tmp_caps);
+      gst_caps_unref (tmp_caps);
+      if (gst_caps_is_empty (profile_caps)) {
+        gst_caps_unref (profile_caps);
+        goto fail;
+      }
     } else {
       profile_caps = gst_caps_intersect (allowed_caps, available_caps);
       profile = find_best_profile (profile_caps);