diff options
author | James Almer <jamrial@gmail.com> | 2017-03-29 05:49:40 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-03-31 19:26:56 +0300 |
commit | 9033e8723c86ed31872b22bd576602d48e2b9d0e (patch) | |
tree | 31575f1baae237a2304564f8f9e7b8d531e5f97a /libavutil/spherical.c | |
parent | 76dd87c9296917bf6394b2a41820f92aeaeae447 (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/spherical.c')
-rw-r--r-- | libavutil/spherical.c | 27 |
1 files changed, 27 insertions, 0 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; +} |