video-info.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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_INFO_H__
  20. #define __GST_VIDEO_INFO_H__
  21. #include <gst/gst.h>
  22. #include <gst/video/video-format.h>
  23. #include <gst/video/video-color.h>
  24. G_BEGIN_DECLS
  25. #include <gst/video/video-enumtypes.h>
  26. typedef struct _GstVideoInfo GstVideoInfo;
  27. /**
  28. * GstVideoInterlaceMode:
  29. * @GST_VIDEO_INTERLACE_MODE_PROGRESSIVE: all frames are progressive
  30. * @GST_VIDEO_INTERLACE_MODE_INTERLEAVED: 2 fields are interleaved in one video
  31. * frame. Extra buffer flags describe the field order.
  32. * @GST_VIDEO_INTERLACE_MODE_MIXED: frames contains both interlaced and
  33. * progressive video, the buffer flags describe the frame and fields.
  34. * @GST_VIDEO_INTERLACE_MODE_FIELDS: 2 fields are stored in one buffer, use the
  35. * frame ID to get access to the required field. For multiview (the
  36. * 'views' property > 1) the fields of view N can be found at frame ID
  37. * (N * 2) and (N * 2) + 1.
  38. * Each field has only half the amount of lines as noted in the
  39. * height property. This mode requires multiple GstVideoMeta metadata
  40. * to describe the fields.
  41. *
  42. * The possible values of the #GstVideoInterlaceMode describing the interlace
  43. * mode of the stream.
  44. */
  45. typedef enum {
  46. GST_VIDEO_INTERLACE_MODE_PROGRESSIVE = 0,
  47. GST_VIDEO_INTERLACE_MODE_INTERLEAVED,
  48. GST_VIDEO_INTERLACE_MODE_MIXED,
  49. GST_VIDEO_INTERLACE_MODE_FIELDS
  50. } GstVideoInterlaceMode;
  51. /**
  52. * GstVideoFlags:
  53. * @GST_VIDEO_FLAG_NONE: no flags
  54. * @GST_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d
  55. * denote the maximum fps of the video
  56. * @GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA: Each color has been scaled by the alpha
  57. * value.
  58. *
  59. * Extra video flags
  60. */
  61. typedef enum {
  62. GST_VIDEO_FLAG_NONE = 0,
  63. GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 0),
  64. GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA = (1 << 1)
  65. } GstVideoFlags;
  66. /**
  67. * GstVideoInfo:
  68. * @finfo: the format info of the video
  69. * @interlace_mode: the interlace mode
  70. * @flags: additional video flags
  71. * @width: the width of the video
  72. * @height: the height of the video
  73. * @views: the number of views for multiview video
  74. * @size: the default size of one frame
  75. * @chroma_site: a #GstVideoChromaSite.
  76. * @colorimetry: the colorimetry info
  77. * @par_n: the pixel-aspect-ratio numerator
  78. * @par_d: the pixel-aspect-ratio demnominator
  79. * @fps_n: the framerate numerator
  80. * @fps_d: the framerate demnominator
  81. * @offset: offsets of the planes
  82. * @stride: strides of the planes
  83. *
  84. * Information describing image properties. This information can be filled
  85. * in from GstCaps with gst_video_info_from_caps(). The information is also used
  86. * to store the specific video info when mapping a video frame with
  87. * gst_video_frame_map().
  88. *
  89. * Use the provided macros to access the info in this structure.
  90. */
  91. struct _GstVideoInfo {
  92. const GstVideoFormatInfo *finfo;
  93. GstVideoInterlaceMode interlace_mode;
  94. GstVideoFlags flags;
  95. gint width;
  96. gint height;
  97. gsize size;
  98. gint views;
  99. GstVideoChromaSite chroma_site;
  100. GstVideoColorimetry colorimetry;
  101. gint par_n;
  102. gint par_d;
  103. gint fps_n;
  104. gint fps_d;
  105. gsize offset[GST_VIDEO_MAX_PLANES];
  106. gint stride[GST_VIDEO_MAX_PLANES];
  107. /*< private >*/
  108. gpointer _gst_reserved[GST_PADDING];
  109. };
  110. /* general info */
  111. #define GST_VIDEO_INFO_FORMAT(i) (GST_VIDEO_FORMAT_INFO_FORMAT((i)->finfo))
  112. #define GST_VIDEO_INFO_NAME(i) (GST_VIDEO_FORMAT_INFO_NAME((i)->finfo))
  113. #define GST_VIDEO_INFO_IS_YUV(i) (GST_VIDEO_FORMAT_INFO_IS_YUV((i)->finfo))
  114. #define GST_VIDEO_INFO_IS_RGB(i) (GST_VIDEO_FORMAT_INFO_IS_RGB((i)->finfo))
  115. #define GST_VIDEO_INFO_IS_GRAY(i) (GST_VIDEO_FORMAT_INFO_IS_GRAY((i)->finfo))
  116. #define GST_VIDEO_INFO_HAS_ALPHA(i) (GST_VIDEO_FORMAT_INFO_HAS_ALPHA((i)->finfo))
  117. #define GST_VIDEO_INFO_INTERLACE_MODE(i) ((i)->interlace_mode)
  118. #define GST_VIDEO_INFO_IS_INTERLACED(i) ((i)->interlace_mode != GST_VIDEO_INTERLACE_MODE_PROGRESSIVE)
  119. #define GST_VIDEO_INFO_FLAGS(i) ((i)->flags)
  120. #define GST_VIDEO_INFO_WIDTH(i) ((i)->width)
  121. #define GST_VIDEO_INFO_HEIGHT(i) ((i)->height)
  122. #define GST_VIDEO_INFO_SIZE(i) ((i)->size)
  123. #define GST_VIDEO_INFO_VIEWS(i) ((i)->views)
  124. #define GST_VIDEO_INFO_PAR_N(i) ((i)->par_n)
  125. #define GST_VIDEO_INFO_PAR_D(i) ((i)->par_d)
  126. #define GST_VIDEO_INFO_FPS_N(i) ((i)->fps_n)
  127. #define GST_VIDEO_INFO_FPS_D(i) ((i)->fps_d)
  128. /* dealing with GstVideoInfo flags */
  129. #define GST_VIDEO_INFO_FLAG_IS_SET(i,flag) ((GST_VIDEO_INFO_FLAGS(i) & (flag)) == (flag))
  130. #define GST_VIDEO_INFO_FLAG_SET(i,flag) (GST_VIDEO_INFO_FLAGS(i) |= (flag))
  131. #define GST_VIDEO_INFO_FLAG_UNSET(i,flag) (GST_VIDEO_INFO_FLAGS(i) &= ~(flag))
  132. /* dealing with planes */
  133. #define GST_VIDEO_INFO_N_PLANES(i) (GST_VIDEO_FORMAT_INFO_N_PLANES((i)->finfo))
  134. #define GST_VIDEO_INFO_PLANE_OFFSET(i,p) ((i)->offset[p])
  135. #define GST_VIDEO_INFO_PLANE_STRIDE(i,p) ((i)->stride[p])
  136. /* dealing with components */
  137. #define GST_VIDEO_INFO_N_COMPONENTS(i) GST_VIDEO_FORMAT_INFO_N_COMPONENTS((i)->finfo)
  138. #define GST_VIDEO_INFO_COMP_DEPTH(i,c) GST_VIDEO_FORMAT_INFO_DEPTH((i)->finfo,(c))
  139. #define GST_VIDEO_INFO_COMP_DATA(i,d,c) GST_VIDEO_FORMAT_INFO_DATA((i)->finfo,d,(c))
  140. #define GST_VIDEO_INFO_COMP_OFFSET(i,c) GST_VIDEO_FORMAT_INFO_OFFSET((i)->finfo,(i)->offset,(c))
  141. #define GST_VIDEO_INFO_COMP_STRIDE(i,c) GST_VIDEO_FORMAT_INFO_STRIDE((i)->finfo,(i)->stride,(c))
  142. #define GST_VIDEO_INFO_COMP_WIDTH(i,c) GST_VIDEO_FORMAT_INFO_SCALE_WIDTH((i)->finfo,(c),(i)->width)
  143. #define GST_VIDEO_INFO_COMP_HEIGHT(i,c) GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT((i)->finfo,(c),(i)->height)
  144. #define GST_VIDEO_INFO_COMP_PLANE(i,c) GST_VIDEO_FORMAT_INFO_PLANE((i)->finfo,(c))
  145. #define GST_VIDEO_INFO_COMP_PSTRIDE(i,c) GST_VIDEO_FORMAT_INFO_PSTRIDE((i)->finfo,(c))
  146. #define GST_VIDEO_INFO_COMP_POFFSET(i,c) GST_VIDEO_FORMAT_INFO_POFFSET((i)->finfo,(c))
  147. void gst_video_info_init (GstVideoInfo *info);
  148. void gst_video_info_set_format (GstVideoInfo *info, GstVideoFormat format,
  149. guint width, guint height);
  150. gboolean gst_video_info_from_caps (GstVideoInfo *info, const GstCaps * caps);
  151. GstCaps * gst_video_info_to_caps (GstVideoInfo *info);
  152. gboolean gst_video_info_convert (GstVideoInfo *info,
  153. GstFormat src_format,
  154. gint64 src_value,
  155. GstFormat dest_format,
  156. gint64 *dest_value);
  157. gboolean gst_video_info_is_equal (const GstVideoInfo *info,
  158. const GstVideoInfo *other);
  159. #include <gst/video/video.h>
  160. void gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align);
  161. G_END_DECLS
  162. #endif /* __GST_VIDEO_INFO_H__ */