From 80a07f6e47a842ca351ebec3478878204cd1d0b7 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 30 Jan 2010 18:50:00 +0000 Subject: Implement av_get_pix_fmt(), and deprecate avcodec_get_pix_fmt(). Originally committed as revision 21545 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/avcodec.h | 6 +++++- libavcodec/imgconvert.c | 33 +++------------------------------ 2 files changed, 8 insertions(+), 31 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 87d00fe2f4..e5c86fde44 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2995,6 +2995,7 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int * const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); void avcodec_set_dimensions(AVCodecContext *s, int width, int height); +#if LIBAVCODEC_VERSION_MAJOR < 53 /** * Returns the pixel format corresponding to the name name. * @@ -3005,8 +3006,11 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height); * then for "gray16le". * * Finally if no pixel format has been found, returns PIX_FMT_NONE. + * + * @deprecated Deprecated in favor of av_get_pix_fmt(). */ -enum PixelFormat avcodec_get_pix_fmt(const char* name); +attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name); +#endif /** * Returns a value representing the fourCC code associated to the diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 5dc7b92ee0..de6032d5c0 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -391,39 +391,12 @@ const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt) return av_pix_fmt_descriptors[pix_fmt].name; } -static enum PixelFormat avcodec_get_pix_fmt_internal(const char *name) -{ - int i; - - for (i=0; i < PIX_FMT_NB; i++) - if (av_pix_fmt_descriptors[i].name && !strcmp(av_pix_fmt_descriptors[i].name, name)) - return i; - return PIX_FMT_NONE; -} - -#if HAVE_BIGENDIAN -# define X_NE(be, le) be -#else -# define X_NE(be, le) le -#endif - +#if LIBAVCODEC_VERSION_MAJOR < 53 enum PixelFormat avcodec_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 = avcodec_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 = avcodec_get_pix_fmt_internal(name2); - } - return pix_fmt; + return av_get_pix_fmt(name); } +#endif void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) { -- cgit v1.2.3