1/* GStreamer
2 * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
3 *
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.
8 *
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.
13 *
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.
18 */
19
20#ifndef __GST_VIDEO_FORMAT_H__
21#define __GST_VIDEO_FORMAT_H__
22
23#include <gst/gst.h>
24
25G_BEGIN_DECLS
26
27#include <gst/video/video-enumtypes.h>
28#include <gst/video/video-tile.h>
29
30/**
31 * GstVideoFormat:
32 * @GST_VIDEO_FORMAT_UNKNOWN: Unknown or unset video format id
33 * @GST_VIDEO_FORMAT_ENCODED: Encoded video format. Only ever use that in caps for
34 * special video formats in combination with non-system
35 * memory GstCapsFeatures where it does not make sense
36 * to specify a real video format.
37 * @GST_VIDEO_FORMAT_I420: planar 4:2:0 YUV
38 * @GST_VIDEO_FORMAT_YV12: planar 4:2:0 YVU (like I420 but UV planes swapped)
39 * @GST_VIDEO_FORMAT_YUY2: packed 4:2:2 YUV (Y0-U0-Y1-V0 Y2-U2-Y3-V2 Y4 ...)
40 * @GST_VIDEO_FORMAT_UYVY: packed 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...)
41 * @GST_VIDEO_FORMAT_VYUY: packed 4:2:2 YUV (V0-Y0-U0-Y1 V2-Y2-U2-Y3 V4 ...)
42 * @GST_VIDEO_FORMAT_AYUV: packed 4:4:4 YUV with alpha channel (A0-Y0-U0-V0 ...)
43 * @GST_VIDEO_FORMAT_RGBx: sparse rgb packed into 32 bit, space last
44 * @GST_VIDEO_FORMAT_BGRx: sparse reverse rgb packed into 32 bit, space last
45 * @GST_VIDEO_FORMAT_xRGB: sparse rgb packed into 32 bit, space first
46 * @GST_VIDEO_FORMAT_xBGR: sparse reverse rgb packed into 32 bit, space first
47 * @GST_VIDEO_FORMAT_RGBA: rgb with alpha channel last
48 * @GST_VIDEO_FORMAT_BGRA: reverse rgb with alpha channel last
49 * @GST_VIDEO_FORMAT_ARGB: rgb with alpha channel first
50 * @GST_VIDEO_FORMAT_ABGR: reverse rgb with alpha channel first
51 * @GST_VIDEO_FORMAT_RGB: RGB packed into 24 bits without padding (`R-G-B-R-G-B`)
52 * @GST_VIDEO_FORMAT_BGR: reverse RGB packed into 24 bits without padding (`B-G-R-B-G-R`)
53 * @GST_VIDEO_FORMAT_Y41B: planar 4:1:1 YUV
54 * @GST_VIDEO_FORMAT_Y42B: planar 4:2:2 YUV
55 * @GST_VIDEO_FORMAT_YVYU: packed 4:2:2 YUV (Y0-V0-Y1-U0 Y2-V2-Y3-U2 Y4 ...)
56 * @GST_VIDEO_FORMAT_Y444: planar 4:4:4 YUV
57 * @GST_VIDEO_FORMAT_v210: packed 4:2:2 10-bit YUV, complex format
58 * @GST_VIDEO_FORMAT_v216: packed 4:2:2 16-bit YUV, Y0-U0-Y1-V1 order
59 * @GST_VIDEO_FORMAT_NV12: planar 4:2:0 YUV with interleaved UV plane
60 * @GST_VIDEO_FORMAT_NV21: planar 4:2:0 YUV with interleaved VU plane
61 * @GST_VIDEO_FORMAT_NV12_10LE32: 10-bit variant of @GST_VIDEO_FORMAT_NV12, packed into 32bit words (MSB 2 bits padding) (Since: 1.14)
62 * @GST_VIDEO_FORMAT_GRAY8: 8-bit grayscale
63 * @GST_VIDEO_FORMAT_GRAY10_LE32: 10-bit grayscale, packed into 32bit words (2 bits padding) (Since: 1.14)
64 * @GST_VIDEO_FORMAT_GRAY16_BE: 16-bit grayscale, most significant byte first
65 * @GST_VIDEO_FORMAT_GRAY16_LE: 16-bit grayscale, least significant byte first
66 * @GST_VIDEO_FORMAT_v308: packed 4:4:4 YUV (Y-U-V ...)
67 * @GST_VIDEO_FORMAT_IYU2: packed 4:4:4 YUV (U-Y-V ...) (Since 1.10)
68 * @GST_VIDEO_FORMAT_RGB16: rgb 5-6-5 bits per component
69 * @GST_VIDEO_FORMAT_BGR16: reverse rgb 5-6-5 bits per component
70 * @GST_VIDEO_FORMAT_RGB15: rgb 5-5-5 bits per component
71 * @GST_VIDEO_FORMAT_BGR15: reverse rgb 5-5-5 bits per component
72 * @GST_VIDEO_FORMAT_UYVP: packed 10-bit 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...)
73 * @GST_VIDEO_FORMAT_A420: planar 4:4:2:0 AYUV
74 * @GST_VIDEO_FORMAT_RGB8P: 8-bit paletted RGB
75 * @GST_VIDEO_FORMAT_YUV9: planar 4:1:0 YUV
76 * @GST_VIDEO_FORMAT_YVU9: planar 4:1:0 YUV (like YUV9 but UV planes swapped)
77 * @GST_VIDEO_FORMAT_IYU1: packed 4:1:1 YUV (Cb-Y0-Y1-Cr-Y2-Y3 ...)
78 * @GST_VIDEO_FORMAT_ARGB64: rgb with alpha channel first, 16 bits per channel
79 * @GST_VIDEO_FORMAT_AYUV64: packed 4:4:4 YUV with alpha channel, 16 bits per channel (A0-Y0-U0-V0 ...)
80 * @GST_VIDEO_FORMAT_r210: packed 4:4:4 RGB, 10 bits per channel
81 * @GST_VIDEO_FORMAT_I420_10BE: planar 4:2:0 YUV, 10 bits per channel
82 * @GST_VIDEO_FORMAT_I420_10LE: planar 4:2:0 YUV, 10 bits per channel
83 * @GST_VIDEO_FORMAT_I422_10BE: planar 4:2:2 YUV, 10 bits per channel
84 * @GST_VIDEO_FORMAT_I422_10LE: planar 4:2:2 YUV, 10 bits per channel
85 * @GST_VIDEO_FORMAT_Y444_10BE: planar 4:4:4 YUV, 10 bits per channel (Since: 1.2)
86 * @GST_VIDEO_FORMAT_Y444_10LE: planar 4:4:4 YUV, 10 bits per channel (Since: 1.2)
87 * @GST_VIDEO_FORMAT_GBR: planar 4:4:4 RGB, 8 bits per channel (Since: 1.2)
88 * @GST_VIDEO_FORMAT_GBR_10BE: planar 4:4:4 RGB, 10 bits per channel (Since: 1.2)
89 * @GST_VIDEO_FORMAT_GBR_10LE: planar 4:4:4 RGB, 10 bits per channel (Since: 1.2)
90 * @GST_VIDEO_FORMAT_NV16: planar 4:2:2 YUV with interleaved UV plane (Since: 1.2)
91 * @GST_VIDEO_FORMAT_NV16_10LE32: 10-bit variant of @GST_VIDEO_FORMAT_NV16, packed into 32bit words (MSB 2 bits padding) (Since: 1.14)
92 * @GST_VIDEO_FORMAT_NV24: planar 4:4:4 YUV with interleaved UV plane (Since: 1.2)
93 * @GST_VIDEO_FORMAT_NV12_64Z32: NV12 with 64x32 tiling in zigzag pattern (Since: 1.4)
94 * @GST_VIDEO_FORMAT_A420_10BE: planar 4:4:2:0 YUV, 10 bits per channel (Since: 1.6)
95 * @GST_VIDEO_FORMAT_A420_10LE: planar 4:4:2:0 YUV, 10 bits per channel (Since: 1.6)
96 * @GST_VIDEO_FORMAT_A422_10BE: planar 4:4:2:2 YUV, 10 bits per channel (Since: 1.6)
97 * @GST_VIDEO_FORMAT_A422_10LE: planar 4:4:2:2 YUV, 10 bits per channel (Since: 1.6)
98 * @GST_VIDEO_FORMAT_A444_10BE: planar 4:4:4:4 YUV, 10 bits per channel (Since: 1.6)
99 * @GST_VIDEO_FORMAT_A444_10LE: planar 4:4:4:4 YUV, 10 bits per channel (Since: 1.6)
100 * @GST_VIDEO_FORMAT_NV61: planar 4:2:2 YUV with interleaved VU plane (Since: 1.6)
101 * @GST_VIDEO_FORMAT_P010_10BE: planar 4:2:0 YUV with interleaved UV plane, 10 bits per channel (Since: 1.10)
102 * @GST_VIDEO_FORMAT_P010_10LE: planar 4:2:0 YUV with interleaved UV plane, 10 bits per channel (Since: 1.10)
103 * @GST_VIDEO_FORMAT_GBRA: planar 4:4:4:4 ARGB, 8 bits per channel (Since: 1.12)
104 * @GST_VIDEO_FORMAT_GBRA_10BE: planar 4:4:4:4 ARGB, 10 bits per channel (Since: 1.12)
105 * @GST_VIDEO_FORMAT_GBRA_10LE: planar 4:4:4:4 ARGB, 10 bits per channel (Since: 1.12)
106 * @GST_VIDEO_FORMAT_GBR_12BE: planar 4:4:4 RGB, 12 bits per channel (Since: 1.12)
107 * @GST_VIDEO_FORMAT_GBR_12LE: planar 4:4:4 RGB, 12 bits per channel (Since: 1.12)
108 * @GST_VIDEO_FORMAT_GBRA_12BE: planar 4:4:4:4 ARGB, 12 bits per channel (Since: 1.12)
109 * @GST_VIDEO_FORMAT_GBRA_12LE: planar 4:4:4:4 ARGB, 12 bits per channel (Since: 1.12)
110 * @GST_VIDEO_FORMAT_I420_12BE: planar 4:2:0 YUV, 12 bits per channel (Since: 1.12)
111 * @GST_VIDEO_FORMAT_I420_12LE: planar 4:2:0 YUV, 12 bits per channel (Since: 1.12)
112 * @GST_VIDEO_FORMAT_I422_12BE: planar 4:2:2 YUV, 12 bits per channel (Since: 1.12)
113 * @GST_VIDEO_FORMAT_I422_12LE: planar 4:2:2 YUV, 12 bits per channel (Since: 1.12)
114 * @GST_VIDEO_FORMAT_Y444_12BE: planar 4:4:4 YUV, 12 bits per channel (Since: 1.12)
115 * @GST_VIDEO_FORMAT_Y444_12LE: planar 4:4:4 YUV, 12 bits per channel (Since: 1.12)
116 * @GST_VIDEO_FORMAT_NV12_10LE40: Fully packed variant of NV12_10LE32 (Since: 1.16)
117 * @GST_VIDEO_FORMAT_Y210: packed 4:2:2 YUV, 10 bits per channel (Since: 1.16)
118 * @GST_VIDEO_FORMAT_Y410: packed 4:4:4 YUV, 10 bits per channel(A-V-Y-U...) (Since: 1.16)
119 * @GST_VIDEO_FORMAT_VUYA: packed 4:4:4 YUV with alpha channel (V0-U0-Y0-A0...) (Since: 1.16)
120 * @GST_VIDEO_FORMAT_BGR10A2_LE: packed 4:4:4 RGB with alpha channel(B-G-R-A), 10 bits for R/G/B channel and MSB 2 bits for alpha channel (Since: 1.16)
121 *
122 * Enum value describing the most common video formats.
123 *
124 * See the [GStreamer raw video format design document](https://gstreamer.freedesktop.org/documentation/design/mediatype-video-raw.html#formats)
125 * for details about the layout and packing of these formats in memory.
126 */
127typedef enum {
128 GST_VIDEO_FORMAT_UNKNOWN,
129 GST_VIDEO_FORMAT_ENCODED,
130 GST_VIDEO_FORMAT_I420,
131 GST_VIDEO_FORMAT_YV12,
132 GST_VIDEO_FORMAT_YUY2,
133 GST_VIDEO_FORMAT_UYVY,
134 GST_VIDEO_FORMAT_AYUV,
135 GST_VIDEO_FORMAT_RGBx,
136 GST_VIDEO_FORMAT_BGRx,
137 GST_VIDEO_FORMAT_xRGB,
138 GST_VIDEO_FORMAT_xBGR,
139 GST_VIDEO_FORMAT_RGBA,
140 GST_VIDEO_FORMAT_BGRA,
141 GST_VIDEO_FORMAT_ARGB,
142 GST_VIDEO_FORMAT_ABGR,
143 GST_VIDEO_FORMAT_RGB,
144 GST_VIDEO_FORMAT_BGR,
145 GST_VIDEO_FORMAT_Y41B,
146 GST_VIDEO_FORMAT_Y42B,
147 GST_VIDEO_FORMAT_YVYU,
148 GST_VIDEO_FORMAT_Y444,
149 GST_VIDEO_FORMAT_v210,
150 GST_VIDEO_FORMAT_v216,
151 GST_VIDEO_FORMAT_NV12,
152 GST_VIDEO_FORMAT_NV21,
153 GST_VIDEO_FORMAT_GRAY8,
154 GST_VIDEO_FORMAT_GRAY16_BE,
155 GST_VIDEO_FORMAT_GRAY16_LE,
156 GST_VIDEO_FORMAT_v308,
157 GST_VIDEO_FORMAT_RGB16,
158 GST_VIDEO_FORMAT_BGR16,
159 GST_VIDEO_FORMAT_RGB15,
160 GST_VIDEO_FORMAT_BGR15,
161 GST_VIDEO_FORMAT_UYVP,
162 GST_VIDEO_FORMAT_A420,
163 GST_VIDEO_FORMAT_RGB8P,
164 GST_VIDEO_FORMAT_YUV9,
165 GST_VIDEO_FORMAT_YVU9,
166 GST_VIDEO_FORMAT_IYU1,
167 GST_VIDEO_FORMAT_ARGB64,
168 GST_VIDEO_FORMAT_AYUV64,
169 GST_VIDEO_FORMAT_r210,
170 GST_VIDEO_FORMAT_I420_10BE,
171 GST_VIDEO_FORMAT_I420_10LE,
172 GST_VIDEO_FORMAT_I422_10BE,
173 GST_VIDEO_FORMAT_I422_10LE,
174 GST_VIDEO_FORMAT_Y444_10BE,
175 GST_VIDEO_FORMAT_Y444_10LE,
176 GST_VIDEO_FORMAT_GBR,
177 GST_VIDEO_FORMAT_GBR_10BE,
178 GST_VIDEO_FORMAT_GBR_10LE,
179 GST_VIDEO_FORMAT_NV16,
180 GST_VIDEO_FORMAT_NV24,
181 GST_VIDEO_FORMAT_NV12_64Z32,
182 GST_VIDEO_FORMAT_A420_10BE,
183 GST_VIDEO_FORMAT_A420_10LE,
184 GST_VIDEO_FORMAT_A422_10BE,
185 GST_VIDEO_FORMAT_A422_10LE,
186 GST_VIDEO_FORMAT_A444_10BE,
187 GST_VIDEO_FORMAT_A444_10LE,
188 GST_VIDEO_FORMAT_NV61,
189 GST_VIDEO_FORMAT_P010_10BE,
190 GST_VIDEO_FORMAT_P010_10LE,
191 GST_VIDEO_FORMAT_IYU2,
192 GST_VIDEO_FORMAT_VYUY,
193 GST_VIDEO_FORMAT_GBRA,
194 GST_VIDEO_FORMAT_GBRA_10BE,
195 GST_VIDEO_FORMAT_GBRA_10LE,
196 GST_VIDEO_FORMAT_GBR_12BE,
197 GST_VIDEO_FORMAT_GBR_12LE,
198 GST_VIDEO_FORMAT_GBRA_12BE,
199 GST_VIDEO_FORMAT_GBRA_12LE,
200 GST_VIDEO_FORMAT_I420_12BE,
201 GST_VIDEO_FORMAT_I420_12LE,
202 GST_VIDEO_FORMAT_I422_12BE,
203 GST_VIDEO_FORMAT_I422_12LE,
204 GST_VIDEO_FORMAT_Y444_12BE,
205 GST_VIDEO_FORMAT_Y444_12LE,
206 GST_VIDEO_FORMAT_GRAY10_LE32,
207 GST_VIDEO_FORMAT_NV12_10LE32,
208 GST_VIDEO_FORMAT_NV16_10LE32,
209 GST_VIDEO_FORMAT_NV12_10LE40,
210 GST_VIDEO_FORMAT_Y210,
211 GST_VIDEO_FORMAT_Y410,
212 GST_VIDEO_FORMAT_VUYA,
213 GST_VIDEO_FORMAT_BGR10A2_LE,
214} GstVideoFormat;
215
216#define GST_VIDEO_MAX_PLANES 4
217#define GST_VIDEO_MAX_COMPONENTS 4
218
219typedef struct _GstVideoFormatInfo GstVideoFormatInfo;
220
221/**
222 * GstVideoFormatFlags:
223 * @GST_VIDEO_FORMAT_FLAG_YUV: The video format is YUV, components are numbered
224 * 0=Y, 1=U, 2=V.
225 * @GST_VIDEO_FORMAT_FLAG_RGB: The video format is RGB, components are numbered
226 * 0=R, 1=G, 2=B.
227 * @GST_VIDEO_FORMAT_FLAG_GRAY: The video is gray, there is one gray component
228 * with index 0.
229 * @GST_VIDEO_FORMAT_FLAG_ALPHA: The video format has an alpha components with
230 * the number 3.
231 * @GST_VIDEO_FORMAT_FLAG_LE: The video format has data stored in little
232 * endianness.
233 * @GST_VIDEO_FORMAT_FLAG_PALETTE: The video format has a palette. The palette
234 * is stored in the second plane and indexes are stored in the first plane.
235 * @GST_VIDEO_FORMAT_FLAG_COMPLEX: The video format has a complex layout that
236 * can't be described with the usual information in the #GstVideoFormatInfo.
237 * @GST_VIDEO_FORMAT_FLAG_UNPACK: This format can be used in a
238 * #GstVideoFormatUnpack and #GstVideoFormatPack function.
239 * @GST_VIDEO_FORMAT_FLAG_TILED: The format is tiled, there is tiling information
240 * in the last plane.
241 *
242 * The different video flags that a format info can have.
243 */
244typedef enum
245{
246 GST_VIDEO_FORMAT_FLAG_YUV = (1 << 0),
247 GST_VIDEO_FORMAT_FLAG_RGB = (1 << 1),
248 GST_VIDEO_FORMAT_FLAG_GRAY = (1 << 2),
249 GST_VIDEO_FORMAT_FLAG_ALPHA = (1 << 3),
250 GST_VIDEO_FORMAT_FLAG_LE = (1 << 4),
251 GST_VIDEO_FORMAT_FLAG_PALETTE = (1 << 5),
252 GST_VIDEO_FORMAT_FLAG_COMPLEX = (1 << 6),
253 GST_VIDEO_FORMAT_FLAG_UNPACK = (1 << 7),
254 GST_VIDEO_FORMAT_FLAG_TILED = (1 << 8)
255} GstVideoFormatFlags;
256
257/* YUV components */
258#define GST_VIDEO_COMP_Y 0
259#define GST_VIDEO_COMP_U 1
260#define GST_VIDEO_COMP_V 2
261
262/* RGB components */
263#define GST_VIDEO_COMP_R 0
264#define GST_VIDEO_COMP_G 1
265#define GST_VIDEO_COMP_B 2
266
267/* alpha component */
268#define GST_VIDEO_COMP_A 3
269
270/* palette components */
271#define GST_VIDEO_COMP_INDEX 0
272#define GST_VIDEO_COMP_PALETTE 1
273
274#include <gst/video/video-chroma.h>
275
276/**
277 * GstVideoPackFlags:
278 * @GST_VIDEO_PACK_FLAG_NONE: No flag
279 * @GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE: When the source has a smaller depth
280 * than the target format, set the least significant bits of the target
281 * to 0. This is likely sightly faster but less accurate. When this flag
282 * is not specified, the most significant bits of the source are duplicated
283 * in the least significant bits of the destination.
284 * @GST_VIDEO_PACK_FLAG_INTERLACED: The source is interlaced. The unpacked
285 * format will be interlaced as well with each line containing
286 * information from alternating fields. (Since 1.2)
287 *
288 * The different flags that can be used when packing and unpacking.
289 */
290typedef enum
291{
292 GST_VIDEO_PACK_FLAG_NONE = 0,
293 GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE = (1 << 0),
294 GST_VIDEO_PACK_FLAG_INTERLACED = (1 << 1)
295} GstVideoPackFlags;
296
297/**
298 * GstVideoFormatUnpack:
299 * @info: a #GstVideoFormatInfo
300 * @flags: flags to control the unpacking
301 * @dest: a destination array
302 * @data: pointers to the data planes
303 * @stride: strides of the planes
304 * @x: the x position in the image to start from
305 * @y: the y position in the image to start from
306 * @width: the amount of pixels to unpack.
307 *
308 * Unpacks @width pixels from the given planes and strides containing data of
309 * format @info. The pixels will be unpacked into @dest with each component
310 * interleaved as per @info's unpack_format, which will usually be one of
311 * #GST_VIDEO_FORMAT_ARGB, #GST_VIDEO_FORMAT_AYUV, #GST_VIDEO_FORMAT_ARGB64 or
312 * #GST_VIDEO_FORMAT_AYUV64 depending on the format to unpack.
313 * @dest should at least be big enough to hold @width * bytes_per_pixel bytes
314 * where bytes_per_pixel relates to the unpack format and will usually be
315 * either 4 or 8 depending on the unpack format. bytes_per_pixel will be
316 * the same as the pixel stride for plane 0 for the above formats.
317 *
318 * For subsampled formats, the components will be duplicated in the destination
319 * array. Reconstruction of the missing components can be performed in a
320 * separate step after unpacking.
321 */
322typedef void (*GstVideoFormatUnpack) (const GstVideoFormatInfo *info,
323 GstVideoPackFlags flags, gpointer dest,
324 const gpointer data[GST_VIDEO_MAX_PLANES],
325 const gint stride[GST_VIDEO_MAX_PLANES],
326 gint x, gint y, gint width);
327/**
328 * GstVideoFormatPack:
329 * @info: a #GstVideoFormatInfo
330 * @flags: flags to control the packing
331 * @src: a source array
332 * @sstride: the source array stride
333 * @data: pointers to the destination data planes
334 * @stride: strides of the destination planes
335 * @chroma_site: the chroma siting of the target when subsampled (not used)
336 * @y: the y position in the image to pack to
337 * @width: the amount of pixels to pack.
338 *
339 * Packs @width pixels from @src to the given planes and strides in the
340 * format @info. The pixels from source have each component interleaved
341 * and will be packed into the planes in @data.
342 *
343 * This function operates on pack_lines lines, meaning that @src should
344 * contain at least pack_lines lines with a stride of @sstride and @y
345 * should be a multiple of pack_lines.
346 *
347 * Subsampled formats will use the horizontally and vertically cosited
348 * component from the source. Subsampling should be performed before
349 * packing.
350 *
351 * Because this function does not have a x coordinate, it is not possible to
352 * pack pixels starting from an unaligned position. For tiled images this
353 * means that packing should start from a tile coordinate. For subsampled
354 * formats this means that a complete pixel needs to be packed.
355 */
356/* FIXME(2.0): remove the chroma_site, it is unused and is not relevant for
357 * packing, chroma subsampling based on chroma-site should be done in a separate
358 * step before packing*/
359typedef void (*GstVideoFormatPack) (const GstVideoFormatInfo *info,
360 GstVideoPackFlags flags,
361 const gpointer src, gint sstride,
362 gpointer data[GST_VIDEO_MAX_PLANES],
363 const gint stride[GST_VIDEO_MAX_PLANES],
364 GstVideoChromaSite chroma_site,
365 gint y, gint width);
366
367/**
368 * GstVideoFormatInfo:
369 * @format: #GstVideoFormat
370 * @name: string representation of the format
371 * @description: use readable description of the format
372 * @flags: #GstVideoFormatFlags
373 * @bits: The number of bits used to pack data items. This can be less than 8
374 * when multiple pixels are stored in a byte. for values > 8 multiple bytes
375 * should be read according to the endianness flag before applying the shift
376 * and mask.
377 * @n_components: the number of components in the video format.
378 * @shift: the number of bits to shift away to get the component data
379 * @depth: the depth in bits for each component
380 * @pixel_stride: the pixel stride of each component. This is the amount of
381 * bytes to the pixel immediately to the right. When bits < 8, the stride is
382 * expressed in bits. For 24-bit RGB, this would be 3 bytes, for example,
383 * while it would be 4 bytes for RGBx or ARGB.
384 * @n_planes: the number of planes for this format. The number of planes can be
385 * less than the amount of components when multiple components are packed into
386 * one plane.
387 * @plane: the plane number where a component can be found
388 * @poffset: the offset in the plane where the first pixel of the components
389 * can be found.
390 * @w_sub: subsampling factor of the width for the component. Use
391 * GST_VIDEO_SUB_SCALE to scale a width.
392 * @h_sub: subsampling factor of the height for the component. Use
393 * GST_VIDEO_SUB_SCALE to scale a height.
394 * @unpack_format: the format of the unpacked pixels. This format must have the
395 * #GST_VIDEO_FORMAT_FLAG_UNPACK flag set.
396 * @unpack_func: an unpack function for this format
397 * @pack_lines: the amount of lines that will be packed
398 * @pack_func: an pack function for this format
399 * @tile_mode: The tiling mode
400 * @tile_ws: The width of a tile, in bytes, represented as a shift
401 * @tile_hs: The height of a tile, in bytes, represented as a shift
402 *
403 * Information for a video format.
404 */
405struct _GstVideoFormatInfo {
406 GstVideoFormat format;
407 const gchar *name;
408 const gchar *description;
409 GstVideoFormatFlags flags;
410 guint bits;
411 guint n_components;
412 guint shift[GST_VIDEO_MAX_COMPONENTS];
413 guint depth[GST_VIDEO_MAX_COMPONENTS];
414 gint pixel_stride[GST_VIDEO_MAX_COMPONENTS];
415 guint n_planes;
416 guint plane[GST_VIDEO_MAX_COMPONENTS];
417 guint poffset[GST_VIDEO_MAX_COMPONENTS];
418 guint w_sub[GST_VIDEO_MAX_COMPONENTS];
419 guint h_sub[GST_VIDEO_MAX_COMPONENTS];
420
421 GstVideoFormat unpack_format;
422 GstVideoFormatUnpack unpack_func;
423 gint pack_lines;
424 GstVideoFormatPack pack_func;
425
426 GstVideoTileMode tile_mode;
427 guint tile_ws;
428 guint tile_hs;
429
430 /*< private >*/
431 gpointer _gst_reserved[GST_PADDING];
432};
433
434#define GST_VIDEO_FORMAT_INFO_FORMAT(info) ((info)->format)
435#define GST_VIDEO_FORMAT_INFO_NAME(info) ((info)->name)
436#define GST_VIDEO_FORMAT_INFO_FLAGS(info) ((info)->flags)
437
438#define GST_VIDEO_FORMAT_INFO_IS_YUV(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_YUV)
439#define GST_VIDEO_FORMAT_INFO_IS_RGB(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_RGB)
440#define GST_VIDEO_FORMAT_INFO_IS_GRAY(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_GRAY)
441#define GST_VIDEO_FORMAT_INFO_HAS_ALPHA(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_ALPHA)
442#define GST_VIDEO_FORMAT_INFO_IS_LE(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_LE)
443#define GST_VIDEO_FORMAT_INFO_HAS_PALETTE(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_PALETTE)
444#define GST_VIDEO_FORMAT_INFO_IS_COMPLEX(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_COMPLEX)
445#define GST_VIDEO_FORMAT_INFO_IS_TILED(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_TILED)
446
447#define GST_VIDEO_FORMAT_INFO_BITS(info) ((info)->bits)
448#define GST_VIDEO_FORMAT_INFO_N_COMPONENTS(info) ((info)->n_components)
449#define GST_VIDEO_FORMAT_INFO_SHIFT(info,c) ((info)->shift[c])
450#define GST_VIDEO_FORMAT_INFO_DEPTH(info,c) ((info)->depth[c])
451/**
452 * GST_VIDEO_FORMAT_INFO_PSTRIDE:
453 * @info: a #GstVideoFormatInfo
454 * @c: the component index
455 *
456 * pixel stride for the given component. This is the amount of bytes to the
457 * pixel immediately to the right, so basically bytes from one pixel to the
458 * next. When bits < 8, the stride is expressed in bits.
459 *
460 * Examples: for 24-bit RGB, the pixel stride would be 3 bytes, while it
461 * would be 4 bytes for RGBx or ARGB, and 8 bytes for ARGB64 or AYUV64.
462 * For planar formats such as I420 the pixel stride is usually 1. For
463 * YUY2 it would be 2 bytes.
464 */
465#define GST_VIDEO_FORMAT_INFO_PSTRIDE(info,c) ((info)->pixel_stride[c])
466/**
467 * GST_VIDEO_FORMAT_INFO_N_PLANES:
468 * @info: a #GstVideoFormatInfo
469 *
470 * Number of planes. This is the number of planes the pixel layout is
471 * organized in in memory. The number of planes can be less than the
472 * number of components (e.g. Y,U,V,A or R, G, B, A) when multiple
473 * components are packed into one plane.
474 *
475 * Examples: RGB/RGBx/RGBA: 1 plane, 3/3/4 components;
476 * I420: 3 planes, 3 components; NV21/NV12: 2 planes, 3 components.
477 */
478#define GST_VIDEO_FORMAT_INFO_N_PLANES(info) ((info)->n_planes)
479/**
480 * GST_VIDEO_FORMAT_INFO_PLANE:
481 * @info: a #GstVideoFormatInfo
482 * @c: the component index
483 *
484 * Plane number where the given component can be found. A plane may
485 * contain data for multiple components.
486 */
487#define GST_VIDEO_FORMAT_INFO_PLANE(info,c) ((info)->plane[c])
488#define GST_VIDEO_FORMAT_INFO_POFFSET(info,c) ((info)->poffset[c])
489#define GST_VIDEO_FORMAT_INFO_W_SUB(info,c) ((info)->w_sub[c])
490#define GST_VIDEO_FORMAT_INFO_H_SUB(info,c) ((info)->h_sub[c])
491
492/* rounds up */
493#define GST_VIDEO_SUB_SCALE(scale,val) (-((-((gint)(val)))>>(scale)))
494
495#define GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info,c,w) GST_VIDEO_SUB_SCALE ((info)->w_sub[c],(w))
496#define GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info,c,h) GST_VIDEO_SUB_SCALE ((info)->h_sub[c],(h))
497
498#define GST_VIDEO_FORMAT_INFO_DATA(info,planes,comp) \
499 (((guint8*)(planes)[(info)->plane[comp]]) + (info)->poffset[comp])
500/**
501 * GST_VIDEO_FORMAT_INFO_STRIDE:
502 * @info: a #GstVideoFormatInfo
503 * @strides: an array of strides
504 * @comp: the component index
505 *
506 * Row stride in bytes, that is number of bytes from the first pixel component
507 * of a row to the first pixel component in the next row. This might include
508 * some row padding (memory not actually used for anything, to make sure the
509 * beginning of the next row is aligned in a particular way).
510 */
511#define GST_VIDEO_FORMAT_INFO_STRIDE(info,strides,comp) ((strides)[(info)->plane[comp]])
512#define GST_VIDEO_FORMAT_INFO_OFFSET(info,offsets,comp) \
513 (((offsets)[(info)->plane[comp]]) + (info)->poffset[comp])
514
515#define GST_VIDEO_FORMAT_INFO_TILE_MODE(info) ((info)->tile_mode)
516#define GST_VIDEO_FORMAT_INFO_TILE_WS(info) ((info)->tile_ws)
517#define GST_VIDEO_FORMAT_INFO_TILE_HS(info) ((info)->tile_hs)
518
519/* format properties */
520
521GST_VIDEO_API
522GstVideoFormat gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
523 guint red_mask, guint green_mask,
524 guint blue_mask, guint alpha_mask) G_GNUC_CONST;
525
526GST_VIDEO_API
527GstVideoFormat gst_video_format_from_fourcc (guint32 fourcc) G_GNUC_CONST;
528
529GST_VIDEO_API
530GstVideoFormat gst_video_format_from_string (const gchar *format) G_GNUC_CONST;
531
532GST_VIDEO_API
533guint32 gst_video_format_to_fourcc (GstVideoFormat format) G_GNUC_CONST;
534
535GST_VIDEO_API
536const gchar * gst_video_format_to_string (GstVideoFormat format) G_GNUC_CONST;
537
538GST_VIDEO_API
539const GstVideoFormatInfo *
540 gst_video_format_get_info (GstVideoFormat format) G_GNUC_CONST;
541
542GST_VIDEO_API
543gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsize *size);
544
545#define GST_VIDEO_SIZE_RANGE "(int) [ 1, max ]"
546#define GST_VIDEO_FPS_RANGE "(fraction) [ 0, max ]"
547
548#if G_BYTE_ORDER == G_LITTLE_ENDIAN
549# define GST_VIDEO_NE(s) G_STRINGIFY(s)"_LE"
550# define GST_VIDEO_OE(s) G_STRINGIFY(s)"_BE"
551#else
552# define GST_VIDEO_NE(s) G_STRINGIFY(s)"_BE"
553# define GST_VIDEO_OE(s) G_STRINGIFY(s)"_LE"
554#endif
555
556#define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, VUYA, RGBx, " \
557 "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, " \
558 "Y444, v210, v216, Y210, Y410, NV12, NV21, GRAY8, GRAY16_BE, GRAY16_LE, v308, RGB16, " \
559 "BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, " \
560 "AYUV64, r210, I420_10BE, I420_10LE, I422_10BE, I422_10LE, Y444_10BE, " \
561 "Y444_10LE, GBR, GBR_10BE, GBR_10LE, NV16, NV24, NV12_64Z32, A420_10BE, " \
562 "A420_10LE, A422_10BE, A422_10LE, A444_10BE, A444_10LE, NV61, P010_10BE, " \
563 "P010_10LE, IYU2, VYUY, GBRA, GBRA_10BE, GBRA_10LE, BGR10A2_LE, GBR_12BE, GBR_12LE, " \
564 "GBRA_12BE, GBRA_12LE, I420_12BE, I420_12LE, I422_12BE, I422_12LE, " \
565 "Y444_12BE, Y444_12LE, GRAY10_LE32, NV12_10LE32, NV16_10LE32, NV12_10LE40 }"
566
567/**
568 * GST_VIDEO_CAPS_MAKE:
569 * @format: string format that describes the pixel layout, as string
570 * (e.g. "I420", "RGB", "YV12", "YUY2", "AYUV", etc.)
571 *
572 * Generic caps string for video, for use in pad templates.
573 */
574#define GST_VIDEO_CAPS_MAKE(format) \
575 "video/x-raw, " \
576 "format = (string) " format ", " \
577 "width = " GST_VIDEO_SIZE_RANGE ", " \
578 "height = " GST_VIDEO_SIZE_RANGE ", " \
579 "framerate = " GST_VIDEO_FPS_RANGE
580
581/**
582 * GST_VIDEO_CAPS_MAKE_WITH_FEATURES:
583 * @format: string format that describes the pixel layout, as string
584 * (e.g. "I420", "RGB", "YV12", "YUY2", "AYUV", etc.)
585 * @features: Requires caps features as a string, e.g.
586 * "memory:SystemMemory".
587 *
588 * Generic caps string for video, for use in pad templates.
589 *
590 * Since: 1.2
591 */
592#define GST_VIDEO_CAPS_MAKE_WITH_FEATURES(features,format) \
593 "video/x-raw(" features "), " \
594 "format = (string) " format ", " \
595 "width = " GST_VIDEO_SIZE_RANGE ", " \
596 "height = " GST_VIDEO_SIZE_RANGE ", " \
597 "framerate = " GST_VIDEO_FPS_RANGE
598
599G_END_DECLS
600
601#endif /* __GST_VIDEO_FORMAT_H__ */
602