diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2019-08-05 19:47:30 +0200 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2019-08-19 17:26:55 +0000 |
commit | f7c1ac036d11b1120664ce79cbdc7d311144fd41 (patch) | |
tree | e945f415c55561542884b3ffa570c6b165ae57fe /gst-libs/gst/vaapi/gstvaapiprofilecaps.c | |
parent | 4b5459b1b14d42e77f2651dfc3e69e81c7266168 (diff) |
libs: profilecaps: move caps config into a new file
Implement all the appending of frame size restrictions in caps, for
encoders and decoders, in a new source file.
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapiprofilecaps.c')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiprofilecaps.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiprofilecaps.c b/gst-libs/gst/vaapi/gstvaapiprofilecaps.c new file mode 100644 index 00000000..b786b77b --- /dev/null +++ b/gst-libs/gst/vaapi/gstvaapiprofilecaps.c @@ -0,0 +1,118 @@ +/* + * gstvaapiprofilecaps.h - VA config attributes as gstreamer capabilities + * + * Copyright (C) 2019 Igalia, S.L. + * Author: Víctor Jáquez <vjaquez@igalia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +/** + * SECTION:gstvaapiprofilecaps + * @short_description: VA config attributes as gstreamer capabilities + */ + +#include "sysdeps.h" +#include "gstvaapicompat.h" +#include "gstvaapicontext.h" +#include "gstvaapiprofilecaps.h" +#include "gstvaapiutils.h" + +static gboolean +init_context_info (GstVaapiDisplay * display, GstVaapiContextInfo * cip) +{ + guint value = 0; + + /* XXX: Only try a context from he first RTFormat in config. */ + if (!gst_vaapi_get_config_attribute (display, + gst_vaapi_profile_get_va_profile (cip->profile), + gst_vaapi_entrypoint_get_va_entrypoint (cip->entrypoint), + VAConfigAttribRTFormat, &value)) { + return FALSE; + } + + cip->chroma_type = to_GstVaapiChromaType (value); + return cip->chroma_type != 0; +} + +static GstVaapiContext * +create_context (GstVaapiDisplay * display, GstVaapiContextInfo * cip) +{ + if (!init_context_info (display, cip)) + return NULL; + return gst_vaapi_context_new (display, cip); +} + +static gboolean +append_caps (GstVaapiContext * context, GstStructure * structure) +{ + GstVaapiConfigSurfaceAttributes attribs = { 0, }; + + if (!gst_vaapi_context_get_surface_attributes (context, &attribs)) + return FALSE; + + 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_decoder_add_profile_caps: + * @display: a #GstVaapiDisplay + * @profile: a #GstVaapiProfile + * @structure: a #GstStructure + * + * Extracts the config's surface attributes, from @profile, in an + * decoder context, and transforms it into a caps formats and appended + * into @structure. + * + * Returns: %TRUE if the capabilities could be extracted and appended + * into @structure; otherwise %FALSE + **/ +gboolean +gst_vaapi_profile_caps_append_decoder (GstVaapiDisplay * display, + GstVaapiProfile profile, GstStructure * structure) +{ + GstVaapiContext *context; + GstVaapiContextInfo cip = { + GST_VAAPI_CONTEXT_USAGE_DECODE, profile, GST_VAAPI_ENTRYPOINT_VLD, 0, + }; + gboolean ret; + + g_return_val_if_fail (display != NULL, FALSE); + g_return_val_if_fail (structure != NULL, FALSE); + + context = create_context (display, &cip); + if (!context) + return FALSE; + + ret = append_caps (context, structure); + gst_vaapi_object_unref (context); + return ret; +} + +gboolean +gst_vaapi_profile_caps_append_encoder (GstVaapiDisplay * display, + GstVaapiProfile profile, GstStructure * structure) +{ + return TRUE; +} |