swscale: add support for endianness only conversion
authorJanne Grunau <janne-libav@jannau.net>
Fri, 26 Apr 2013 12:47:08 +0000 (14:47 +0200)
committerJanne Grunau <janne-libav@jannau.net>
Mon, 6 May 2013 16:55:58 +0000 (18:55 +0200)
Use bitfields in FormatEntry array to avoid wasting an int for each flag.

libswscale/swscale.h
libswscale/utils.c
libswscale/version.h

index 8ba09e6960456dae34848238a9fbc63a6940a7bf..e69a69461bd3996c6f064cae2fd30407eb445987 100644 (file)
@@ -140,6 +140,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
index 93cb60fdf1999477df9c5dc7cb2a3fecab7d31df..538a3df665152274fe9ede58a8cd5a1ebabd5772 100644 (file)
@@ -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          |
index acbdf6b012eafcef56b706c292be40f494e05c9d..54836739c09e41bc378ef57bf8be33e4893e3140 100644 (file)
@@ -28,7 +28,7 @@
 
 #define LIBSWSCALE_VERSION_MAJOR 2
 #define LIBSWSCALE_VERSION_MINOR 1
-#define LIBSWSCALE_VERSION_MICRO 1
+#define LIBSWSCALE_VERSION_MICRO 2
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
                                                LIBSWSCALE_VERSION_MINOR, \