1/* GStreamer
2 * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef __GST_VIDEO_META_H__
21#define __GST_VIDEO_META_H__
22
23#include <gst/gst.h>
24
25#include <gst/video/video.h>
26#include <gst/video/gstvideotimecode.h>
27
28G_BEGIN_DECLS
29
30#define GST_VIDEO_META_API_TYPE (gst_video_meta_api_get_type())
31#define GST_VIDEO_META_INFO (gst_video_meta_get_info())
32typedef struct _GstVideoMeta GstVideoMeta;
33
34#define GST_CAPS_FEATURE_META_GST_VIDEO_META "meta:GstVideoMeta"
35
36#define GST_VIDEO_CROP_META_API_TYPE (gst_video_crop_meta_api_get_type())
37#define GST_VIDEO_CROP_META_INFO (gst_video_crop_meta_get_info())
38typedef struct _GstVideoCropMeta GstVideoCropMeta;
39
40/**
41 * GstVideoMeta:
42 * @meta: parent #GstMeta
43 * @buffer: the buffer this metadata belongs to
44 * @flags: additional video flags
45 * @format: the video format
46 * @id: identifier of the frame
47 * @width: the video width
48 * @height: the video height
49 * @n_planes: the number of planes in the image
50 * @offset: array of offsets for the planes. This field might not always be
51 * valid, it is used by the default implementation of @map.
52 * @stride: array of strides for the planes. This field might not always be
53 * valid, it is used by the default implementation of @map.
54 * @map: map the memory of a plane
55 * @unmap: unmap the memory of a plane
56 * @alignment: the paddings and alignment constraints of the video buffer.
57 * It is up to the caller of `gst_buffer_add_video_meta_full()` to set it
58 * using gst_video_meta_set_alignment(), if they did not it defaults
59 * to no padding and no alignment. Since: 1.18
60 *
61 * Extra buffer metadata describing image properties
62 *
63 * This meta can also be used by downstream elements to specifiy their
64 * buffer layout requirements for upstream. Upstream should try to
65 * fit those requirements, if possible, in order to prevent buffer copies.
66 *
67 * This is done by passing a custom #GstStructure to
68 * gst_query_add_allocation_meta() when handling the ALLOCATION query.
69 * This structure should be named 'video-meta' and can have the following
70 * fields:
71 * - padding-top (uint): extra pixels on the top
72 * - padding-bottom (uint): extra pixels on the bottom
73 * - padding-left (uint): extra pixels on the left side
74 * - padding-right (uint): extra pixels on the right side
75 * The padding fields have the same semantic as #GstVideoMeta.alignment
76 * and so represent the paddings requested on produced video buffers.
77 *
78 * Since 1.24 it can be serialized using gst_meta_serialize() and
79 * gst_meta_deserialize().
80 */
81struct _GstVideoMeta {
82 GstMeta meta;
83
84 GstBuffer *buffer;
85
86 GstVideoFrameFlags flags;
87 GstVideoFormat format;
88 gint id;
89 guint width;
90 guint height;
91
92 guint n_planes;
93 gsize offset[GST_VIDEO_MAX_PLANES];
94 gint stride[GST_VIDEO_MAX_PLANES];
95
96 gboolean (*map) (GstVideoMeta *meta, guint plane, GstMapInfo *info,
97 gpointer *data, gint * stride, GstMapFlags flags);
98 gboolean (*unmap) (GstVideoMeta *meta, guint plane, GstMapInfo *info);
99
100 GstVideoAlignment alignment;
101};
102
103GST_VIDEO_API
104GType gst_video_meta_api_get_type (void);
105
106GST_VIDEO_API
107const GstMetaInfo * gst_video_meta_get_info (void);
108
109GST_VIDEO_API
110GstVideoMeta * gst_buffer_get_video_meta (GstBuffer *buffer);
111
112GST_VIDEO_API
113GstVideoMeta * gst_buffer_get_video_meta_id (GstBuffer *buffer, gint id);
114
115GST_VIDEO_API
116GstVideoMeta * gst_buffer_add_video_meta (GstBuffer *buffer, GstVideoFrameFlags flags,
117 GstVideoFormat format, guint width, guint height);
118
119GST_VIDEO_API
120GstVideoMeta * gst_buffer_add_video_meta_full (GstBuffer *buffer, GstVideoFrameFlags flags,
121 GstVideoFormat format, guint width, guint height,
122 guint n_planes, const gsize offset[GST_VIDEO_MAX_PLANES],
123 const gint stride[GST_VIDEO_MAX_PLANES]);
124
125GST_VIDEO_API
126gboolean gst_video_meta_map (GstVideoMeta *meta, guint plane, GstMapInfo *info,
127 gpointer *data, gint *stride, GstMapFlags flags);
128
129GST_VIDEO_API
130gboolean gst_video_meta_unmap (GstVideoMeta *meta, guint plane, GstMapInfo *info);
131
132GST_VIDEO_API
133gboolean gst_video_meta_set_alignment (GstVideoMeta * meta, GstVideoAlignment alignment);
134
135GST_VIDEO_API
136gboolean gst_video_meta_get_plane_size (GstVideoMeta * meta, gsize plane_size[GST_VIDEO_MAX_PLANES]);
137
138GST_VIDEO_API
139gboolean gst_video_meta_get_plane_height (GstVideoMeta * meta, guint plane_height[GST_VIDEO_MAX_PLANES]);
140
141/**
142 * GstVideoCropMeta:
143 * @meta: parent #GstMeta
144 * @x: the horizontal offset
145 * @y: the vertical offset
146 * @width: the cropped width
147 * @height: the cropped height
148 *
149 * Extra buffer metadata describing image cropping.
150 */
151struct _GstVideoCropMeta {
152 GstMeta meta;
153
154 guint x;
155 guint y;
156 guint width;
157 guint height;
158};
159
160GST_VIDEO_API
161GType gst_video_crop_meta_api_get_type (void);
162
163GST_VIDEO_API
164const GstMetaInfo * gst_video_crop_meta_get_info (void);
165
166#define gst_buffer_get_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_get_meta((b),GST_VIDEO_CROP_META_API_TYPE))
167#define gst_buffer_add_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_add_meta((b),GST_VIDEO_CROP_META_INFO, NULL))
168
169/* video metadata transforms */
170
171GST_VIDEO_API
172GQuark gst_video_meta_transform_scale_get_quark (void);
173/**
174 * gst_video_meta_transform_scale:
175 *
176 * GQuark for the video "gst-video-scale" transform.
177 */
178#define GST_VIDEO_META_TRANSFORM_IS_SCALE(type) ((type) == gst_video_meta_transform_scale_get_quark())
179
180/**
181 * GstVideoMetaTransform:
182 * @in_info: the input #GstVideoInfo
183 * @out_info: the output #GstVideoInfo
184 *
185 * Extra data passed to a video transform #GstMetaTransformFunction such as:
186 * "gst-video-scale".
187 */
188typedef struct {
189 GstVideoInfo *in_info;
190 GstVideoInfo *out_info;
191} GstVideoMetaTransform;
192
193/**
194 * GstVideoGLTextureType:
195 * @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE: Luminance texture, GL_LUMINANCE
196 * @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA: Luminance-alpha texture, GL_LUMINANCE_ALPHA
197 * @GST_VIDEO_GL_TEXTURE_TYPE_RGB16: RGB 565 texture, GL_RGB
198 * @GST_VIDEO_GL_TEXTURE_TYPE_RGB: RGB texture, GL_RGB
199 * @GST_VIDEO_GL_TEXTURE_TYPE_RGBA: RGBA texture, GL_RGBA
200 * @GST_VIDEO_GL_TEXTURE_TYPE_R: R texture, GL_RED_EXT
201 * @GST_VIDEO_GL_TEXTURE_TYPE_RG: RG texture, GL_RG_EXT
202 *
203 * The GL texture type.
204 */
205typedef enum
206{
207 GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE,
208 GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
209 GST_VIDEO_GL_TEXTURE_TYPE_RGB16,
210 GST_VIDEO_GL_TEXTURE_TYPE_RGB,
211 GST_VIDEO_GL_TEXTURE_TYPE_RGBA,
212 GST_VIDEO_GL_TEXTURE_TYPE_R,
213 GST_VIDEO_GL_TEXTURE_TYPE_RG
214} GstVideoGLTextureType;
215
216/**
217 * GstVideoGLTextureOrientation:
218 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL: Top line first in memory, left row first
219 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP: Bottom line first in memory, left row first
220 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL: Top line first in memory, right row first
221 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP: Bottom line first in memory, right row first
222 *
223 * The orientation of the GL texture.
224 */
225typedef enum
226{
227 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL,
228 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP,
229 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL,
230 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP
231} GstVideoGLTextureOrientation;
232
233#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE (gst_video_gl_texture_upload_meta_api_get_type())
234#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_INFO (gst_video_gl_texture_upload_meta_get_info())
235
236typedef struct _GstVideoGLTextureUploadMeta GstVideoGLTextureUploadMeta;
237typedef gboolean (*GstVideoGLTextureUpload) (GstVideoGLTextureUploadMeta *meta, guint texture_id[4]);
238
239#define GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META "meta:GstVideoGLTextureUploadMeta"
240
241/**
242 * GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META:
243 *
244 * An option that can be activated on a bufferpool to request gl texture upload
245 * meta on buffers from the pool.
246 *
247 * When this option is enabled on the bufferpool,
248 * @GST_BUFFER_POOL_OPTION_VIDEO_META should also be enabled.
249 *
250 * Since: 1.2.2
251 */
252#define GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META "GstBufferPoolOptionVideoGLTextureUploadMeta"
253
254/**
255 * GstVideoGLTextureUploadMeta:
256 * @meta: parent #GstMeta
257 * @texture_orientation: Orientation of the textures
258 * @n_textures: Number of textures that are generated
259 * @texture_type: Type of each texture
260 *
261 * Extra buffer metadata for uploading a buffer to an OpenGL texture
262 * ID. The caller of gst_video_gl_texture_upload_meta_upload() must
263 * have OpenGL set up and call this from a thread where it is valid
264 * to upload something to an OpenGL texture.
265 */
266
267struct _GstVideoGLTextureUploadMeta {
268 GstMeta meta;
269
270 GstVideoGLTextureOrientation texture_orientation;
271 guint n_textures;
272 GstVideoGLTextureType texture_type[4];
273
274 /* <private> */
275 GstBuffer *buffer;
276 GstVideoGLTextureUpload upload;
277
278 gpointer user_data;
279 GBoxedCopyFunc user_data_copy;
280 GBoxedFreeFunc user_data_free;
281};
282
283GST_VIDEO_API
284GType gst_video_gl_texture_upload_meta_api_get_type (void);
285
286GST_VIDEO_API
287const GstMetaInfo * gst_video_gl_texture_upload_meta_get_info (void);
288
289#define gst_buffer_get_video_gl_texture_upload_meta(b) ((GstVideoGLTextureUploadMeta*)gst_buffer_get_meta((b),GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE))
290
291GST_VIDEO_API
292GstVideoGLTextureUploadMeta *
293 gst_buffer_add_video_gl_texture_upload_meta (GstBuffer *buffer,
294 GstVideoGLTextureOrientation texture_orientation,
295 guint n_textures,
296 GstVideoGLTextureType texture_type[4],
297 GstVideoGLTextureUpload upload,
298 gpointer user_data,
299 GBoxedCopyFunc user_data_copy,
300 GBoxedFreeFunc user_data_free);
301
302GST_VIDEO_API
303gboolean gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta *meta,
304 guint texture_id[4]);
305
306
307/**
308 * GstVideoRegionOfInterestMeta:
309 * @meta: parent #GstMeta
310 * @roi_type: GQuark describing the semantic of the Roi (f.i. a face, a pedestrian)
311 * @id: identifier of this particular ROI
312 * @parent_id: identifier of its parent ROI, used f.i. for ROI hierarchisation.
313 * @x: x component of upper-left corner
314 * @y: y component of upper-left corner
315 * @w: bounding box width
316 * @h: bounding box height
317 * @params: list of #GstStructure containing element-specific params for downstream,
318 * see gst_video_region_of_interest_meta_add_param(). (Since: 1.14)
319 *
320 * Extra buffer metadata describing an image region of interest
321 */
322typedef struct {
323 GstMeta meta;
324
325 GQuark roi_type;
326 gint id;
327 gint parent_id;
328
329 guint x;
330 guint y;
331 guint w;
332 guint h;
333
334 GList *params;
335} GstVideoRegionOfInterestMeta;
336
337GST_VIDEO_API
338GType gst_video_region_of_interest_meta_api_get_type (void);
339#define GST_VIDEO_REGION_OF_INTEREST_META_API_TYPE (gst_video_region_of_interest_meta_api_get_type())
340GST_VIDEO_API
341const GstMetaInfo *gst_video_region_of_interest_meta_get_info (void);
342#define GST_VIDEO_REGION_OF_INTEREST_META_INFO (gst_video_region_of_interest_meta_get_info())
343
344#define gst_buffer_get_video_region_of_interest_meta(b) \
345 ((GstVideoRegionOfInterestMeta*)gst_buffer_get_meta((b),GST_VIDEO_REGION_OF_INTEREST_META_API_TYPE))
346GST_VIDEO_API
347GstVideoRegionOfInterestMeta *gst_buffer_get_video_region_of_interest_meta_id (GstBuffer * buffer,
348 gint id);
349
350GST_VIDEO_API
351GstVideoRegionOfInterestMeta *gst_buffer_add_video_region_of_interest_meta (GstBuffer * buffer,
352 const gchar * roi_type,
353 guint x,
354 guint y,
355 guint w,
356 guint h);
357
358GST_VIDEO_API
359GstVideoRegionOfInterestMeta *gst_buffer_add_video_region_of_interest_meta_id (GstBuffer * buffer,
360 GQuark roi_type,
361 guint x,
362 guint y,
363 guint w,
364 guint h);
365GST_VIDEO_API
366void gst_video_region_of_interest_meta_add_param (GstVideoRegionOfInterestMeta * meta,
367 GstStructure * s);
368
369GST_VIDEO_API
370GstStructure *gst_video_region_of_interest_meta_get_param (GstVideoRegionOfInterestMeta * meta,
371 const gchar * name);
372
373/**
374 * GstVideoTimeCodeMeta:
375 * @meta: parent #GstMeta
376 * @tc: the GstVideoTimeCode to attach
377 *
378 * Extra buffer metadata describing the GstVideoTimeCode of the frame.
379 *
380 * Each frame is assumed to have its own timecode, i.e. they are not
381 * automatically incremented/interpolated.
382 *
383 * Since: 1.10
384 */
385typedef struct {
386 GstMeta meta;
387
388 GstVideoTimeCode tc;
389} GstVideoTimeCodeMeta;
390
391GST_VIDEO_API
392GType gst_video_time_code_meta_api_get_type (void);
393#define GST_VIDEO_TIME_CODE_META_API_TYPE (gst_video_time_code_meta_api_get_type())
394
395GST_VIDEO_API
396const GstMetaInfo *gst_video_time_code_meta_get_info (void);
397#define GST_VIDEO_TIME_CODE_META_INFO (gst_video_time_code_meta_get_info())
398
399#define gst_buffer_get_video_time_code_meta(b) \
400 ((GstVideoTimeCodeMeta*)gst_buffer_get_meta((b),GST_VIDEO_TIME_CODE_META_API_TYPE))
401
402GST_VIDEO_API
403GstVideoTimeCodeMeta *gst_buffer_add_video_time_code_meta (GstBuffer * buffer,
404 const GstVideoTimeCode* tc);
405
406GST_VIDEO_API
407GstVideoTimeCodeMeta *
408gst_buffer_add_video_time_code_meta_full (GstBuffer * buffer,
409 guint fps_n,
410 guint fps_d,
411 GDateTime * latest_daily_jam,
412 GstVideoTimeCodeFlags flags,
413 guint hours,
414 guint minutes,
415 guint seconds,
416 guint frames,
417 guint field_count);
418
419G_END_DECLS
420
421#endif /* __GST_VIDEO_META_H__ */
422

source code of include/gstreamer-1.0/gst/video/gstvideometa.h