From: Gwenole Beauchesne Date: Wed, 20 Aug 2014 09:30:41 +0000 (+0200) Subject: plugins: add helper for detecting VA surfaces in caps. X-Git-Tag: 1.19.3~503^2~2021 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95d1826dca82025c51a3e524f404bd15fc753da4;p=platform%2Fupstream%2Fgstreamer.git plugins: add helper for detecting VA surfaces in caps. Introduce new gst_caps_has_vaapi_surface() helper function to detect whether the supplied caps has VA surfaces. With GStreamer >= 1.2, this implies a check for memory:VASurface caps features, and format=ENCODED for earlier versions of GStreamer. --- diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index 7c3e354..2c3a3cd 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -612,3 +612,47 @@ gst_caps_set_interlaced (GstCaps * caps, GstVideoInfo * vip) #endif return TRUE; } + +/* Checks whether the supplied caps contain VA surfaces */ +gboolean +gst_caps_has_vaapi_surface (GstCaps * caps) +{ + gboolean found_caps = FALSE; + guint i, num_structures; + + g_return_val_if_fail (caps != NULL, FALSE); + + num_structures = gst_caps_get_size (caps); + if (num_structures < 1) + return FALSE; + +#if GST_CHECK_VERSION(1,1,0) + for (i = 0; i < num_structures && !found_caps; i++) { + GstCapsFeatures *const features = gst_caps_get_features (caps, i); + +#if GST_CHECK_VERSION(1,3,0) + /* Skip ANY features, we need an exact match for correct evaluation */ + if (gst_caps_features_is_any (features)) + continue; +#endif + + found_caps = gst_caps_features_contains (features, + GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE); + } +#else + for (i = 0; i < num_structures && !found_caps; i++) { + GstStructure *const structure = gst_caps_get_structure (caps, i); + GstCaps *test_caps; + GstVideoInfo vi; + + test_caps = gst_caps_new_full (gst_structure_copy (structure), NULL); + if (!test_caps) + continue; + + found_caps = gst_video_info_from_caps (&vi, test_caps) && + GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED; + gst_caps_unref (test_caps); + } +#endif + return found_caps; +} diff --git a/gst/vaapi/gstvaapipluginutil.h b/gst/vaapi/gstvaapipluginutil.h index 4fc7450..6380a11 100644 --- a/gst/vaapi/gstvaapipluginutil.h +++ b/gst/vaapi/gstvaapipluginutil.h @@ -109,4 +109,8 @@ G_GNUC_INTERNAL gboolean gst_caps_set_interlaced (GstCaps * caps, GstVideoInfo * vip); +G_GNUC_INTERNAL +gboolean +gst_caps_has_vaapi_surface (GstCaps * caps); + #endif /* GST_VAAPI_PLUGIN_UTIL_H */