}
/* Convert formats array to GstCaps */
-static GstCaps *
-get_format_caps (GArray * formats)
+static GArray *
+get_formats (GArray * formats)
{
const GstVaapiFormatInfo *fip;
- GstCaps *out_caps, *caps;
+ GArray *out_formats;
guint i;
- out_caps = gst_caps_new_empty ();
- if (!out_caps)
+ out_formats = g_array_new (FALSE, FALSE, sizeof (GstVideoFormat));
+ if (!out_formats)
return NULL;
for (i = 0; i < formats->len; i++) {
fip = &g_array_index (formats, GstVaapiFormatInfo, i);
- caps = gst_vaapi_video_format_to_caps (fip->format);
- if (caps)
- gst_caps_append (out_caps, caps);
+ g_array_append_val (out_formats, fip->format);
}
- return out_caps;
+ return out_formats;
}
/* Find display attribute */
}
/**
- * gst_vaapi_display_get_image_caps:
+ * gst_vaapi_display_get_image_formats:
* @display: a #GstVaapiDisplay
*
* Gets the supported image formats for gst_vaapi_surface_get_image()
- * or gst_vaapi_surface_put_image() as #GstCaps capabilities.
+ * or gst_vaapi_surface_put_image().
*
* Note that this method does not necessarily map image formats
* returned by vaQueryImageFormats(). The set of capabilities can be
* driver. e.g. I420 can be supported even if the driver only exposes
* YV12.
*
- * Return value: a newly allocated #GstCaps object, possibly empty
+ * Note: the caller owns an extra reference to the resulting array of
+ * #GstVideoFormat elements, so it shall be released with
+ * g_array_unref() after usage.
+ *
+ * Return value: a newly allocated #GArray, or %NULL on error or if
+ * the set is empty
*/
-GstCaps *
-gst_vaapi_display_get_image_caps (GstVaapiDisplay * display)
+GArray *
+gst_vaapi_display_get_image_formats (GstVaapiDisplay * display)
{
g_return_val_if_fail (display != NULL, NULL);
if (!ensure_image_formats (display))
return NULL;
- return get_format_caps (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->
- image_formats);
+ return get_formats (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->image_formats);
}
/**
}
/**
- * gst_vaapi_display_get_subpicture_caps:
+ * gst_vaapi_display_get_subpicture_formats:
* @display: a #GstVaapiDisplay
*
- * Gets the supported subpicture formats as #GstCaps capabilities.
+ * Gets the supported subpicture formats.
*
* Note that this method does not necessarily map subpicture formats
* returned by vaQuerySubpictureFormats(). The set of capabilities can
* be stripped down if gstreamer-vaapi does not support the
* format. e.g. this is the case for paletted formats like IA44.
*
- * Return value: a newly allocated #GstCaps object, possibly empty
+ * Note: the caller owns an extra reference to the resulting array of
+ * #GstVideoFormat elements, so it shall be released with
+ * g_array_unref() after usage.
+ *
+ * Return value: a newly allocated #GArray, or %NULL on error of if
+ * the set is empty
*/
-GstCaps *
-gst_vaapi_display_get_subpicture_caps (GstVaapiDisplay * display)
+GArray *
+gst_vaapi_display_get_subpicture_formats (GstVaapiDisplay * display)
{
g_return_val_if_fail (display != NULL, NULL);
if (!ensure_subpicture_formats (display))
return NULL;
- return get_format_caps (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->
+ return get_formats (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->
subpicture_formats);
}
gst_vaapi_display_has_encoder (GstVaapiDisplay * display,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint);
-GstCaps *
-gst_vaapi_display_get_image_caps (GstVaapiDisplay * display);
+GArray *
+gst_vaapi_display_get_image_formats (GstVaapiDisplay * display);
gboolean
gst_vaapi_display_has_image_format (GstVaapiDisplay * display,
GstVideoFormat format);
-GstCaps *
-gst_vaapi_display_get_subpicture_caps (GstVaapiDisplay * display);
+GArray *
+gst_vaapi_display_get_subpicture_formats (GstVaapiDisplay * display);
gboolean
gst_vaapi_display_has_subpicture_format (GstVaapiDisplay * display,
GstPad *srcpad;
GstCaps *allowed_caps, *inter_caps, *out_caps = NULL;
GstStructure *structure;
+ GArray *formats;
+ guint i;
g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
if (download->allowed_caps)
allowed_caps = gst_caps_ref(download->allowed_caps);
else {
- allowed_caps = gst_vaapi_display_get_image_caps(
- GST_VAAPI_PLUGIN_BASE_DISPLAY(download));
+ allowed_caps = gst_caps_new_empty();
if (!allowed_caps)
return NULL;
+
+ formats = gst_vaapi_display_get_image_formats(
+ GST_VAAPI_PLUGIN_BASE_DISPLAY(download));
+ if (formats) {
+ for (i = 0; i < formats->len; i++) {
+ const GstVideoFormat format =
+ g_array_index(formats, GstVideoFormat, i);
+ gst_caps_merge(allowed_caps,
+ gst_vaapi_video_format_to_caps(format));
+ }
+ g_array_unref(formats);
+ }
}
inter_caps = gst_caps_intersect(out_caps, allowed_caps);
gst_caps_unref(allowed_caps);
{
GstVaapiUploaderPrivate * const priv = uploader->priv;
GstVaapiSurface *surface = NULL;
- GstCaps *out_caps, *image_caps = NULL;
- guint i, n_structures;
+ GArray *image_formats = NULL;
+ GstCaps *out_caps;
+ guint i;
gboolean success = FALSE;
enum { WIDTH = 64, HEIGHT = 64 };
if (!out_caps)
return FALSE;
- image_caps = gst_vaapi_display_get_image_caps(priv->display);
- if (!image_caps)
+ image_formats = gst_vaapi_display_get_image_formats(priv->display);
+ if (!image_formats)
goto end;
surface = gst_vaapi_surface_new(priv->display,
if (!surface)
goto end;
- n_structures = gst_caps_get_size(image_caps);
- for (i = 0; i < n_structures; i++) {
- GstStructure * const structure = gst_caps_get_structure(image_caps, i);
+ for (i = 0; i < image_formats->len; i++) {
+ const GstVideoFormat format =
+ g_array_index(image_formats, GstVideoFormat, i);
GstVaapiImage *image;
- GstVideoFormat format;
- format = gst_vaapi_video_format_from_structure(structure);
if (format == GST_VIDEO_FORMAT_UNKNOWN)
continue;
image = gst_vaapi_image_new(priv->display, format, WIDTH, HEIGHT);
if (!image)
continue;
if (ensure_image(image) && gst_vaapi_surface_put_image(surface, image))
- gst_caps_append_structure(out_caps, gst_structure_copy(structure));
+ gst_caps_append(out_caps, gst_vaapi_video_format_to_caps(format));
gst_vaapi_object_unref(image);
}
end:
gst_caps_unref(out_caps);
- if (image_caps)
- gst_caps_unref(image_caps);
+ if (image_formats)
+ g_array_unref(image_formats);
if (surface)
gst_vaapi_object_unref(surface);
return success;
}
static void
-print_format_caps_yuv(const VAImageFormat *va_format)
+print_format_yuv(const VAImageFormat *va_format)
{
const guint32 fourcc = va_format->fourcc;
}
static void
-print_format_caps_rgb(const VAImageFormat *va_format)
+print_format_rgb(const VAImageFormat *va_format)
{
g_print(" %d bits per pixel, %s endian,",
va_format->bits_per_pixel,
}
static void
-print_format_caps(GstCaps *caps, const gchar *name)
+print_formats(GArray *formats, const gchar *name)
{
- guint i, n_caps = gst_caps_get_size(caps);
+ guint i;
- g_print("%u %s caps\n", n_caps, name);
+ g_print("%u %s caps\n", formats->len, name);
- for (i = 0; i < gst_caps_get_size(caps); i++) {
- GstStructure * const structure = gst_caps_get_structure(caps, i);
+ for (i = 0; i < formats->len; i++) {
+ const GstVideoFormat format = g_array_index(formats, GstVideoFormat, i);
const VAImageFormat *va_format;
- GstVideoFormat format;
- if (!structure)
- g_error("could not get caps structure %d", i);
-
- g_print(" %s:", gst_structure_get_name(structure));
-
- format = gst_vaapi_video_format_from_structure(structure);
- if (format == GST_VIDEO_FORMAT_UNKNOWN)
- g_error("could not determine format");
+ g_print(" %s:", gst_vaapi_video_format_to_string(format));
va_format = gst_vaapi_video_format_to_va_format(format);
if (!va_format)
g_error("could not determine VA format");
if (gst_vaapi_video_format_is_yuv(format))
- print_format_caps_yuv(va_format);
+ print_format_yuv(va_format);
else
- print_format_caps_rgb(va_format);
+ print_format_rgb(va_format);
g_print("\n");
}
}
static void
dump_info(GstVaapiDisplay *display)
{
+ GArray *formats;
GstCaps *caps;
caps = gst_vaapi_display_get_decode_caps(display);
print_profile_caps(caps, "encoders");
gst_caps_unref(caps);
- caps = gst_vaapi_display_get_image_caps(display);
- if (!caps)
- g_error("could not get VA image caps");
+ formats = gst_vaapi_display_get_image_formats(display);
+ if (!formats)
+ g_error("could not get VA image formats");
- print_format_caps(caps, "image");
- gst_caps_unref(caps);
+ print_formats(formats, "image");
+ g_array_unref(formats);
- caps = gst_vaapi_display_get_subpicture_caps(display);
- if (!caps)
- g_error("could not get VA subpicture caps");
+ formats = gst_vaapi_display_get_subpicture_formats(display);
+ if (!formats)
+ g_error("could not get VA subpicture formats");
- print_format_caps(caps, "subpicture");
- gst_caps_unref(caps);
+ print_formats(formats, "subpicture");
+ g_array_unref(formats);
dump_properties(display);
}