1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* 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;
}
static gboolean
append_caps_with_context_info (GstVaapiDisplay * display,
GstVaapiContextInfo * cip, GstStructure * structure)
{
GstVaapiContext *context;
gboolean ret;
context = create_context (display, cip);
if (!context)
return FALSE;
ret = append_caps (context, structure);
gst_vaapi_context_unref (context);
return ret;
}
/**
* gst_vaapi_decoder_add_profile_caps:
* @display: a #GstVaapiDisplay
* @profile: a #GstVaapiProfile
* @structure: a #GstStructure
*
* Extracts the config's surface attributes, from @profile, in a
* 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)
{
GstVaapiContextInfo cip = {
GST_VAAPI_CONTEXT_USAGE_DECODE, profile, GST_VAAPI_ENTRYPOINT_VLD, 0,
};
g_return_val_if_fail (display != NULL, FALSE);
g_return_val_if_fail (structure != NULL, FALSE);
return append_caps_with_context_info (display, &cip, structure);
}
|