stereo3d.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. * @ingroup lavu_video_stereo3d
  23. * Stereoscopic video
  24. */
  25. #ifndef AVUTIL_STEREO3D_H
  26. #define AVUTIL_STEREO3D_H
  27. #include <stdint.h>
  28. #include "frame.h"
  29. /**
  30. * @defgroup lavu_video_stereo3d Stereo3D types and functions
  31. * @ingroup lavu_video
  32. *
  33. * A stereoscopic video file consists in multiple views embedded in a single
  34. * frame, usually describing two views of a scene. This file describes all
  35. * possible codec-independent view arrangements.
  36. *
  37. * @{
  38. */
  39. /**
  40. * List of possible 3D Types
  41. */
  42. enum AVStereo3DType {
  43. /**
  44. * Video is not stereoscopic (and metadata has to be there).
  45. */
  46. AV_STEREO3D_2D,
  47. /**
  48. * Views are next to each other.
  49. *
  50. * @code{.unparsed}
  51. * LLLLRRRR
  52. * LLLLRRRR
  53. * LLLLRRRR
  54. * ...
  55. * @endcode
  56. */
  57. AV_STEREO3D_SIDEBYSIDE,
  58. /**
  59. * Views are on top of each other.
  60. *
  61. * @code{.unparsed}
  62. * LLLLLLLL
  63. * LLLLLLLL
  64. * RRRRRRRR
  65. * RRRRRRRR
  66. * @endcode
  67. */
  68. AV_STEREO3D_TOPBOTTOM,
  69. /**
  70. * Views are alternated temporally.
  71. *
  72. * @code{.unparsed}
  73. * frame0 frame1 frame2 ...
  74. * LLLLLLLL RRRRRRRR LLLLLLLL
  75. * LLLLLLLL RRRRRRRR LLLLLLLL
  76. * LLLLLLLL RRRRRRRR LLLLLLLL
  77. * ... ... ...
  78. * @endcode
  79. */
  80. AV_STEREO3D_FRAMESEQUENCE,
  81. /**
  82. * Views are packed in a checkerboard-like structure per pixel.
  83. *
  84. * @code{.unparsed}
  85. * LRLRLRLR
  86. * RLRLRLRL
  87. * LRLRLRLR
  88. * ...
  89. * @endcode
  90. */
  91. AV_STEREO3D_CHECKERBOARD,
  92. /**
  93. * Views are next to each other, but when upscaling
  94. * apply a checkerboard pattern.
  95. *
  96. * @code{.unparsed}
  97. * LLLLRRRR L L L L R R R R
  98. * LLLLRRRR => L L L L R R R R
  99. * LLLLRRRR L L L L R R R R
  100. * LLLLRRRR L L L L R R R R
  101. * @endcode
  102. */
  103. AV_STEREO3D_SIDEBYSIDE_QUINCUNX,
  104. /**
  105. * Views are packed per line, as if interlaced.
  106. *
  107. * @code{.unparsed}
  108. * LLLLLLLL
  109. * RRRRRRRR
  110. * LLLLLLLL
  111. * ...
  112. * @endcode
  113. */
  114. AV_STEREO3D_LINES,
  115. /**
  116. * Views are packed per column.
  117. *
  118. * @code{.unparsed}
  119. * LRLRLRLR
  120. * LRLRLRLR
  121. * LRLRLRLR
  122. * ...
  123. * @endcode
  124. */
  125. AV_STEREO3D_COLUMNS,
  126. };
  127. /**
  128. * List of possible view types.
  129. */
  130. enum AVStereo3DView {
  131. /**
  132. * Frame contains two packed views.
  133. */
  134. AV_STEREO3D_VIEW_PACKED,
  135. /**
  136. * Frame contains only the left view.
  137. */
  138. AV_STEREO3D_VIEW_LEFT,
  139. /**
  140. * Frame contains only the right view.
  141. */
  142. AV_STEREO3D_VIEW_RIGHT,
  143. };
  144. /**
  145. * Inverted views, Right/Bottom represents the left view.
  146. */
  147. #define AV_STEREO3D_FLAG_INVERT (1 << 0)
  148. /**
  149. * Stereo 3D type: this structure describes how two videos are packed
  150. * within a single video surface, with additional information as needed.
  151. *
  152. * @note The struct must be allocated with av_stereo3d_alloc() and
  153. * its size is not a part of the public ABI.
  154. */
  155. typedef struct AVStereo3D {
  156. /**
  157. * How views are packed within the video.
  158. */
  159. enum AVStereo3DType type;
  160. /**
  161. * Additional information about the frame packing.
  162. */
  163. int flags;
  164. /**
  165. * Determines which views are packed.
  166. */
  167. enum AVStereo3DView view;
  168. } AVStereo3D;
  169. /**
  170. * Allocate an AVStereo3D structure and set its fields to default values.
  171. * The resulting struct can be freed using av_freep().
  172. *
  173. * @return An AVStereo3D filled with default values or NULL on failure.
  174. */
  175. AVStereo3D *av_stereo3d_alloc(void);
  176. /**
  177. * Allocate a complete AVFrameSideData and add it to the frame.
  178. *
  179. * @param frame The frame which side data is added to.
  180. *
  181. * @return The AVStereo3D structure to be filled by caller.
  182. */
  183. AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame);
  184. /**
  185. * Provide a human-readable name of a given stereo3d type.
  186. *
  187. * @param type The input stereo3d type value.
  188. *
  189. * @return The name of the stereo3d value, or "unknown".
  190. */
  191. const char *av_stereo3d_type_name(unsigned int type);
  192. /**
  193. * Get the AVStereo3DType form a human-readable name.
  194. *
  195. * @param name The input string.
  196. *
  197. * @return The AVStereo3DType value, or -1 if not found.
  198. */
  199. int av_stereo3d_from_name(const char *name);
  200. /**
  201. * @}
  202. */
  203. #endif /* AVUTIL_STEREO3D_H */