You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.5KB

  1. /*
  2. * Copyright (c) 2016 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. * Spherical video
  23. */
  24. #ifndef AVUTIL_SPHERICAL_H
  25. #define AVUTIL_SPHERICAL_H
  26. #include <stddef.h>
  27. #include <stdint.h>
  28. /**
  29. * @addtogroup lavu_video
  30. * @{
  31. *
  32. * @defgroup lavu_video_spherical Spherical video mapping
  33. * @{
  34. */
  35. /**
  36. * @addtogroup lavu_video_spherical
  37. * A spherical video file contains surfaces that need to be mapped onto a
  38. * sphere. Depending on how the frame was converted, a different distortion
  39. * transformation or surface recomposition function needs to be applied before
  40. * the video should be mapped and displayed.
  41. */
  42. /**
  43. * Projection of the video surface(s) on a sphere.
  44. */
  45. enum AVSphericalProjection {
  46. /**
  47. * Video represents a sphere mapped on a flat surface using
  48. * equirectangular projection.
  49. */
  50. AV_SPHERICAL_EQUIRECTANGULAR,
  51. /**
  52. * Video frame is split into 6 faces of a cube, and arranged on a
  53. * 3x2 layout. Faces are oriented upwards for the front, left, right,
  54. * and back faces. The up face is oriented so the top of the face is
  55. * forwards and the down face is oriented so the top of the face is
  56. * to the back.
  57. */
  58. AV_SPHERICAL_CUBEMAP,
  59. };
  60. /**
  61. * This structure describes how to handle spherical videos, outlining
  62. * information about projection, initial layout, and any other view modifier.
  63. *
  64. * @note The struct must be allocated with av_spherical_alloc() and
  65. * its size is not a part of the public ABI.
  66. */
  67. typedef struct AVSphericalMapping {
  68. /**
  69. * Projection type.
  70. */
  71. enum AVSphericalProjection projection;
  72. /**
  73. * @name Initial orientation
  74. * @{
  75. * There fields describe additional rotations applied to the sphere after
  76. * the video frame is mapped onto it. The sphere is rotated around the
  77. * viewer, who remains stationary. The order of transformation is always
  78. * yaw, followed by pitch, and finally by roll.
  79. *
  80. * The coordinate system matches the one defined in OpenGL, where the
  81. * forward vector (z) is coming out of screen, and it is equivalent to
  82. * a rotation matrix of R = r_y(yaw) * r_x(pitch) * r_z(roll).
  83. *
  84. * A positive yaw rotates the portion of the sphere in front of the viewer
  85. * toward their right. A positive pitch rotates the portion of the sphere
  86. * in front of the viewer upwards. A positive roll tilts the portion of
  87. * the sphere in front of the viewer to the viewer's right.
  88. *
  89. * These values are exported as 16.16 fixed point.
  90. *
  91. * See this equirectangular projection as example:
  92. *
  93. * @code{.unparsed}
  94. * Yaw
  95. * -180 0 180
  96. * 90 +-------------+-------------+ 180
  97. * | | | up
  98. * P | | | y| forward
  99. * i | ^ | | /z
  100. * t 0 +-------------X-------------+ 0 Roll | /
  101. * c | | | | /
  102. * h | | | 0|/_____right
  103. * | | | x
  104. * -90 +-------------+-------------+ -180
  105. *
  106. * X - the default camera center
  107. * ^ - the default up vector
  108. * @endcode
  109. */
  110. int32_t yaw; ///< Rotation around the up vector [-180, 180].
  111. int32_t pitch; ///< Rotation around the right vector [-90, 90].
  112. int32_t roll; ///< Rotation around the forward vector [-180, 180].
  113. /**
  114. * @}
  115. */
  116. } AVSphericalMapping;
  117. /**
  118. * Allocate a AVSphericalVideo structure and initialize its fields to default
  119. * values.
  120. *
  121. * @return the newly allocated struct or NULL on failure
  122. */
  123. AVSphericalMapping *av_spherical_alloc(size_t *size);
  124. /**
  125. * @}
  126. * @}
  127. */
  128. #endif /* AVUTIL_SPHERICAL_H */