diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2020-01-22 17:41:28 +0100 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2020-07-27 19:32:00 +0200 |
commit | 634fefab5df3caf98586cb4314ecd2deb0a59eba (patch) | |
tree | 1c0346b759bc80beabada3617d3b2a15276b6343 /gst-libs/gst | |
parent | f04dd7f33100ead30d98e5c76d42ee24290fa771 (diff) |
vaapidecode: build allowed srcpad caps from va context
Instead of generating allowed srcpad caps with generic information,
now it takes the size an formats limits from the decoder's context.
This is possible since srcpad caps are generated after the internal
decoder is created.
The patch replaces gst_vaapi_decoder_get_surface_formats() with
gst_vaapi_decoder_get_suface_attributes().
From these attributes, formats are only used for VASurface memory
caps feature. For system memory caps feature, the old
gst_vaapi_plugin_get_allowed_srcpad_caps() is still used, since
i965 jpeg decoder cannot deliver mappable format for gstreamer.
And for the other caps features (dmabuf and texture upload) the
same static list are used.
This patch also adds DMABuf caps feature only if the context
supports that memory type. Nonetheless, we keep the pre-defined
formats since they are the subset of common derive formats formats
supported either by amd/gallium and both intel drivers, since,
when exporting the fd through vaAcquireBufferHandle()/
vaReleaseBufferHandle(), the formats of the derivable image cannot
be retriebable from the driver. Later we'll use the attribute
formats for the DMABuf feature too, when the code be ported to
vaExportSurfaceHandle().
Finally, the allowed srcpad caps are removed if the internal decoder
is destroyed, since context attribues will change.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
Diffstat (limited to 'gst-libs/gst')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidecoder.c | 65 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidecoder.h | 8 |
2 files changed, 52 insertions, 21 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.c b/gst-libs/gst/vaapi/gstvaapidecoder.c index 0b60b877..093fcc05 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder.c @@ -1125,24 +1125,6 @@ gst_vaapi_decoder_decode_codec_data (GstVaapiDecoder * decoder) } /** - * gst_vaapi_decoder_get_surface_formats: - * @decoder: a #GstVaapiDecoder - * - * Retrieves an array of #GstVideoFormat which the output surfaces of - * the @decoder can handle. - * - * Return value: (transfer full): a #GArray of #GstVideoFormat or - * %NULL - */ -GArray * -gst_vaapi_decoder_get_surface_formats (GstVaapiDecoder * decoder) -{ - if (decoder && decoder->context) - return gst_vaapi_context_get_surface_formats (decoder->context); - return NULL; -} - -/** * gst_vaapi_decoder_update_caps: * @decoder: a #GstVaapiDecoder * @caps: a #GstCaps @@ -1189,3 +1171,50 @@ gst_vaapi_decoder_update_caps (GstVaapiDecoder * decoder, GstCaps * caps) return FALSE; } + +/** + * gst_vaapi_decoder_get_surface_attributres: + * @decoder: a #GstVaapiDecoder instances + * @min_width (out): the minimal surface width + * @min_height (out): the minimal surface height + * @max_width (out): the maximal surface width + * @max_height (out): the maximal surface height + * + * Fetches the valid surface's attributes for the current context. + * + * Returns: a #GArray of valid formats we get or %NULL if failed. + **/ +GArray * +gst_vaapi_decoder_get_surface_attributes (GstVaapiDecoder * decoder, + gint * min_width, gint * min_height, gint * max_width, gint * max_height, + guint * mem_types) +{ + gboolean ret; + GstVaapiConfigSurfaceAttributes attribs = { 0, }; + + g_return_val_if_fail (decoder != NULL, FALSE); + + if (!decoder->context) + return NULL; + + ret = gst_vaapi_context_get_surface_attributes (decoder->context, &attribs); + if (ret) + attribs.formats = gst_vaapi_context_get_surface_formats (decoder->context); + + if (attribs.formats->len == 0) { + g_array_unref (attribs.formats); + return NULL; + } + + if (min_width) + *min_width = attribs.min_width; + if (min_height) + *min_height = attribs.min_height; + if (max_width) + *max_width = attribs.max_width; + if (max_height) + *max_height = attribs.max_height; + if (mem_types) + *mem_types = attribs.mem_types; + return attribs.formats; +} diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.h b/gst-libs/gst/vaapi/gstvaapidecoder.h index b9bca4b2..2c55e2e1 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder.h +++ b/gst-libs/gst/vaapi/gstvaapidecoder.h @@ -103,9 +103,6 @@ gst_vaapi_decoder_set_codec_state_changed_func (GstVaapiDecoder * decoder, GstCaps * gst_vaapi_decoder_get_caps (GstVaapiDecoder * decoder); -GArray * -gst_vaapi_decoder_get_surface_formats (GstVaapiDecoder * decoder); - gboolean gst_vaapi_decoder_put_buffer (GstVaapiDecoder * decoder, GstBuffer * buf); @@ -139,6 +136,11 @@ gst_vaapi_decoder_reset (GstVaapiDecoder * decoder); gboolean gst_vaapi_decoder_update_caps (GstVaapiDecoder * decoder, GstCaps * caps); +GArray * +gst_vaapi_decoder_get_surface_attributes (GstVaapiDecoder * decoder, + gint * min_width, gint * min_height, gint * max_width, gint * max_height, + guint * mem_types); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiDecoder, gst_object_unref) G_END_DECLS |