stereo3d.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. * Inverted views, Right/Bottom represents the left view.
  131. */
  132. #define AV_STEREO3D_FLAG_INVERT (1 << 0)
  133. /**
  134. * Stereo 3D type: this structure describes how two videos are packed
  135. * within a single video surface, with additional information as needed.
  136. *
  137. * @note The struct must be allocated with av_stereo3d_alloc() and
  138. * its size is not a part of the public ABI.
  139. */
  140. typedef struct AVStereo3D {
  141. /**
  142. * How views are packed within the video.
  143. */
  144. enum AVStereo3DType type;
  145. /**
  146. * Additional information about the frame packing.
  147. */
  148. int flags;
  149. } AVStereo3D;
  150. /**
  151. * Allocate an AVStereo3D structure and set its fields to default values.
  152. * The resulting struct can be freed using av_freep().
  153. *
  154. * @return An AVStereo3D filled with default values or NULL on failure.
  155. */
  156. AVStereo3D *av_stereo3d_alloc(void);
  157. /**
  158. * Allocate a complete AVFrameSideData and add it to the frame.
  159. *
  160. * @param frame The frame which side data is added to.
  161. *
  162. * @return The AVStereo3D structure to be filled by caller.
  163. */
  164. AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame);
  165. /**
  166. * Provide a human-readable name of a given stereo3d type.
  167. *
  168. * @param type The input stereo3d type value.
  169. *
  170. * @return The name of the stereo3d value, or "unknown".
  171. */
  172. const char *av_stereo3d_type_name(unsigned int type);
  173. /**
  174. * Get the AVStereo3DType form a human-readable name.
  175. *
  176. * @param name The input string.
  177. *
  178. * @return The AVStereo3DType value, or -1 if not found.
  179. */
  180. int av_stereo3d_from_name(const char *name);
  181. /**
  182. * @}
  183. * @}
  184. */
  185. #endif /* AVUTIL_STEREO3D_H */