diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-01-30 18:50:00 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-01-30 18:50:00 +0000 |
commit | 80a07f6e47a842ca351ebec3478878204cd1d0b7 (patch) | |
tree | 8fd672ac9acafe58958f0de532966c6dcfe8b6f3 /libavutil/pixdesc.c | |
parent | 7b0b81a16d16f583b7a871e19ada8ccc1b6b4aa3 (diff) | |
download | ffmpeg-80a07f6e47a842ca351ebec3478878204cd1d0b7.tar.gz |
Implement av_get_pix_fmt(), and deprecate avcodec_get_pix_fmt().
Originally committed as revision 21545 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/pixdesc.c')
-rw-r--r-- | libavutil/pixdesc.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 972da4578f..837927ba7d 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -654,6 +654,43 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, }; +static enum PixelFormat get_pix_fmt_internal(const char *name) +{ + enum PixelFormat pix_fmt; + + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) + if (av_pix_fmt_descriptors[pix_fmt].name && + !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name)) + return pix_fmt; + + return PIX_FMT_NONE; +} + +#if HAVE_BIGENDIAN +# define X_NE(be, le) be +#else +# define X_NE(be, le) le +#endif + +enum PixelFormat av_get_pix_fmt(const char *name) +{ + enum PixelFormat pix_fmt; + + if (!strcmp(name, "rgb32")) + name = X_NE("argb", "bgra"); + else if (!strcmp(name, "bgr32")) + name = X_NE("abgr", "rgba"); + + pix_fmt = get_pix_fmt_internal(name); + if (pix_fmt == PIX_FMT_NONE) { + char name2[32]; + + snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le")); + pix_fmt = get_pix_fmt_internal(name2); + } + return pix_fmt; +} + int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) { int c, bits = 0; |