mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
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.
This commit is contained in:
parent
3b2e06be6c
commit
95d1826dca
2 changed files with 48 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue