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
1515
1616 API changes, most recent first:
1717
18+2017-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+
1823 2017-09-13 - xxxxxxx - lavc 57.106.100 - avcodec.h
1924 Add AV_PKT_FLAG_TRUSTED.
2025
libavutil/pixdesc.c+65−0
@@ -2749,26 +2749,91 @@ const char *av_color_range_name(enum AVColorRange range) · 2748 unmodified lines
27492749 color_range_names[range] : NULL;
27502750 }
27512751
2752+int 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+
27522765 const char *av_color_primaries_name(enum AVColorPrimaries primaries)
27532766 {
27542767 return (unsigned) primaries < AVCOL_PRI_NB ?
27552768 color_primaries_names[primaries] : NULL;
27562769 }
27572770
2771+int 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+
27582784 const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
27592785 {
27602786 return (unsigned) transfer < AVCOL_TRC_NB ?
27612787 color_transfer_names[transfer] : NULL;
27622788 }
27632789
2790+int 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+
27642803 const char *av_color_space_name(enum AVColorSpace space)
27652804 {
27662805 return (unsigned) space < AVCOL_SPC_NB ?
27672806 color_space_names[space] : NULL;
27682807 }
27692808
2809+int 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+
27702822 const char *av_chroma_location_name(enum AVChromaLocation location)
27712823 {
27722824 return (unsigned) location < AVCHROMA_LOC_NB ?
27732825 chroma_location_names[location] : NULL;
27742826 }
2827+
2828+int 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
250250 */
251251 const char *av_color_range_name(enum AVColorRange range);
252252
253+/**
254+ * @return the AVColorRange value for name or an AVError if not found.
255+ */
256+int av_color_range_from_name(const char *name);
257+
253258 /**
254259 * @return the name for provided color primaries or NULL if unknown.
255260 */
256261 const char *av_color_primaries_name(enum AVColorPrimaries primaries);
257262
263+/**
264+ * @return the AVColorPrimaries value for name or an AVError if not found.
265+ */
266+int av_color_primaries_from_name(const char *name);
267+
258268 /**
259269 * @return the name for provided color transfer or NULL if unknown.
260270 */
261271 const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);
262272
273+/**
274+ * @return the AVColorTransferCharacteristic value for name or an AVError if not found.
275+ */
276+int av_color_transfer_from_name(const char *name);
277+
263278 /**
264279 * @return the name for provided color space or NULL if unknown.
265280 */
266281 const char *av_color_space_name(enum AVColorSpace space);
267282
283+/**
284+ * @return the AVColorSpace value for name or an AVError if not found.
285+ */
286+int av_color_space_from_name(const char *name);
287+
268288 /**
269289 * @return the name for provided chroma location or NULL if unknown.
270290 */
271291 const char *av_chroma_location_name(enum AVChromaLocation location);
272292
293+/**
294+ * @return the AVChromaLocation value for name or an AVError if not found.
295+ */
296+int av_chroma_location_from_name(const char *name);
297+
273298 /**
274299 * Return the pixel format corresponding to name.
275300 *
libavutil/version.h+1−1
@@ -80,7 +80,7 @@ · 79 unmodified lines
8080
8181
8282 #define LIBAVUTIL_VERSION_MAJOR 55
83−#define LIBAVUTIL_VERSION_MINOR 75
83+#define LIBAVUTIL_VERSION_MINOR 76
8484 #define LIBAVUTIL_VERSION_MICRO 100
8585
8686 #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