diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-03-21 22:43:46 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-03-21 22:43:46 +0000 |
commit | d89f692f0ea078867be00397b2f8229510400325 (patch) | |
tree | 43b0dbd08ce0c0194494fe65eb585240d9a04702 /libavcodec/imgconvert.c | |
parent | a61ec8e7ae1f74716142d72c07740f90c33ff67b (diff) | |
download | ffmpeg-d89f692f0ea078867be00397b2f8229510400325.tar.gz |
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.
Originally committed as revision 18130 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/imgconvert.c')
-rw-r--r-- | libavcodec/imgconvert.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 962c012194..8619b40336 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -457,7 +457,7 @@ const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt) 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 @@ enum PixelFormat avcodec_get_pix_fmt(const char* name) 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 */ |