lsws/rgb2rgb: Add unscaled 48bit to 64bit rgb conversion.
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>
Wed, 23 Aug 2017 12:19:14 +0000 (14:19 +0200)
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>
Thu, 24 Aug 2017 10:50:06 +0000 (12:50 +0200)
Based on b4befca2 and 6b7849e6 by Paul B Mahol.

Fixes ticket #6608.

libswscale/rgb2rgb.c
libswscale/rgb2rgb.h
libswscale/swscale_unscaled.c
libswscale/version.h

index f7f8188..04b7908 100644 (file)
@@ -391,3 +391,41 @@ void rgb64to48_ ## need_bswap(const uint8_t *src,                       \
 
 DEFINE_RGB64TO48(nobswap, 0)
 DEFINE_RGB64TO48(bswap, 1)
+
+#define DEFINE_RGB48TOBGR64(need_bswap, swap)                           \
+void rgb48tobgr64_ ## need_bswap(const uint8_t *src,                    \
+                                 uint8_t *dst, int src_size)            \
+{                                                                       \
+    uint16_t *d = (uint16_t *)dst;                                      \
+    uint16_t *s = (uint16_t *)src;                                      \
+    int i, num_pixels = src_size / 6;                                   \
+                                                                        \
+    for (i = 0; i < num_pixels; i++) {                                  \
+        d[4 * i    ] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2];  \
+        d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1];  \
+        d[4 * i + 2] = swap ? av_bswap16(s[3 * i    ]) : s[3 * i    ];  \
+        d[4 * i + 3] = 0xFFFF;                                          \
+    }                                                                   \
+}
+
+DEFINE_RGB48TOBGR64(nobswap, 0)
+DEFINE_RGB48TOBGR64(bswap, 1)
+
+#define DEFINE_RGB48TO64(need_bswap, swap)                              \
+void rgb48to64_ ## need_bswap(const uint8_t *src,                       \
+                              uint8_t *dst, int src_size)               \
+{                                                                       \
+    uint16_t *d = (uint16_t *)dst;                                      \
+    uint16_t *s = (uint16_t *)src;                                      \
+    int i, num_pixels = src_size / 6;                                   \
+                                                                        \
+    for (i = 0; i < num_pixels; i++) {                                  \
+        d[4 * i    ] = swap ? av_bswap16(s[3 * i    ]) : s[3 * i    ];  \
+        d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1];  \
+        d[4 * i + 2] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2];  \
+        d[4 * i + 3] = 0xFFFF;                                          \
+    }                                                                   \
+}
+
+DEFINE_RGB48TO64(nobswap, 0)
+DEFINE_RGB48TO64(bswap, 1)
index 0645404..6994839 100644 (file)
@@ -59,6 +59,10 @@ void rgb48tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
 void   rgb48tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
 void    rgb64to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
 void      rgb64to48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
+void rgb48tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
+void   rgb48tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size);
+void    rgb48to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
+void      rgb48to64_bswap(const uint8_t *src, uint8_t *dst, int src_size);
 void    rgb24to32(const uint8_t *src, uint8_t *dst, int src_size);
 void    rgb32to24(const uint8_t *src, uint8_t *dst, int src_size);
 void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size);
index 3b1b366..ef36aec 100644 (file)
@@ -1292,6 +1292,23 @@ static rgbConvFn findRgbConvFn(SwsContext *c)
               || CONV_IS(BGR48LE, RGB48BE)
               || CONV_IS(RGB48BE, BGR48LE)
               || CONV_IS(BGR48BE, RGB48LE)) conv = rgb48tobgr48_bswap;
+    } else if (isRGB48(srcFormat) && isRGBA64(dstFormat)) {
+        if      (CONV_IS(RGB48LE, BGRA64LE)
+              || CONV_IS(BGR48LE, RGBA64LE)
+              || CONV_IS(RGB48BE, BGRA64BE)
+              || CONV_IS(BGR48BE, RGBA64BE)) conv = rgb48tobgr64_nobswap;
+        else if (CONV_IS(RGB48LE, BGRA64BE)
+              || CONV_IS(BGR48LE, RGBA64BE)
+              || CONV_IS(RGB48BE, BGRA64LE)
+              || CONV_IS(BGR48BE, RGBA64LE)) conv = rgb48tobgr64_bswap;
+        if      (CONV_IS(RGB48LE, RGBA64LE)
+              || CONV_IS(BGR48LE, BGRA64LE)
+              || CONV_IS(RGB48BE, RGBA64BE)
+              || CONV_IS(BGR48BE, BGRA64BE)) conv = rgb48to64_nobswap;
+        else if (CONV_IS(RGB48LE, RGBA64BE)
+              || CONV_IS(BGR48LE, BGRA64BE)
+              || CONV_IS(RGB48BE, RGBA64LE)
+              || CONV_IS(BGR48BE, BGRA64LE)) conv = rgb48to64_bswap;
     } else if (isRGBA64(srcFormat) && isRGB48(dstFormat)) {
         if      (CONV_IS(RGBA64LE, BGR48LE)
               || CONV_IS(BGRA64LE, RGB48LE)
index 8dff77e..dcf7959 100644 (file)
@@ -28,7 +28,7 @@
 
 #define LIBSWSCALE_VERSION_MAJOR   4
 #define LIBSWSCALE_VERSION_MINOR   7
-#define LIBSWSCALE_VERSION_MICRO 102
+#define LIBSWSCALE_VERSION_MICRO 103
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
                                                LIBSWSCALE_VERSION_MINOR, \