video-frame.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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_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 flags specifies if the frame is interlace 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. *
  34. * Extra video frame flags
  35. */
  36. typedef enum {
  37. GST_VIDEO_FRAME_FLAG_NONE = 0,
  38. GST_VIDEO_FRAME_FLAG_INTERLACED = (1 << 0),
  39. GST_VIDEO_FRAME_FLAG_TFF = (1 << 1),
  40. GST_VIDEO_FRAME_FLAG_RFF = (1 << 2),
  41. GST_VIDEO_FRAME_FLAG_ONEFIELD = (1 << 3)
  42. } GstVideoFrameFlags;
  43. /* circular dependency, need to include this after defining the enums */
  44. #include <gst/video/video-format.h>
  45. #include <gst/video/video-info.h>
  46. /**
  47. * GstVideoFrame:
  48. * @info: the #GstVideoInfo
  49. * @buffer: the mapped buffer
  50. * @meta: pointer to metadata if any
  51. * @id: id of the mapped frame. the id can for example be used to
  52. * indentify the frame in case of multiview video.
  53. * @data: pointers to the plane data
  54. * @map: mappings of the planes
  55. *
  56. * A video frame obtained from gst_video_frame_map()
  57. */
  58. struct _GstVideoFrame {
  59. GstVideoInfo info;
  60. GstVideoFrameFlags flags;
  61. GstBuffer *buffer;
  62. gpointer meta;
  63. gint id;
  64. gpointer data[GST_VIDEO_MAX_PLANES];
  65. GstMapInfo map[GST_VIDEO_MAX_PLANES];
  66. /*< private >*/
  67. gpointer _gst_reserved[GST_PADDING];
  68. };
  69. gboolean gst_video_frame_map (GstVideoFrame *frame, GstVideoInfo *info,
  70. GstBuffer *buffer, GstMapFlags flags);
  71. gboolean gst_video_frame_map_id (GstVideoFrame *frame, GstVideoInfo *info,
  72. GstBuffer *buffer, gint id, GstMapFlags flags);
  73. void gst_video_frame_unmap (GstVideoFrame *frame);
  74. gboolean gst_video_frame_copy (GstVideoFrame *dest, const GstVideoFrame *src);
  75. gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFrame *src,
  76. guint plane);
  77. /* general info */
  78. #define GST_VIDEO_FRAME_FORMAT(f) (GST_VIDEO_INFO_FORMAT(&(f)->info))
  79. #define GST_VIDEO_FRAME_WIDTH(f) (GST_VIDEO_INFO_WIDTH(&(f)->info))
  80. #define GST_VIDEO_FRAME_HEIGHT(f) (GST_VIDEO_INFO_HEIGHT(&(f)->info))
  81. #define GST_VIDEO_FRAME_SIZE(f) (GST_VIDEO_INFO_SIZE(&(f)->info))
  82. /* flags */
  83. #define GST_VIDEO_FRAME_FLAGS(f) ((f)->flags)
  84. #define GST_VIDEO_FRAME_FLAG_IS_SET(f,fl) ((GST_VIDEO_FRAME_FLAGS(f) & (fl)) == (fl))
  85. #define GST_VIDEO_FRAME_IS_INTERLACED(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_INTERLACED))
  86. #define GST_VIDEO_FRAME_IS_TFF(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_TFF))
  87. #define GST_VIDEO_FRAME_IS_RFF(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_RFF))
  88. #define GST_VIDEO_FRAME_IS_ONEFIELD(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_ONEFIELD))
  89. /* dealing with planes */
  90. #define GST_VIDEO_FRAME_N_PLANES(f) (GST_VIDEO_INFO_N_PLANES(&(f)->info))
  91. #define GST_VIDEO_FRAME_PLANE_DATA(f,p) ((f)->data[p])
  92. #define GST_VIDEO_FRAME_PLANE_OFFSET(f,p) (GST_VIDEO_INFO_PLANE_OFFSET(&(f)->info,(p)))
  93. #define GST_VIDEO_FRAME_PLANE_STRIDE(f,p) (GST_VIDEO_INFO_PLANE_STRIDE(&(f)->info,(p)))
  94. /* dealing with components */
  95. #define GST_VIDEO_FRAME_N_COMPONENTS(f) GST_VIDEO_INFO_N_COMPONENTS(&(f)->info)
  96. #define GST_VIDEO_FRAME_COMP_DEPTH(f,c) GST_VIDEO_INFO_COMP_DEPTH(&(f)->info,(c))
  97. #define GST_VIDEO_FRAME_COMP_DATA(f,c) GST_VIDEO_INFO_COMP_DATA(&(f)->info,(f)->data,(c))
  98. #define GST_VIDEO_FRAME_COMP_STRIDE(f,c) GST_VIDEO_INFO_COMP_STRIDE(&(f)->info,(c))
  99. #define GST_VIDEO_FRAME_COMP_OFFSET(f,c) GST_VIDEO_INFO_COMP_OFFSET(&(f)->info,(c))
  100. #define GST_VIDEO_FRAME_COMP_WIDTH(f,c) GST_VIDEO_INFO_COMP_WIDTH(&(f)->info,(c))
  101. #define GST_VIDEO_FRAME_COMP_HEIGHT(f,c) GST_VIDEO_INFO_COMP_HEIGHT(&(f)->info,(c))
  102. #define GST_VIDEO_FRAME_COMP_PLANE(f,c) GST_VIDEO_INFO_COMP_PLANE(&(f)->info,(c))
  103. #define GST_VIDEO_FRAME_COMP_PSTRIDE(f,c) GST_VIDEO_INFO_COMP_PSTRIDE(&(f)->info,(c))
  104. #define GST_VIDEO_FRAME_COMP_POFFSET(f,c) GST_VIDEO_INFO_COMP_POFFSET(&(f)->info,(c))
  105. /* buffer flags */
  106. /**
  107. * GstVideoBufferFlags:
  108. * @GST_VIDEO_BUFFER_FLAG_INTERLACED: If the #GstBuffer is interlaced. In mixed
  109. * interlace-mode, this flags specifies if the frame is
  110. * interlaced or progressive.
  111. * @GST_VIDEO_BUFFER_FLAG_TFF: If the #GstBuffer is interlaced, then the first field
  112. * in the video frame is the top field. If unset, the
  113. * bottom field is first.
  114. * @GST_VIDEO_BUFFER_FLAG_RFF: If the #GstBuffer is interlaced, then the first field
  115. * (as defined by the %GST_VIDEO_BUFFER_TFF flag setting)
  116. * is repeated.
  117. * @GST_VIDEO_BUFFER_FLAG_ONEFIELD: If the #GstBuffer is interlaced, then only the
  118. * first field (as defined by the %GST_VIDEO_BUFFER_TFF
  119. * flag setting) is to be displayed.
  120. *
  121. * Additional video buffer flags.
  122. */
  123. typedef enum {
  124. GST_VIDEO_BUFFER_FLAG_INTERLACED = (GST_BUFFER_FLAG_LAST << 0),
  125. GST_VIDEO_BUFFER_FLAG_TFF = (GST_BUFFER_FLAG_LAST << 1),
  126. GST_VIDEO_BUFFER_FLAG_RFF = (GST_BUFFER_FLAG_LAST << 2),
  127. GST_VIDEO_BUFFER_FLAG_ONEFIELD = (GST_BUFFER_FLAG_LAST << 3),
  128. GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8)
  129. } GstVideoBufferFlags;
  130. G_END_DECLS
  131. #endif /* __GST_VIDEO_FRAME_H__ */