2 * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
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.
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.
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.
20 #ifndef __GST_VIDEO_META_H__
21 #define __GST_VIDEO_META_H__
25 #include <gst/video/video.h>
26 #include <gst/video/gstvideotimecode.h>
30 #define GST_VIDEO_META_API_TYPE (gst_video_meta_api_get_type())
31 #define GST_VIDEO_META_INFO (gst_video_meta_get_info())
32 typedef struct _GstVideoMeta GstVideoMeta;
34 #define GST_CAPS_FEATURE_META_GST_VIDEO_META "meta:GstVideoMeta"
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())
38 typedef struct _GstVideoCropMeta GstVideoCropMeta;
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
61 * Extra buffer metadata describing image properties
63 struct _GstVideoMeta {
68 GstVideoFrameFlags flags;
69 GstVideoFormat format;
75 gsize offset[GST_VIDEO_MAX_PLANES];
76 gint stride[GST_VIDEO_MAX_PLANES];
78 gboolean (*map) (GstVideoMeta *meta, guint plane, GstMapInfo *info,
79 gpointer *data, gint * stride, GstMapFlags flags);
80 gboolean (*unmap) (GstVideoMeta *meta, guint plane, GstMapInfo *info);
82 GstVideoAlignment alignment;
86 GType gst_video_meta_api_get_type (void);
89 const GstMetaInfo * gst_video_meta_get_info (void);
92 GstVideoMeta * gst_buffer_get_video_meta (GstBuffer *buffer);
95 GstVideoMeta * gst_buffer_get_video_meta_id (GstBuffer *buffer, gint id);
98 GstVideoMeta * gst_buffer_add_video_meta (GstBuffer *buffer, GstVideoFrameFlags flags,
99 GstVideoFormat format, guint width, guint height);
102 GstVideoMeta * gst_buffer_add_video_meta_full (GstBuffer *buffer, GstVideoFrameFlags flags,
103 GstVideoFormat format, guint width, guint height,
104 guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
105 gint stride[GST_VIDEO_MAX_PLANES]);
108 gboolean gst_video_meta_map (GstVideoMeta *meta, guint plane, GstMapInfo *info,
109 gpointer *data, gint *stride, GstMapFlags flags);
112 gboolean gst_video_meta_unmap (GstVideoMeta *meta, guint plane, GstMapInfo *info);
115 gboolean gst_video_meta_set_alignment (GstVideoMeta * meta, GstVideoAlignment alignment);
118 gboolean gst_video_meta_get_plane_size (GstVideoMeta * meta, gsize plane_size[GST_VIDEO_MAX_PLANES]);
121 gboolean gst_video_meta_get_plane_height (GstVideoMeta * meta, guint plane_height[GST_VIDEO_MAX_PLANES]);
125 * @meta: parent #GstMeta
126 * @x: the horizontal offset
127 * @y: the vertical offset
128 * @width: the cropped width
129 * @height: the cropped height
131 * Extra buffer metadata describing image cropping.
133 struct _GstVideoCropMeta {
143 GType gst_video_crop_meta_api_get_type (void);
146 const GstMetaInfo * gst_video_crop_meta_get_info (void);
148 #define gst_buffer_get_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_get_meta((b),GST_VIDEO_CROP_META_API_TYPE))
149 #define gst_buffer_add_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_add_meta((b),GST_VIDEO_CROP_META_INFO, NULL))
151 /* video metadata transforms */
154 GQuark gst_video_meta_transform_scale_get_quark (void);
156 * gst_video_meta_transform_scale:
158 * GQuark for the video "gst-video-scale" transform.
160 #define GST_VIDEO_META_TRANSFORM_IS_SCALE(type) ((type) == gst_video_meta_transform_scale_get_quark())
163 * GstVideoMetaTransform:
164 * @in_info: the input #GstVideoInfo
165 * @out_info: the output #GstVideoInfo
167 * Extra data passed to a video transform #GstMetaTransformFunction such as:
171 GstVideoInfo *in_info;
172 GstVideoInfo *out_info;
173 } GstVideoMetaTransform;
176 * GstVideoGLTextureType:
177 * @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE: Luminance texture, GL_LUMINANCE
178 * @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA: Luminance-alpha texture, GL_LUMINANCE_ALPHA
179 * @GST_VIDEO_GL_TEXTURE_TYPE_RGB16: RGB 565 texture, GL_RGB
180 * @GST_VIDEO_GL_TEXTURE_TYPE_RGB: RGB texture, GL_RGB
181 * @GST_VIDEO_GL_TEXTURE_TYPE_RGBA: RGBA texture, GL_RGBA
182 * @GST_VIDEO_GL_TEXTURE_TYPE_R: R texture, GL_RED_EXT
183 * @GST_VIDEO_GL_TEXTURE_TYPE_RG: RG texture, GL_RG_EXT
185 * The GL texture type.
189 GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE,
190 GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
191 GST_VIDEO_GL_TEXTURE_TYPE_RGB16,
192 GST_VIDEO_GL_TEXTURE_TYPE_RGB,
193 GST_VIDEO_GL_TEXTURE_TYPE_RGBA,
194 GST_VIDEO_GL_TEXTURE_TYPE_R,
195 GST_VIDEO_GL_TEXTURE_TYPE_RG
196 } GstVideoGLTextureType;
199 * GstVideoGLTextureOrientation:
200 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL: Top line first in memory, left row first
201 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP: Bottom line first in memory, left row first
202 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL: Top line first in memory, right row first
203 * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP: Bottom line first in memory, right row first
205 * The orientation of the GL texture.
209 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL,
210 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP,
211 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL,
212 GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP
213 } GstVideoGLTextureOrientation;
215 #define GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE (gst_video_gl_texture_upload_meta_api_get_type())
216 #define GST_VIDEO_GL_TEXTURE_UPLOAD_META_INFO (gst_video_gl_texture_upload_meta_get_info())
218 typedef struct _GstVideoGLTextureUploadMeta GstVideoGLTextureUploadMeta;
219 typedef gboolean (*GstVideoGLTextureUpload) (GstVideoGLTextureUploadMeta *meta, guint texture_id[4]);
221 #define GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META "meta:GstVideoGLTextureUploadMeta"
224 * GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META:
226 * An option that can be activated on a bufferpool to request gl texture upload
227 * meta on buffers from the pool.
229 * When this option is enabled on the bufferpool,
230 * @GST_BUFFER_POOL_OPTION_VIDEO_META should also be enabled.
234 #define GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META "GstBufferPoolOptionVideoGLTextureUploadMeta"
237 * GstVideoGLTextureUploadMeta:
238 * @meta: parent #GstMeta
239 * @texture_orientation: Orientation of the textures
240 * @n_textures: Number of textures that are generated
241 * @texture_type: Type of each texture
243 * Extra buffer metadata for uploading a buffer to an OpenGL texture
244 * ID. The caller of gst_video_gl_texture_upload_meta_upload() must
245 * have OpenGL set up and call this from a thread where it is valid
246 * to upload something to an OpenGL texture.
249 struct _GstVideoGLTextureUploadMeta {
252 GstVideoGLTextureOrientation texture_orientation;
254 GstVideoGLTextureType texture_type[4];
258 GstVideoGLTextureUpload upload;
261 GBoxedCopyFunc user_data_copy;
262 GBoxedFreeFunc user_data_free;
266 GType gst_video_gl_texture_upload_meta_api_get_type (void);
269 const GstMetaInfo * gst_video_gl_texture_upload_meta_get_info (void);
271 #define gst_buffer_get_video_gl_texture_upload_meta(b) ((GstVideoGLTextureUploadMeta*)gst_buffer_get_meta((b),GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE))
274 GstVideoGLTextureUploadMeta *
275 gst_buffer_add_video_gl_texture_upload_meta (GstBuffer *buffer,
276 GstVideoGLTextureOrientation texture_orientation,
278 GstVideoGLTextureType texture_type[4],
279 GstVideoGLTextureUpload upload,
281 GBoxedCopyFunc user_data_copy,
282 GBoxedFreeFunc user_data_free);
285 gboolean gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta *meta,
286 guint texture_id[4]);
290 * GstVideoRegionOfInterestMeta:
291 * @meta: parent #GstMeta
292 * @roi_type: GQuark describing the semantic of the Roi (f.i. a face, a pedestrian)
293 * @id: identifier of this particular ROI
294 * @parent_id: identifier of its parent ROI, used f.i. for ROI hierarchisation.
295 * @x: x component of upper-left corner
296 * @y: y component of upper-left corner
297 * @w: bounding box width
298 * @h: bounding box height
299 * @params: list of #GstStructure containing element-specific params for downstream, see gst_video_region_of_interest_meta_add_params(). (Since: 1.14)
301 * Extra buffer metadata describing an image region of interest
316 } GstVideoRegionOfInterestMeta;
319 GType gst_video_region_of_interest_meta_api_get_type (void);
320 #define GST_VIDEO_REGION_OF_INTEREST_META_API_TYPE (gst_video_region_of_interest_meta_api_get_type())
322 const GstMetaInfo *gst_video_region_of_interest_meta_get_info (void);
323 #define GST_VIDEO_REGION_OF_INTEREST_META_INFO (gst_video_region_of_interest_meta_get_info())
325 #define gst_buffer_get_video_region_of_interest_meta(b) \
326 ((GstVideoRegionOfInterestMeta*)gst_buffer_get_meta((b),GST_VIDEO_REGION_OF_INTEREST_META_API_TYPE))
328 GstVideoRegionOfInterestMeta *gst_buffer_get_video_region_of_interest_meta_id (GstBuffer * buffer,
332 GstVideoRegionOfInterestMeta *gst_buffer_add_video_region_of_interest_meta (GstBuffer * buffer,
333 const gchar * roi_type,
340 GstVideoRegionOfInterestMeta *gst_buffer_add_video_region_of_interest_meta_id (GstBuffer * buffer,
347 void gst_video_region_of_interest_meta_add_param (GstVideoRegionOfInterestMeta * meta,
351 GstStructure *gst_video_region_of_interest_meta_get_param (GstVideoRegionOfInterestMeta * meta,
355 * GstVideoTimeCodeMeta:
356 * @meta: parent #GstMeta
357 * @tc: the GstVideoTimeCode to attach
359 * Extra buffer metadata describing the GstVideoTimeCode of the frame.
361 * Each frame is assumed to have its own timecode, i.e. they are not
362 * automatically incremented/interpolated.
370 } GstVideoTimeCodeMeta;
373 GType gst_video_time_code_meta_api_get_type (void);
374 #define GST_VIDEO_TIME_CODE_META_API_TYPE (gst_video_time_code_meta_api_get_type())
377 const GstMetaInfo *gst_video_time_code_meta_get_info (void);
378 #define GST_VIDEO_TIME_CODE_META_INFO (gst_video_time_code_meta_get_info())
380 #define gst_buffer_get_video_time_code_meta(b) \
381 ((GstVideoTimeCodeMeta*)gst_buffer_get_meta((b),GST_VIDEO_TIME_CODE_META_API_TYPE))
384 GstVideoTimeCodeMeta *gst_buffer_add_video_time_code_meta (GstBuffer * buffer,
385 GstVideoTimeCode * tc);
388 GstVideoTimeCodeMeta *
389 gst_buffer_add_video_time_code_meta_full (GstBuffer * buffer,
392 GDateTime * latest_daily_jam,
393 GstVideoTimeCodeFlags flags,
402 #endif /* __GST_VIDEO_META_H__ */