[FFmpeg-cvslog] avutil/spherical: add av_spherical_projection_name()

James Almer git at videolan.org
Fri Mar 31 20:13:07 EEST 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Mar 28 23:49:40 2017 -0300| [9033e8723c86ed31872b22bd576602d48e2b9d0e] | committer: James Almer

avutil/spherical: add av_spherical_projection_name()

Reviewed-by: Benoit Fouet <benoit.fouet at free.fr>
Reviewed-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9033e8723c86ed31872b22bd576602d48e2b9d0e
---

 doc/APIchanges        |  4 ++++
 libavutil/spherical.c | 27 +++++++++++++++++++++++++++
 libavutil/spherical.h | 18 ++++++++++++++++++
 libavutil/version.h   |  2 +-
 4 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 6314937..adff133 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-03-31 - xxxxxxx - lavu 55.57.100 - spherical.h
+  Add av_spherical_projection_name().
+  Add av_spherical_from_name().
+
 2017-03-30 - xxxxxxx - lavu 55.53.100 / 55.27.0 - hwcontext.h
   Add av_hwframe_map() and associated AV_HWFRAME_MAP_* flags.
   Add av_hwframe_ctx_create_derived().
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index f0b6221..4be55f3 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 a795287..cef759c 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 9d2a4e3..d89a418 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, \



More information about the ffmpeg-cvslog mailing list