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_INFO_H__
21 #define __GST_VIDEO_INFO_H__
24 #include <gst/video/video-format.h>
25 #include <gst/video/video-color.h>
29 #include <gst/video/video-enumtypes.h>
31 typedef struct _GstVideoInfo GstVideoInfo;
34 * GstVideoInterlaceMode:
35 * @GST_VIDEO_INTERLACE_MODE_PROGRESSIVE: all frames are progressive
36 * @GST_VIDEO_INTERLACE_MODE_INTERLEAVED: 2 fields are interleaved in one video
37 * frame. Extra buffer flags describe the field order.
38 * @GST_VIDEO_INTERLACE_MODE_MIXED: frames contains both interlaced and
39 * progressive video, the buffer flags describe the frame and fields.
40 * @GST_VIDEO_INTERLACE_MODE_FIELDS: 2 fields are stored in one buffer, use the
41 * frame ID to get access to the required field. For multiview (the
42 * 'views' property > 1) the fields of view N can be found at frame ID
43 * (N * 2) and (N * 2) + 1.
44 * Each field has only half the amount of lines as noted in the
45 * height property. This mode requires multiple GstVideoMeta metadata
46 * to describe the fields.
48 * The possible values of the #GstVideoInterlaceMode describing the interlace
52 GST_VIDEO_INTERLACE_MODE_PROGRESSIVE = 0,
53 GST_VIDEO_INTERLACE_MODE_INTERLEAVED,
54 GST_VIDEO_INTERLACE_MODE_MIXED,
55 GST_VIDEO_INTERLACE_MODE_FIELDS
56 } GstVideoInterlaceMode;
59 const gchar * gst_video_interlace_mode_to_string (GstVideoInterlaceMode mode);
62 GstVideoInterlaceMode gst_video_interlace_mode_from_string (const gchar * mode);
65 * GstVideoMultiviewMode:
66 * @GST_VIDEO_MULTIVIEW_MODE_NONE: A special value indicating
67 * no multiview information. Used in GstVideoInfo and other places to
68 * indicate that no specific multiview handling has been requested or
69 * provided. This value is never carried on caps.
70 * @GST_VIDEO_MULTIVIEW_MODE_MONO: All frames are monoscopic.
71 * @GST_VIDEO_MULTIVIEW_MODE_LEFT: All frames represent a left-eye view.
72 * @GST_VIDEO_MULTIVIEW_MODE_RIGHT: All frames represent a right-eye view.
73 * @GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE: Left and right eye views are
74 * provided in the left and right half of the frame respectively.
75 * @GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX: Left and right eye
76 * views are provided in the left and right half of the frame, but
77 * have been sampled using quincunx method, with half-pixel offset
78 * between the 2 views.
79 * @GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED: Alternating vertical
80 * columns of pixels represent the left and right eye view respectively.
81 * @GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED: Alternating horizontal
82 * rows of pixels represent the left and right eye view respectively.
83 * @GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM: The top half of the frame
84 * contains the left eye, and the bottom half the right eye.
85 * @GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD: Pixels are arranged with
86 * alternating pixels representing left and right eye views in a
87 * checkerboard fashion.
88 * @GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME: Left and right eye views
89 * are provided in separate frames alternately.
90 * @GST_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME: Multiple
91 * independent views are provided in separate frames in sequence.
92 * This method only applies to raw video buffers at the moment.
93 * Specific view identification is via the #GstVideoMultiviewMeta
94 * and #GstVideoMeta(s) on raw video buffers.
95 * @GST_VIDEO_MULTIVIEW_MODE_SEPARATED: Multiple views are
96 * provided as separate #GstMemory framebuffers attached to each
97 * #GstBuffer, described by the #GstVideoMultiviewMeta
98 * and #GstVideoMeta(s)
100 * All possible stereoscopic 3D and multiview representations.
101 * In conjunction with #GstVideoMultiviewFlags, describes how
102 * multiview content is being transported in the stream.
105 GST_VIDEO_MULTIVIEW_MODE_NONE = -1,
106 GST_VIDEO_MULTIVIEW_MODE_MONO = 0,
107 /* Single view modes */
108 GST_VIDEO_MULTIVIEW_MODE_LEFT,
109 GST_VIDEO_MULTIVIEW_MODE_RIGHT,
110 /* Stereo view modes */
111 GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE,
112 GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX,
113 GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED,
114 GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED,
115 GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM,
116 GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD,
117 /* Padding for new frame packing modes */
119 GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME = 32,
120 /* Multivew mode(s) */
121 GST_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME,
122 GST_VIDEO_MULTIVIEW_MODE_SEPARATED
123 /* future expansion for annotated modes */
124 } GstVideoMultiviewMode;
127 * GstVideoMultiviewFramePacking:
128 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE: A special value indicating
129 * no frame packing info.
130 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_MONO: All frames are monoscopic.
131 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_LEFT: All frames represent a left-eye view.
132 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_RIGHT: All frames represent a right-eye view.
133 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE: Left and right eye views are
134 * provided in the left and right half of the frame respectively.
135 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE_QUINCUNX: Left and right eye
136 * views are provided in the left and right half of the frame, but
137 * have been sampled using quincunx method, with half-pixel offset
138 * between the 2 views.
139 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_COLUMN_INTERLEAVED: Alternating vertical
140 * columns of pixels represent the left and right eye view respectively.
141 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_ROW_INTERLEAVED: Alternating horizontal
142 * rows of pixels represent the left and right eye view respectively.
143 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_TOP_BOTTOM: The top half of the frame
144 * contains the left eye, and the bottom half the right eye.
145 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_CHECKERBOARD: Pixels are arranged with
146 * alternating pixels representing left and right eye views in a
147 * checkerboard fashion.
149 * #GstVideoMultiviewFramePacking represents the subset of #GstVideoMultiviewMode
150 * values that can be applied to any video frame without needing extra metadata.
151 * It can be used by elements that provide a property to override the
152 * multiview interpretation of a video stream when the video doesn't contain
155 * This enum is used (for example) on playbin, to re-interpret a played
156 * video stream as a stereoscopic video. The individual enum values are
157 * equivalent to and have the same value as the matching #GstVideoMultiviewMode.
161 GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE = GST_VIDEO_MULTIVIEW_MODE_NONE,
162 GST_VIDEO_MULTIVIEW_FRAME_PACKING_MONO = GST_VIDEO_MULTIVIEW_MODE_MONO,
163 GST_VIDEO_MULTIVIEW_FRAME_PACKING_LEFT = GST_VIDEO_MULTIVIEW_MODE_LEFT,
164 GST_VIDEO_MULTIVIEW_FRAME_PACKING_RIGHT = GST_VIDEO_MULTIVIEW_MODE_RIGHT,
165 GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE = GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE,
166 GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE_QUINCUNX = GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX,
167 GST_VIDEO_MULTIVIEW_FRAME_PACKING_COLUMN_INTERLEAVED = GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED,
168 GST_VIDEO_MULTIVIEW_FRAME_PACKING_ROW_INTERLEAVED = GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED,
169 GST_VIDEO_MULTIVIEW_FRAME_PACKING_TOP_BOTTOM = GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM,
170 GST_VIDEO_MULTIVIEW_FRAME_PACKING_CHECKERBOARD = GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD
171 } GstVideoMultiviewFramePacking;
173 #define GST_VIDEO_MULTIVIEW_MAX_FRAME_PACKING GST_VIDEO_MULTIVIEW_FRAME_PACKING_CHECKERBOARD
176 * GstVideoMultiviewFlags:
177 * @GST_VIDEO_MULTIVIEW_FLAGS_NONE: No flags
178 * @GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST: For stereo streams, the
179 * normal arrangement of left and right views is reversed.
180 * @GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED: The left view is vertically
182 * @GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED: The left view is horizontally
184 * @GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED: The right view is
185 * vertically mirrored.
186 * @GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED: The right view is
187 * horizontally mirrored.
188 * @GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT: For frame-packed
189 * multiview modes, indicates that the individual
190 * views have been encoded with half the true width or height
191 * and should be scaled back up for display. This flag
192 * is used for overriding input layout interpretation
193 * by adjusting pixel-aspect-ratio.
194 * For side-by-side, column interleaved or checkerboard packings, the
195 * pixel width will be doubled. For row interleaved and top-bottom
196 * encodings, pixel height will be doubled.
197 * @GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO: The video stream contains both
198 * mono and multiview portions, signalled on each buffer by the
199 * absence or presence of the @GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW
202 * GstVideoMultiviewFlags are used to indicate extra properties of a
203 * stereo/multiview stream beyond the frame layout and buffer mapping
204 * that is conveyed in the #GstMultiviewMode.
207 GST_VIDEO_MULTIVIEW_FLAGS_NONE = 0,
208 GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST = (1 << 0),
209 GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED = (1 << 1),
210 GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED = (1 << 2),
211 GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED = (1 << 3),
212 GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED = (1 << 4),
213 GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT = (1 << 14),
214 GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO = (1 << 15)
215 } GstVideoMultiviewFlags;
219 * @GST_VIDEO_FLAG_NONE: no flags
220 * @GST_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d
221 * denote the maximum fps of the video
222 * @GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA: Each color has been scaled by the alpha
228 GST_VIDEO_FLAG_NONE = 0,
229 GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 0),
230 GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA = (1 << 1)
234 * GstVideoFieldOrder:
235 * @GST_VIDEO_FIELD_ORDER_UNKNOWN: unknown field order for interlaced content.
236 * The actual field order is signalled via buffer flags.
237 * @GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST: top field is first
238 * @GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST: bottom field is first
240 * Field order of interlaced content. This is only valid for
241 * interlace-mode=interleaved and not interlace-mode=mixed. In the case of
242 * mixed or GST_VIDEO_FIELD_ORDER_UNKOWN, the field order is signalled via
248 GST_VIDEO_FIELD_ORDER_UNKNOWN = 0,
249 GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST = 1,
250 GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST = 2,
251 } GstVideoFieldOrder;
254 const gchar * gst_video_field_order_to_string (GstVideoFieldOrder order);
257 GstVideoFieldOrder gst_video_field_order_from_string (const gchar * order);
261 * @finfo: the format info of the video
262 * @interlace_mode: the interlace mode
263 * @flags: additional video flags
264 * @width: the width of the video
265 * @height: the height of the video
266 * @views: the number of views for multiview video
267 * @size: the default size of one frame
268 * @chroma_site: a #GstVideoChromaSite.
269 * @colorimetry: the colorimetry info
270 * @par_n: the pixel-aspect-ratio numerator
271 * @par_d: the pixel-aspect-ratio demnominator
272 * @fps_n: the framerate numerator
273 * @fps_d: the framerate demnominator
274 * @offset: offsets of the planes
275 * @stride: strides of the planes
276 * @multiview_mode: delivery mode for multiple views. (Since 1.6)
277 * @multiview_flags: flags for multiple views configuration (Since 1.6)
279 * Information describing image properties. This information can be filled
280 * in from GstCaps with gst_video_info_from_caps(). The information is also used
281 * to store the specific video info when mapping a video frame with
282 * gst_video_frame_map().
284 * Use the provided macros to access the info in this structure.
286 struct _GstVideoInfo {
287 const GstVideoFormatInfo *finfo;
289 GstVideoInterlaceMode interlace_mode;
296 GstVideoChromaSite chroma_site;
297 GstVideoColorimetry colorimetry;
304 gsize offset[GST_VIDEO_MAX_PLANES];
305 gint stride[GST_VIDEO_MAX_PLANES];
307 /* Union preserves padded struct size for backwards compat
308 * Consumer code should use the accessor macros for fields */
311 GstVideoMultiviewMode multiview_mode;
312 GstVideoMultiviewFlags multiview_flags;
313 GstVideoFieldOrder field_order;
316 gpointer _gst_reserved[GST_PADDING];
320 #define GST_TYPE_VIDEO_INFO (gst_video_info_get_type ())
322 GType gst_video_info_get_type (void);
325 #define GST_VIDEO_INFO_FORMAT(i) (GST_VIDEO_FORMAT_INFO_FORMAT((i)->finfo))
326 #define GST_VIDEO_INFO_NAME(i) (GST_VIDEO_FORMAT_INFO_NAME((i)->finfo))
327 #define GST_VIDEO_INFO_IS_YUV(i) (GST_VIDEO_FORMAT_INFO_IS_YUV((i)->finfo))
328 #define GST_VIDEO_INFO_IS_RGB(i) (GST_VIDEO_FORMAT_INFO_IS_RGB((i)->finfo))
329 #define GST_VIDEO_INFO_IS_GRAY(i) (GST_VIDEO_FORMAT_INFO_IS_GRAY((i)->finfo))
330 #define GST_VIDEO_INFO_HAS_ALPHA(i) (GST_VIDEO_FORMAT_INFO_HAS_ALPHA((i)->finfo))
332 #define GST_VIDEO_INFO_INTERLACE_MODE(i) ((i)->interlace_mode)
333 #define GST_VIDEO_INFO_IS_INTERLACED(i) ((i)->interlace_mode != GST_VIDEO_INTERLACE_MODE_PROGRESSIVE)
334 #define GST_VIDEO_INFO_FIELD_ORDER(i) ((i)->ABI.abi.field_order)
335 #define GST_VIDEO_INFO_FLAGS(i) ((i)->flags)
336 #define GST_VIDEO_INFO_WIDTH(i) ((i)->width)
337 #define GST_VIDEO_INFO_HEIGHT(i) ((i)->height)
338 #define GST_VIDEO_INFO_SIZE(i) ((i)->size)
339 #define GST_VIDEO_INFO_VIEWS(i) ((i)->views)
340 #define GST_VIDEO_INFO_PAR_N(i) ((i)->par_n)
341 #define GST_VIDEO_INFO_PAR_D(i) ((i)->par_d)
342 #define GST_VIDEO_INFO_FPS_N(i) ((i)->fps_n)
343 #define GST_VIDEO_INFO_FPS_D(i) ((i)->fps_d)
345 #define GST_VIDEO_INFO_COLORIMETRY(i) ((i)->colorimetry)
346 #define GST_VIDEO_INFO_CHROMA_SITE(i) ((i)->chroma_site)
348 #define GST_VIDEO_INFO_MULTIVIEW_MODE(i) ((i)->ABI.abi.multiview_mode)
349 #define GST_VIDEO_INFO_MULTIVIEW_FLAGS(i) ((i)->ABI.abi.multiview_flags)
351 /* dealing with GstVideoInfo flags */
352 #define GST_VIDEO_INFO_FLAG_IS_SET(i,flag) ((GST_VIDEO_INFO_FLAGS(i) & (flag)) == (flag))
353 #define GST_VIDEO_INFO_FLAG_SET(i,flag) (GST_VIDEO_INFO_FLAGS(i) |= (flag))
354 #define GST_VIDEO_INFO_FLAG_UNSET(i,flag) (GST_VIDEO_INFO_FLAGS(i) &= ~(flag))
356 /* dealing with planes */
357 #define GST_VIDEO_INFO_N_PLANES(i) (GST_VIDEO_FORMAT_INFO_N_PLANES((i)->finfo))
358 #define GST_VIDEO_INFO_PLANE_OFFSET(i,p) ((i)->offset[p])
359 #define GST_VIDEO_INFO_PLANE_STRIDE(i,p) ((i)->stride[p])
361 /* dealing with components */
362 #define GST_VIDEO_INFO_N_COMPONENTS(i) GST_VIDEO_FORMAT_INFO_N_COMPONENTS((i)->finfo)
363 #define GST_VIDEO_INFO_COMP_DEPTH(i,c) GST_VIDEO_FORMAT_INFO_DEPTH((i)->finfo,(c))
364 #define GST_VIDEO_INFO_COMP_DATA(i,d,c) GST_VIDEO_FORMAT_INFO_DATA((i)->finfo,d,(c))
365 #define GST_VIDEO_INFO_COMP_OFFSET(i,c) GST_VIDEO_FORMAT_INFO_OFFSET((i)->finfo,(i)->offset,(c))
366 #define GST_VIDEO_INFO_COMP_STRIDE(i,c) GST_VIDEO_FORMAT_INFO_STRIDE((i)->finfo,(i)->stride,(c))
367 #define GST_VIDEO_INFO_COMP_WIDTH(i,c) GST_VIDEO_FORMAT_INFO_SCALE_WIDTH((i)->finfo,(c),(i)->width)
368 #define GST_VIDEO_INFO_COMP_HEIGHT(i,c) GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT((i)->finfo,(c),(i)->height)
369 #define GST_VIDEO_INFO_COMP_PLANE(i,c) GST_VIDEO_FORMAT_INFO_PLANE((i)->finfo,(c))
370 #define GST_VIDEO_INFO_COMP_PSTRIDE(i,c) GST_VIDEO_FORMAT_INFO_PSTRIDE((i)->finfo,(c))
371 #define GST_VIDEO_INFO_COMP_POFFSET(i,c) GST_VIDEO_FORMAT_INFO_POFFSET((i)->finfo,(c))
374 GstVideoInfo * gst_video_info_new (void);
377 void gst_video_info_init (GstVideoInfo *info);
380 GstVideoInfo * gst_video_info_copy (const GstVideoInfo *info);
383 void gst_video_info_free (GstVideoInfo *info);
386 gboolean gst_video_info_set_format (GstVideoInfo *info, GstVideoFormat format,
387 guint width, guint height);
390 gboolean gst_video_info_from_caps (GstVideoInfo *info, const GstCaps * caps);
393 GstCaps * gst_video_info_to_caps (GstVideoInfo *info);
396 gboolean gst_video_info_convert (GstVideoInfo *info,
397 GstFormat src_format,
399 GstFormat dest_format,
403 gboolean gst_video_info_is_equal (const GstVideoInfo *info,
404 const GstVideoInfo *other);
406 #include <gst/video/video.h>
409 gboolean gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align);
412 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
413 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoInfo, gst_video_info_free)
418 #endif /* __GST_VIDEO_INFO_H__ */