diff options
author | Janne Grunau <janne-libav@jannau.net> | 2013-04-26 14:47:08 +0200 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2013-05-06 18:55:58 +0200 |
commit | c1eb3e7fecdc270e03a700d61ef941600a6af491 (patch) | |
tree | 2a280b28311debfd7f8dc9812280473cd3eb0706 /libswscale/utils.c | |
parent | 74652af821d7e526a6541876a637fbf81261fa8e (diff) | |
download | ffmpeg-c1eb3e7fecdc270e03a700d61ef941600a6af491.tar.gz |
swscale: add support for endianness only conversion
Use bitfields in FormatEntry array to avoid wasting an int for each flag.
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r-- | libswscale/utils.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c index 93cb60fdf1..538a3df665 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) @@ -880,6 +888,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, unscaled = (srcW == dstW && srcH == dstH); + 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", sws_format_name(srcFormat)); @@ -890,6 +900,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, sws_format_name(dstFormat)); return AVERROR(EINVAL); } + } i = flags & (SWS_POINT | SWS_AREA | |