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;
60 * @GST_VIDEO_FLAG_NONE: no flags
61 * @GST_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d
62 * denote the maximum fps of the video
63 * @GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA: Each color has been scaled by the alpha
69 GST_VIDEO_FLAG_NONE = 0,
70 GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 0),
71 GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA = (1 << 1)
76 * @finfo: the format info of the video
77 * @interlace_mode: the interlace mode
78 * @flags: additional video flags
79 * @width: the width of the video
80 * @height: the height of the video
81 * @views: the number of views for multiview video
82 * @size: the default size of one frame
83 * @chroma_site: a #GstVideoChromaSite.
84 * @colorimetry: the colorimetry info
85 * @par_n: the pixel-aspect-ratio numerator
86 * @par_d: the pixel-aspect-ratio demnominator
87 * @fps_n: the framerate numerator
88 * @fps_d: the framerate demnominator
89 * @offset: offsets of the planes
90 * @stride: strides of the planes
92 * Information describing image properties. This information can be filled
93 * in from GstCaps with gst_video_info_from_caps(). The information is also used
94 * to store the specific video info when mapping a video frame with
95 * gst_video_frame_map().
97 * Use the provided macros to access the info in this structure.
99 struct _GstVideoInfo {
100 const GstVideoFormatInfo *finfo;
102 GstVideoInterlaceMode interlace_mode;
109 GstVideoChromaSite chroma_site;
110 GstVideoColorimetry colorimetry;
117 gsize offset[GST_VIDEO_MAX_PLANES];
118 gint stride[GST_VIDEO_MAX_PLANES];
121 gpointer _gst_reserved[GST_PADDING];
125 #define GST_VIDEO_INFO_FORMAT(i) (GST_VIDEO_FORMAT_INFO_FORMAT((i)->finfo))
126 #define GST_VIDEO_INFO_NAME(i) (GST_VIDEO_FORMAT_INFO_NAME((i)->finfo))
127 #define GST_VIDEO_INFO_IS_YUV(i) (GST_VIDEO_FORMAT_INFO_IS_YUV((i)->finfo))
128 #define GST_VIDEO_INFO_IS_RGB(i) (GST_VIDEO_FORMAT_INFO_IS_RGB((i)->finfo))
129 #define GST_VIDEO_INFO_IS_GRAY(i) (GST_VIDEO_FORMAT_INFO_IS_GRAY((i)->finfo))
130 #define GST_VIDEO_INFO_HAS_ALPHA(i) (GST_VIDEO_FORMAT_INFO_HAS_ALPHA((i)->finfo))
132 #define GST_VIDEO_INFO_INTERLACE_MODE(i) ((i)->interlace_mode)
133 #define GST_VIDEO_INFO_IS_INTERLACED(i) ((i)->interlace_mode != GST_VIDEO_INTERLACE_MODE_PROGRESSIVE)
134 #define GST_VIDEO_INFO_FLAGS(i) ((i)->flags)
135 #define GST_VIDEO_INFO_WIDTH(i) ((i)->width)
136 #define GST_VIDEO_INFO_HEIGHT(i) ((i)->height)
137 #define GST_VIDEO_INFO_SIZE(i) ((i)->size)
138 #define GST_VIDEO_INFO_VIEWS(i) ((i)->views)
139 #define GST_VIDEO_INFO_PAR_N(i) ((i)->par_n)
140 #define GST_VIDEO_INFO_PAR_D(i) ((i)->par_d)
141 #define GST_VIDEO_INFO_FPS_N(i) ((i)->fps_n)
142 #define GST_VIDEO_INFO_FPS_D(i) ((i)->fps_d)
144 /* dealing with GstVideoInfo flags */
145 #define GST_VIDEO_INFO_FLAG_IS_SET(i,flag) ((GST_VIDEO_INFO_FLAGS(i) & (flag)) == (flag))
146 #define GST_VIDEO_INFO_FLAG_SET(i,flag) (GST_VIDEO_INFO_FLAGS(i) |= (flag))
147 #define GST_VIDEO_INFO_FLAG_UNSET(i,flag) (GST_VIDEO_INFO_FLAGS(i) &= ~(flag))
149 /* dealing with planes */
150 #define GST_VIDEO_INFO_N_PLANES(i) (GST_VIDEO_FORMAT_INFO_N_PLANES((i)->finfo))
151 #define GST_VIDEO_INFO_PLANE_OFFSET(i,p) ((i)->offset[p])
152 #define GST_VIDEO_INFO_PLANE_STRIDE(i,p) ((i)->stride[p])
154 /* dealing with components */
155 #define GST_VIDEO_INFO_N_COMPONENTS(i) GST_VIDEO_FORMAT_INFO_N_COMPONENTS((i)->finfo)
156 #define GST_VIDEO_INFO_COMP_DEPTH(i,c) GST_VIDEO_FORMAT_INFO_DEPTH((i)->finfo,(c))
157 #define GST_VIDEO_INFO_COMP_DATA(i,d,c) GST_VIDEO_FORMAT_INFO_DATA((i)->finfo,d,(c))
158 #define GST_VIDEO_INFO_COMP_OFFSET(i,c) GST_VIDEO_FORMAT_INFO_OFFSET((i)->finfo,(i)->offset,(c))
159 #define GST_VIDEO_INFO_COMP_STRIDE(i,c) GST_VIDEO_FORMAT_INFO_STRIDE((i)->finfo,(i)->stride,(c))
160 #define GST_VIDEO_INFO_COMP_WIDTH(i,c) GST_VIDEO_FORMAT_INFO_SCALE_WIDTH((i)->finfo,(c),(i)->width)
161 #define GST_VIDEO_INFO_COMP_HEIGHT(i,c) GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT((i)->finfo,(c),(i)->height)
162 #define GST_VIDEO_INFO_COMP_PLANE(i,c) GST_VIDEO_FORMAT_INFO_PLANE((i)->finfo,(c))
163 #define GST_VIDEO_INFO_COMP_PSTRIDE(i,c) GST_VIDEO_FORMAT_INFO_PSTRIDE((i)->finfo,(c))
164 #define GST_VIDEO_INFO_COMP_POFFSET(i,c) GST_VIDEO_FORMAT_INFO_POFFSET((i)->finfo,(c))
166 void gst_video_info_init (GstVideoInfo *info);
168 void gst_video_info_set_format (GstVideoInfo *info, GstVideoFormat format,
169 guint width, guint height);
171 gboolean gst_video_info_from_caps (GstVideoInfo *info, const GstCaps * caps);
173 GstCaps * gst_video_info_to_caps (GstVideoInfo *info);
175 gboolean gst_video_info_convert (GstVideoInfo *info,
176 GstFormat src_format,
178 GstFormat dest_format,
180 gboolean gst_video_info_is_equal (const GstVideoInfo *info,
181 const GstVideoInfo *other);
183 #include <gst/video/video.h>
185 void gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align);
190 #endif /* __GST_VIDEO_INFO_H__ */