On Fri, 26 Apr 2013, Janne Grunau wrote:
Converting FormatEntry to bitfields. --- libswscale/swscale.h | 7 +++++++ libswscale/utils.c | 13 ++++++++++++- libswscale/version.h | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-)diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 8ba09e6..89cfa67 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -141,6 +141,13 @@ int sws_isSupportedInput(enum AVPixelFormat pix_fmt); int sws_isSupportedOutput(enum AVPixelFormat pix_fmt); /** + * 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 6bbdb64..d974074 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -70,7 +70,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] = { @@ -184,6 +186,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]; const char *sws_format_name(enum AVPixelFormat format) @@ -879,6 +887,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, unscaled = (srcW == dstW && srcH == dstH); + if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) && + av_pix_fmt_equal_except_endianness(srcFormat, dstFormat))) {
Could this share the pixel format check with swscale_unscaled.c in some way, to avoid having to add the public function with known flaws?
// Martin _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
