Originally committed as revision 21545 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -2995,6 +2995,7 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int * · 2994 unmodified lines | |||
| 2995 | const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); | 2995 | const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); |
| 2996 | void avcodec_set_dimensions(AVCodecContext *s, int width, int height); | 2996 | void avcodec_set_dimensions(AVCodecContext *s, int width, int height); |
| 2997 | 2997 | ||
| 2998 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
| 2998 | /** | 2999 | /** |
| 2999 | * Returns the pixel format corresponding to the name name. | 3000 | * Returns the pixel format corresponding to the name name. |
| 3000 | * | 3001 | * |
| @@ -3005,8 +3006,11 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height); · 4 unmodified lines | |||
| 3005 | * then for "gray16le". | 3006 | * then for "gray16le". |
| 3006 | * | 3007 | * |
| 3007 | * Finally if no pixel format has been found, returns PIX_FMT_NONE. | 3008 | * Finally if no pixel format has been found, returns PIX_FMT_NONE. |
| 3009 | * | ||
| 3010 | * @deprecated Deprecated in favor of av_get_pix_fmt(). | ||
| 3008 | */ | 3011 | */ |
| 3009 | enum PixelFormat avcodec_get_pix_fmt(const char* name); | 3012 | attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name); |
| 3013 | #endif | ||
| 3010 | 3014 | ||
| 3011 | /** | 3015 | /** |
| 3012 | * Returns a value representing the fourCC code associated to the | 3016 | * Returns a value representing the fourCC code associated to the |
| @@ -391,39 +391,12 @@ const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt) · 390 unmodified lines | |||
| 391 | return av_pix_fmt_descriptors[pix_fmt].name; | 391 | return av_pix_fmt_descriptors[pix_fmt].name; |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | static enum PixelFormat avcodec_get_pix_fmt_internal(const char *name) | 394 | #if LIBAVCODEC_VERSION_MAJOR < 53 |
| 395 | { | ||
| 396 | int i; | ||
| 397 | |||
| 398 | for (i=0; i < PIX_FMT_NB; i++) | ||
| 399 | if (av_pix_fmt_descriptors[i].name && !strcmp(av_pix_fmt_descriptors[i].name, name)) | ||
| 400 | return i; | ||
| 401 | return PIX_FMT_NONE; | ||
| 402 | } | ||
| 403 | |||
| 404 | #if HAVE_BIGENDIAN | ||
| 405 | # define X_NE(be, le) be | ||
| 406 | #else | ||
| 407 | # define X_NE(be, le) le | ||
| 408 | #endif | ||
| 409 | |||
| 410 | enum PixelFormat avcodec_get_pix_fmt(const char *name) | 395 | enum PixelFormat avcodec_get_pix_fmt(const char *name) |
| 411 | { | 396 | { |
| 412 | enum PixelFormat pix_fmt; | 397 | return av_get_pix_fmt(name); |
| 413 | |||
| 414 | if (!strcmp(name, "rgb32")) | ||
| 415 | name = X_NE("argb", "bgra"); | ||
| 416 | else if (!strcmp(name, "bgr32")) | ||
| 417 | name = X_NE("abgr", "rgba"); | ||
| 418 | |||
| 419 | pix_fmt = avcodec_get_pix_fmt_internal(name); | ||
| 420 | if (pix_fmt == PIX_FMT_NONE) { | ||
| 421 | char name2[32]; | ||
| 422 | snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le")); | ||
| 423 | pix_fmt = avcodec_get_pix_fmt_internal(name2); | ||
| 424 | } | ||
| 425 | return pix_fmt; | ||
| 426 | } | 398 | } |
| 399 | #endif | ||
| 427 | 400 | ||
| 428 | void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) | 401 | void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) |
| 429 | { | 402 | { |
| @@ -40,7 +40,7 @@ · 39 unmodified lines | |||
| 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) | 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) |
| 41 | 41 | ||
| 42 | #define LIBAVUTIL_VERSION_MAJOR 50 | 42 | #define LIBAVUTIL_VERSION_MAJOR 50 |
| 43 | #define LIBAVUTIL_VERSION_MINOR 7 | 43 | #define LIBAVUTIL_VERSION_MINOR 8 |
| 44 | #define LIBAVUTIL_VERSION_MICRO 0 | 44 | #define LIBAVUTIL_VERSION_MICRO 0 |
| 45 | 45 | ||
| 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -654,6 +654,43 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { · 653 unmodified lines | |||
| 654 | }, | 654 | }, |
| 655 | }; | 655 | }; |
| 656 | 656 | ||
| 657 | static enum PixelFormat get_pix_fmt_internal(const char *name) | ||
| 658 | { | ||
| 659 | enum PixelFormat pix_fmt; | ||
| 660 | |||
| 661 | for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) | ||
| 662 | if (av_pix_fmt_descriptors[pix_fmt].name && | ||
| 663 | !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name)) | ||
| 664 | return pix_fmt; | ||
| 665 | |||
| 666 | return PIX_FMT_NONE; | ||
| 667 | } | ||
| 668 | |||
| 669 | #if HAVE_BIGENDIAN | ||
| 670 | # define X_NE(be, le) be | ||
| 671 | #else | ||
| 672 | # define X_NE(be, le) le | ||
| 673 | #endif | ||
| 674 | |||
| 675 | enum PixelFormat av_get_pix_fmt(const char *name) | ||
| 676 | { | ||
| 677 | enum PixelFormat pix_fmt; | ||
| 678 | |||
| 679 | if (!strcmp(name, "rgb32")) | ||
| 680 | name = X_NE("argb", "bgra"); | ||
| 681 | else if (!strcmp(name, "bgr32")) | ||
| 682 | name = X_NE("abgr", "rgba"); | ||
| 683 | |||
| 684 | pix_fmt = get_pix_fmt_internal(name); | ||
| 685 | if (pix_fmt == PIX_FMT_NONE) { | ||
| 686 | char name2[32]; | ||
| 687 | |||
| 688 | snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le")); | ||
| 689 | pix_fmt = get_pix_fmt_internal(name2); | ||
| 690 | } | ||
| 691 | return pix_fmt; | ||
| 692 | } | ||
| 693 | |||
| 657 | int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) | 694 | int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) |
| 658 | { | 695 | { |
| 659 | int c, bits = 0; | 696 | int c, bits = 0; |
| @@ -202,6 +202,19 @@ static inline void write_line(const uint16_t *src, uint8_t *data[4], const int l · 201 unmodified lines | |||
| 202 | } | 202 | } |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | /** | ||
| 206 | * Returns the pixel format corresponding to name. | ||
| 207 | * | ||
| 208 | * If there is no pixel format with name name, then looks for a | ||
| 209 | * pixel format with the name corresponding to the native endian | ||
| 210 | * format of name. | ||
| 211 | * For example in a little-endian system, first looks for "gray16", | ||
| 212 | * then for "gray16le". | ||
| 213 | * | ||
| 214 | * Finally if no pixel format has been found, returns PIX_FMT_NONE. | ||
| 215 | */ | ||
| 216 | enum PixelFormat av_get_pix_fmt(const char *name); | ||
| 217 | |||
| 205 | /** | 218 | /** |
| 206 | * Returns the number of bits per pixel used by the pixel format | 219 | * Returns the number of bits per pixel used by the pixel format |
| 207 | * described by pixdesc. | 220 | * described by pixdesc. |