support YUY2 convert to surface
[profile/ivi/gstreamer-vaapi.git] / gst / vaapi / gstvaapiupload.c
index 3116449..f91f148 100644 (file)
@@ -24,7 +24,7 @@
  * SECTION:gstvaapiupload
  * @short_description: A video to VA flow filter
  *
- * vaapiupload converts from raw YUV pixels to VA surfaces suitable
+ * vaapiupload uploads from raw YUV pixels to VA surfaces suitable
  * for the vaapisink element, for example.
  */
 
@@ -47,7 +47,7 @@ GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapiupload);
 /* ElementFactory information */
 static const GstElementDetails gst_vaapiupload_details =
     GST_ELEMENT_DETAILS(
-        "VA-API colorspace converter",
+        "VA-API colorspace uploader",
         "Filter/Converter/Video",
         GST_PLUGIN_DESC,
         "Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
@@ -448,6 +448,14 @@ error_put_image:
 }
 
 static GstCaps *
+gst_vaapi_get_other_support_caps(GstVaapiConvert *upload)
+{
+  GstCaps *caps;
+  caps = gst_caps_from_string(GST_VIDEO_CAPS_YUV("YUY2"));
+  return caps;
+}
+
+static GstCaps *
 gst_vaapiupload_transform_caps(
     GstBaseTransform *trans,
     GstPadDirection   direction,
@@ -480,10 +488,14 @@ gst_vaapiupload_transform_caps(
             return NULL;
         out_caps = gst_caps_from_string(gst_vaapiupload_yuv_caps_str);
         if (upload->display) {
-            GstCaps *allowed_caps, *inter_caps;
+            GstCaps *allowed_caps, *inter_caps, *other_caps;
             allowed_caps = gst_vaapi_display_get_image_caps(upload->display);
             if (!allowed_caps)
                 return NULL;
+            /* can direct copy other YUV to va surface */
+            other_caps = gst_vaapi_get_other_support_caps(upload);
+            gst_caps_merge(allowed_caps, other_caps);
+
             inter_caps = gst_caps_intersect(out_caps, allowed_caps);
             gst_caps_unref(allowed_caps);
             gst_caps_unref(out_caps);
@@ -622,7 +634,7 @@ gst_vaapiupload_negotiate_buffers(
     if (!gst_vaapiupload_ensure_surface_pool(upload, outcaps))
         return FALSE;
 
-    if (convert->direct_rendering)
+    if (upload->direct_rendering)
         gst_vaapiupload_ensure_direct_rendering_caps(upload, incaps);
     dr = MIN(upload->direct_rendering, upload->direct_rendering_caps);
     if (upload->direct_rendering != dr) {
@@ -642,6 +654,8 @@ gst_vaapiupload_set_caps(
     if (!gst_vaapiupload_negotiate_buffers(upload, incaps, outcaps))
         return FALSE;
 
+    GST_INFO("set caps\nIN caps:\n%" GST_PTR_FORMAT "\nOUT caps:\n%" GST_PTR_FORMAT,
+             incaps, outcaps);
     return TRUE;
 }