video-format.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. /* GStreamer
  2. * Copyright (C) <2011> Wim Taymans <[email protected]>
  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. #ifndef __GST_VIDEO_FORMAT_H__
  20. #define __GST_VIDEO_FORMAT_H__
  21. #include <gst/gst.h>
  22. G_BEGIN_DECLS
  23. #include <gst/video/video-enumtypes.h>
  24. #include <gst/video/video-tile.h>
  25. /**
  26. * GstVideoFormat:
  27. * @GST_VIDEO_FORMAT_UNKNOWN: Unknown or unset video format id
  28. * @GST_VIDEO_FORMAT_ENCODED: Encoded video format. Only ever use that in caps for
  29. * special video formats in combination with non-system
  30. * memory GstCapsFeatures where it does not make sense
  31. * to specify a real video format.
  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
  48. * @GST_VIDEO_FORMAT_Y42B: planar 4:2:2 YUV
  49. * @GST_VIDEO_FORMAT_YVYU: packed 4:2:2 YUV (Y0-V0-Y1-U0 Y2-V2-Y3-U2 Y4 ...)
  50. * @GST_VIDEO_FORMAT_Y444: planar 4:4:4 YUV
  51. * @GST_VIDEO_FORMAT_v210: packed 4:2:2 10-bit YUV, complex format
  52. * @GST_VIDEO_FORMAT_v216: packed 4:2:2 16-bit YUV, Y0-U0-Y1-V1 order
  53. * @GST_VIDEO_FORMAT_NV12: planar 4:2:0 YUV with interleaved UV plane
  54. * @GST_VIDEO_FORMAT_NV21: planar 4:2:0 YUV with interleaved VU plane
  55. * @GST_VIDEO_FORMAT_GRAY8: 8-bit grayscale
  56. * @GST_VIDEO_FORMAT_GRAY16_BE: 16-bit grayscale, most significant byte first
  57. * @GST_VIDEO_FORMAT_GRAY16_LE: 16-bit grayscale, least significant byte first
  58. * @GST_VIDEO_FORMAT_v308: packed 4:4:4 YUV
  59. * @GST_VIDEO_FORMAT_RGB16: rgb 5-6-5 bits per component
  60. * @GST_VIDEO_FORMAT_BGR16: reverse rgb 5-6-5 bits per component
  61. * @GST_VIDEO_FORMAT_RGB15: rgb 5-5-5 bits per component
  62. * @GST_VIDEO_FORMAT_BGR15: reverse rgb 5-5-5 bits per component
  63. * @GST_VIDEO_FORMAT_UYVP: packed 10-bit 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...)
  64. * @GST_VIDEO_FORMAT_A420: planar 4:4:2:0 AYUV
  65. * @GST_VIDEO_FORMAT_RGB8P: 8-bit paletted RGB
  66. * @GST_VIDEO_FORMAT_YUV9: planar 4:1:0 YUV
  67. * @GST_VIDEO_FORMAT_YVU9: planar 4:1:0 YUV (like YUV9 but UV planes swapped)
  68. * @GST_VIDEO_FORMAT_IYU1: packed 4:1:1 YUV (Cb-Y0-Y1-Cr-Y2-Y3 ...)
  69. * @GST_VIDEO_FORMAT_ARGB64: rgb with alpha channel first, 16 bits per channel
  70. * @GST_VIDEO_FORMAT_AYUV64: packed 4:4:4 YUV with alpha channel, 16 bits per channel (A0-Y0-U0-V0 ...)
  71. * @GST_VIDEO_FORMAT_r210: packed 4:4:4 RGB, 10 bits per channel
  72. * @GST_VIDEO_FORMAT_I420_10BE: planar 4:2:0 YUV, 10 bits per channel
  73. * @GST_VIDEO_FORMAT_I420_10LE: planar 4:2:0 YUV, 10 bits per channel
  74. * @GST_VIDEO_FORMAT_I422_10BE: planar 4:2:2 YUV, 10 bits per channel
  75. * @GST_VIDEO_FORMAT_I422_10LE: planar 4:2:2 YUV, 10 bits per channel
  76. * @GST_VIDEO_FORMAT_Y444_10BE: planar 4:4:4 YUV, 10 bits per channel
  77. * @GST_VIDEO_FORMAT_Y444_10LE: planar 4:4:4 YUV, 10 bits per channel
  78. * @GST_VIDEO_FORMAT_GBR: planar 4:4:4 RGB, 8 bits per channel
  79. * @GST_VIDEO_FORMAT_GBR_10BE: planar 4:4:4 RGB, 10 bits per channel
  80. * @GST_VIDEO_FORMAT_GBR_10LE: planar 4:4:4 RGB, 10 bits per channel
  81. * @GST_VIDEO_FORMAT_NV16: planar 4:2:2 YUV with interleaved UV plane
  82. * @GST_VIDEO_FORMAT_NV24: planar 4:4:4 YUV with interleaved UV plane
  83. * @GST_VIDEO_FORMAT_NV12_64Z32: NV12 with 64x32 tiling in zigzag pattern
  84. *
  85. * Enum value describing the most common video formats.
  86. */
  87. typedef enum {
  88. GST_VIDEO_FORMAT_UNKNOWN,
  89. GST_VIDEO_FORMAT_ENCODED,
  90. GST_VIDEO_FORMAT_I420,
  91. GST_VIDEO_FORMAT_YV12,
  92. GST_VIDEO_FORMAT_YUY2,
  93. GST_VIDEO_FORMAT_UYVY,
  94. GST_VIDEO_FORMAT_AYUV,
  95. GST_VIDEO_FORMAT_RGBx,
  96. GST_VIDEO_FORMAT_BGRx,
  97. GST_VIDEO_FORMAT_xRGB,
  98. GST_VIDEO_FORMAT_xBGR,
  99. GST_VIDEO_FORMAT_RGBA,
  100. GST_VIDEO_FORMAT_BGRA,
  101. GST_VIDEO_FORMAT_ARGB,
  102. GST_VIDEO_FORMAT_ABGR,
  103. GST_VIDEO_FORMAT_RGB,
  104. GST_VIDEO_FORMAT_BGR,
  105. GST_VIDEO_FORMAT_Y41B,
  106. GST_VIDEO_FORMAT_Y42B,
  107. GST_VIDEO_FORMAT_YVYU,
  108. GST_VIDEO_FORMAT_Y444,
  109. GST_VIDEO_FORMAT_v210,
  110. GST_VIDEO_FORMAT_v216,
  111. GST_VIDEO_FORMAT_NV12,
  112. GST_VIDEO_FORMAT_NV21,
  113. GST_VIDEO_FORMAT_GRAY8,
  114. GST_VIDEO_FORMAT_GRAY16_BE,
  115. GST_VIDEO_FORMAT_GRAY16_LE,
  116. GST_VIDEO_FORMAT_v308,
  117. GST_VIDEO_FORMAT_RGB16,
  118. GST_VIDEO_FORMAT_BGR16,
  119. GST_VIDEO_FORMAT_RGB15,
  120. GST_VIDEO_FORMAT_BGR15,
  121. GST_VIDEO_FORMAT_UYVP,
  122. GST_VIDEO_FORMAT_A420,
  123. GST_VIDEO_FORMAT_RGB8P,
  124. GST_VIDEO_FORMAT_YUV9,
  125. GST_VIDEO_FORMAT_YVU9,
  126. GST_VIDEO_FORMAT_IYU1,
  127. GST_VIDEO_FORMAT_ARGB64,
  128. GST_VIDEO_FORMAT_AYUV64,
  129. GST_VIDEO_FORMAT_r210,
  130. GST_VIDEO_FORMAT_I420_10BE,
  131. GST_VIDEO_FORMAT_I420_10LE,
  132. GST_VIDEO_FORMAT_I422_10BE,
  133. GST_VIDEO_FORMAT_I422_10LE,
  134. GST_VIDEO_FORMAT_Y444_10BE,
  135. GST_VIDEO_FORMAT_Y444_10LE,
  136. GST_VIDEO_FORMAT_GBR,
  137. GST_VIDEO_FORMAT_GBR_10BE,
  138. GST_VIDEO_FORMAT_GBR_10LE,
  139. GST_VIDEO_FORMAT_NV16,
  140. GST_VIDEO_FORMAT_NV24,
  141. GST_VIDEO_FORMAT_NV12_64Z32,
  142. } GstVideoFormat;
  143. #define GST_VIDEO_MAX_PLANES 4
  144. #define GST_VIDEO_MAX_COMPONENTS 4
  145. typedef struct _GstVideoFormatInfo GstVideoFormatInfo;
  146. /**
  147. * GstVideoFormatFlags:
  148. * @GST_VIDEO_FORMAT_FLAG_YUV: The video format is YUV, components are numbered
  149. * 0=Y, 1=U, 2=V.
  150. * @GST_VIDEO_FORMAT_FLAG_RGB: The video format is RGB, components are numbered
  151. * 0=R, 1=G, 2=B.
  152. * @GST_VIDEO_FORMAT_FLAG_GRAY: The video is gray, there is one gray component
  153. * with index 0.
  154. * @GST_VIDEO_FORMAT_FLAG_ALPHA: The video format has an alpha components with
  155. * the number 3.
  156. * @GST_VIDEO_FORMAT_FLAG_LE: The video format has data stored in little
  157. * endianness.
  158. * @GST_VIDEO_FORMAT_FLAG_PALETTE: The video format has a palette. The palette
  159. * is stored in the second plane and indexes are stored in the first plane.
  160. * @GST_VIDEO_FORMAT_FLAG_COMPLEX: The video format has a complex layout that
  161. * can't be described with the usual information in the #GstVideoFormatInfo.
  162. * @GST_VIDEO_FORMAT_FLAG_UNPACK: This format can be used in a
  163. * #GstVideoFormatUnpack and #GstVideoFormatPack function.
  164. * @GST_VIDEO_FORMAT_FLAG_TILED: The format is tiled, there is tiling information
  165. * in the last plane.
  166. *
  167. * The different video flags that a format info can have.
  168. */
  169. typedef enum
  170. {
  171. GST_VIDEO_FORMAT_FLAG_YUV = (1 << 0),
  172. GST_VIDEO_FORMAT_FLAG_RGB = (1 << 1),
  173. GST_VIDEO_FORMAT_FLAG_GRAY = (1 << 2),
  174. GST_VIDEO_FORMAT_FLAG_ALPHA = (1 << 3),
  175. GST_VIDEO_FORMAT_FLAG_LE = (1 << 4),
  176. GST_VIDEO_FORMAT_FLAG_PALETTE = (1 << 5),
  177. GST_VIDEO_FORMAT_FLAG_COMPLEX = (1 << 6),
  178. GST_VIDEO_FORMAT_FLAG_UNPACK = (1 << 7),
  179. GST_VIDEO_FORMAT_FLAG_TILED = (1 << 8)
  180. } GstVideoFormatFlags;
  181. /* YUV components */
  182. #define GST_VIDEO_COMP_Y 0
  183. #define GST_VIDEO_COMP_U 1
  184. #define GST_VIDEO_COMP_V 2
  185. /* RGB components */
  186. #define GST_VIDEO_COMP_R 0
  187. #define GST_VIDEO_COMP_G 1
  188. #define GST_VIDEO_COMP_B 2
  189. /* alpha component */
  190. #define GST_VIDEO_COMP_A 3
  191. /* palette components */
  192. #define GST_VIDEO_COMP_INDEX 0
  193. #define GST_VIDEO_COMP_PALETTE 1
  194. #include <gst/video/video-chroma.h>
  195. /**
  196. * GstVideoPackFlags:
  197. * @GST_VIDEO_PACK_FLAG_NONE: No flag
  198. * @GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE: When the source has a smaller depth
  199. * than the target format, set the least significant bits of the target
  200. * to 0. This is likely sightly faster but less accurate. When this flag
  201. * is not specified, the most significant bits of the source are duplicated
  202. * in the least significant bits of the destination.
  203. * @GST_VIDEO_PACK_FLAG_INTERLACED: The source is interlaced. The unpacked
  204. * format will be interlaced as well with each line containing
  205. * information from alternating fields. (Since 1.2)
  206. *
  207. * The different flags that can be used when packing and unpacking.
  208. */
  209. typedef enum
  210. {
  211. GST_VIDEO_PACK_FLAG_NONE = 0,
  212. GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE = (1 << 0),
  213. GST_VIDEO_PACK_FLAG_INTERLACED = (1 << 1)
  214. } GstVideoPackFlags;
  215. /**
  216. * GstVideoFormatUnpack:
  217. * @info: a #GstVideoFormatInfo
  218. * @flags: flags to control the unpacking
  219. * @dest: a destination array
  220. * @data: pointers to the data planes
  221. * @stride: strides of the planes
  222. * @x: the x position in the image to start from
  223. * @y: the y position in the image to start from
  224. * @width: the amount of pixels to unpack.
  225. *
  226. * Unpacks @width pixels from the given planes and strides containing data of
  227. * format @info. The pixels will be unpacked into @dest which each component
  228. * interleaved. @dest should at least be big enough to hold @width *
  229. * n_components * size(unpack_format) bytes.
  230. *
  231. * For subsampled formats, the components will be duplicated in the destination
  232. * array. Reconstruction of the missing components can be performed in a
  233. * separate step after unpacking.
  234. */
  235. typedef void (*GstVideoFormatUnpack) (const GstVideoFormatInfo *info,
  236. GstVideoPackFlags flags, gpointer dest,
  237. const gpointer data[GST_VIDEO_MAX_PLANES],
  238. const gint stride[GST_VIDEO_MAX_PLANES],
  239. gint x, gint y, gint width);
  240. /**
  241. * GstVideoFormatPack:
  242. * @info: a #GstVideoFormatInfo
  243. * @flags: flags to control the packing
  244. * @src: a source array
  245. * @sstride: the source array stride
  246. * @data: pointers to the destination data planes
  247. * @stride: strides of the destination planes
  248. * @chroma_site: the chroma siting of the target when subsampled (not used)
  249. * @y: the y position in the image to pack to
  250. * @width: the amount of pixels to pack.
  251. *
  252. * Packs @width pixels from @src to the given planes and strides in the
  253. * format @info. The pixels from source have each component interleaved
  254. * and will be packed into the planes in @data.
  255. *
  256. * This function operates on pack_lines lines, meaning that @src should
  257. * contain at least pack_lines lines with a stride of @sstride and @y
  258. * should be a multiple of pack_lines.
  259. *
  260. * Subsampled formats will use the horizontally cosited component in the
  261. * destination. Subsampling should be performed before packing.
  262. *
  263. * Because tis function does not have a x coordinate, it is not possible to
  264. * pack pixels starting from an unaligned position. For tiled images this
  265. * means that packing should start from a tile coordinate. For subsampled
  266. * formats this means that a complete pixel need to be packed.
  267. */
  268. typedef void (*GstVideoFormatPack) (const GstVideoFormatInfo *info,
  269. GstVideoPackFlags flags,
  270. const gpointer src, gint sstride,
  271. gpointer data[GST_VIDEO_MAX_PLANES],
  272. const gint stride[GST_VIDEO_MAX_PLANES],
  273. GstVideoChromaSite chroma_site,
  274. gint y, gint width);
  275. /**
  276. * GstVideoFormatInfo:
  277. * @format: #GstVideoFormat
  278. * @name: string representation of the format
  279. * @description: use readable description of the format
  280. * @flags: #GstVideoFormatFlags
  281. * @bits: The number of bits used to pack data items. This can be less than 8
  282. * when multiple pixels are stored in a byte. for values > 8 multiple bytes
  283. * should be read according to the endianness flag before applying the shift
  284. * and mask.
  285. * @n_components: the number of components in the video format.
  286. * @shift: the number of bits to shift away to get the component data
  287. * @depth: the depth in bits for each component
  288. * @pixel_stride: the pixel stride of each component. This is the amount of
  289. * bytes to the pixel immediately to the right. When bits < 8, the stride is
  290. * expressed in bits. For 24-bit RGB, this would be 3 bytes, for example,
  291. * while it would be 4 bytes for RGBx or ARGB.
  292. * @n_planes: the number of planes for this format. The number of planes can be
  293. * less than the amount of components when multiple components are packed into
  294. * one plane.
  295. * @plane: the plane number where a component can be found
  296. * @poffset: the offset in the plane where the first pixel of the components
  297. * can be found.
  298. * @w_sub: subsampling factor of the width for the component. Use
  299. * GST_VIDEO_SUB_SCALE to scale a width.
  300. * @h_sub: subsampling factor of the height for the component. Use
  301. * GST_VIDEO_SUB_SCALE to scale a height.
  302. * @unpack_format: the format of the unpacked pixels. This format must have the
  303. * #GST_VIDEO_FORMAT_FLAG_UNPACK flag set.
  304. * @unpack_func: an unpack function for this format
  305. * @pack_lines: the amount of lines that will be packed
  306. * @pack_func: an pack function for this format
  307. * @tile_mode: The tiling mode
  308. * @tile_ws The width of a tile, in bytes, represented as a shift
  309. * @tile_hs The height of a tile, in bytes, represented as a shift
  310. *
  311. * Information for a video format.
  312. */
  313. struct _GstVideoFormatInfo {
  314. GstVideoFormat format;
  315. const gchar *name;
  316. const gchar *description;
  317. GstVideoFormatFlags flags;
  318. guint bits;
  319. guint n_components;
  320. guint shift[GST_VIDEO_MAX_COMPONENTS];
  321. guint depth[GST_VIDEO_MAX_COMPONENTS];
  322. gint pixel_stride[GST_VIDEO_MAX_COMPONENTS];
  323. guint n_planes;
  324. guint plane[GST_VIDEO_MAX_COMPONENTS];
  325. guint poffset[GST_VIDEO_MAX_COMPONENTS];
  326. guint w_sub[GST_VIDEO_MAX_COMPONENTS];
  327. guint h_sub[GST_VIDEO_MAX_COMPONENTS];
  328. GstVideoFormat unpack_format;
  329. GstVideoFormatUnpack unpack_func;
  330. gint pack_lines;
  331. GstVideoFormatPack pack_func;
  332. GstVideoTileMode tile_mode;
  333. guint tile_ws;
  334. guint tile_hs;
  335. gpointer _gst_reserved[GST_PADDING];
  336. };
  337. #define GST_VIDEO_FORMAT_INFO_FORMAT(info) ((info)->format)
  338. #define GST_VIDEO_FORMAT_INFO_NAME(info) ((info)->name)
  339. #define GST_VIDEO_FORMAT_INFO_FLAGS(info) ((info)->flags)
  340. #define GST_VIDEO_FORMAT_INFO_IS_YUV(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_YUV)
  341. #define GST_VIDEO_FORMAT_INFO_IS_RGB(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_RGB)
  342. #define GST_VIDEO_FORMAT_INFO_IS_GRAY(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_GRAY)
  343. #define GST_VIDEO_FORMAT_INFO_HAS_ALPHA(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_ALPHA)
  344. #define GST_VIDEO_FORMAT_INFO_IS_LE(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_LE)
  345. #define GST_VIDEO_FORMAT_INFO_HAS_PALETTE(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_PALETTE)
  346. #define GST_VIDEO_FORMAT_INFO_IS_COMPLEX(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_COMPLEX)
  347. #define GST_VIDEO_FORMAT_INFO_IS_TILED(info) ((info)->flags & GST_VIDEO_FORMAT_FLAG_TILED)
  348. #define GST_VIDEO_FORMAT_INFO_BITS(info) ((info)->bits)
  349. #define GST_VIDEO_FORMAT_INFO_N_COMPONENTS(info) ((info)->n_components)
  350. #define GST_VIDEO_FORMAT_INFO_SHIFT(info,c) ((info)->shift[c])
  351. #define GST_VIDEO_FORMAT_INFO_DEPTH(info,c) ((info)->depth[c])
  352. /**
  353. * GST_VIDEO_FORMAT_INFO_PSTRIDE:
  354. *
  355. * pixel stride for the given component. This is the amount of bytes to the
  356. * pixel immediately to the right, so basically bytes from one pixel to the
  357. * next. When bits < 8, the stride is expressed in bits.
  358. *
  359. * Examples: for 24-bit RGB, the pixel stride would be 3 bytes, while it
  360. * would be 4 bytes for RGBx or ARGB, and 8 bytes for ARGB64 or AYUV64.
  361. * For planar formats such as I420 the pixel stride is usually 1. For
  362. * YUY2 it would be 2 bytes.
  363. */
  364. #define GST_VIDEO_FORMAT_INFO_PSTRIDE(info,c) ((info)->pixel_stride[c])
  365. /**
  366. * GST_VIDEO_FORMAT_INFO_N_PLANES:
  367. *
  368. * Number of planes. This is the number of planes the pixel layout is
  369. * organized in in memory. The number of planes can be less than the
  370. * number of components (e.g. Y,U,V,A or R, G, B, A) when multiple
  371. * components are packed into one plane.
  372. *
  373. * Examples: RGB/RGBx/RGBA: 1 plane, 3/3/4 components;
  374. * I420: 3 planes, 3 components; NV21/NV12: 2 planes, 3 components.
  375. */
  376. #define GST_VIDEO_FORMAT_INFO_N_PLANES(info) ((info)->n_planes)
  377. /**
  378. * GST_VIDEO_FORMAT_INFO_PLANE:
  379. *
  380. * Plane number where the given component can be found. A plane may
  381. * contain data for multiple components.
  382. */
  383. #define GST_VIDEO_FORMAT_INFO_PLANE(info,c) ((info)->plane[c])
  384. #define GST_VIDEO_FORMAT_INFO_POFFSET(info,c) ((info)->poffset[c])
  385. #define GST_VIDEO_FORMAT_INFO_W_SUB(info,c) ((info)->w_sub[c])
  386. #define GST_VIDEO_FORMAT_INFO_H_SUB(info,c) ((info)->h_sub[c])
  387. /* rounds up */
  388. #define GST_VIDEO_SUB_SCALE(scale,val) (-((-((gint)(val)))>>(scale)))
  389. #define GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info,c,w) GST_VIDEO_SUB_SCALE ((info)->w_sub[c],(w))
  390. #define GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info,c,h) GST_VIDEO_SUB_SCALE ((info)->h_sub[c],(h))
  391. #define GST_VIDEO_FORMAT_INFO_DATA(info,planes,comp) \
  392. (((guint8*)(planes)[(info)->plane[comp]]) + (info)->poffset[comp])
  393. /**
  394. * GST_VIDEO_FORMAT_INFO_STRIDE:
  395. *
  396. * Row stride in bytes, that is number of bytes from the first pixel component
  397. * of a row to the first pixel component in the next row. This might include
  398. * some row padding (memory not actually used for anything, to make sure the
  399. * beginning of the next row is aligned in a particular way).
  400. */
  401. #define GST_VIDEO_FORMAT_INFO_STRIDE(info,strides,comp) ((strides)[(info)->plane[comp]])
  402. #define GST_VIDEO_FORMAT_INFO_OFFSET(info,offsets,comp) \
  403. (((offsets)[(info)->plane[comp]]) + (info)->poffset[comp])
  404. #define GST_VIDEO_FORMAT_INFO_TILE_MODE(info) ((info)->tile_mode)
  405. #define GST_VIDEO_FORMAT_INFO_TILE_WS(info) ((info)->tile_ws)
  406. #define GST_VIDEO_FORMAT_INFO_TILE_HS(info) ((info)->tile_hs)
  407. /* format properties */
  408. GstVideoFormat gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
  409. guint red_mask, guint green_mask,
  410. guint blue_mask, guint alpha_mask) G_GNUC_CONST;
  411. GstVideoFormat gst_video_format_from_fourcc (guint32 fourcc) G_GNUC_CONST;
  412. GstVideoFormat gst_video_format_from_string (const gchar *format) G_GNUC_CONST;
  413. guint32 gst_video_format_to_fourcc (GstVideoFormat format) G_GNUC_CONST;
  414. const gchar * gst_video_format_to_string (GstVideoFormat format) G_GNUC_CONST;
  415. const GstVideoFormatInfo *
  416. gst_video_format_get_info (GstVideoFormat format) G_GNUC_CONST;
  417. gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsize *size);
  418. #define GST_VIDEO_SIZE_RANGE "(int) [ 1, max ]"
  419. #define GST_VIDEO_FPS_RANGE "(fraction) [ 0, max ]"
  420. #if G_BYTE_ORDER == G_LITTLE_ENDIAN
  421. # define GST_VIDEO_NE(s) G_STRINGIFY(s)"_LE"
  422. # define GST_VIDEO_OE(s) G_STRINGIFY(s)"_BE"
  423. #else
  424. # define GST_VIDEO_NE(s) G_STRINGIFY(s)"_BE"
  425. # define GST_VIDEO_OE(s) G_STRINGIFY(s)"_LE"
  426. #endif
  427. #define GST_VIDEO_FORMATS_ALL "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, " \
  428. "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, " \
  429. "YVYU, Y444, v210, v216, NV12, NV21, NV16, NV24, GRAY8, GRAY16_BE, GRAY16_LE, " \
  430. "v308, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, " \
  431. "IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE, I422_10LE, I422_10BE, " \
  432. " Y444_10LE, Y444_10BE, GBR, GBR_10LE, GBR_10BE, NV12_64Z32 }"
  433. /**
  434. * GST_VIDEO_CAPS_MAKE:
  435. * @format: string format that describes the pixel layout, as string
  436. * (e.g. "I420", "RGB", "YV12", "YUY2", "AYUV", etc.)
  437. *
  438. * Generic caps string for video, for use in pad templates.
  439. */
  440. #define GST_VIDEO_CAPS_MAKE(format) \
  441. "video/x-raw, " \
  442. "format = (string) " format ", " \
  443. "width = " GST_VIDEO_SIZE_RANGE ", " \
  444. "height = " GST_VIDEO_SIZE_RANGE ", " \
  445. "framerate = " GST_VIDEO_FPS_RANGE
  446. /**
  447. * GST_VIDEO_CAPS_MAKE_WITH_FEATURES:
  448. * @format: string format that describes the pixel layout, as string
  449. * (e.g. "I420", "RGB", "YV12", "YUY2", "AYUV", etc.)
  450. * @features: Requires caps features as a string, e.g.
  451. * "memory:SystemMemory".
  452. *
  453. * Generic caps string for video, for use in pad templates.
  454. *
  455. * Since: 1.2
  456. */
  457. #define GST_VIDEO_CAPS_MAKE_WITH_FEATURES(features,format) \
  458. "video/x-raw(" features "), " \
  459. "format = (string) " format ", " \
  460. "width = " GST_VIDEO_SIZE_RANGE ", " \
  461. "height = " GST_VIDEO_SIZE_RANGE ", " \
  462. "framerate = " GST_VIDEO_FPS_RANGE
  463. G_END_DECLS
  464. #endif /* __GST_VIDEO_FORMAT_H__ */