video-frame.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. #ifndef __GST_VIDEO_FRAME_H__
  20. #define __GST_VIDEO_FRAME_H__
  21. #include <gst/video/video-enumtypes.h>
  22. G_BEGIN_DECLS
  23. typedef struct _GstVideoFrame GstVideoFrame;
  24. /**
  25. * GstVideoFrameFlags:
  26. * @GST_VIDEO_FRAME_FLAG_NONE: no flags
  27. * @GST_VIDEO_FRAME_FLAG_INTERLACED: The video frame is interlaced. In mixed
  28. * interlace-mode, this flag specifies if the frame is interlaced or
  29. * progressive.
  30. * @GST_VIDEO_FRAME_FLAG_TFF: The video frame has the top field first
  31. * @GST_VIDEO_FRAME_FLAG_RFF: The video frame has the repeat flag
  32. * @GST_VIDEO_FRAME_FLAG_ONEFIELD: The video frame has one field
  33. * @GST_VIDEO_FRAME_FLAG_MULTIPLE_VIEW: The video contains one or
  34. * more non-mono views
  35. * @GST_VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE: The video frame is the first
  36. * in a set of corresponding views provided as sequential frames.
  37. *
  38. * Extra video frame flags
  39. */
  40. typedef enum {
  41. GST_VIDEO_FRAME_FLAG_NONE = 0,
  42. GST_VIDEO_FRAME_FLAG_INTERLACED = (1 << 0),
  43. GST_VIDEO_FRAME_FLAG_TFF = (1 << 1),
  44. GST_VIDEO_FRAME_FLAG_RFF = (1 << 2),
  45. GST_VIDEO_FRAME_FLAG_ONEFIELD = (1 << 3),
  46. GST_VIDEO_FRAME_FLAG_MULTIPLE_VIEW = (1 << 4),
  47. GST_VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE = (1 << 5)
  48. } GstVideoFrameFlags;
  49. /* circular dependency, need to include this after defining the enums */
  50. #include <gst/video/video-format.h>
  51. #include <gst/video/video-info.h>
  52. /**
  53. * GstVideoFrame:
  54. * @info: the #GstVideoInfo
  55. * @flags: #GstVideoFrameFlags for the frame
  56. * @buffer: the mapped buffer
  57. * @meta: pointer to metadata if any
  58. * @id: id of the mapped frame. the id can for example be used to
  59. * indentify the frame in case of multiview video.
  60. * @data: pointers to the plane data
  61. * @map: mappings of the planes
  62. *
  63. * A video frame obtained from gst_video_frame_map()
  64. */
  65. struct _GstVideoFrame {
  66. GstVideoInfo info;
  67. GstVideoFrameFlags flags;
  68. GstBuffer *buffer;
  69. gpointer meta;
  70. gint id;
  71. gpointer data[GST_VIDEO_MAX_PLANES];
  72. GstMapInfo map[GST_VIDEO_MAX_PLANES];
  73. /*< private >*/
  74. gpointer _gst_reserved[GST_PADDING];
  75. };
  76. gboolean gst_video_frame_map (GstVideoFrame *frame, GstVideoInfo *info,
  77. GstBuffer *buffer, GstMapFlags flags);
  78. gboolean gst_video_frame_map_id (GstVideoFrame *frame, GstVideoInfo *info,
  79. GstBuffer *buffer, gint id, GstMapFlags flags);
  80. void gst_video_frame_unmap (GstVideoFrame *frame);
  81. gboolean gst_video_frame_copy (GstVideoFrame *dest, const GstVideoFrame *src);
  82. gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFrame *src,
  83. guint plane);
  84. /* general info */
  85. #define GST_VIDEO_FRAME_FORMAT(f) (GST_VIDEO_INFO_FORMAT(&(f)->info))
  86. #define GST_VIDEO_FRAME_WIDTH(f) (GST_VIDEO_INFO_WIDTH(&(f)->info))
  87. #define GST_VIDEO_FRAME_HEIGHT(f) (GST_VIDEO_INFO_HEIGHT(&(f)->info))
  88. #define GST_VIDEO_FRAME_SIZE(f) (GST_VIDEO_INFO_SIZE(&(f)->info))
  89. /* flags */
  90. #define GST_VIDEO_FRAME_FLAGS(f) ((f)->flags)
  91. #define GST_VIDEO_FRAME_FLAG_IS_SET(f,fl) ((GST_VIDEO_FRAME_FLAGS(f) & (fl)) == (fl))
  92. #define GST_VIDEO_FRAME_IS_INTERLACED(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_INTERLACED))
  93. #define GST_VIDEO_FRAME_IS_TFF(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_TFF))
  94. #define GST_VIDEO_FRAME_IS_RFF(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_RFF))
  95. #define GST_VIDEO_FRAME_IS_ONEFIELD(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_ONEFIELD))
  96. /* dealing with planes */
  97. #define GST_VIDEO_FRAME_N_PLANES(f) (GST_VIDEO_INFO_N_PLANES(&(f)->info))
  98. #define GST_VIDEO_FRAME_PLANE_DATA(f,p) ((f)->data[p])
  99. #define GST_VIDEO_FRAME_PLANE_OFFSET(f,p) (GST_VIDEO_INFO_PLANE_OFFSET(&(f)->info,(p)))
  100. #define GST_VIDEO_FRAME_PLANE_STRIDE(f,p) (GST_VIDEO_INFO_PLANE_STRIDE(&(f)->info,(p)))
  101. /* dealing with components */
  102. #define GST_VIDEO_FRAME_N_COMPONENTS(f) GST_VIDEO_INFO_N_COMPONENTS(&(f)->info)
  103. #define GST_VIDEO_FRAME_COMP_DEPTH(f,c) GST_VIDEO_INFO_COMP_DEPTH(&(f)->info,(c))
  104. #define GST_VIDEO_FRAME_COMP_DATA(f,c) GST_VIDEO_INFO_COMP_DATA(&(f)->info,(f)->data,(c))
  105. #define GST_VIDEO_FRAME_COMP_STRIDE(f,c) GST_VIDEO_INFO_COMP_STRIDE(&(f)->info,(c))
  106. #define GST_VIDEO_FRAME_COMP_OFFSET(f,c) GST_VIDEO_INFO_COMP_OFFSET(&(f)->info,(c))
  107. #define GST_VIDEO_FRAME_COMP_WIDTH(f,c) GST_VIDEO_INFO_COMP_WIDTH(&(f)->info,(c))
  108. #define GST_VIDEO_FRAME_COMP_HEIGHT(f,c) GST_VIDEO_INFO_COMP_HEIGHT(&(f)->info,(c))
  109. #define GST_VIDEO_FRAME_COMP_PLANE(f,c) GST_VIDEO_INFO_COMP_PLANE(&(f)->info,(c))
  110. #define GST_VIDEO_FRAME_COMP_PSTRIDE(f,c) GST_VIDEO_INFO_COMP_PSTRIDE(&(f)->info,(c))
  111. #define GST_VIDEO_FRAME_COMP_POFFSET(f,c) GST_VIDEO_INFO_COMP_POFFSET(&(f)->info,(c))
  112. /* buffer flags */
  113. /**
  114. * GstVideoBufferFlags:
  115. * @GST_VIDEO_BUFFER_FLAG_INTERLACED: If the #GstBuffer is interlaced. In mixed
  116. * interlace-mode, this flags specifies if the frame is
  117. * interlaced or progressive.
  118. * @GST_VIDEO_BUFFER_FLAG_TFF: If the #GstBuffer is interlaced, then the first field
  119. * in the video frame is the top field. If unset, the
  120. * bottom field is first.
  121. * @GST_VIDEO_BUFFER_FLAG_RFF: If the #GstBuffer is interlaced, then the first field
  122. * (as defined by the %GST_VIDEO_BUFFER_TFF flag setting)
  123. * is repeated.
  124. * @GST_VIDEO_BUFFER_FLAG_ONEFIELD: If the #GstBuffer is interlaced, then only the
  125. * first field (as defined by the %GST_VIDEO_BUFFER_TFF
  126. * flag setting) is to be displayed.
  127. * @GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW: The #GstBuffer contains one or more specific views,
  128. * such as left or right eye view. This flags is set on
  129. * any buffer that contains non-mono content - even for
  130. * streams that contain only a single viewpoint. In mixed
  131. * mono / non-mono streams, the absense of the flag marks
  132. * mono buffers.
  133. * @GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE: When conveying stereo/multiview content with
  134. * frame-by-frame methods, this flag marks the first buffer
  135. * in a bundle of frames that belong together.
  136. * @GST_VIDEO_BUFFER_FLAG_LAST: Offset to define more flags
  137. *
  138. * Additional video buffer flags. These flags can potentially be used on any
  139. * buffers carrying video data - even encoded data.
  140. */
  141. typedef enum {
  142. GST_VIDEO_BUFFER_FLAG_INTERLACED = (GST_BUFFER_FLAG_LAST << 0),
  143. GST_VIDEO_BUFFER_FLAG_TFF = (GST_BUFFER_FLAG_LAST << 1),
  144. GST_VIDEO_BUFFER_FLAG_RFF = (GST_BUFFER_FLAG_LAST << 2),
  145. GST_VIDEO_BUFFER_FLAG_ONEFIELD = (GST_BUFFER_FLAG_LAST << 3),
  146. GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW = (GST_BUFFER_FLAG_LAST << 4),
  147. GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE = (GST_BUFFER_FLAG_LAST << 5),
  148. GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8)
  149. } GstVideoBufferFlags;
  150. /**
  151. * GstVideoFrameMapFlags:
  152. * @GST_VIDEO_FRAME_MAP_FLAG_NO_REF: Don't take another reference of the buffer and store it in
  153. * the GstVideoFrame. This makes sure that the buffer stays
  154. * writable while the frame is mapped, but requires that the
  155. * buffer reference stays valid until the frame is unmapped again.
  156. * @GST_VIDEO_FRAME_MAP_FLAG_LAST: Offset to define more flags
  157. *
  158. * Additional mapping flags for gst_video_frame_map().
  159. *
  160. * Since: 1.6
  161. */
  162. typedef enum {
  163. GST_VIDEO_FRAME_MAP_FLAG_NO_REF = (GST_MAP_FLAG_LAST << 0),
  164. GST_VIDEO_FRAME_MAP_FLAG_LAST = (GST_MAP_FLAG_LAST << 8)
  165. /* 8 more flags possible afterwards */
  166. } GstVideoFrameMapFlags;
  167. G_END_DECLS
  168. #endif /* __GST_VIDEO_FRAME_H__ */