vaapipostproc: Tweak the output video format setting to enable the autoplugging
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Mon, 3 Nov 2014 17:19:20 +0000 (19:19 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 12 Nov 2014 08:45:50 +0000 (09:45 +0100)
This is a workaround until auto-plugging is fixed when
format=ENCODED + memory:VASurface caps feature are provided.

Use the downstream negotiated video format as the output video format
if the user didn't ask for the colorspace conversion explicitly.
Usecase: This will help to connect elements like videoscale, videorate etc
to vaapipostproc.

https://bugzilla.gnome.org/show_bug.cgi?id=739443

gst/vaapi/gstvaapipostproc.c

index bcddea6..2664b61 100644 (file)
@@ -1127,7 +1127,28 @@ gst_vaapipostproc_transform_caps_impl(GstBaseTransform *trans,
     // Update size from user-specified parameters
     format = GST_VIDEO_INFO_FORMAT(&vi);
 #if GST_CHECK_VERSION(1,1,0)
-    out_format = postproc->format;
+    /* XXX: this is a workaround until auto-plugging is fixed when
+     * format=ENCODED + memory:VASurface caps feature are provided.
+     * use the downstream negotiated video format as the output format
+     * if the user didn't explicitly ask for colorspace conversion.
+     * Use a filter caps which contain all raw video formats, (excluding
+     * GST_VIDEO_FORMAT_ENCODED) */
+    if (postproc->format != DEFAULT_FORMAT)
+      out_format = postproc->format;
+    else {
+      GstCaps *peer_caps, *filter_caps;
+      GstVideoInfo peer_vi;
+      filter_caps = gst_caps_from_string (GST_VIDEO_CAPS_MAKE(GST_VIDEO_FORMATS_ALL));
+      peer_caps = gst_pad_peer_query_caps(
+          GST_BASE_TRANSFORM_SRC_PAD(trans), filter_caps);
+      if (!gst_caps_is_fixed(peer_caps))
+        peer_caps = gst_caps_fixate (peer_caps);
+      gst_video_info_from_caps(&peer_vi, peer_caps);
+      out_format = GST_VIDEO_INFO_FORMAT (&peer_vi);
+      gst_caps_unref (filter_caps);
+      if (peer_caps)
+        gst_caps_unref (peer_caps);
+    }
 #else
     out_format = GST_VIDEO_FORMAT_ENCODED;
 #endif