1 /*
2  *  gstvaapitexture.h - VA texture abstraction
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2012-2013 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_TEXTURE_H
26 #define GST_VAAPI_TEXTURE_H
27 
28 #include <gst/vaapi/gstvaapitypes.h>
29 #include <gst/vaapi/gstvaapisurface.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GST_VAAPI_TEXTURE(obj) \
34   ((GstVaapiTexture *)(obj))
35 
36 /**
37  * GST_VAAPI_TEXTURE_ID:
38  * @texture: a #GstVaapiTexture
39  *
40  * Macro that evaluates to the GL texture id associated with the @texture
41  */
42 #define GST_VAAPI_TEXTURE_ID(texture) \
43   gst_vaapi_texture_get_id (GST_VAAPI_TEXTURE (texture))
44 
45 /**
46  * GST_VAAPI_TEXTURE_TARGET:
47  * @texture: a #GstVaapiTexture
48  *
49  * Macro that evaluates to the GL texture target associated with the @texture
50  */
51 #define GST_VAAPI_TEXTURE_TARGET(texture) \
52   gst_vaapi_texture_get_target (GST_VAAPI_TEXTURE (texture))
53 
54 /**
55  * GST_VAAPI_TEXTURE_FORMAT:
56  * @texture: a #GstVaapiTexture
57  *
58  * Macro that evaluates to the GL texture format associated with the @texture
59  */
60 #define GST_VAAPI_TEXTURE_FORMAT(texture) \
61   gst_vaapi_texture_get_format (GST_VAAPI_TEXTURE (texture))
62 
63 /**
64  * GST_VAAPI_TEXTURE_WIDTH:
65  * @texture: a #GstVaapiTexture
66  *
67  * Macro that evaluates to the GL texture width associated with the @texture
68  */
69 #define GST_VAAPI_TEXTURE_WIDTH(texture) \
70   gst_vaapi_texture_get_width (GST_VAAPI_TEXTURE (texture))
71 
72 /**
73  * GST_VAAPI_TEXTURE_HEIGHT:
74  * @texture: a #GstVaapiTexture
75  *
76  * Macro that evaluates to the GL texture height associated with the @texture
77  */
78 #define GST_VAAPI_TEXTURE_HEIGHT(texture) \
79   gst_vaapi_texture_get_height (GST_VAAPI_TEXTURE (texture))
80 
81 typedef struct _GstVaapiTexture GstVaapiTexture;
82 
83 /**
84  * GstVaapiTextureOrientationFlags:
85  * @GST_VAAPI_TEXTURE_ORIENTATION_FLAG_X_INVERTED: indicates whether
86  *   the right row comes first in memory.
87  * @GST_VAAPI_TEXTURE_ORIENTATION_FLAG_Y_INVERTED: indicates whether
88  *   the bottom line comes first in memory.
89  *
90  * Additional flags to indicate whether the texture data is organized
91  * in memory with the X or Y, or both, axis inverted. e.g. if only
92  * @GST_VAAPI_TEXTURE_ORIENTATION_FLAG_Y_INVERTED is set, this means
93  * that the bottom line comes first in memory, with pixels laid out
94  * from the left to the right.
95  */
96 typedef enum {
97   GST_VAAPI_TEXTURE_ORIENTATION_FLAG_X_INVERTED = 1 << 31,
98   GST_VAAPI_TEXTURE_ORIENTATION_FLAG_Y_INVERTED = 1 << 30,
99 } GstVaapiTextureOrientationFlags;
100 
101 GstVaapiTexture *
102 gst_vaapi_texture_new (GstVaapiDisplay * display, guint target, guint format,
103     guint width, guint height);
104 
105 GstVaapiTexture *
106 gst_vaapi_texture_new_wrapped (GstVaapiDisplay * display, guint id,
107     guint target, guint format, guint width, guint height);
108 
109 GstVaapiTexture *
110 gst_vaapi_texture_ref (GstVaapiTexture * texture);
111 
112 void
113 gst_vaapi_texture_unref (GstVaapiTexture * texture);
114 
115 void
116 gst_vaapi_texture_replace (GstVaapiTexture ** old_texture_ptr,
117     GstVaapiTexture * new_texture);
118 
119 guint
120 gst_vaapi_texture_get_id (GstVaapiTexture * texture);
121 
122 guint
123 gst_vaapi_texture_get_target (GstVaapiTexture * texture);
124 
125 guint
126 gst_vaapi_texture_get_format (GstVaapiTexture * texture);
127 
128 guint
129 gst_vaapi_texture_get_width (GstVaapiTexture * texture);
130 
131 guint
132 gst_vaapi_texture_get_height (GstVaapiTexture * texture);
133 
134 void
135 gst_vaapi_texture_get_size (GstVaapiTexture * texture, guint * width_ptr,
136     guint * height_ptr);
137 
138 guint
139 gst_vaapi_texture_get_orientation_flags (GstVaapiTexture * texture);
140 
141 void
142 gst_vaapi_texture_set_orientation_flags (GstVaapiTexture * texture,
143     guint flags);
144 
145 gboolean
146 gst_vaapi_texture_put_surface (GstVaapiTexture * texture,
147     GstVaapiSurface * surface, const GstVaapiRectangle * crop_rect,
148     guint flags);
149 
150 G_END_DECLS
151 
152 #endif /* GST_VAAPI_TEXTURE_H */
153