va: caps: expose gst_caps_set_format_array()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
This commit is contained in:
Víctor Manuel Jáquez Leal 2020-08-18 19:12:46 +02:00
parent b1a1e2d841
commit 6af7ec3c0f
2 changed files with 15 additions and 8 deletions

View file

@ -93,14 +93,17 @@ bail:
return NULL; return NULL;
} }
static gboolean gboolean
_gst_caps_set_format_array (GstCaps * caps, GArray * formats) gst_caps_set_format_array (GstCaps * caps, GArray * formats)
{ {
GstVideoFormat fmt; GstVideoFormat fmt;
GValue v_formats = G_VALUE_INIT; GValue v_formats = G_VALUE_INIT;
const gchar *format; const gchar *format;
guint i; guint i;
g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
g_return_val_if_fail (formats, FALSE);
if (formats->len == 1) { if (formats->len == 1) {
fmt = g_array_index (formats, GstVideoFormat, 0); fmt = g_array_index (formats, GstVideoFormat, 0);
if (fmt == GST_VIDEO_FORMAT_UNKNOWN) if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
@ -144,7 +147,7 @@ GstCaps *
gst_va_create_raw_caps_from_config (GstVaDisplay * display, VAConfigID config) gst_va_create_raw_caps_from_config (GstVaDisplay * display, VAConfigID config)
{ {
GArray *formats; GArray *formats;
GstCaps *caps, *base_caps, *feature_caps; GstCaps *caps = NULL, *base_caps, *feature_caps;
GstCapsFeatures *features; GstCapsFeatures *features;
GstVideoFormat format; GstVideoFormat format;
VASurfaceAttrib *attribs; VASurfaceAttrib *attribs;
@ -188,16 +191,17 @@ gst_va_create_raw_caps_from_config (GstVaDisplay * display, VAConfigID config)
/* if driver doesn't report surface formats for current /* if driver doesn't report surface formats for current
* chroma. Gallium AMD bug for 4:2:2 */ * chroma. Gallium AMD bug for 4:2:2 */
if (formats->len == 0) { if (formats->len == 0)
caps = NULL;
goto bail; goto bail;
}
base_caps = gst_caps_new_simple ("video/x-raw", "width", GST_TYPE_INT_RANGE, base_caps = gst_caps_new_simple ("video/x-raw", "width", GST_TYPE_INT_RANGE,
min_width, max_width, "height", GST_TYPE_INT_RANGE, min_height, min_width, max_width, "height", GST_TYPE_INT_RANGE, min_height,
max_height, NULL); max_height, NULL);
_gst_caps_set_format_array (base_caps, formats); if (!gst_caps_set_format_array (base_caps, formats)) {
gst_caps_unref (base_caps);
goto bail;
}
caps = gst_caps_new_empty (); caps = gst_caps_new_empty ();
@ -250,7 +254,7 @@ gst_va_create_raw_caps_from_config (GstVaDisplay * display, VAConfigID config)
} }
} }
if (!_gst_caps_set_format_array (raw_caps, raw_formats)) { if (!gst_caps_set_format_array (raw_caps, raw_formats)) {
gst_caps_unref (raw_caps); gst_caps_unref (raw_caps);
raw_caps = gst_caps_copy (base_caps); raw_caps = gst_caps_copy (base_caps);
} }

View file

@ -37,5 +37,8 @@ VASurfaceAttrib * gst_va_get_surface_attribs (GstVaDisplay * displa
GstCaps * gst_va_create_raw_caps_from_config (GstVaDisplay * display, GstCaps * gst_va_create_raw_caps_from_config (GstVaDisplay * display,
VAConfigID config); VAConfigID config);
gboolean gst_caps_set_format_array (GstCaps * caps,
GArray * formats);
G_END_DECLS G_END_DECLS