encoder: vaapicontext support rate-control
[vaapi:windyuan-gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapicontext.h
1 /*
2  *  gstvaapicontext.h - VA context abstraction
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *  Copyright (C) 2011 Intel Corporation
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Lesser General Public License
9  *  as published by the Free Software Foundation; either version 2.1
10  *  of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this library; if not, write to the Free
19  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  *  Boston, MA 02110-1301 USA
21  */
22
23 #ifndef GST_VAAPI_CONTEXT_H
24 #define GST_VAAPI_CONTEXT_H
25
26 #include <gst/vaapi/gstvaapiobject.h>
27 #include <gst/vaapi/gstvaapiprofile.h>
28 #include <gst/vaapi/gstvaapidisplay.h>
29 #include <gst/vaapi/gstvaapisurface.h>
30 #include <gst/video/video-overlay-composition.h>
31 #include <gst/vaapi/gstvaapisurfacepool.h>
32
33 G_BEGIN_DECLS
34
35 #define GST_VAAPI_TYPE_CONTEXT \
36     (gst_vaapi_context_get_type())
37
38 #define GST_VAAPI_CONTEXT(obj)                          \
39     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
40                                 GST_VAAPI_TYPE_CONTEXT, \
41                                 GstVaapiContext))
42
43 #define GST_VAAPI_CONTEXT_CLASS(klass)                  \
44     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
45                              GST_VAAPI_TYPE_CONTEXT,    \
46                              GstVaapiContextClass))
47
48 #define GST_VAAPI_IS_CONTEXT(obj) \
49     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_CONTEXT))
50
51 #define GST_VAAPI_IS_CONTEXT_CLASS(klass) \
52     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_CONTEXT))
53
54 #define GST_VAAPI_CONTEXT_GET_CLASS(obj)                \
55     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
56                                GST_VAAPI_TYPE_CONTEXT,  \
57                                GstVaapiContextClass))
58
59 typedef struct _GstVaapiContext                 GstVaapiContext;
60 typedef struct _GstVaapiContextInfo             GstVaapiContextInfo;
61 typedef struct _GstVaapiContextPrivate          GstVaapiContextPrivate;
62 typedef struct _GstVaapiContextClass            GstVaapiContextClass;
63
64 /**
65  * GstVaapiContextInfo:
66  *
67  * Structure holding VA context info like encoded size, decoder
68  * profile and entry-point to use, and maximum number of reference
69  * frames reported by the bitstream.
70  */
71 struct _GstVaapiContextInfo {
72     GstVaapiProfile     profile;
73     GstVaapiEntrypoint  entrypoint;
74     GstVaapiRateControl rate_control;
75     guint               width;
76     guint               height;
77     guint               ref_frames;
78 };
79
80 /**
81  * GstVaapiContext:
82  *
83  * A VA context wrapper.
84  */
85 struct _GstVaapiContext {
86     /*< private >*/
87     GstVaapiObject parent_instance;
88
89     GstVaapiContextPrivate *priv;
90 };
91
92 /**
93  * GstVaapiContextClass:
94  *
95  * A VA context wrapper class.
96  */
97 struct _GstVaapiContextClass {
98     /*< private >*/
99     GstVaapiObjectClass parent_class;
100 };
101
102 GType
103 gst_vaapi_context_get_type(void) G_GNUC_CONST;
104
105 GstVaapiContext *
106 gst_vaapi_context_new(
107     GstVaapiDisplay    *display,
108     GstVaapiProfile     profile,
109     GstVaapiEntrypoint  entrypoint,
110     guint               width,
111     guint               height
112 );
113
114 GstVaapiContext *
115 gst_vaapi_context_new_encoder(
116     GstVaapiDisplay    *display,
117     GstVaapiProfile     profile,
118     guint               width,
119     guint               height,
120     GstVaapiRateControl rate_control
121 );
122
123 GstVaapiContext *
124 gst_vaapi_context_new_full(GstVaapiDisplay *display, GstVaapiContextInfo *cip);
125
126 gboolean
127 gst_vaapi_context_reset(
128     GstVaapiContext    *context,
129     GstVaapiProfile     profile,
130     GstVaapiEntrypoint  entrypoint,
131     guint               width,
132     guint               height
133 );
134
135 gboolean
136 gst_vaapi_context_reset_full(GstVaapiContext *context, GstVaapiContextInfo *cip);
137
138 GstVaapiID
139 gst_vaapi_context_get_id(GstVaapiContext *context);
140
141 GstVaapiProfile
142 gst_vaapi_context_get_profile(GstVaapiContext *context);
143
144 gboolean
145 gst_vaapi_context_set_profile(GstVaapiContext *context, GstVaapiProfile profile);
146
147 GstVaapiEntrypoint
148 gst_vaapi_context_get_entrypoint(GstVaapiContext *context);
149
150 void
151 gst_vaapi_context_get_size(
152     GstVaapiContext *context,
153     guint           *pwidth,
154     guint           *pheight
155 );
156
157 GstVaapiSurface *
158 gst_vaapi_context_get_surface(GstVaapiContext *context);
159
160 GstVaapiSurfacePool *
161 gst_vaapi_context_get_surface_pool(GstVaapiContext *context);
162
163
164 guint
165 gst_vaapi_context_get_surface_count(GstVaapiContext *context);
166
167 void
168 gst_vaapi_context_put_surface(GstVaapiContext *context, GstVaapiSurface *surface);
169
170 GstVaapiSurface *
171 gst_vaapi_context_find_surface_by_id(GstVaapiContext *context, GstVaapiID id);
172
173 gboolean
174 gst_vaapi_context_apply_composition(
175     GstVaapiContext            *context,
176     GstVideoOverlayComposition *composition
177 );
178
179 G_END_DECLS
180
181 #endif /* GST_VAAPI_CONTEXT_H */