History

pixdesc: Add API to map color property names to enum values

Vittorio Giovara committed 9 years ago

Commit 6f15f1c1 parent bba9c1c4 files · +96 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +5 −0
  2. libavutil/pixdesc.c +65 −0
  3. libavutil/pixdesc.h +25 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+5−0
@@ -15,6 +15,11 @@ libavutil: 2015-08-28 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182017-xx-xx - xxxxxxx - lavu 55.76.100 / 56.6.0 - pixdesc.h
19 Add av_color_range_from_name(), av_color_primaries_from_name(),
20 av_color_transfer_from_name(), av_color_space_from_name(), and
21 av_chroma_location_from_name().
22
182017-09-13 - xxxxxxx - lavc 57.106.100 - avcodec.h232017-09-13 - xxxxxxx - lavc 57.106.100 - avcodec.h
19 Add AV_PKT_FLAG_TRUSTED.24 Add AV_PKT_FLAG_TRUSTED.
20 25
libavutil/pixdesc.c+65−0
@@ -2749,26 +2749,91 @@ const char *av_color_range_name(enum AVColorRange range) · 2748 unmodified lines
2749 color_range_names[range] : NULL;2749 color_range_names[range] : NULL;
2750}2750}
2751 2751
2752int av_color_range_from_name(const char *name)
2753{
2754 int i;
2755
2756 for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
2757 size_t len = strlen(color_range_names[i]);
2758 if (!strncmp(color_range_names[i], name, len))
2759 return i;
2760 }
2761
2762 return AVERROR(EINVAL);
2763}
2764
2752const char *av_color_primaries_name(enum AVColorPrimaries primaries)2765const char *av_color_primaries_name(enum AVColorPrimaries primaries)
2753{2766{
2754 return (unsigned) primaries < AVCOL_PRI_NB ?2767 return (unsigned) primaries < AVCOL_PRI_NB ?
2755 color_primaries_names[primaries] : NULL;2768 color_primaries_names[primaries] : NULL;
2756}2769}
2757 2770
2771int av_color_primaries_from_name(const char *name)
2772{
2773 int i;
2774
2775 for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) {
2776 size_t len = strlen(color_primaries_names[i]);
2777 if (!strncmp(color_primaries_names[i], name, len))
2778 return i;
2779 }
2780
2781 return AVERROR(EINVAL);
2782}
2783
2758const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer)2784const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
2759{2785{
2760 return (unsigned) transfer < AVCOL_TRC_NB ?2786 return (unsigned) transfer < AVCOL_TRC_NB ?
2761 color_transfer_names[transfer] : NULL;2787 color_transfer_names[transfer] : NULL;
2762}2788}
2763 2789
2790int av_color_transfer_from_name(const char *name)
2791{
2792 int i;
2793
2794 for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) {
2795 size_t len = strlen(color_transfer_names[i]);
2796 if (!strncmp(color_transfer_names[i], name, len))
2797 return i;
2798 }
2799
2800 return AVERROR(EINVAL);
2801}
2802
2764const char *av_color_space_name(enum AVColorSpace space)2803const char *av_color_space_name(enum AVColorSpace space)
2765{2804{
2766 return (unsigned) space < AVCOL_SPC_NB ?2805 return (unsigned) space < AVCOL_SPC_NB ?
2767 color_space_names[space] : NULL;2806 color_space_names[space] : NULL;
2768}2807}
2769 2808
2809int av_color_space_from_name(const char *name)
2810{
2811 int i;
2812
2813 for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) {
2814 size_t len = strlen(color_space_names[i]);
2815 if (!strncmp(color_space_names[i], name, len))
2816 return i;
2817 }
2818
2819 return AVERROR(EINVAL);
2820}
2821
2770const char *av_chroma_location_name(enum AVChromaLocation location)2822const char *av_chroma_location_name(enum AVChromaLocation location)
2771{2823{
2772 return (unsigned) location < AVCHROMA_LOC_NB ?2824 return (unsigned) location < AVCHROMA_LOC_NB ?
2773 chroma_location_names[location] : NULL;2825 chroma_location_names[location] : NULL;
2774}2826}
2827
2828int av_chroma_location_from_name(const char *name)
2829{
2830 int i;
2831
2832 for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) {
2833 size_t len = strlen(chroma_location_names[i]);
2834 if (!strncmp(chroma_location_names[i], name, len))
2835 return i;
2836 }
2837
2838 return AVERROR(EINVAL);
2839}
libavutil/pixdesc.h+25−0
@@ -250,26 +250,51 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt); · 249 unmodified lines
250 */250 */
251const char *av_color_range_name(enum AVColorRange range);251const char *av_color_range_name(enum AVColorRange range);
252 252
253/**
254 * @return the AVColorRange value for name or an AVError if not found.
255 */
256int av_color_range_from_name(const char *name);
257
253/**258/**
254 * @return the name for provided color primaries or NULL if unknown.259 * @return the name for provided color primaries or NULL if unknown.
255 */260 */
256const char *av_color_primaries_name(enum AVColorPrimaries primaries);261const char *av_color_primaries_name(enum AVColorPrimaries primaries);
257 262
263/**
264 * @return the AVColorPrimaries value for name or an AVError if not found.
265 */
266int av_color_primaries_from_name(const char *name);
267
258/**268/**
259 * @return the name for provided color transfer or NULL if unknown.269 * @return the name for provided color transfer or NULL if unknown.
260 */270 */
261const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);271const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);
262 272
273/**
274 * @return the AVColorTransferCharacteristic value for name or an AVError if not found.
275 */
276int av_color_transfer_from_name(const char *name);
277
263/**278/**
264 * @return the name for provided color space or NULL if unknown.279 * @return the name for provided color space or NULL if unknown.
265 */280 */
266const char *av_color_space_name(enum AVColorSpace space);281const char *av_color_space_name(enum AVColorSpace space);
267 282
283/**
284 * @return the AVColorSpace value for name or an AVError if not found.
285 */
286int av_color_space_from_name(const char *name);
287
268/**288/**
269 * @return the name for provided chroma location or NULL if unknown.289 * @return the name for provided chroma location or NULL if unknown.
270 */290 */
271const char *av_chroma_location_name(enum AVChromaLocation location);291const char *av_chroma_location_name(enum AVChromaLocation location);
272 292
293/**
294 * @return the AVChromaLocation value for name or an AVError if not found.
295 */
296int av_chroma_location_from_name(const char *name);
297
273/**298/**
274 * Return the pixel format corresponding to name.299 * Return the pixel format corresponding to name.
275 *300 *
libavutil/version.h+1−1
@@ -80,7 +80,7 @@ · 79 unmodified lines
80 80
81 81
82#define LIBAVUTIL_VERSION_MAJOR 5582#define LIBAVUTIL_VERSION_MAJOR 55
83#define LIBAVUTIL_VERSION_MINOR 7583#define LIBAVUTIL_VERSION_MINOR 76
84#define LIBAVUTIL_VERSION_MICRO 10084#define LIBAVUTIL_VERSION_MICRO 100
85 85
86#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \86#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t