History

spherical: add functions to retrieve and request projection names

James Almer committed 9 years ago

Commit ad52eef1 parent 7acb9034 files · +50 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/spherical.c +28 −0
  3. libavutil/spherical.h +18 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2017-03-23 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2017-04-xx - xxxxxxx - lavu 56.1.0 - spherical.h
17+ Add av_spherical_projection_name() and av_spherical_from_name().
18+
1619 2017-04-26 - xxxxxxx - lavc 58.3.1 - avcodec.h
1720 Add AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH.
1821
libavutil/spherical.c+28−0
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919 */
2020
21+#include "common.h"
2122 #include "mem.h"
2223 #include "spherical.h"
2324
@@ -50,3 +51,30 @@ void av_spherical_tile_bounds(AVSphericalMapping *map, · 26 unmodified lines
5051 *right = orig_width - width - *left;
5152 *bottom = orig_height - height - *top;
5253 }
54+
55+static const char *spherical_projection_names[] = {
56+ [AV_SPHERICAL_EQUIRECTANGULAR] = "equirectangular",
57+ [AV_SPHERICAL_CUBEMAP] = "cubemap",
58+ [AV_SPHERICAL_EQUIRECTANGULAR_TILE] = "tiled equirectangular",
59+};
60+
61+const char *av_spherical_projection_name(enum AVSphericalProjection projection)
62+{
63+ if ((unsigned) projection >= FF_ARRAY_ELEMS(spherical_projection_names))
64+ return "unknown";
65+
66+ return spherical_projection_names[projection];
67+}
68+
69+int av_spherical_from_name(const char *name)
70+{
71+ int i;
72+
73+ for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
74+ size_t len = strlen(spherical_projection_names[i]);
75+ if (!strncmp(spherical_projection_names[i], name, len))
76+ return i;
77+ }
78+
79+ return AVERROR(EINVAL);
80+}
libavutil/spherical.h+18−0
@@ -206,6 +206,24 @@ void av_spherical_tile_bounds(AVSphericalMapping *map, · 205 unmodified lines
206206 size_t width, size_t height,
207207 size_t *left, size_t *top,
208208 size_t *right, size_t *bottom);
209+
210+/**
211+ * Provide a human-readable name of a given AVSphericalProjection.
212+ *
213+ * @param projection The input AVSphericalProjection.
214+ *
215+ * @return The name of the AVSphericalProjection, or "unknown".
216+ */
217+const char *av_spherical_projection_name(enum AVSphericalProjection projection);
218+
219+/**
220+ * Get the AVSphericalProjection form a human-readable name.
221+ *
222+ * @param name The input string.
223+ *
224+ * @return The AVSphericalProjection value, or AVERROR if not found.
225+ */
226+int av_spherical_from_name(const char *name);
209227 /**
210228 * @}
211229 * @}
libavutil/version.h+1−1
@@ -54,7 +54,7 @@ · 53 unmodified lines
5454 */
5555
5656 #define LIBAVUTIL_VERSION_MAJOR 56
57−#define LIBAVUTIL_VERSION_MINOR 0
57+#define LIBAVUTIL_VERSION_MINOR 1
5858 #define LIBAVUTIL_VERSION_MICRO 0
5959
6060 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

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