vaapipostproc: append frame size restrictions in caps

parent 13e369aa
......@@ -1699,6 +1699,43 @@ gst_vaapi_filter_set_format (GstVaapiFilter * filter, GstVideoFormat format)
return TRUE;
}
/**
* 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
......
......@@ -210,6 +210,9 @@ gst_vaapi_filter_get_formats (GstVaapiFilter * filter);
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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment