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_FRAME_H__
21 #define __GST_VIDEO_FRAME_H__
23 #include <gst/video/video-enumtypes.h>
27 typedef struct _GstVideoFrame GstVideoFrame;
31 * @GST_VIDEO_FRAME_FLAG_NONE: no flags
32 * @GST_VIDEO_FRAME_FLAG_INTERLACED: The video frame is interlaced. In mixed
33 * interlace-mode, this flag specifies if the frame is interlaced or
35 * @GST_VIDEO_FRAME_FLAG_TFF: The video frame has the top field first
36 * @GST_VIDEO_FRAME_FLAG_RFF: The video frame has the repeat flag
37 * @GST_VIDEO_FRAME_FLAG_ONEFIELD: The video frame has one field
38 * @GST_VIDEO_FRAME_FLAG_MULTIPLE_VIEW: The video contains one or
40 * @GST_VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE: The video frame is the first
41 * in a set of corresponding views provided as sequential frames.
43 * Extra video frame flags
46 GST_VIDEO_FRAME_FLAG_NONE = 0,
47 GST_VIDEO_FRAME_FLAG_INTERLACED = (1 << 0),
48 GST_VIDEO_FRAME_FLAG_TFF = (1 << 1),
49 GST_VIDEO_FRAME_FLAG_RFF = (1 << 2),
50 GST_VIDEO_FRAME_FLAG_ONEFIELD = (1 << 3),
51 GST_VIDEO_FRAME_FLAG_MULTIPLE_VIEW = (1 << 4),
52 GST_VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE = (1 << 5)
55 /* circular dependency, need to include this after defining the enums */
56 #include <gst/video/video-format.h>
57 #include <gst/video/video-info.h>
61 * @info: the #GstVideoInfo
62 * @flags: #GstVideoFrameFlags for the frame
63 * @buffer: the mapped buffer
64 * @meta: pointer to metadata if any
65 * @id: id of the mapped frame. the id can for example be used to
66 * indentify the frame in case of multiview video.
67 * @data: pointers to the plane data
68 * @map: mappings of the planes
70 * A video frame obtained from gst_video_frame_map()
72 struct _GstVideoFrame {
74 GstVideoFrameFlags flags;
80 gpointer data[GST_VIDEO_MAX_PLANES];
81 GstMapInfo map[GST_VIDEO_MAX_PLANES];
84 gpointer _gst_reserved[GST_PADDING];
88 gboolean gst_video_frame_map (GstVideoFrame *frame, GstVideoInfo *info,
89 GstBuffer *buffer, GstMapFlags flags);
92 gboolean gst_video_frame_map_id (GstVideoFrame *frame, GstVideoInfo *info,
93 GstBuffer *buffer, gint id, GstMapFlags flags);
96 void gst_video_frame_unmap (GstVideoFrame *frame);
99 gboolean gst_video_frame_copy (GstVideoFrame *dest, const GstVideoFrame *src);
102 gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFrame *src,
106 #define GST_VIDEO_FRAME_FORMAT(f) (GST_VIDEO_INFO_FORMAT(&(f)->info))
107 #define GST_VIDEO_FRAME_WIDTH(f) (GST_VIDEO_INFO_WIDTH(&(f)->info))
108 #define GST_VIDEO_FRAME_HEIGHT(f) (GST_VIDEO_INFO_HEIGHT(&(f)->info))
109 #define GST_VIDEO_FRAME_SIZE(f) (GST_VIDEO_INFO_SIZE(&(f)->info))
112 #define GST_VIDEO_FRAME_FLAGS(f) ((f)->flags)
113 #define GST_VIDEO_FRAME_FLAG_IS_SET(f,fl) ((GST_VIDEO_FRAME_FLAGS(f) & (fl)) == (fl))
114 #define GST_VIDEO_FRAME_IS_INTERLACED(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_INTERLACED))
115 #define GST_VIDEO_FRAME_IS_TFF(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_TFF))
116 #define GST_VIDEO_FRAME_IS_RFF(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_RFF))
117 #define GST_VIDEO_FRAME_IS_ONEFIELD(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_ONEFIELD))
119 /* dealing with planes */
120 #define GST_VIDEO_FRAME_N_PLANES(f) (GST_VIDEO_INFO_N_PLANES(&(f)->info))
121 #define GST_VIDEO_FRAME_PLANE_DATA(f,p) ((f)->data[p])
122 #define GST_VIDEO_FRAME_PLANE_OFFSET(f,p) (GST_VIDEO_INFO_PLANE_OFFSET(&(f)->info,(p)))
123 #define GST_VIDEO_FRAME_PLANE_STRIDE(f,p) (GST_VIDEO_INFO_PLANE_STRIDE(&(f)->info,(p)))
125 /* dealing with components */
126 #define GST_VIDEO_FRAME_N_COMPONENTS(f) GST_VIDEO_INFO_N_COMPONENTS(&(f)->info)
127 #define GST_VIDEO_FRAME_COMP_DEPTH(f,c) GST_VIDEO_INFO_COMP_DEPTH(&(f)->info,(c))
128 #define GST_VIDEO_FRAME_COMP_DATA(f,c) GST_VIDEO_INFO_COMP_DATA(&(f)->info,(f)->data,(c))
129 #define GST_VIDEO_FRAME_COMP_STRIDE(f,c) GST_VIDEO_INFO_COMP_STRIDE(&(f)->info,(c))
130 #define GST_VIDEO_FRAME_COMP_OFFSET(f,c) GST_VIDEO_INFO_COMP_OFFSET(&(f)->info,(c))
131 #define GST_VIDEO_FRAME_COMP_WIDTH(f,c) GST_VIDEO_INFO_COMP_WIDTH(&(f)->info,(c))
132 #define GST_VIDEO_FRAME_COMP_HEIGHT(f,c) GST_VIDEO_INFO_COMP_HEIGHT(&(f)->info,(c))
133 #define GST_VIDEO_FRAME_COMP_PLANE(f,c) GST_VIDEO_INFO_COMP_PLANE(&(f)->info,(c))
134 #define GST_VIDEO_FRAME_COMP_PSTRIDE(f,c) GST_VIDEO_INFO_COMP_PSTRIDE(&(f)->info,(c))
135 #define GST_VIDEO_FRAME_COMP_POFFSET(f,c) GST_VIDEO_INFO_COMP_POFFSET(&(f)->info,(c))
140 * GstVideoBufferFlags:
141 * @GST_VIDEO_BUFFER_FLAG_INTERLACED: If the #GstBuffer is interlaced. In mixed
142 * interlace-mode, this flags specifies if the frame is
143 * interlaced or progressive.
144 * @GST_VIDEO_BUFFER_FLAG_TFF: If the #GstBuffer is interlaced, then the first field
145 * in the video frame is the top field. If unset, the
146 * bottom field is first.
147 * @GST_VIDEO_BUFFER_FLAG_RFF: If the #GstBuffer is interlaced, then the first field
148 * (as defined by the %GST_VIDEO_BUFFER_TFF flag setting)
150 * @GST_VIDEO_BUFFER_FLAG_ONEFIELD: If the #GstBuffer is interlaced, then only the
151 * first field (as defined by the %GST_VIDEO_BUFFER_TFF
152 * flag setting) is to be displayed.
153 * @GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW: The #GstBuffer contains one or more specific views,
154 * such as left or right eye view. This flags is set on
155 * any buffer that contains non-mono content - even for
156 * streams that contain only a single viewpoint. In mixed
157 * mono / non-mono streams, the absense of the flag marks
159 * @GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE: When conveying stereo/multiview content with
160 * frame-by-frame methods, this flag marks the first buffer
161 * in a bundle of frames that belong together.
162 * @GST_VIDEO_BUFFER_FLAG_LAST: Offset to define more flags
164 * Additional video buffer flags. These flags can potentially be used on any
165 * buffers carrying video data - even encoded data.
167 * Note that these are only valid for #GstCaps of type: video/...
168 * They can conflict with other extended buffer flags.
171 GST_VIDEO_BUFFER_FLAG_INTERLACED = (GST_BUFFER_FLAG_LAST << 0),
172 GST_VIDEO_BUFFER_FLAG_TFF = (GST_BUFFER_FLAG_LAST << 1),
173 GST_VIDEO_BUFFER_FLAG_RFF = (GST_BUFFER_FLAG_LAST << 2),
174 GST_VIDEO_BUFFER_FLAG_ONEFIELD = (GST_BUFFER_FLAG_LAST << 3),
176 GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW = (GST_BUFFER_FLAG_LAST << 4),
177 GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE = (GST_BUFFER_FLAG_LAST << 5),
179 GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8)
180 } GstVideoBufferFlags;
183 * GstVideoFrameMapFlags:
184 * @GST_VIDEO_FRAME_MAP_FLAG_NO_REF: Don't take another reference of the buffer and store it in
185 * the GstVideoFrame. This makes sure that the buffer stays
186 * writable while the frame is mapped, but requires that the
187 * buffer reference stays valid until the frame is unmapped again.
188 * @GST_VIDEO_FRAME_MAP_FLAG_LAST: Offset to define more flags
190 * Additional mapping flags for gst_video_frame_map().
195 GST_VIDEO_FRAME_MAP_FLAG_NO_REF = (GST_MAP_FLAG_LAST << 0),
196 GST_VIDEO_FRAME_MAP_FLAG_LAST = (GST_MAP_FLAG_LAST << 8)
197 /* 8 more flags possible afterwards */
198 } GstVideoFrameMapFlags;
202 #endif /* __GST_VIDEO_FRAME_H__ */