From f88d18bebe0b21db2f5a2dce82899046a4c7a0ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Sun, 18 Aug 2019 13:53:19 +0200 Subject: [PATCH] vaapipostproc: append frame size restrictions in caps --- gst-libs/gst/vaapi/gstvaapifilter.c | 37 +++++++++++++++++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapifilter.h | 3 +++ gst/vaapi/gstvaapipostproc.c | 22 +++++++++++++++++++--- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapifilter.c b/gst-libs/gst/vaapi/gstvaapifilter.c index 82a7cd6..766b421 100644 --- a/gst-libs/gst/vaapi/gstvaapifilter.c +++ b/gst-libs/gst/vaapi/gstvaapifilter.c @@ -1700,6 +1700,43 @@ gst_vaapi_filter_set_format (GstVaapiFilter * filter, GstVideoFormat format) } /** + * gst_vaapi_filter_append_caps: + * @filter: a #GstVaapiFilter + * @structure: a #GstStructure from #GstCaps + * + * Extracts the config's surface attributes, from @filter's context, + * and transforms it into a caps formats and appended them into + * @structure. + * + * Returns: %TRUE if the capabilities could be extracted and appended + * into @structure; otherwise %FALSE + **/ +gboolean +gst_vaapi_filter_append_caps (GstVaapiFilter * filter, GstStructure * structure) +{ + GstVaapiConfigSurfaceAttributes *attribs; + + g_return_val_if_fail (filter != NULL, FALSE); + g_return_val_if_fail (structure != NULL, FALSE); + + if (!ensure_attributes (filter)) + return FALSE; + + attribs = filter->attribs; + + if (attribs->min_width >= attribs->max_width || + attribs->min_height >= attribs->max_height) + return FALSE; + + gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, attribs->min_width, + attribs->max_width, "height", GST_TYPE_INT_RANGE, attribs->min_height, + attribs->max_height, NULL); + + return TRUE; + +} + +/** * gst_vaapi_filter_set_cropping_rectangle: * @filter: a #GstVaapiFilter * @rect: the cropping region diff --git a/gst-libs/gst/vaapi/gstvaapifilter.h b/gst-libs/gst/vaapi/gstvaapifilter.h index 45990e0..3424ba5 100644 --- a/gst-libs/gst/vaapi/gstvaapifilter.h +++ b/gst-libs/gst/vaapi/gstvaapifilter.h @@ -211,6 +211,9 @@ gboolean gst_vaapi_filter_set_format (GstVaapiFilter * filter, GstVideoFormat format); gboolean +gst_vaapi_filter_append_caps (GstVaapiFilter * filter, GstStructure * structure); + +gboolean gst_vaapi_filter_set_cropping_rectangle (GstVaapiFilter * filter, const GstVaapiRectangle * rect); diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c index ac8bcb2..b852e89 100644 --- a/gst/vaapi/gstvaapipostproc.c +++ b/gst/vaapi/gstvaapipostproc.c @@ -1103,6 +1103,7 @@ static gboolean ensure_allowed_sinkpad_caps (GstVaapiPostproc * postproc) { GstCaps *out_caps, *raw_caps; + guint i, num_structures; if (postproc->allowed_sinkpad_caps) return TRUE; @@ -1128,6 +1129,18 @@ ensure_allowed_sinkpad_caps (GstVaapiPostproc * postproc) out_caps = gst_caps_make_writable (out_caps); gst_caps_append (out_caps, gst_caps_copy (raw_caps)); + + num_structures = gst_caps_get_size (out_caps); + for (i = 0; i < num_structures; i++) { + GstStructure *structure; + + structure = gst_caps_get_structure (out_caps, i); + if (!structure) + continue; + + gst_vaapi_filter_append_caps (postproc->filter, structure); + } + postproc->allowed_sinkpad_caps = out_caps; /* XXX: append VA/VPP filters */ @@ -1160,15 +1173,18 @@ expand_allowed_srcpad_caps (GstVaapiPostproc * postproc, GstCaps * caps) GstCapsFeatures *const features = gst_caps_get_features (caps, i); GstStructure *structure; + structure = gst_caps_get_structure (caps, i); + if (!structure) + continue; + + gst_vaapi_filter_append_caps (postproc->filter, structure); + if (gst_caps_features_contains (features, GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META)) { gl_upload_meta_idx = i; continue; } - structure = gst_caps_get_structure (caps, i); - if (!structure) - continue; gst_structure_set_value (structure, "format", &value); } g_value_unset (&value); -- 2.7.4