diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-10-06 14:36:38 +0400 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-10-12 14:45:25 +0400 |
commit | d2fcb356caf38c12b0fc9d8c5bac592a28b0f0f1 (patch) | |
tree | bfb4c40085c804f2fddff72acfe966ae24e45d1f /libavutil/pixdesc.c | |
parent | fdd666094d42f46935a86ad8375cec67c540bf38 (diff) |
pixdesc: add functions for accessing pixel format descriptors.
Make av_pix_fmt_descriptors table static on next major bump.
Making the table public is dangerous, since the caller has no way to
know how large it actually is. It also prevents adding new fields to
AVPixFmtDescriptor without a major bump.
Diffstat (limited to 'libavutil/pixdesc.c')
-rw-r--r-- | libavutil/pixdesc.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index f5098a7320..3a1f9fe957 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -21,6 +21,8 @@ #include <stdio.h> #include <string.h> + +#include "common.h" #include "pixfmt.h" #include "pixdesc.h" @@ -122,6 +124,9 @@ void av_write_image_line(const uint16_t *src, } } +#if !FF_API_PIX_FMT_DESC +static +#endif const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { [AV_PIX_FMT_YUV420P] = { .name = "yuv420p", @@ -1164,3 +1169,28 @@ char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt return buf; } + +const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt) +{ + if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB) + return NULL; + return &av_pix_fmt_descriptors[pix_fmt]; +} + +const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev) +{ + if (!prev) + return &av_pix_fmt_descriptors[0]; + if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) + return prev + 1; + return NULL; +} + +enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc) +{ + if (desc < av_pix_fmt_descriptors || + desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors)) + return AV_PIX_FMT_NONE; + + return desc - av_pix_fmt_descriptors; +} |