1 /*
2  *  gstvaapicontext.h - VA context abstraction (private)
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2011-2014 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24 
25 #ifndef GST_VAAPI_CONTEXT_H
26 #define GST_VAAPI_CONTEXT_H
27 
28 #include "gstvaapiobject.h"
29 #include "gstvaapiobject_priv.h"
30 #include "gstvaapiprofile.h"
31 #include "gstvaapidisplay.h"
32 #include "gstvaapisurface.h"
33 #include "gstvaapivideopool.h"
34 
35 G_BEGIN_DECLS
36 
37 #define GST_VAAPI_CONTEXT(obj) \
38   ((GstVaapiContext *) (obj))
39 
40 typedef struct _GstVaapiConfigInfoEncoder GstVaapiConfigInfoEncoder;
41 typedef struct _GstVaapiContextInfo GstVaapiContextInfo;
42 typedef struct _GstVaapiContext GstVaapiContext;
43 typedef struct _GstVaapiContextClass GstVaapiContextClass;
44 
45 /**
46  * GstVaapiContextUsage:
47  * @GST_VAAPI_CONTEXT_MODE_DECODE: context used for decoding.
48  * @GST_VAAPI_CONTEXT_MODE_ENCODE: context used for encoding.
49  * @GST_VAAPI_CONTEXT_MODE_VPP: context used for video processing.
50  *
51  * The set of supported VA context usages.
52  */
53 typedef enum {
54   GST_VAAPI_CONTEXT_USAGE_DECODE = 1,
55   GST_VAAPI_CONTEXT_USAGE_ENCODE,
56   GST_VAAPI_CONTEXT_USAGE_VPP,
57 } GstVaapiContextUsage;
58 
59 /**
60  * GstVaapiConfigInfoEncoder:
61  * @rc_mode: rate-control mode (#GstVaapiRateControl).
62  * @packed_headers: notify encoder that packed headers are submitted (mask).
63  * @roi_capability: if encoder supports regions-of-interest.
64  * @roi_num_supported: The number of regions-of-interest supported.
65  * @fei_function: The functional mode for FEI Entrypoint (VA_FEI_FUNCTION_*).
66  *
67  * Extra configuration for encoding.
68  */
69 struct _GstVaapiConfigInfoEncoder
70 {
71   GstVaapiRateControl rc_mode;
72   guint packed_headers;
73   gboolean roi_capability;
74   guint roi_num_supported;
75   guint fei_function;
76 };
77 
78 /**
79  * GstVaapiContextInfo:
80  *
81  * Structure holding VA context info like encoded size, decoder
82  * profile and entry-point to use, and maximum number of reference
83  * frames reported by the bitstream.
84  */
85 struct _GstVaapiContextInfo
86 {
87   GstVaapiContextUsage usage;
88   GstVaapiProfile profile;
89   GstVaapiEntrypoint entrypoint;
90   GstVaapiChromaType chroma_type;
91   guint width;
92   guint height;
93   guint ref_frames;
94   union _GstVaapiConfigInfo {
95     GstVaapiConfigInfoEncoder encoder;
96   } config;
97 };
98 
99 /**
100  * GstVaapiContext:
101  *
102  * A VA context wrapper.
103  */
104 struct _GstVaapiContext
105 {
106   /*< private >*/
107   GstVaapiObject parent_instance;
108 
109   GstVaapiContextInfo info;
110   VAProfile va_profile;
111   VAEntrypoint va_entrypoint;
112   VAConfigID va_config;
113   GPtrArray *surfaces;
114   GstVaapiVideoPool *surfaces_pool;
115   GPtrArray *overlays[2];
116   guint overlay_id;
117   gboolean reset_on_resize;
118   GArray *formats;
119 };
120 
121 /**
122  * GstVaapiContextClass:
123  *
124  * A VA context wrapper class.
125  */
126 struct _GstVaapiContextClass
127 {
128   /*< private >*/
129   GstVaapiObjectClass parent_class;
130 };
131 
132 G_GNUC_INTERNAL
133 GstVaapiContext *
134 gst_vaapi_context_new (GstVaapiDisplay * display,
135     const GstVaapiContextInfo * cip);
136 
137 G_GNUC_INTERNAL
138 gboolean
139 gst_vaapi_context_reset (GstVaapiContext * context,
140     const GstVaapiContextInfo * new_cip);
141 
142 G_GNUC_INTERNAL
143 GstVaapiID
144 gst_vaapi_context_get_id (GstVaapiContext * context);
145 
146 G_GNUC_INTERNAL
147 GstVaapiSurfaceProxy *
148 gst_vaapi_context_get_surface_proxy (GstVaapiContext * context);
149 
150 G_GNUC_INTERNAL
151 guint
152 gst_vaapi_context_get_surface_count (GstVaapiContext * context);
153 
154 G_GNUC_INTERNAL
155 void
156 gst_vaapi_context_reset_on_resize (GstVaapiContext * context,
157     gboolean reset_on_resize);
158 
159 G_GNUC_INTERNAL
160 GArray *
161 gst_vaapi_context_get_surface_formats (GstVaapiContext * context);
162 
163 G_END_DECLS
164 
165 #endif /* GST_VAAPI_CONTEXT_H */
166