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 * GST_CAPS_FEATURE_FORMAT_INTERLACED:
36 * Name of the caps feature indicating that the stream is interlaced. Currently
37 * it is only used for video.
41 #define GST_CAPS_FEATURE_FORMAT_INTERLACED "format:Interlaced"
44 * GstVideoInterlaceMode:
45 * @GST_VIDEO_INTERLACE_MODE_PROGRESSIVE: all frames are progressive
46 * @GST_VIDEO_INTERLACE_MODE_INTERLEAVED: 2 fields are interleaved in one video
47 * frame. Extra buffer flags describe the field order.
48 * @GST_VIDEO_INTERLACE_MODE_MIXED: frames contains both interlaced and
49 * progressive video, the buffer flags describe the frame and fields.
50 * @GST_VIDEO_INTERLACE_MODE_FIELDS: 2 fields are stored in one buffer, use the
51 * frame ID to get access to the required field. For multiview (the
52 * 'views' property > 1) the fields of view N can be found at frame ID
53 * (N * 2) and (N * 2) + 1.
54 * Each field has only half the amount of lines as noted in the
55 * height property. This mode requires multiple GstVideoMeta metadata
56 * to describe the fields.
57 * @GST_VIDEO_INTERLACE_MODE_ALTERNATE: 1 field is stored in one buffer,
58 * @GST_VIDEO_BUFFER_FLAG_TF or @GST_VIDEO_BUFFER_FLAG_BF indicates if
59 * the buffer is carrying the top or bottom field, respectively. The top and
60 * bottom buffers are expected to alternate in the pipeline, with this mode
63 * The possible values of the #GstVideoInterlaceMode describing the interlace
67 GST_VIDEO_INTERLACE_MODE_PROGRESSIVE = 0,
68 GST_VIDEO_INTERLACE_MODE_INTERLEAVED,
69 GST_VIDEO_INTERLACE_MODE_MIXED,
70 GST_VIDEO_INTERLACE_MODE_FIELDS,
71 GST_VIDEO_INTERLACE_MODE_ALTERNATE,
72 } GstVideoInterlaceMode;
75 const gchar * gst_video_interlace_mode_to_string (GstVideoInterlaceMode mode);
78 GstVideoInterlaceMode gst_video_interlace_mode_from_string (const gchar * mode);
81 * GstVideoMultiviewMode:
82 * @GST_VIDEO_MULTIVIEW_MODE_NONE: A special value indicating
83 * no multiview information. Used in GstVideoInfo and other places to
84 * indicate that no specific multiview handling has been requested or
85 * provided. This value is never carried on caps.
86 * @GST_VIDEO_MULTIVIEW_MODE_MONO: All frames are monoscopic.
87 * @GST_VIDEO_MULTIVIEW_MODE_LEFT: All frames represent a left-eye view.
88 * @GST_VIDEO_MULTIVIEW_MODE_RIGHT: All frames represent a right-eye view.
89 * @GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE: Left and right eye views are
90 * provided in the left and right half of the frame respectively.
91 * @GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX: Left and right eye
92 * views are provided in the left and right half of the frame, but
93 * have been sampled using quincunx method, with half-pixel offset
94 * between the 2 views.
95 * @GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED: Alternating vertical
96 * columns of pixels represent the left and right eye view respectively.
97 * @GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED: Alternating horizontal
98 * rows of pixels represent the left and right eye view respectively.
99 * @GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM: The top half of the frame
100 * contains the left eye, and the bottom half the right eye.
101 * @GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD: Pixels are arranged with
102 * alternating pixels representing left and right eye views in a
103 * checkerboard fashion.
104 * @GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME: Left and right eye views
105 * are provided in separate frames alternately.
106 * @GST_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME: Multiple
107 * independent views are provided in separate frames in sequence.
108 * This method only applies to raw video buffers at the moment.
109 * Specific view identification is via the #GstVideoMultiviewMeta
110 * and #GstVideoMeta(s) on raw video buffers.
111 * @GST_VIDEO_MULTIVIEW_MODE_SEPARATED: Multiple views are
112 * provided as separate #GstMemory framebuffers attached to each
113 * #GstBuffer, described by the #GstVideoMultiviewMeta
114 * and #GstVideoMeta(s)
116 * All possible stereoscopic 3D and multiview representations.
117 * In conjunction with #GstVideoMultiviewFlags, describes how
118 * multiview content is being transported in the stream.
121 GST_VIDEO_MULTIVIEW_MODE_NONE = -1,
122 GST_VIDEO_MULTIVIEW_MODE_MONO = 0,
123 /* Single view modes */
124 GST_VIDEO_MULTIVIEW_MODE_LEFT,
125 GST_VIDEO_MULTIVIEW_MODE_RIGHT,
126 /* Stereo view modes */
127 GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE,
128 GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX,
129 GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED,
130 GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED,
131 GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM,
132 GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD,
133 /* Padding for new frame packing modes */
135 GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME = 32,
136 /* Multivew mode(s) */
137 GST_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME,
138 GST_VIDEO_MULTIVIEW_MODE_SEPARATED
139 /* future expansion for annotated modes */
140 } GstVideoMultiviewMode;
143 * GstVideoMultiviewFramePacking:
144 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE: A special value indicating
145 * no frame packing info.
146 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_MONO: All frames are monoscopic.
147 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_LEFT: All frames represent a left-eye view.
148 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_RIGHT: All frames represent a right-eye view.
149 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE: Left and right eye views are
150 * provided in the left and right half of the frame respectively.
151 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE_QUINCUNX: Left and right eye
152 * views are provided in the left and right half of the frame, but
153 * have been sampled using quincunx method, with half-pixel offset
154 * between the 2 views.
155 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_COLUMN_INTERLEAVED: Alternating vertical
156 * columns of pixels represent the left and right eye view respectively.
157 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_ROW_INTERLEAVED: Alternating horizontal
158 * rows of pixels represent the left and right eye view respectively.
159 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_TOP_BOTTOM: The top half of the frame
160 * contains the left eye, and the bottom half the right eye.
161 * @GST_VIDEO_MULTIVIEW_FRAME_PACKING_CHECKERBOARD: Pixels are arranged with
162 * alternating pixels representing left and right eye views in a
163 * checkerboard fashion.
165 * #GstVideoMultiviewFramePacking represents the subset of #GstVideoMultiviewMode
166 * values that can be applied to any video frame without needing extra metadata.
167 * It can be used by elements that provide a property to override the
168 * multiview interpretation of a video stream when the video doesn't contain
171 * This enum is used (for example) on playbin, to re-interpret a played
172 * video stream as a stereoscopic video. The individual enum values are
173 * equivalent to and have the same value as the matching #GstVideoMultiviewMode.
177 GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE = GST_VIDEO_MULTIVIEW_MODE_NONE,
178 GST_VIDEO_MULTIVIEW_FRAME_PACKING_MONO = GST_VIDEO_MULTIVIEW_MODE_MONO,
179 GST_VIDEO_MULTIVIEW_FRAME_PACKING_LEFT = GST_VIDEO_MULTIVIEW_MODE_LEFT,
180 GST_VIDEO_MULTIVIEW_FRAME_PACKING_RIGHT = GST_VIDEO_MULTIVIEW_MODE_RIGHT,
181 GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE = GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE,
182 GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE_QUINCUNX = GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX,
183 GST_VIDEO_MULTIVIEW_FRAME_PACKING_COLUMN_INTERLEAVED = GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED,
184 GST_VIDEO_MULTIVIEW_FRAME_PACKING_ROW_INTERLEAVED = GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED,
185 GST_VIDEO_MULTIVIEW_FRAME_PACKING_TOP_BOTTOM = GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM,
186 GST_VIDEO_MULTIVIEW_FRAME_PACKING_CHECKERBOARD = GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD
187 } GstVideoMultiviewFramePacking;
189 #define GST_VIDEO_MULTIVIEW_MAX_FRAME_PACKING GST_VIDEO_MULTIVIEW_FRAME_PACKING_CHECKERBOARD
192 * GstVideoMultiviewFlags:
193 * @GST_VIDEO_MULTIVIEW_FLAGS_NONE: No flags
194 * @GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST: For stereo streams, the
195 * normal arrangement of left and right views is reversed.
196 * @GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED: The left view is vertically
198 * @GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED: The left view is horizontally
200 * @GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED: The right view is
201 * vertically mirrored.
202 * @GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED: The right view is
203 * horizontally mirrored.
204 * @GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT: For frame-packed
205 * multiview modes, indicates that the individual
206 * views have been encoded with half the true width or height
207 * and should be scaled back up for display. This flag
208 * is used for overriding input layout interpretation
209 * by adjusting pixel-aspect-ratio.
210 * For side-by-side, column interleaved or checkerboard packings, the
211 * pixel width will be doubled. For row interleaved and top-bottom
212 * encodings, pixel height will be doubled.
213 * @GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO: The video stream contains both
214 * mono and multiview portions, signalled on each buffer by the
215 * absence or presence of the @GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW
218 * GstVideoMultiviewFlags are used to indicate extra properties of a
219 * stereo/multiview stream beyond the frame layout and buffer mapping
220 * that is conveyed in the #GstVideoMultiviewMode.
223 GST_VIDEO_MULTIVIEW_FLAGS_NONE = 0,
224 GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST = (1 << 0),
225 GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED = (1 << 1),
226 GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED = (1 << 2),
227 GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED = (1 << 3),
228 GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED = (1 << 4),
229 GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT = (1 << 14),
230 GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO = (1 << 15)
231 } GstVideoMultiviewFlags;
235 * @GST_VIDEO_FLAG_NONE: no flags
236 * @GST_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d
237 * denote the maximum fps of the video
238 * @GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA: Each color has been scaled by the alpha
244 GST_VIDEO_FLAG_NONE = 0,
245 GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 0),
246 GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA = (1 << 1)
250 * GstVideoFieldOrder:
251 * @GST_VIDEO_FIELD_ORDER_UNKNOWN: unknown field order for interlaced content.
252 * The actual field order is signalled via buffer flags.
253 * @GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST: top field is first
254 * @GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST: bottom field is first
256 * Field order of interlaced content. This is only valid for
257 * interlace-mode=interleaved and not interlace-mode=mixed. In the case of
258 * mixed or GST_VIDEO_FIELD_ORDER_UNKOWN, the field order is signalled via
264 GST_VIDEO_FIELD_ORDER_UNKNOWN = 0,
265 GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST = 1,
266 GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST = 2,
267 } GstVideoFieldOrder;
270 const gchar * gst_video_field_order_to_string (GstVideoFieldOrder order);
273 GstVideoFieldOrder gst_video_field_order_from_string (const gchar * order);
277 * @finfo: the format info of the video
278 * @interlace_mode: the interlace mode
279 * @flags: additional video flags
280 * @width: the width of the video
281 * @height: the height of the video
282 * @views: the number of views for multiview video
283 * @size: the default size of one frame
284 * @chroma_site: a #GstVideoChromaSite.
285 * @colorimetry: the colorimetry info
286 * @par_n: the pixel-aspect-ratio numerator
287 * @par_d: the pixel-aspect-ratio demnominator
288 * @fps_n: the framerate numerator
289 * @fps_d: the framerate demnominator
290 * @offset: offsets of the planes
291 * @stride: strides of the planes
292 * @multiview_mode: delivery mode for multiple views. (Since 1.6)
293 * @multiview_flags: flags for multiple views configuration (Since 1.6)
295 * Information describing image properties. This information can be filled
296 * in from GstCaps with gst_video_info_from_caps(). The information is also used
297 * to store the specific video info when mapping a video frame with
298 * gst_video_frame_map().
300 * Use the provided macros to access the info in this structure.
302 struct _GstVideoInfo {
303 const GstVideoFormatInfo *finfo;
305 GstVideoInterlaceMode interlace_mode;
312 GstVideoChromaSite chroma_site;
313 GstVideoColorimetry colorimetry;
320 gsize offset[GST_VIDEO_MAX_PLANES];
321 gint stride[GST_VIDEO_MAX_PLANES];
323 /* Union preserves padded struct size for backwards compat
324 * Consumer code should use the accessor macros for fields */
327 GstVideoMultiviewMode multiview_mode;
328 GstVideoMultiviewFlags multiview_flags;
329 GstVideoFieldOrder field_order;
332 gpointer _gst_reserved[GST_PADDING];
336 #define GST_TYPE_VIDEO_INFO (gst_video_info_get_type ())
338 GType gst_video_info_get_type (void);
341 #define GST_VIDEO_INFO_FORMAT(i) (GST_VIDEO_FORMAT_INFO_FORMAT((i)->finfo))
342 #define GST_VIDEO_INFO_NAME(i) (GST_VIDEO_FORMAT_INFO_NAME((i)->finfo))
343 #define GST_VIDEO_INFO_IS_YUV(i) (GST_VIDEO_FORMAT_INFO_IS_YUV((i)->finfo))
344 #define GST_VIDEO_INFO_IS_RGB(i) (GST_VIDEO_FORMAT_INFO_IS_RGB((i)->finfo))
345 #define GST_VIDEO_INFO_IS_GRAY(i) (GST_VIDEO_FORMAT_INFO_IS_GRAY((i)->finfo))
346 #define GST_VIDEO_INFO_HAS_ALPHA(i) (GST_VIDEO_FORMAT_INFO_HAS_ALPHA((i)->finfo))
348 #define GST_VIDEO_INFO_INTERLACE_MODE(i) ((i)->interlace_mode)
349 #define GST_VIDEO_INFO_IS_INTERLACED(i) ((i)->interlace_mode != GST_VIDEO_INTERLACE_MODE_PROGRESSIVE)
350 #define GST_VIDEO_INFO_FIELD_ORDER(i) ((i)->ABI.abi.field_order)
351 #define GST_VIDEO_INFO_FLAGS(i) ((i)->flags)
352 #define GST_VIDEO_INFO_WIDTH(i) ((i)->width)
353 #define GST_VIDEO_INFO_HEIGHT(i) ((i)->height)
354 #define GST_VIDEO_INFO_SIZE(i) ((i)->size)
355 #define GST_VIDEO_INFO_VIEWS(i) ((i)->views)
356 #define GST_VIDEO_INFO_PAR_N(i) ((i)->par_n)
357 #define GST_VIDEO_INFO_PAR_D(i) ((i)->par_d)
358 #define GST_VIDEO_INFO_FPS_N(i) ((i)->fps_n)
359 #define GST_VIDEO_INFO_FPS_D(i) ((i)->fps_d)
361 #define GST_VIDEO_INFO_COLORIMETRY(i) ((i)->colorimetry)
362 #define GST_VIDEO_INFO_CHROMA_SITE(i) ((i)->chroma_site)
364 #define GST_VIDEO_INFO_MULTIVIEW_MODE(i) ((i)->ABI.abi.multiview_mode)
365 #define GST_VIDEO_INFO_MULTIVIEW_FLAGS(i) ((i)->ABI.abi.multiview_flags)
367 /* dealing with GstVideoInfo flags */
368 #define GST_VIDEO_INFO_FLAG_IS_SET(i,flag) ((GST_VIDEO_INFO_FLAGS(i) & (flag)) == (flag))
369 #define GST_VIDEO_INFO_FLAG_SET(i,flag) (GST_VIDEO_INFO_FLAGS(i) |= (flag))
370 #define GST_VIDEO_INFO_FLAG_UNSET(i,flag) (GST_VIDEO_INFO_FLAGS(i) &= ~(flag))
372 /* dealing with planes */
373 #define GST_VIDEO_INFO_N_PLANES(i) (GST_VIDEO_FORMAT_INFO_N_PLANES((i)->finfo))
374 #define GST_VIDEO_INFO_PLANE_OFFSET(i,p) ((i)->offset[p])
375 #define GST_VIDEO_INFO_PLANE_STRIDE(i,p) ((i)->stride[p])
377 /* dealing with components */
378 #define GST_VIDEO_INFO_N_COMPONENTS(i) GST_VIDEO_FORMAT_INFO_N_COMPONENTS((i)->finfo)
379 #define GST_VIDEO_INFO_COMP_DEPTH(i,c) GST_VIDEO_FORMAT_INFO_DEPTH((i)->finfo,(c))
380 #define GST_VIDEO_INFO_COMP_DATA(i,d,c) GST_VIDEO_FORMAT_INFO_DATA((i)->finfo,d,(c))
381 #define GST_VIDEO_INFO_COMP_OFFSET(i,c) GST_VIDEO_FORMAT_INFO_OFFSET((i)->finfo,(i)->offset,(c))
382 #define GST_VIDEO_INFO_COMP_STRIDE(i,c) GST_VIDEO_FORMAT_INFO_STRIDE((i)->finfo,(i)->stride,(c))
383 #define GST_VIDEO_INFO_COMP_WIDTH(i,c) GST_VIDEO_FORMAT_INFO_SCALE_WIDTH((i)->finfo,(c),(i)->width)
384 #define GST_VIDEO_INFO_COMP_HEIGHT(i,c) GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT((i)->finfo,(c),(i)->height)
385 #define GST_VIDEO_INFO_COMP_PLANE(i,c) GST_VIDEO_FORMAT_INFO_PLANE((i)->finfo,(c))
386 #define GST_VIDEO_INFO_COMP_PSTRIDE(i,c) GST_VIDEO_FORMAT_INFO_PSTRIDE((i)->finfo,(c))
387 #define GST_VIDEO_INFO_COMP_POFFSET(i,c) GST_VIDEO_FORMAT_INFO_POFFSET((i)->finfo,(c))
390 GstVideoInfo * gst_video_info_new (void);
393 void gst_video_info_init (GstVideoInfo *info);
396 GstVideoInfo * gst_video_info_copy (const GstVideoInfo *info);
399 void gst_video_info_free (GstVideoInfo *info);
402 gboolean gst_video_info_set_format (GstVideoInfo *info, GstVideoFormat format,
403 guint width, guint height);
406 gboolean gst_video_info_set_interlaced_format
408 GstVideoFormat format,
409 GstVideoInterlaceMode mode,
414 gboolean gst_video_info_from_caps (GstVideoInfo *info, const GstCaps * caps);
417 GstCaps * gst_video_info_to_caps (GstVideoInfo *info);
420 gboolean gst_video_info_convert (GstVideoInfo *info,
421 GstFormat src_format,
423 GstFormat dest_format,
427 gboolean gst_video_info_is_equal (const GstVideoInfo *info,
428 const GstVideoInfo *other);
430 #include <gst/video/video.h>
433 gboolean gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align);
436 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
437 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoInfo, gst_video_info_free)
442 #endif /* __GST_VIDEO_INFO_H__ */