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>
This commit is contained in:
James Almer 2017-03-28 23:49:40 -03:00
parent 76dd87c929
commit 9033e8723c
4 changed files with 50 additions and 1 deletions

View File

@ -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().

View File

@ -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;
}

View File

@ -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);
/**
* @}
* @}

View File

@ -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, \