mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-08 23:42:28 +00:00
vaapidecode: use caps to check the features
Instead of calling gst_vaapi_find_preferred_caps_feature(), which is expensive, we check the caps from the allocation query, to check the negotiated feature. In order to do this verification a new utility function has been implemented: gst_vaapi_caps_feature_contains(). As this new function shared its logic with gst_caps_has_vaapi_surface(), both have been refactorized. Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> https://bugzilla.gnome.org/show_bug.cgi?id=756686
This commit is contained in:
parent
45487fe87c
commit
6d9f31e305
3 changed files with 41 additions and 29 deletions
|
@ -576,20 +576,15 @@ gst_vaapidecode_decide_allocation (GstVideoDecoder * vdec, GstQuery * query)
|
||||||
GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec);
|
GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec);
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstVideoCodecState *state;
|
GstVideoCodecState *state;
|
||||||
GstVaapiCapsFeature feature;
|
|
||||||
GstVideoFormat out_format;
|
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &caps, NULL);
|
gst_query_parse_allocation (query, &caps, NULL);
|
||||||
|
|
||||||
feature =
|
|
||||||
gst_vaapi_find_preferred_caps_feature (GST_VIDEO_DECODER_SRC_PAD (vdec),
|
|
||||||
GST_VIDEO_FORMAT_ENCODED, &out_format);
|
|
||||||
decode->has_texture_upload_meta = FALSE;
|
decode->has_texture_upload_meta = FALSE;
|
||||||
#if (USE_GLX || USE_EGL)
|
#if (USE_GLX || USE_EGL)
|
||||||
decode->has_texture_upload_meta =
|
decode->has_texture_upload_meta =
|
||||||
(feature == GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META) &&
|
|
||||||
gst_query_find_allocation_meta (query,
|
gst_query_find_allocation_meta (query,
|
||||||
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL);
|
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL) &&
|
||||||
|
gst_vaapi_caps_feature_contains (caps,
|
||||||
|
GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update src caps if feature is not handled downstream */
|
/* Update src caps if feature is not handled downstream */
|
||||||
|
@ -599,7 +594,7 @@ gst_vaapidecode_decide_allocation (GstVideoDecoder * vdec, GstQuery * query)
|
||||||
gst_video_codec_state_unref (state);
|
gst_video_codec_state_unref (state);
|
||||||
|
|
||||||
return gst_vaapi_plugin_base_decide_allocation (GST_VAAPI_PLUGIN_BASE (vdec),
|
return gst_vaapi_plugin_base_decide_allocation (GST_VAAPI_PLUGIN_BASE (vdec),
|
||||||
query, feature);
|
query, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
|
|
|
@ -590,32 +590,44 @@ gst_caps_set_interlaced (GstCaps * caps, GstVideoInfo * vip)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_gst_caps_has_feature (const GstCaps * caps, const gchar * feature)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||||
|
GstCapsFeatures *const features = gst_caps_get_features (caps, i);
|
||||||
|
/* Skip ANY features, we need an exact match for correct evaluation */
|
||||||
|
if (gst_caps_features_is_any (features))
|
||||||
|
continue;
|
||||||
|
if (gst_caps_features_contains (features, feature))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_caps_feature_contains (const GstCaps * caps, GstVaapiCapsFeature feature)
|
||||||
|
{
|
||||||
|
const gchar *feature_str;
|
||||||
|
|
||||||
|
g_return_val_if_fail (caps != NULL, FALSE);
|
||||||
|
|
||||||
|
feature_str = gst_vaapi_caps_feature_to_string (feature);
|
||||||
|
if (!feature_str)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return _gst_caps_has_feature (caps, feature_str);
|
||||||
|
}
|
||||||
|
|
||||||
/* Checks whether the supplied caps contain VA surfaces */
|
/* Checks whether the supplied caps contain VA surfaces */
|
||||||
gboolean
|
gboolean
|
||||||
gst_caps_has_vaapi_surface (GstCaps * caps)
|
gst_caps_has_vaapi_surface (GstCaps * caps)
|
||||||
{
|
{
|
||||||
gboolean found_caps = FALSE;
|
|
||||||
guint i, num_structures;
|
|
||||||
|
|
||||||
g_return_val_if_fail (caps != NULL, FALSE);
|
g_return_val_if_fail (caps != NULL, FALSE);
|
||||||
|
|
||||||
num_structures = gst_caps_get_size (caps);
|
return _gst_caps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE);
|
||||||
if (num_structures < 1)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return found_caps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -91,6 +91,11 @@ G_GNUC_INTERNAL
|
||||||
const gchar *
|
const gchar *
|
||||||
gst_vaapi_caps_feature_to_string (GstVaapiCapsFeature feature);
|
gst_vaapi_caps_feature_to_string (GstVaapiCapsFeature feature);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_caps_feature_contains (const GstCaps * caps,
|
||||||
|
GstVaapiCapsFeature feature);
|
||||||
|
|
||||||
/* Helpers to handle interlaced contents */
|
/* Helpers to handle interlaced contents */
|
||||||
# define GST_CAPS_INTERLACED_MODES \
|
# define GST_CAPS_INTERLACED_MODES \
|
||||||
"interlace-mode = (string){ progressive, interleaved, mixed }"
|
"interlace-mode = (string){ progressive, interleaved, mixed }"
|
||||||
|
|
Loading…
Reference in a new issue