diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-05-07 10:59:26 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-05-07 11:04:07 +0200 |
commit | 2060d944090f10fb60e5c0ac42b7a946b9d5859f (patch) | |
tree | bb3f3548cd807a25de3a5cb5e6140f4e00c6e58b | |
parent | 60fd88059a62c9237893ff6d159c28cd929aadf0 (diff) | |
parent | c1eb3e7fecdc270e03a700d61ef941600a6af491 (diff) | |
download | ffmpeg-2060d944090f10fb60e5c0ac42b7a946b9d5859f.tar.gz |
Merge commit 'c1eb3e7fecdc270e03a700d61ef941600a6af491'
* commit 'c1eb3e7fecdc270e03a700d61ef941600a6af491':
swscale: add support for endianness only conversion
Conflicts:
libswscale/utils.c
libswscale/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libswscale/swscale.h | 7 | ||||
-rw-r--r-- | libswscale/utils.c | 13 | ||||
-rw-r--r-- | libswscale/version.h | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 5f6ae0ff46..42702b7aa2 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -147,6 +147,13 @@ int sws_isSupportedInput(enum AVPixelFormat pix_fmt); int sws_isSupportedOutput(enum AVPixelFormat pix_fmt); /** + * @param[in] pix_fmt the pixel format + * @return a positive value if an endianness conversion for pix_fmt is + * supported, 0 otherwise. + */ +int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt); + +/** * Allocate an empty SwsContext. This must be filled and passed to * sws_init_context(). For filling see AVOptions, options.c and * sws_setColorspaceDetails(). diff --git a/libswscale/utils.c b/libswscale/utils.c index 1ce9576cb2..7ba50a11ac 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -72,7 +72,9 @@ const char *swscale_license(void) #define RET 0xC3 // near return opcode for x86 typedef struct FormatEntry { - int is_supported_in, is_supported_out; + uint8_t is_supported_in :1; + uint8_t is_supported_out :1; + uint8_t is_supported_endianness :1; } FormatEntry; static const FormatEntry format_entries[AV_PIX_FMT_NB] = { @@ -215,6 +217,12 @@ int sws_isSupportedOutput(enum AVPixelFormat pix_fmt) format_entries[pix_fmt].is_supported_out : 0; } +int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt) +{ + return (unsigned)pix_fmt < AV_PIX_FMT_NB ? + format_entries[pix_fmt].is_supported_endianness : 0; +} + extern const int32_t ff_yuv2rgb_coeffs[8][4]; #if FF_API_SWS_FORMAT_NAME @@ -1077,6 +1085,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, c->dstFormat= dstFormat; } + if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) && + av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) { if (!sws_isSupportedInput(srcFormat)) { av_log(c, AV_LOG_ERROR, "%s is not supported as input pixel format\n", av_get_pix_fmt_name(srcFormat)); @@ -1087,6 +1097,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, av_get_pix_fmt_name(dstFormat)); return AVERROR(EINVAL); } + } i = flags & (SWS_POINT | SWS_AREA | diff --git a/libswscale/version.h b/libswscale/version.h index c430f2def8..f635e3d0a7 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -27,7 +27,7 @@ #include "libavutil/avutil.h" #define LIBSWSCALE_VERSION_MAJOR 2 -#define LIBSWSCALE_VERSION_MINOR 2 +#define LIBSWSCALE_VERSION_MINOR 3 #define LIBSWSCALE_VERSION_MICRO 100 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ |