diff --git a/doc/APIchanges b/doc/APIchanges index 6314937964..adff133855 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 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, \