summaryrefslogtreecommitdiff
path: root/gst-libs/gst/video/gstmetavideo.h
blob: e88b0b58749d8498aaa4e453a55b39a8c1cbe33f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* GStreamer
 * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef __GST_META_VIDEO_H__
#define __GST_META_VIDEO_H__

#include <gst/gst.h>

#include <gst/video/video.h>

G_BEGIN_DECLS

#define GST_META_API_VIDEO   "GstMetaVideo"
#define GST_META_INFO_VIDEO  (gst_meta_video_get_info())
typedef struct _GstMetaVideo GstMetaVideo;

#define GST_META_API_VIDEO_CROP   "GstMetaVideoCrop"
#define GST_META_INFO_VIDEO_CROP  (gst_meta_video_crop_get_info())
typedef struct _GstMetaVideoCrop GstMetaVideoCrop;

/**
 * GstMetaVideo:
 * @meta: parent #GstMeta
 * @flags: additional video flags
 * @n_planes: the number of planes in the image
 * @offset: array of offsets for the planes
 * @stride: array of strides for the planes
 * @map: map the memory of a plane
 * @unmap: unmap the memory of a plane
 *
 * Extra buffer metadata describing image properties
 */
struct _GstMetaVideo {
  GstMeta            meta;

  GstBuffer         *buffer;

  GstVideoFlags      flags;
  GstVideoFormat     format;
  guint              width;
  guint              height;

  guint              n_planes;
  gsize              offset[GST_VIDEO_MAX_PLANES];
  gint               stride[GST_VIDEO_MAX_PLANES];

  gpointer (*map)    (GstMetaVideo *meta, guint plane, gint *stride,
                      GstMapFlags flags);
  gboolean (*unmap)  (GstMetaVideo *meta, guint plane, gpointer data);
};

const GstMetaInfo * gst_meta_video_get_info (void);

#define gst_buffer_get_meta_video(b) ((GstMetaVideo*)gst_buffer_get_meta((b),GST_META_INFO_VIDEO))
GstMetaVideo * gst_buffer_add_meta_video       (GstBuffer *buffer, GstVideoFlags flags,
                                                GstVideoFormat format, guint width, guint height);
GstMetaVideo * gst_buffer_add_meta_video_full  (GstBuffer *buffer, GstVideoFlags flags,
                                                GstVideoFormat format, guint width, guint height,
                                                guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
                                                gint stride[GST_VIDEO_MAX_PLANES]);

gpointer       gst_meta_video_map        (GstMetaVideo *meta, guint plane, gint *stride,
                                          GstMapFlags flags);
gboolean       gst_meta_video_unmap      (GstMetaVideo *meta, guint plane, gpointer data);

/**
 * GstMetaVideoCrop:
 * @meta: parent #GstMeta
 * @x: the horizontal offset
 * @y: the vertical offset
 * @width: the cropped width
 * @height: the cropped height
 *
 * Extra buffer metadata describing image cropping.
 */
struct _GstMetaVideoCrop {
  GstMeta       meta;

  guint         x;
  guint         y;
  guint         width;
  guint         height;
};

const GstMetaInfo * gst_meta_video_crop_get_info (void);

#define gst_buffer_get_meta_video_crop(b) ((GstMetaVideoCrop*)gst_buffer_get_meta((b),GST_META_INFO_VIDEO_CROP))
#define gst_buffer_add_meta_video_crop(b) ((GstMetaVideoCrop*)gst_buffer_add_meta((b),GST_META_INFO_VIDEO_CROP, NULL))

G_END_DECLS

#endif /* __GST_META_VIDEO_H__ */