mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
display: don't use GstCaps for image or subpicture formats list.
Replace gst_vaapi_display_get_{image,subpicture}_caps() APIs, that returned GstCaps, with more convenient APIs that return an array of GstVideoFormat: gst_vaapi_display_get_{image,subpicture}_formats().
This commit is contained in:
parent
446b060c7a
commit
c4ca08a8d6
5 changed files with 80 additions and 68 deletions
|
@ -394,24 +394,22 @@ find_format (GArray * formats, GstVideoFormat format)
|
|||
}
|
||||
|
||||
/* 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 */
|
||||
|
@ -1448,11 +1446,11 @@ gst_vaapi_display_has_encoder (GstVaapiDisplay * display,
|
|||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -1461,17 +1459,21 @@ gst_vaapi_display_has_encoder (GstVaapiDisplay * display,
|
|||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1509,26 +1511,31 @@ gst_vaapi_display_has_image_format (GstVaapiDisplay * display,
|
|||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -158,15 +158,15 @@ gboolean
|
|||
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,
|
||||
|
|
|
@ -391,6 +391,8 @@ gst_vaapidownload_transform_caps(
|
|||
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);
|
||||
|
||||
|
@ -409,10 +411,21 @@ gst_vaapidownload_transform_caps(
|
|||
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);
|
||||
|
|
|
@ -112,8 +112,9 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
|
|||
{
|
||||
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 };
|
||||
|
@ -125,8 +126,8 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
|
|||
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,
|
||||
|
@ -134,20 +135,18 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -156,8 +155,8 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
|
|||
|
||||
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;
|
||||
|
|
|
@ -94,7 +94,7 @@ print_profile_caps(GstCaps *caps, const gchar *name)
|
|||
}
|
||||
|
||||
static void
|
||||
print_format_caps_yuv(const VAImageFormat *va_format)
|
||||
print_format_yuv(const VAImageFormat *va_format)
|
||||
{
|
||||
const guint32 fourcc = va_format->fourcc;
|
||||
|
||||
|
@ -106,7 +106,7 @@ print_format_caps_yuv(const VAImageFormat *va_format)
|
|||
}
|
||||
|
||||
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,
|
||||
|
@ -119,34 +119,26 @@ print_format_caps_rgb(const VAImageFormat *va_format)
|
|||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -240,6 +232,7 @@ end:
|
|||
static void
|
||||
dump_info(GstVaapiDisplay *display)
|
||||
{
|
||||
GArray *formats;
|
||||
GstCaps *caps;
|
||||
|
||||
caps = gst_vaapi_display_get_decode_caps(display);
|
||||
|
@ -256,19 +249,19 @@ dump_info(GstVaapiDisplay *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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue