spherical: add functions to retrieve and request projection names
authorJames Almer <jamrial@gmail.com>
Thu, 20 Apr 2017 15:40:48 +0000 (11:40 -0400)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Thu, 27 Apr 2017 13:59:54 +0000 (09:59 -0400)
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
doc/APIchanges
libavutil/spherical.c
libavutil/spherical.h
libavutil/version.h

index 58d59dd..34d788a 100644 (file)
@@ -13,6 +13,9 @@ libavutil:     2017-03-23
 
 API changes, most recent first:
 
+2017-04-xx - xxxxxxx - lavu 56.1.0 - spherical.h
+  Add av_spherical_projection_name() and av_spherical_from_name().
+
 2017-04-26 - xxxxxxx - lavc 58.3.1 - avcodec.h
   Add AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH.
 
index f5accc4..b37db93 100644 (file)
@@ -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);
+}
index fd662cf..51ef224 100644 (file)
@@ -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);
 /**
  * @}
  * @}
index b8425ea..fd72ff4 100644 (file)
@@ -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, \