diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2017-09-21 13:23:21 +0200 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2017-09-21 13:23:21 +0200 |
commit | 2b50847e0f8f8894bfa74aa1c5a63e90a9867b45 (patch) | |
tree | 0b46c3fa7b249bbd045ff03216b6501644105b7e /libavutil | |
parent | a5a6ac1a123a927e5bed984ed757a29b7ff87dab (diff) | |
download | ffmpeg-2b50847e0f8f8894bfa74aa1c5a63e90a9867b45.tar.gz |
pixdesc: Add API to map color property names to enum values
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/pixdesc.c | 64 | ||||
-rw-r--r-- | libavutil/pixdesc.h | 25 | ||||
-rw-r--r-- | libavutil/version.h | 2 |
3 files changed, 90 insertions, 1 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index b168ac7d0b..957f99fdaa 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2013,27 +2013,91 @@ const char *av_color_range_name(enum AVColorRange range) color_range_names[range] : NULL; } +int av_color_range_from_name(const char *name) +{ + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) { + size_t len = strlen(color_range_names[i]); + if (!strncmp(color_range_names[i], name, len)) + return i; + } + + return AVERROR(EINVAL); +} + const char *av_color_primaries_name(enum AVColorPrimaries primaries) { return (unsigned) primaries < AVCOL_PRI_NB ? color_primaries_names[primaries] : NULL; } +int av_color_primaries_from_name(const char *name) +{ + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) { + size_t len = strlen(color_primaries_names[i]); + if (!strncmp(color_primaries_names[i], name, len)) + return i; + } + + return AVERROR(EINVAL); +} + const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer) { return (unsigned) transfer < AVCOL_TRC_NB ? color_transfer_names[transfer] : NULL; } +int av_color_transfer_from_name(const char *name) +{ + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) { + size_t len = strlen(color_transfer_names[i]); + if (!strncmp(color_transfer_names[i], name, len)) + return i; + } + + return AVERROR(EINVAL); +} + const char *av_color_space_name(enum AVColorSpace space) { return (unsigned) space < AVCOL_SPC_NB ? color_space_names[space] : NULL; } +int av_color_space_from_name(const char *name) +{ + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) { + size_t len = strlen(color_space_names[i]); + if (!strncmp(color_space_names[i], name, len)) + return i; + } + + return AVERROR(EINVAL); +} + const char *av_chroma_location_name(enum AVChromaLocation location) { return (unsigned) location < AVCHROMA_LOC_NB ? chroma_location_names[location] : NULL; } +int av_chroma_location_from_name(const char *name) +{ + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) { + size_t len = strlen(chroma_location_names[i]); + if (!strncmp(chroma_location_names[i], name, len)) + return i; + } + + return AVERROR(EINVAL); +} diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h index 3bb10f777a..4e8a29e607 100644 --- a/libavutil/pixdesc.h +++ b/libavutil/pixdesc.h @@ -298,23 +298,48 @@ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt); const char *av_color_range_name(enum AVColorRange range); /** + * @return the AVColorRange value for name or an AVError if not found. + */ +int av_color_range_from_name(const char *name); + +/** * @return the name for provided color primaries or NULL if unknown. */ const char *av_color_primaries_name(enum AVColorPrimaries primaries); /** + * @return the AVColorPrimaries value for name or an AVError if not found. + */ +int av_color_primaries_from_name(const char *name); + +/** * @return the name for provided color transfer or NULL if unknown. */ const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer); /** + * @return the AVColorTransferCharacteristic value for name or an AVError if not found. + */ +int av_color_transfer_from_name(const char *name); + +/** * @return the name for provided color space or NULL if unknown. */ const char *av_color_space_name(enum AVColorSpace space); /** + * @return the AVColorSpace value for name or an AVError if not found. + */ +int av_color_space_from_name(const char *name); + +/** * @return the name for provided chroma location or NULL if unknown. */ const char *av_chroma_location_name(enum AVChromaLocation location); +/** + * @return the AVChromaLocation value for name or an AVError if not found. + */ +int av_chroma_location_from_name(const char *name); + #endif /* AVUTIL_PIXDESC_H */ diff --git a/libavutil/version.h b/libavutil/version.h index 5d0bb61124..c258968b8e 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -54,7 +54,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 5 +#define LIBAVUTIL_VERSION_MINOR 6 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |