summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-04-20 11:40:48 -0400
committerVittorio Giovara <vittorio.giovara@gmail.com>2017-04-27 09:59:54 -0400
commitad52eef997dce374b4c7f3d1cdedf382935fea5e (patch)
tree2ca6fdca2c3d06a2f57e1e0aae86ca1cd3605b81 /libavutil
parent7acb90333a187b0e847b66f9d3511245423dc0ce (diff)
spherical: add functions to retrieve and request projection names
Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/spherical.c28
-rw-r--r--libavutil/spherical.h18
-rw-r--r--libavutil/version.h2
3 files changed, 47 insertions, 1 deletions
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index f5accc487d..b37db93b23 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "common.h"
#include "mem.h"
#include "spherical.h"
@@ -50,3 +51,30 @@ void av_spherical_tile_bounds(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 AVERROR(EINVAL);
+}
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
index fd662cf676..51ef22421e 100644
--- a/libavutil/spherical.h
+++ b/libavutil/spherical.h
@@ -206,6 +206,24 @@ void av_spherical_tile_bounds(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 AVERROR if not found.
+ */
+int av_spherical_from_name(const char *name);
/**
* @}
* @}
diff --git a/libavutil/version.h b/libavutil/version.h
index b8425ea2c8..fd72ff431d 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR 0
+#define LIBAVUTIL_VERSION_MINOR 1
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \