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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GST_VIDEO_H__
21 #define __GST_VIDEO_H__
27 #include <gst/video/video-enumtypes.h>
31 * @GST_VIDEO_FORMAT_UNKNOWN: Unknown or unset video format id
32 * @GST_VIDEO_FORMAT_I420: planar 4:2:0 YUV
33 * @GST_VIDEO_FORMAT_YV12: planar 4:2:0 YVU (like I420 but UV planes swapped)
34 * @GST_VIDEO_FORMAT_YUY2: packed 4:2:2 YUV (Y0-U0-Y1-V0 Y2-U2-Y3-V2 Y4 ...)
35 * @GST_VIDEO_FORMAT_UYVY: packed 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...)
36 * @GST_VIDEO_FORMAT_AYUV: packed 4:4:4 YUV with alpha channel (A0-Y0-U0-V0 ...)
37 * @GST_VIDEO_FORMAT_RGBx: sparse rgb packed into 32 bit, space last
38 * @GST_VIDEO_FORMAT_BGRx: sparse reverse rgb packed into 32 bit, space last
39 * @GST_VIDEO_FORMAT_xRGB: sparse rgb packed into 32 bit, space first
40 * @GST_VIDEO_FORMAT_xBGR: sparse reverse rgb packed into 32 bit, space first
41 * @GST_VIDEO_FORMAT_RGBA: rgb with alpha channel last
42 * @GST_VIDEO_FORMAT_BGRA: reverse rgb with alpha channel last
43 * @GST_VIDEO_FORMAT_ARGB: rgb with alpha channel first
44 * @GST_VIDEO_FORMAT_ABGR: reverse rgb with alpha channel first
45 * @GST_VIDEO_FORMAT_RGB: rgb
46 * @GST_VIDEO_FORMAT_BGR: reverse rgb
47 * @GST_VIDEO_FORMAT_Y41B: planar 4:1:1 YUV (Since: 0.10.18)
48 * @GST_VIDEO_FORMAT_Y42B: planar 4:2:2 YUV (Since: 0.10.18)
49 * @GST_VIDEO_FORMAT_YVYU: packed 4:2:2 YUV (Y0-V0-Y1-U0 Y2-V2-Y3-U2 Y4 ...) (Since: 0.10.23)
50 * @GST_VIDEO_FORMAT_Y444: planar 4:4:4 YUV (Since: 0.10.24)
51 * @GST_VIDEO_FORMAT_v210: packed 4:2:2 10-bit YUV, complex format (Since: 0.10.24)
52 * @GST_VIDEO_FORMAT_v216: packed 4:2:2 16-bit YUV, Y0-U0-Y1-V1 order (Since: 0.10.24)
53 * @GST_VIDEO_FORMAT_NV12: planar 4:2:0 YUV with interleaved UV plane (Since: 0.10.26)
54 * @GST_VIDEO_FORMAT_NV21: planar 4:2:0 YUV with interleaved VU plane (Since: 0.10.26)
55 * @GST_VIDEO_FORMAT_GRAY8: 8-bit grayscale (Since: 0.10.29)
56 * @GST_VIDEO_FORMAT_GRAY16_BE: 16-bit grayscale, most significant byte first (Since: 0.10.29)
57 * @GST_VIDEO_FORMAT_GRAY16_LE: 16-bit grayscale, least significant byte first (Since: 0.10.29)
58 * @GST_VIDEO_FORMAT_v308: packed 4:4:4 YUV (Since: 0.10.29)
59 * @GST_VIDEO_FORMAT_Y800: same as GST_VIDEO_FORMAT_GRAY8 (Since: 0.10.30)
60 * @GST_VIDEO_FORMAT_Y16: same as GST_VIDEO_FORMAT_GRAY16_LE (Since: 0.10.30)
61 * @GST_VIDEO_FORMAT_RGB16: rgb 5-6-5 bits per component (Since: 0.10.30)
62 * @GST_VIDEO_FORMAT_BGR16: reverse rgb 5-6-5 bits per component (Since: 0.10.30)
63 * @GST_VIDEO_FORMAT_RGB15: rgb 5-5-5 bits per component (Since: 0.10.30)
64 * @GST_VIDEO_FORMAT_BGR15: reverse rgb 5-5-5 bits per component (Since: 0.10.30)
65 * @GST_VIDEO_FORMAT_UYVP: packed 10-bit 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...) (Since: 0.10.31)
66 * @GST_VIDEO_FORMAT_A420: planar 4:4:2:0 AYUV (Since: 0.10.31)
67 * @GST_VIDEO_FORMAT_RGB8_PALETTED: 8-bit paletted RGB (Since: 0.10.32)
68 * @GST_VIDEO_FORMAT_YUV9: planar 4:1:0 YUV (Since: 0.10.32)
69 * @GST_VIDEO_FORMAT_YVU9: planar 4:1:0 YUV (like YUV9 but UV planes swapped) (Since: 0.10.32)
70 * @GST_VIDEO_FORMAT_IYU1: packed 4:1:1 YUV (Cb-Y0-Y1-Cr-Y2-Y3 ...) (Since: 0.10.32)
71 * @GST_VIDEO_FORMAT_ARGB64: rgb with alpha channel first, 16 bits per channel (Since: 0.10.33)
72 * @GST_VIDEO_FORMAT_AYUV64: packed 4:4:4 YUV with alpha channel, 16 bits per channel (A0-Y0-U0-V0 ...) (Since: 0.10.33)
73 * @GST_VIDEO_FORMAT_r210: packed 4:4:4 RGB, 10 bits per channel (Since: 0.10.33)
75 * Enum value describing the most common video formats.
78 GST_VIDEO_FORMAT_UNKNOWN,
79 GST_VIDEO_FORMAT_I420,
80 GST_VIDEO_FORMAT_YV12,
81 GST_VIDEO_FORMAT_YUY2,
82 GST_VIDEO_FORMAT_UYVY,
83 GST_VIDEO_FORMAT_AYUV,
84 GST_VIDEO_FORMAT_RGBx,
85 GST_VIDEO_FORMAT_BGRx,
86 GST_VIDEO_FORMAT_xRGB,
87 GST_VIDEO_FORMAT_xBGR,
88 GST_VIDEO_FORMAT_RGBA,
89 GST_VIDEO_FORMAT_BGRA,
90 GST_VIDEO_FORMAT_ARGB,
91 GST_VIDEO_FORMAT_ABGR,
94 GST_VIDEO_FORMAT_Y41B,
95 GST_VIDEO_FORMAT_Y42B,
96 GST_VIDEO_FORMAT_YVYU,
97 GST_VIDEO_FORMAT_Y444,
98 GST_VIDEO_FORMAT_v210,
99 GST_VIDEO_FORMAT_v216,
100 GST_VIDEO_FORMAT_NV12,
101 GST_VIDEO_FORMAT_NV21,
102 GST_VIDEO_FORMAT_GRAY8,
103 GST_VIDEO_FORMAT_GRAY16_BE,
104 GST_VIDEO_FORMAT_GRAY16_LE,
105 GST_VIDEO_FORMAT_v308,
106 GST_VIDEO_FORMAT_Y800,
107 GST_VIDEO_FORMAT_Y16,
108 GST_VIDEO_FORMAT_RGB16,
109 GST_VIDEO_FORMAT_BGR16,
110 GST_VIDEO_FORMAT_RGB15,
111 GST_VIDEO_FORMAT_BGR15,
112 GST_VIDEO_FORMAT_UYVP,
113 GST_VIDEO_FORMAT_A420,
114 GST_VIDEO_FORMAT_RGB8_PALETTED,
115 GST_VIDEO_FORMAT_YUV9,
116 GST_VIDEO_FORMAT_YVU9,
117 GST_VIDEO_FORMAT_IYU1,
118 GST_VIDEO_FORMAT_ARGB64,
119 GST_VIDEO_FORMAT_AYUV64,
120 GST_VIDEO_FORMAT_r210
123 #define GST_VIDEO_MAX_PLANES 4
124 #define GST_VIDEO_MAX_COMPONENTS 4
126 typedef struct _GstVideoFormatInfo GstVideoFormatInfo;
129 * GstVideoFormatFlags:
130 * @GST_VIDEO_FORMAT_FLAG_YUV: The video format is YUV, components are numbered
132 * @GST_VIDEO_FORMAT_FLAG_RGB: The video format is RGB, components are numbered
134 * @GST_VIDEO_FORMAT_FLAG_GRAY: The video is gray, there is one gray component
136 * @GST_VIDEO_FORMAT_FLAG_ALPHA: The video format has an alpha components with
138 * @GST_VIDEO_FORMAT_FLAG_LE: The video format has data stored in little
140 * @GST_VIDEO_FORMAT_FLAG_PALETTE: The video format has a palette.
141 * @GST_VIDEO_FORMAT_FLAG_COMPLEX: The video format has a complex layout that
142 * can't be described with the usual information in the #GstVideoFormatInfo.
144 * The different video flags that a format info can have.
148 GST_VIDEO_FORMAT_FLAG_YUV = (1 << 0),
149 GST_VIDEO_FORMAT_FLAG_RGB = (1 << 1),
150 GST_VIDEO_FORMAT_FLAG_GRAY = (1 << 2),
151 GST_VIDEO_FORMAT_FLAG_ALPHA = (1 << 3),
152 GST_VIDEO_FORMAT_FLAG_LE = (1 << 4),
153 GST_VIDEO_FORMAT_FLAG_PALETTE = (1 << 5),
154 GST_VIDEO_FORMAT_FLAG_COMPLEX = (1 << 6)
155 } GstVideoFormatFlags;
157 #define GST_VIDEO_COMP_Y 0
158 #define GST_VIDEO_COMP_U 1
159 #define GST_VIDEO_COMP_V 2
161 #define GST_VIDEO_COMP_R 0
162 #define GST_VIDEO_COMP_G 1
163 #define GST_VIDEO_COMP_B 2
165 #define GST_VIDEO_COMP_A 3
168 * GstVideoFormatUnpack:
169 * @info: a #GstVideoFormatInfo
170 * @dest: a destination array
171 * @data: pointers to the data planes
172 * @stride: strides of the planes
173 * @x: the x position in the image to start from
174 * @y: the y position in the image to start from
175 * @width: the amount of pixels to unpack.
177 * Unpacks @width pixels from the given planes and strides containing data of
178 * format @info. The pixels will be unpacked into @dest which each component
179 * interleaved. @dest should at least be big enough to hold @width *
180 * n_components * size(unpack_format) bytes.
182 typedef void (*GstVideoFormatUnpack) (GstVideoFormatInfo *info, gpointer dest,
183 const gpointer data[GST_VIDEO_MAX_PLANES],
184 const gint stride[GST_VIDEO_MAX_PLANES],
185 gint x, gint y, gint width);
187 * GstVideoFormatPack:
188 * @info: a #GstVideoFormatInfo
189 * @src: a source array
190 * @data: pointers to the destination data planes
191 * @stride: strides of the destination planes
192 * @x: the x position in the image to pack to
193 * @y: the y position in the image to pack to
194 * @width: the amount of pixels to pack.
196 * Packs @width pixels from @src to the given planes and strides in the
197 * format @info. The pixels from source have each component interleaved
198 * and will be packed into the planes in @data.
200 typedef void (*GstVideoFormatPack) (GstVideoFormatInfo *info, const gpointer src,
201 gpointer data[GST_VIDEO_MAX_PLANES],
202 const gint stride[GST_VIDEO_MAX_PLANES],
203 gint x, gint y, gint width);
206 * GstVideoFormatInfo:
207 * @format: #GstVideoFormat
208 * @name: string representation of the format
209 * @description: use readable description of the format
210 * @flags: #GstVideoFormatFlags
211 * @bits: The number of bits used to pack data items. This can be less than 8
212 * when multiple pixels are stored in a byte. for values > 8 multiple bytes
213 * should be read according to the endianness flag before applying the shift
215 * @n_components: the number of components in the video format.
216 * @shift: the number of bits to shift away to get the component data
217 * @depth: the depth in bits for each component
218 * @pixel_stride: the pixel stride of each component. This is the amount of
219 * bytes to the pixel immediately to the right. When bits < 8, the stride is
221 * @n_planes: the number of planes for this format. The number of planes can be
222 * less than the amount of components when multiple components are packed into
224 * @plane: the plane number where a component can be found
225 * @offset: the offset in the plane where the first pixel of the components
226 * can be found. If bits < 8 the amount is specified in bits.
227 * @w_sub: subsampling factor of the width for the component. Use
228 * GST_VIDEO_SUB_SCALE to scale a width.
229 * @h_sub: subsampling factor of the height for the component. Use
230 * GST_VIDEO_SUB_SCALE to scale a height.
231 * @unpack_format: the format of the unpacked pixels.
232 * @unpack_func: an unpack function for this format
233 * @pack_func: an pack function for this format
235 * Information for a video format.
237 struct _GstVideoFormatInfo {
238 GstVideoFormat format;
240 const gchar *description;
241 GstVideoFormatFlags flags;
244 guint shift[GST_VIDEO_MAX_COMPONENTS];
245 guint depth[GST_VIDEO_MAX_COMPONENTS];
246 gint pixel_stride[GST_VIDEO_MAX_COMPONENTS];
248 guint plane[GST_VIDEO_MAX_COMPONENTS];
249 guint offset[GST_VIDEO_MAX_COMPONENTS];
250 guint w_sub[GST_VIDEO_MAX_COMPONENTS];
251 guint h_sub[GST_VIDEO_MAX_COMPONENTS];
253 GstVideoFormat unpack_format;
254 GstVideoFormatUnpack unpack_func;
255 GstVideoFormatPack pack_func;
258 #define GST_VIDEO_FORMAT_INFO_FORMAT(info) ((info)->format)
259 #define GST_VIDEO_FORMAT_INFO_NAME(info) ((info)->name)
260 #define GST_VIDEO_FORMAT_INFO_FLAGS(info) ((info)->flags)
262 #define GST_VIDEO_FORMAT_INFO_IS_YUV(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_YUV)
263 #define GST_VIDEO_FORMAT_INFO_IS_RGB(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_RGB)
264 #define GST_VIDEO_FORMAT_INFO_IS_GRAY(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_GRAY)
265 #define GST_VIDEO_FORMAT_INFO_HAS_ALPHA(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_ALPHA)
266 #define GST_VIDEO_FORMAT_INFO_IS_LE(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_LE)
267 #define GST_VIDEO_FORMAT_INFO_HAS_PALETTE(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_PALETTE)
269 #define GST_VIDEO_FORMAT_INFO_BITS(info) ((info)->bits)
270 #define GST_VIDEO_FORMAT_INFO_N_COMPONENTS(info) ((info)->n_components)
271 #define GST_VIDEO_FORMAT_INFO_SHIFT(info,c) ((info)->shift[c])
272 #define GST_VIDEO_FORMAT_INFO_DEPTH(info,c) ((info)->depth[c])
273 #define GST_VIDEO_FORMAT_INFO_PSTRIDE(info,c) ((info)->pixel_stride[c])
274 #define GST_VIDEO_FORMAT_INFO_N_PLANES(info) ((info)->n_planes)
275 #define GST_VIDEO_FORMAT_INFO_PLANE(info,c) ((info)->plane[c])
276 #define GST_VIDEO_FORMAT_INFO_OFFSET(info,c) ((info)->offset[c])
277 #define GST_VIDEO_FORMAT_INFO_W_SUB(info,c) ((info)->w_sub[c])
278 #define GST_VIDEO_FORMAT_INFO_H_SUB(info,c) ((info)->h_sub[c])
280 #define GST_VIDEO_SUB_SCALE(scale,val) (-((-((gint)val))>>(scale)))
282 #define GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info,c,w) GST_VIDEO_SUB_SCALE ((info)->w_sub[(c)],(w))
283 #define GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info,c,h) GST_VIDEO_SUB_SCALE ((info)->h_sub[(c)],(h))
285 #define GST_VIDEO_FORMAT_INFO_DATA(info,planes,comp) \
286 (((guint8*)(planes)[info->plane[comp]]) + info->offset[comp])
287 #define GST_VIDEO_FORMAT_INFO_STRIDE(info,strides,comp) ((strides)[info->plane[comp]])
289 /* format properties */
290 GstVideoFormat gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
291 gint red_mask, gint green_mask,
292 gint blue_mask, gint alpha_mask) G_GNUC_CONST;
294 GstVideoFormat gst_video_format_from_fourcc (guint32 fourcc) G_GNUC_CONST;
295 GstVideoFormat gst_video_format_from_string (const gchar *format) G_GNUC_CONST;
297 guint32 gst_video_format_to_fourcc (GstVideoFormat format) G_GNUC_CONST;
298 const gchar * gst_video_format_to_string (GstVideoFormat format) G_GNUC_CONST;
300 const GstVideoFormatInfo *
301 gst_video_format_get_info (GstVideoFormat format) G_GNUC_CONST;
303 typedef struct _GstVideoInfo GstVideoInfo;
304 typedef struct _GstVideoFrame GstVideoFrame;
307 * GstVideoInterlaceMode:
308 * GST_VIDEO_INTERLACE_MODE_PROGRESSIVE: all frames are progressive
309 * GST_VIDEO_INTERLACE_MODE_INTERLEAVED: video is interlaced and all fields
310 * are interlaced in one frame.
311 * @GST_VIDEO_INTERLACE_MODE_MIXED: video contains both interlaced and
312 * progressive frames, the buffer flags describe the frame and fields.
313 * @GST_VIDEO_INTERLACE_MODE_FIELDS: video is interlaced and fields are stored
314 * separately. Use the id property to get access to the required field.
316 * The possible values of the #GstVideoInterlaceMode describing the interlace
317 * mode of the stream.
320 GST_VIDEO_INTERLACE_MODE_PROGRESSIVE = 0,
321 GST_VIDEO_INTERLACE_MODE_INTERLEAVED,
322 GST_VIDEO_INTERLACE_MODE_MIXED,
323 GST_VIDEO_INTERLACE_MODE_FIELDS
324 } GstVideoInterlaceMode;
328 * @GST_VIDEO_FLAG_NONE: no flags
329 * @GST_VIDEO_FLAG_INTERLACED: The video is interlaced
330 * @GST_VIDEO_FLAG_TFF: The video has the top field first
331 * @GST_VIDEO_FLAG_RFF: The video has the repeat flag
332 * @GST_VIDEO_FLAG_ONEFIELD: one field
333 * @GST_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d
334 * denote the maximum fps of the video
339 GST_VIDEO_FLAG_NONE = 0,
340 GST_VIDEO_FLAG_INTERLACED = (1 << 0),
341 GST_VIDEO_FLAG_TFF = (1 << 1),
342 GST_VIDEO_FLAG_RFF = (1 << 2),
343 GST_VIDEO_FLAG_ONEFIELD = (1 << 3),
344 GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 4)
349 * @GST_VIDEO_CHROMA_SITE_UNKNOWN: unknown cositing
350 * @GST_VIDEO_CHROMA_SITE_NONE: no cositing
351 * @GST_VIDEO_CHROMA_SITE_H_COSITED: chroma is horizontally cosited
352 * @GST_VIDEO_CHROMA_SITE_V_COSITED: chroma is vertically cosited
353 * @GST_VIDEO_CHROMA_SITE_ALT_LINE: choma samples are sited on alternate lines
354 * @GST_VIDEO_CHROMA_SITE_COSITED: chroma samples cosited with luma samples
355 * @GST_VIDEO_CHROMA_SITE_JPEG: jpeg style cositing, also for mpeg1 and mjpeg
356 * @GST_VIDEO_CHROMA_SITE_MPEG2: mpeg2 style cositing
357 * @GST_VIDEO_CHROMA_SITE_DV: DV style cositing
359 * Various Chroma sitings.
362 GST_VIDEO_CHROMA_SITE_UNKNOWN = 0,
363 GST_VIDEO_CHROMA_SITE_NONE = (1 << 0),
364 GST_VIDEO_CHROMA_SITE_H_COSITED = (1 << 1),
365 GST_VIDEO_CHROMA_SITE_V_COSITED = (1 << 2),
366 GST_VIDEO_CHROMA_SITE_ALT_LINE = (1 << 3),
367 /* some common chroma cositing */
368 GST_VIDEO_CHROMA_SITE_COSITED = (GST_VIDEO_CHROMA_SITE_H_COSITED | GST_VIDEO_CHROMA_SITE_V_COSITED),
369 GST_VIDEO_CHROMA_SITE_JPEG = (GST_VIDEO_CHROMA_SITE_NONE),
370 GST_VIDEO_CHROMA_SITE_MPEG2 = (GST_VIDEO_CHROMA_SITE_H_COSITED),
371 GST_VIDEO_CHROMA_SITE_DV = (GST_VIDEO_CHROMA_SITE_COSITED | GST_VIDEO_CHROMA_SITE_ALT_LINE),
372 } GstVideoChromaSite;
375 * GstVideoColorRange:
376 * @GST_VIDEO_COLOR_RANGE_UNKNOWN: unknown range
377 * @GST_VIDEO_COLOR_RANGE_0_255: [0..255] for 8 bit components
378 * @GST_VIDEO_COLOR_RANGE_16_235: [16..235] for 8 bit components. Chroma has
381 * Possible color range values. These constants are defined for 8 bit color
382 * values and can be scaled for other bit depths.
385 GST_VIDEO_COLOR_RANGE_UNKNOWN = 0,
386 GST_VIDEO_COLOR_RANGE_0_255,
387 GST_VIDEO_COLOR_RANGE_16_235
388 } GstVideoColorRange;
391 * GstVideoColorMatrix:
392 * @GST_VIDEO_COLOR_MATRIX_UNKNOWN: unknown matrix
393 * @GST_VIDEO_COLOR_MATRIX_RGB: identity matrix
394 * @GST_VIDEO_COLOR_MATRIX_FCC: FCC color matrix
395 * @GST_VIDEO_COLOR_MATRIX_BT709: ITU-R BT.709 color matrix
396 * @GST_VIDEO_COLOR_MATRIX_BT601: ITU-R BT.601 color matrix
397 * @GST_VIDEO_COLOR_MATRIX_SMPTE240M: SMPTE 240M color matrix
399 * The color matrix is used to convert between Y'PbPr and
400 * non-linear RGB (R'G'B')
403 GST_VIDEO_COLOR_MATRIX_UNKNOWN = 0,
404 GST_VIDEO_COLOR_MATRIX_RGB,
405 GST_VIDEO_COLOR_MATRIX_FCC,
406 GST_VIDEO_COLOR_MATRIX_BT709,
407 GST_VIDEO_COLOR_MATRIX_BT601,
408 GST_VIDEO_COLOR_MATRIX_SMPTE240M
409 } GstVideoColorMatrix;
412 * GstVideoTransferFunction:
413 * @GST_VIDEO_TRANSFER_UNKNOWN: unknown transfer function
414 * @GST_VIDEO_TRANSFER_GAMMA10: linear RGB, gamma 1.0 curve
415 * @GST_VIDEO_TRANSFER_GAMMA18: Gamma 1.8 curve
416 * @GST_VIDEO_TRANSFER_GAMMA20: Gamma 2.0 curve
417 * @GST_VIDEO_TRANSFER_GAMMA22: Gamma 2.2 curve
418 * @GST_VIDEO_TRANSFER_BT709: Gamma 2.2 curve with a linear segment in the lower
420 * @GST_VIDEO_TRANSFER_SMPTE240M: Gamma 2.2 curve with a linear segment in the
422 * @GST_VIDEO_TRANSFER_SRGB: Gamma 2.4 curve with a linear segment in the lower
424 * @GST_VIDEO_TRANSFER_GAMMA28: Gamma 2.8 curve
425 * @GST_VIDEO_TRANSFER_LOG100: Logarithmic transfer characteristic
427 * @GST_VIDEO_TRANSFER_LOG316: Logarithmic transfer characteristic
430 * The video transfer function defines the formula for converting between
431 * non-linear RGB (R'G'B') and linear RGB
434 GST_VIDEO_TRANSFER_UNKNOWN = 0,
435 GST_VIDEO_TRANSFER_GAMMA10,
436 GST_VIDEO_TRANSFER_GAMMA18,
437 GST_VIDEO_TRANSFER_GAMMA20,
438 GST_VIDEO_TRANSFER_GAMMA22,
439 GST_VIDEO_TRANSFER_BT709,
440 GST_VIDEO_TRANSFER_SMPTE240M,
441 GST_VIDEO_TRANSFER_SRGB,
442 GST_VIDEO_TRANSFER_GAMMA28,
443 GST_VIDEO_TRANSFER_LOG100,
444 GST_VIDEO_TRANSFER_LOG316
445 } GstVideoTransferFunction;
448 * GstVideoColorPrimaries:
449 * @GST_VIDEO_COLOR_PRIMARIES_UNKNOWN: unknown color primaries
450 * @GST_VIDEO_COLOR_PRIMARIES_BT709: BT709 primaries
451 * @GST_VIDEO_COLOR_PRIMARIES_BT470M: BT470M primaries
452 * @GST_VIDEO_COLOR_PRIMARIES_BT470BG: BT470BG primaries
453 * @GST_VIDEO_COLOR_PRIMARIES_SMPTE170M: SMPTE170M primaries
454 * @GST_VIDEO_COLOR_PRIMARIES_SMPTE240M: SMPTE240M primaries
456 * The color primaries define the how to transform linear RGB values to and from
457 * the CIE XYZ colorspace.
460 GST_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0,
461 GST_VIDEO_COLOR_PRIMARIES_BT709,
462 GST_VIDEO_COLOR_PRIMARIES_BT470M,
463 GST_VIDEO_COLOR_PRIMARIES_BT470BG,
464 GST_VIDEO_COLOR_PRIMARIES_SMPTE170M,
465 GST_VIDEO_COLOR_PRIMARIES_SMPTE240M
466 } GstVideoColorPrimaries;
469 * GstVideoColorimetry:
470 * @range: the color range. This is the valid range for the samples.
471 * It is used to convert the samples to Y'PbPr values.
472 * @matrix: the color matrix. Used to convert between Y'PbPr and
473 * non-linear RGB (R'G'B')
474 * @transfer: the transfer function. used to convert between R'G'B' and RGB
475 * @primaries: color primaries. used to convert between R'G'B' and CIE XYZ
477 * Structure describing the color info.
480 GstVideoColorRange range;
481 GstVideoColorMatrix matrix;
482 GstVideoTransferFunction transfer;
483 GstVideoColorPrimaries primaries;
484 } GstVideoColorimetry;
486 /* predefined colorimetry */
487 #define GST_VIDEO_COLORIMETRY_BT601 "bt601"
488 #define GST_VIDEO_COLORIMETRY_BT709 "bt709"
489 #define GST_VIDEO_COLORIMETRY_SMPTE240M "smpte240m"
491 gboolean gst_video_colorimetry_matches (GstVideoColorimetry *cinfo, const gchar *color);
492 gboolean gst_video_colorimetry_from_string (GstVideoColorimetry *cinfo, const gchar *color);
493 gchar * gst_video_colorimetry_to_string (GstVideoColorimetry *cinfo);
497 * @finfo: the format info of the video
498 * @interlace_mode: the interlace mode
499 * @flags: additional video flags
500 * @width: the width of the video
501 * @height: the height of the video
502 * @views: the number of views for multiview video
503 * @size: the default size of one frame
504 * @chroma_site: a #GstVideoChromaSite.
505 * @colorimetry: the colorimetry info
506 * @palette: a buffer with palette data
507 * @par_n: the pixel-aspect-ratio numerator
508 * @par_d: the pixel-aspect-ratio demnominator
509 * @fps_n: the framerate numerator
510 * @fps_d: the framerate demnominator
511 * @offset: offsets of the planes
512 * @stride: strides of the planes
514 * Information describing image properties. This information can be filled
515 * in from GstCaps with gst_video_info_from_caps(). The information is also used
516 * to store the specific video info when mapping a video frame with
517 * gst_video_frame_map().
519 * Use the provided macros to access the info in this structure.
521 struct _GstVideoInfo {
522 const GstVideoFormatInfo *finfo;
524 GstVideoInterlaceMode interlace_mode;
531 GstVideoChromaSite chroma_site;
532 GstVideoColorimetry colorimetry;
541 gsize offset[GST_VIDEO_MAX_PLANES];
542 gint stride[GST_VIDEO_MAX_PLANES];
546 #define GST_VIDEO_INFO_FORMAT(i) (GST_VIDEO_FORMAT_INFO_FORMAT((i)->finfo))
547 #define GST_VIDEO_INFO_NAME(i) (GST_VIDEO_FORMAT_INFO_NAME((i)->finfo))
548 #define GST_VIDEO_INFO_IS_YUV(i) (GST_VIDEO_FORMAT_INFO_IS_YUV((i)->finfo))
549 #define GST_VIDEO_INFO_IS_RGB(i) (GST_VIDEO_FORMAT_INFO_IS_RGB((i)->finfo))
550 #define GST_VIDEO_INFO_IS_GRAY(i) (GST_VIDEO_FORMAT_INFO_IS_GRAY((i)->finfo))
551 #define GST_VIDEO_INFO_HAS_ALPHA(i) (GST_VIDEO_FORMAT_INFO_HAS_ALPHA((i)->finfo))
553 #define GST_VIDEO_INFO_INTERLACE_MODE(i) ((i)->interlace_mode)
554 #define GST_VIDEO_INFO_FLAGS(i) ((i)->flags)
555 #define GST_VIDEO_INFO_WIDTH(i) ((i)->width)
556 #define GST_VIDEO_INFO_HEIGHT(i) ((i)->height)
557 #define GST_VIDEO_INFO_SIZE(i) ((i)->size)
558 #define GST_VIDEO_INFO_VIEWS(i) ((i)->views)
559 #define GST_VIDEO_INFO_PAR_N(i) ((i)->par_n)
560 #define GST_VIDEO_INFO_PAR_D(i) ((i)->par_d)
561 #define GST_VIDEO_INFO_FPS_N(i) ((i)->fps_n)
562 #define GST_VIDEO_INFO_FPS_D(i) ((i)->fps_d)
564 /* dealing with GstVideoInfo flags */
565 #define GST_VIDEO_INFO_FLAG_IS_SET(i,flag) ((GST_VIDEO_INFO_FLAGS(i) & (flag)) == (flag))
566 #define GST_VIDEO_INFO_FLAG_SET(i,flag) (GST_VIDEO_INFO_FLAGS(i) |= (flag))
567 #define GST_VIDEO_INFO_FLAG_UNSET(i,flag) (GST_VIDEO_INFO_FLAGS(i) &= ~(flag))
569 /* dealing with planes */
570 #define GST_VIDEO_INFO_N_PLANES(i) (GST_VIDEO_FORMAT_INFO_N_PLANES((i)->finfo))
571 #define GST_VIDEO_INFO_PLANE_OFFSET(i,p) ((i)->offset[p])
572 #define GST_VIDEO_INFO_PLANE_STRIDE(i,p) ((i)->stride[p])
574 /* dealing with components */
575 #define GST_VIDEO_INFO_N_COMPONENTS(i) GST_VIDEO_FORMAT_INFO_N_COMPONENTS((i)->finfo)
576 #define GST_VIDEO_INFO_COMP_DATA(i,d,c) GST_VIDEO_FORMAT_INFO_DATA((i)->finfo,d,c)
577 #define GST_VIDEO_INFO_COMP_STRIDE(i,c) GST_VIDEO_FORMAT_INFO_STRIDE((i)->finfo,(i)->stride,c)
578 #define GST_VIDEO_INFO_COMP_WIDTH(i,c) GST_VIDEO_FORMAT_INFO_SCALE_WIDTH((i)->finfo,c,(i)->width)
579 #define GST_VIDEO_INFO_COMP_HEIGHT(i,c) GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT((i)->finfo,c,(i)->height)
580 #define GST_VIDEO_INFO_COMP_PLANE(i,c) GST_VIDEO_FORMAT_INFO_PLANE((i)->finfo,c)
581 #define GST_VIDEO_INFO_COMP_OFFSET(i,c) GST_VIDEO_FORMAT_INFO_OFFSET((i)->finfo,c)
582 #define GST_VIDEO_INFO_COMP_PSTRIDE(i,c) GST_VIDEO_FORMAT_INFO_PSTRIDE((i)->finfo,c)
584 void gst_video_info_init (GstVideoInfo *info);
586 void gst_video_info_set_format (GstVideoInfo *info, GstVideoFormat format,
587 guint width, guint height);
589 gboolean gst_video_info_from_caps (GstVideoInfo *info, const GstCaps * caps);
591 GstCaps * gst_video_info_to_caps (GstVideoInfo *info);
593 gboolean gst_video_info_convert (GstVideoInfo *info,
594 GstFormat src_format,
596 GstFormat dest_format,
601 * @info: the #GstVideoInfo
602 * @buffer: the mapped buffer
603 * @meta: pointer to metadata if any
604 * @id: id of the mapped frame. the id can for example be used to
605 * indentify the frame in case of multiview video.
606 * @data: pointers to the plane data
608 * A video frame obtained from gst_video_frame_map()
610 struct _GstVideoFrame {
617 gpointer data[GST_VIDEO_MAX_PLANES];
620 gboolean gst_video_frame_map (GstVideoFrame *frame, GstVideoInfo *info,
621 GstBuffer *buffer, GstMapFlags flags);
622 gboolean gst_video_frame_map_id (GstVideoFrame *frame, GstVideoInfo *info,
623 GstBuffer *buffer, gint id, GstMapFlags flags);
624 void gst_video_frame_unmap (GstVideoFrame *frame);
626 gboolean gst_video_frame_copy (GstVideoFrame *dest, const GstVideoFrame *src);
629 #define GST_VIDEO_FRAME_FORMAT(f) (GST_VIDEO_INFO_FORMAT(&(f)->info))
630 #define GST_VIDEO_FRAME_WIDTH(f) (GST_VIDEO_INFO_WIDTH(&(f)->info))
631 #define GST_VIDEO_FRAME_HEIGHT(f) (GST_VIDEO_INFO_HEIGHT(&(f)->info))
632 #define GST_VIDEO_FRAME_SIZE(f) (GST_VIDEO_INFO_SIZE(&(f)->info))
634 /* dealing with planes */
635 #define GST_VIDEO_FRAME_N_PLANES(f) (GST_VIDEO_INFO_N_PLANES(&(f)->info))
636 #define GST_VIDEO_FRAME_PLANE_DATA(f,p) ((f)->data[p])
637 #define GST_VIDEO_FRAME_PLANE_OFFSET(f,p) (GST_VIDEO_INFO_PLANE_OFFSET(&(f)->info,p))
638 #define GST_VIDEO_FRAME_PLANE_STRIDE(f,p) (GST_VIDEO_INFO_PLANE_STRIDE(&(f)->info,p))
640 /* dealing with components */
641 #define GST_VIDEO_FRAME_N_COMPONENTS(f) GST_VIDEO_INFO_N_COMPONENTS(&(f)->info)
642 #define GST_VIDEO_FRAME_COMP_DATA(f,c) GST_VIDEO_INFO_COMP_DATA(&(f)->info,(f)->data,c)
643 #define GST_VIDEO_FRAME_COMP_STRIDE(f,c) GST_VIDEO_INFO_COMP_STRIDE(&(f)->info,c)
644 #define GST_VIDEO_FRAME_COMP_WIDTH(f,c) GST_VIDEO_INFO_COMP_WIDTH(&(f)->info,c)
645 #define GST_VIDEO_FRAME_COMP_HEIGHT(f,c) GST_VIDEO_INFO_COMP_HEIGHT(&(f)->info,c)
646 #define GST_VIDEO_FRAME_COMP_PLANE(f,c) GST_VIDEO_INFO_COMP_PLANE(&(f)->info,c)
647 #define GST_VIDEO_FRAME_COMP_OFFSET(f,c) GST_VIDEO_INFO_COMP_OFFSET(&(f)->info,c)
648 #define GST_VIDEO_FRAME_COMP_PSTRIDE(f,c) GST_VIDEO_INFO_COMP_PSTRIDE(&(f)->info,c)
650 #define GST_VIDEO_SIZE_RANGE "(int) [ 1, max ]"
651 #define GST_VIDEO_FPS_RANGE "(fraction) [ 0, max ]"
653 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
654 # define GST_VIDEO_NE(s) G_STRINGIFY(s)"_LE"
655 # define GST_VIDEO_OE(s) G_STRINGIFY(s)"_BE"
657 # define GST_VIDEO_NE(s) G_STRINGIFY(s)"_BE"
658 # define GST_VIDEO_OE(s) G_STRINGIFY(s)"_LE"
661 #define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, " \
662 "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, " \
663 "YVYU, Y444, v210, v216, NV12, NV21, GRAY8, GRAY16_BE, GRAY16_LE, " \
664 "v308, Y800, Y16, RGB16, BGR16, RGB15, BGR15, UYVP, A420, " \
665 "RGB8_PALETTED, YUV9, YVU9, IYU1, ARGB64, AYUV64, r210 }"
668 * GST_VIDEO_CAPS_MAKE:
669 * @format: string format that describes the pixel layout, as string
670 * (e.g. "I420", "RGB", "YV12", "YUY2", "AYUV", etc.)
672 * Generic caps string for video, for use in pad templates.
674 #define GST_VIDEO_CAPS_MAKE(format) \
676 "format = (string) " format ", " \
677 "width = " GST_VIDEO_SIZE_RANGE ", " \
678 "height = " GST_VIDEO_SIZE_RANGE ", " \
679 "framerate = " GST_VIDEO_FPS_RANGE
684 * GstVideoBufferFlags:
685 * @GST_VIDEO_BUFFER_FLAG_INTERLACED: Mark #GstBuffer as interlaced
686 * @GST_VIDEO_BUFFER_FLAG_TFF: If the #GstBuffer is interlaced, then the first field
687 * in the video frame is the top field. If unset, the
688 * bottom field is first.
689 * @GST_VIDEO_BUFFER_FLAG_RFF: If the #GstBuffer is interlaced, then the first field
690 * (as defined by the %GST_VIDEO_BUFFER_TFF flag setting)
692 * @GST_VIDEO_BUFFER_FLAG_ONEFIELD: If the #GstBuffer is interlaced, then only the
693 * first field (as defined by the %GST_VIDEO_BUFFER_TFF
694 * flag setting) is to be displayed.
696 * Additional video buffer flags.
699 GST_VIDEO_BUFFER_FLAG_INTERLACED = (GST_BUFFER_FLAG_LAST << 0),
700 GST_VIDEO_BUFFER_FLAG_TFF = (GST_BUFFER_FLAG_LAST << 1),
701 GST_VIDEO_BUFFER_FLAG_RFF = (GST_BUFFER_FLAG_LAST << 2),
702 GST_VIDEO_BUFFER_FLAG_ONEFIELD = (GST_BUFFER_FLAG_LAST << 3),
704 GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8)
705 } GstVideoBufferFlags;
707 /* some helper functions */
708 gboolean gst_video_calculate_display_ratio (guint * dar_n,
715 guint display_par_d);
717 GstBuffer * gst_video_parse_caps_palette (GstCaps * caps);
719 /* video still frame event creation and parsing */
721 GstEvent * gst_video_event_new_still_frame (gboolean in_still);
723 gboolean gst_video_event_parse_still_frame (GstEvent * event, gboolean * in_still);
725 /* video force key unit event creation and parsing */
727 GstEvent * gst_video_event_new_downstream_force_key_unit (GstClockTime timestamp,
728 GstClockTime streamtime,
729 GstClockTime runningtime,
730 gboolean all_headers,
733 gboolean gst_video_event_parse_downstream_force_key_unit (GstEvent * event,
734 GstClockTime * timestamp,
735 GstClockTime * streamtime,
736 GstClockTime * runningtime,
737 gboolean * all_headers,
740 GstEvent * gst_video_event_new_upstream_force_key_unit (GstClockTime running_time,
741 gboolean all_headers,
744 gboolean gst_video_event_parse_upstream_force_key_unit (GstEvent * event,
745 GstClockTime * running_time,
746 gboolean * all_headers,
749 gboolean gst_video_event_is_force_key_unit(GstEvent *event);
751 /* convert/encode video sample from one format to another */
753 typedef void (*GstVideoConvertSampleCallback) (GstSample * sample, GError *error, gpointer user_data);
755 void gst_video_convert_sample_async (GstSample * sample,
756 const GstCaps * to_caps,
757 GstClockTime timeout,
758 GstVideoConvertSampleCallback callback,
760 GDestroyNotify destroy_notify);
762 GstSample * gst_video_convert_sample (GstSample * sample,
763 const GstCaps * to_caps,
764 GstClockTime timeout,
768 #endif /* __GST_VIDEO_H__ */