History

lavu: Add AVSphericalMapping type and frame side data

While no decoder currently exports spherical information, this type represents a frame property that has to be passed through from container to frames.

Vittorio Giovara committed 10 years ago

Commit 8f58ecc1 parent c188f357 files · +192 −3Browse files

Unified · Split

7 files
  1. doc/APIchanges +4 −0
  2. libavutil/Makefile +2 −0
  3. libavutil/avutil.h +6 −0
  4. libavutil/frame.h +7 −1
  5. libavutil/spherical.c +34 −0
  6. libavutil/spherical.h +137 −0
  7. libavutil/version.h +2 −2
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2016-xx-xx - xxxxxxx - lavu 55.42.100 / 55.30.0 - spherical.h
19+ Add AV_FRAME_DATA_SPHERICAL value, av_spherical_alloc() API and
20+ AVSphericalMapping type to export and describe spherical video properties.
21+
1822 2016-11-18 - xxxxxxx - lavf 57.58.100 - avformat.h
1923 Add av_stream_add_side_data().
2024
libavutil/Makefile+2−0
@@ -63,6 +63,7 @@ HEADERS = adler32.h \ · 62 unmodified lines
6363 samplefmt.h \
6464 sha.h \
6565 sha512.h \
66+ spherical.h \
6667 stereo3d.h \
6768 threadmessage.h \
6869 time.h \
@@ -140,6 +141,7 @@ OBJS = adler32.o \ · 71 unmodified lines
140141 samplefmt.o \
141142 sha.o \
142143 sha512.o \
144+ spherical.o \
143145 stereo3d.o \
144146 threadmessage.o \
145147 time.o \
libavutil/avutil.h+6−0
@@ -118,6 +118,12 @@ · 117 unmodified lines
118118 *
119119 * @}
120120 *
121+ * @defgroup lavu_video Video related
122+ *
123+ * @{
124+ *
125+ * @}
126+ *
121127 * @defgroup lavu_audio Audio related
122128 *
123129 * @{
libavutil/frame.h+7−1
@@ -120,7 +120,13 @@ enum AVFrameSideDataType { · 119 unmodified lines
120120 * The GOP timecode in 25 bit timecode format. Data format is 64-bit integer.
121121 * This is set on the first frame of a GOP that has a temporal reference of 0.
122122 */
123− AV_FRAME_DATA_GOP_TIMECODE
123+ AV_FRAME_DATA_GOP_TIMECODE,
124+
125+ /**
126+ * The data represents the AVSphericalMapping structure defined in
127+ * libavutil/spherical.h.
128+ */
129+ AV_FRAME_DATA_SPHERICAL,
124130 };
125131
126132 enum AVActiveFormatDescription {
libavutil/spherical.c+34−0
@@ -0,0 +1,34 @@
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+#include "mem.h"
22+#include "spherical.h"
23+
24+AVSphericalMapping *av_spherical_alloc(size_t *size)
25+{
26+ AVSphericalMapping *spherical = av_mallocz(sizeof(AVSphericalMapping));
27+ if (!spherical)
28+ return NULL;
29+
30+ if (size)
31+ *size = sizeof(*spherical);
32+
33+ return spherical;
34+}
libavutil/spherical.h+137−0
@@ -0,0 +1,137 @@
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+/**
22+ * @file
23+ * Spherical video
24+ */
25+
26+#ifndef AVUTIL_SPHERICAL_H
27+#define AVUTIL_SPHERICAL_H
28+
29+/**
30+ * @addtogroup lavu_video
31+ * @{
32+ *
33+ * @defgroup lavu_video_spherical Spherical video mapping
34+ * @{
35+ */
36+
37+/**
38+ * @addtogroup lavu_video_spherical
39+ * A spherical video file contains surfaces that need to be mapped onto a
40+ * sphere. Depending on how the frame was converted, a different distortion
41+ * transformation or surface recomposition function needs to be applied before
42+ * the video should be mapped and displayed.
43+ */
44+
45+/**
46+ * Projection of the video surface(s) on a sphere.
47+ */
48+enum AVSphericalProjection {
49+ /**
50+ * Video represents a sphere mapped on a flat surface using
51+ * equirectangular projection.
52+ */
53+ AV_SPHERICAL_EQUIRECTANGULAR,
54+
55+ /**
56+ * Video frame is split into 6 faces of a cube, and arranged on a
57+ * 3x2 layout. Faces are oriented upwards for the front, left, right,
58+ * and back faces. The up face is oriented so the top of the face is
59+ * forwards and the down face is oriented so the top of the face is
60+ * to the back.
61+ */
62+ AV_SPHERICAL_CUBEMAP,
63+};
64+
65+/**
66+ * This structure describes how to handle spherical videos, outlining
67+ * information about projection, initial layout, and any other view modifier.
68+ *
69+ * @note The struct must be allocated with av_spherical_alloc() and
70+ * its size is not a part of the public ABI.
71+ */
72+typedef struct AVSphericalMapping {
73+ /**
74+ * Projection type.
75+ */
76+ enum AVSphericalProjection projection;
77+
78+ /**
79+ * @name Initial orientation
80+ * @{
81+ * There fields describe additional rotations applied to the sphere after
82+ * the video frame is mapped onto it. The sphere is rotated around the
83+ * viewer, who remains stationary. The order of transformation is always
84+ * yaw, followed by pitch, and finally by roll.
85+ *
86+ * The coordinate system matches the one defined in OpenGL, where the
87+ * forward vector (z) is coming out of screen, and it is equivalent to
88+ * a rotation matrix of R = r_y(yaw) * r_x(pitch) * r_z(roll).
89+ *
90+ * A positive yaw rotates the portion of the sphere in front of the viewer
91+ * toward their right. A positive pitch rotates the portion of the sphere
92+ * in front of the viewer upwards. A positive roll tilts the portion of
93+ * the sphere in front of the viewer to the viewer's right.
94+ *
95+ * These values are exported as 16.16 fixed point.
96+ *
97+ * See this equirectangular projection as example:
98+ *
99+ * @code{.unparsed}
100+ * Yaw
101+ * -180 0 180
102+ * 90 +-------------+-------------+ 180
103+ * | | | up
104+ * P | | | y| forward
105+ * i | ^ | | /z
106+ * t 0 +-------------X-------------+ 0 Roll | /
107+ * c | | | | /
108+ * h | | | 0|/_____right
109+ * | | | x
110+ * -90 +-------------+-------------+ -180
111+ *
112+ * X - the default camera center
113+ * ^ - the default up vector
114+ * @endcode
115+ */
116+ int32_t yaw; ///< Rotation around the up vector [-180, 180].
117+ int32_t pitch; ///< Rotation around the right vector [-90, 90].
118+ int32_t roll; ///< Rotation around the forward vector [-180, 180].
119+ /**
120+ * @}
121+ */
122+} AVSphericalMapping;
123+
124+/**
125+ * Allocate a AVSphericalVideo structure and initialize its fields to default
126+ * values.
127+ *
128+ * @return the newly allocated struct or NULL on failure
129+ */
130+AVSphericalMapping *av_spherical_alloc(size_t *size);
131+
132+/**
133+ * @}
134+ * @}
135+ */
136+
137+#endif /* AVUTIL_SPHERICAL_H */
libavutil/version.h+2−2
@@ -79,8 +79,8 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 55
82−#define LIBAVUTIL_VERSION_MINOR 41
83−#define LIBAVUTIL_VERSION_MICRO 101
82+#define LIBAVUTIL_VERSION_MINOR 42
83+#define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
8686 LIBAVUTIL_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t