summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-03-28 23:49:40 -0300
committerJames Almer <jamrial@gmail.com>2017-03-31 13:26:56 -0300
commit9033e8723c86ed31872b22bd576602d48e2b9d0e (patch)
tree31575f1baae237a2304564f8f9e7b8d531e5f97a /libavutil
parent76dd87c9296917bf6394b2a41820f92aeaeae447 (diff)
avutil/spherical: add av_spherical_projection_name()
Reviewed-by: Benoit Fouet <benoit.fouet@free.fr> Reviewed-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/spherical.c27
-rw-r--r--libavutil/spherical.h18
-rw-r--r--libavutil/version.h2
3 files changed, 46 insertions, 1 deletions
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index f0b622128a..4be55f36cf 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -50,3 +50,30 @@ void av_spherical_tile_bounds(const AVSphericalMapping *map,
*right = orig_width - width - *left;
*bottom = orig_height - height - *top;
}
+
+static const char *spherical_projection_names[] = {
+ [AV_SPHERICAL_EQUIRECTANGULAR] = "equirectangular",
+ [AV_SPHERICAL_CUBEMAP] = "cubemap",
+ [AV_SPHERICAL_EQUIRECTANGULAR_TILE] = "tiled equirectangular",
+};
+
+const char *av_spherical_projection_name(enum AVSphericalProjection projection)
+{
+ if ((unsigned)projection >= FF_ARRAY_ELEMS(spherical_projection_names))
+ return "unknown";
+
+ return spherical_projection_names[projection];
+}
+
+int av_spherical_from_name(const char *name)
+{
+ int i;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
+ size_t len = strlen(spherical_projection_names[i]);
+ if (!strncmp(spherical_projection_names[i], name, len))
+ return i;
+ }
+
+ return -1;
+}
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
index a7952875af..cef759cf27 100644
--- a/libavutil/spherical.h
+++ b/libavutil/spherical.h
@@ -206,6 +206,24 @@ void av_spherical_tile_bounds(const AVSphericalMapping *map,
size_t width, size_t height,
size_t *left, size_t *top,
size_t *right, size_t *bottom);
+
+/**
+ * Provide a human-readable name of a given AVSphericalProjection.
+ *
+ * @param projection The input AVSphericalProjection.
+ *
+ * @return The name of the AVSphericalProjection, or "unknown".
+ */
+const char *av_spherical_projection_name(enum AVSphericalProjection projection);
+
+/**
+ * Get the AVSphericalProjection form a human-readable name.
+ *
+ * @param name The input string.
+ *
+ * @return The AVSphericalProjection value, or -1 if not found.
+ */
+int av_spherical_from_name(const char *name);
/**
* @}
* @}
diff --git a/libavutil/version.h b/libavutil/version.h
index 9d2a4e322b..d89a4187e8 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 56
+#define LIBAVUTIL_VERSION_MINOR 57
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \