Mercurial > libavcodec.hg
diff imgconvert.c @ 9222:e314914641bc libavcodec
Extend the behavior of avcodec_get_pix_fmt(), if it cannot find a
pixel format for the provided name, make it look for the native endian
variant of the name.
author | stefano |
---|---|
date | Sat, 21 Mar 2009 22:43:46 +0000 |
parents | a15ec86bf752 |
children | 53f2c0f6e71d |
line wrap: on
line diff
--- a/imgconvert.c Sat Mar 21 22:24:44 2009 +0000 +++ b/imgconvert.c Sat Mar 21 22:43:46 2009 +0000 @@ -457,7 +457,7 @@ return pix_fmt_info[pix_fmt].name; } -enum PixelFormat avcodec_get_pix_fmt(const char* name) +static enum PixelFormat avcodec_get_pix_fmt_internal(const char *name) { int i; @@ -467,6 +467,24 @@ return PIX_FMT_NONE; } +enum PixelFormat avcodec_get_pix_fmt(const char *name) +{ +#ifdef WORDS_BIGENDIAN +# define NE "be" +#else +# define NE "le" +#endif + enum PixelFormat pix_fmt = avcodec_get_pix_fmt_internal(name); + + if (pix_fmt == PIX_FMT_NONE) { + char name2[32]; + snprintf(name2, sizeof(name2), "%s%s", name, NE); + pix_fmt = avcodec_get_pix_fmt_internal(name2); + } + return pix_fmt; +#undef NE +} + void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) { /* print header */