stereo3d.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Copyright (c) 2013 Vittorio Giovara <vittorio.giovara@gmail.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * Stereoscopic video
  23. */
  24. #ifndef AVUTIL_STEREO3D_H
  25. #define AVUTIL_STEREO3D_H
  26. #include <stdint.h>
  27. #include "frame.h"
  28. /**
  29. * @addtogroup lavu_video
  30. * @{
  31. *
  32. * @defgroup lavu_video_stereo3d Stereo3D types and functions
  33. * @{
  34. */
  35. /**
  36. * @addtogroup lavu_video_stereo3d
  37. * A stereoscopic video file consists in multiple views embedded in a single
  38. * frame, usually describing two views of a scene. This file describes all
  39. * possible codec-independent view arrangements.
  40. * */
  41. /**
  42. * List of possible 3D Types
  43. */
  44. enum AVStereo3DType {
  45. /**
  46. * Video is not stereoscopic (and metadata has to be there).
  47. */
  48. AV_STEREO3D_2D,
  49. /**
  50. * Views are next to each other.
  51. *
  52. * @code{.unparsed}
  53. * LLLLRRRR
  54. * LLLLRRRR
  55. * LLLLRRRR
  56. * ...
  57. * @endcode
  58. */
  59. AV_STEREO3D_SIDEBYSIDE,
  60. /**
  61. * Views are on top of each other.
  62. *
  63. * @code{.unparsed}
  64. * LLLLLLLL
  65. * LLLLLLLL
  66. * RRRRRRRR
  67. * RRRRRRRR
  68. * @endcode
  69. */
  70. AV_STEREO3D_TOPBOTTOM,
  71. /**
  72. * Views are alternated temporally.
  73. *
  74. * @code{.unparsed}
  75. * frame0 frame1 frame2 ...
  76. * LLLLLLLL RRRRRRRR LLLLLLLL
  77. * LLLLLLLL RRRRRRRR LLLLLLLL
  78. * LLLLLLLL RRRRRRRR LLLLLLLL
  79. * ... ... ...
  80. * @endcode
  81. */
  82. AV_STEREO3D_FRAMESEQUENCE,
  83. /**
  84. * Views are packed in a checkerboard-like structure per pixel.
  85. *
  86. * @code{.unparsed}
  87. * LRLRLRLR
  88. * RLRLRLRL
  89. * LRLRLRLR
  90. * ...
  91. * @endcode
  92. */
  93. AV_STEREO3D_CHECKERBOARD,
  94. /**
  95. * Views are next to each other, but when upscaling
  96. * apply a checkerboard pattern.
  97. *
  98. * @code{.unparsed}
  99. * LLLLRRRR L L L L R R R R
  100. * LLLLRRRR => L L L L R R R R
  101. * LLLLRRRR L L L L R R R R
  102. * LLLLRRRR L L L L R R R R
  103. * @endcode
  104. */
  105. AV_STEREO3D_SIDEBYSIDE_QUINCUNX,
  106. /**
  107. * Views are packed per line, as if interlaced.
  108. *
  109. * @code{.unparsed}
  110. * LLLLLLLL
  111. * RRRRRRRR
  112. * LLLLLLLL
  113. * ...
  114. * @endcode
  115. */
  116. AV_STEREO3D_LINES,
  117. /**
  118. * Views are packed per column.
  119. *
  120. * @code{.unparsed}
  121. * LRLRLRLR
  122. * LRLRLRLR
  123. * LRLRLRLR
  124. * ...
  125. * @endcode
  126. */
  127. AV_STEREO3D_COLUMNS,
  128. };
  129. /**
  130. * List of possible view types.
  131. */
  132. enum AVStereo3DView {
  133. /**
  134. * Frame contains two packed views.
  135. */
  136. AV_STEREO3D_VIEW_PACKED,
  137. /**
  138. * Frame contains only the left view.
  139. */
  140. AV_STEREO3D_VIEW_LEFT,
  141. /**
  142. * Frame contains only the right view.
  143. */
  144. AV_STEREO3D_VIEW_RIGHT,
  145. };
  146. /**
  147. * Inverted views, Right/Bottom represents the left view.
  148. */
  149. #define AV_STEREO3D_FLAG_INVERT (1 << 0)
  150. /**
  151. * Stereo 3D type: this structure describes how two videos are packed
  152. * within a single video surface, with additional information as needed.
  153. *
  154. * @note The struct must be allocated with av_stereo3d_alloc() and
  155. * its size is not a part of the public ABI.
  156. */
  157. typedef struct AVStereo3D {
  158. /**
  159. * How views are packed within the video.
  160. */
  161. enum AVStereo3DType type;
  162. /**
  163. * Additional information about the frame packing.
  164. */
  165. int flags;
  166. /**
  167. * Determines which views are packed.
  168. */
  169. enum AVStereo3DView view;
  170. } AVStereo3D;
  171. /**
  172. * Allocate an AVStereo3D structure and set its fields to default values.
  173. * The resulting struct can be freed using av_freep().
  174. *
  175. * @return An AVStereo3D filled with default values or NULL on failure.
  176. */
  177. AVStereo3D *av_stereo3d_alloc(void);
  178. /**
  179. * Allocate a complete AVFrameSideData and add it to the frame.
  180. *
  181. * @param frame The frame which side data is added to.
  182. *
  183. * @return The AVStereo3D structure to be filled by caller.
  184. */
  185. AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame);
  186. /**
  187. * Provide a human-readable name of a given stereo3d type.
  188. *
  189. * @param type The input stereo3d type value.
  190. *
  191. * @return The name of the stereo3d value, or "unknown".
  192. */
  193. const char *av_stereo3d_type_name(unsigned int type);
  194. /**
  195. * Get the AVStereo3DType form a human-readable name.
  196. *
  197. * @param name The input string.
  198. *
  199. * @return The AVStereo3DType value, or -1 if not found.
  200. */
  201. int av_stereo3d_from_name(const char *name);
  202. /**
  203. * @}
  204. * @}
  205. */
  206. #endif /* AVUTIL_STEREO3D_H */