Mercurial > libavutil.hg
diff pixdesc.c @ 827:f01765adeb5c libavutil
Implement av_get_pix_fmt(), and deprecate avcodec_get_pix_fmt().
author | stefano |
---|---|
date | Sat, 30 Jan 2010 18:50:00 +0000 |
parents | 2715180d7ffa |
children | af688c6fa72f |
line wrap: on
line diff
--- a/pixdesc.c Fri Jan 29 03:26:17 2010 +0000 +++ b/pixdesc.c Sat Jan 30 18:50:00 2010 +0000 @@ -654,6 +654,43 @@ }, }; +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;