]> git.sesse.net Git - ffmpeg/blobdiff - libswscale/yuv2rgb.c
swscale: remove if(bitexact) branch from functions.
[ffmpeg] / libswscale / yuv2rgb.c
index 8ea41af79b1d04c46d72cf49da11e398941c9be4..a502f654ed48164f3a84ebfb36ac8bc6e4aca87f 100644 (file)
@@ -32,7 +32,7 @@
 #include "rgb2rgb.h"
 #include "swscale.h"
 #include "swscale_internal.h"
-#include "libavutil/x86_cpu.h"
+#include "libavutil/cpu.h"
 #include "libavutil/bswap.h"
 
 extern const uint8_t dither_4x4_16[4][8];
@@ -99,6 +99,16 @@ const int *sws_getCoefficients(int colorspace)
     dst[12*i+ 8] = dst[12*i+ 9] = g[Y]; \
     dst[12*i+10] = dst[12*i+11] = b[Y];
 
+#define PUTBGR48(dst,src,i)             \
+    Y = src[2*i];                       \
+    dst[12*i+ 0] = dst[12*i+ 1] = b[Y]; \
+    dst[12*i+ 2] = dst[12*i+ 3] = g[Y]; \
+    dst[12*i+ 4] = dst[12*i+ 5] = r[Y]; \
+    Y = src[2*i+1];                     \
+    dst[12*i+ 6] = dst[12*i+ 7] = b[Y]; \
+    dst[12*i+ 8] = dst[12*i+ 9] = g[Y]; \
+    dst[12*i+10] = dst[12*i+11] = r[Y];
+
 #define YUV2RGBFUNC(func_name, dst_type, alpha) \
 static int func_name(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, \
                      int srcSliceH, uint8_t* dst[], int dstStride[]) \
@@ -175,6 +185,32 @@ ENDYUV2RGBLINE(48)
     PUTRGB48(dst_1,py_1,1);
 ENDYUV2RGBFUNC()
 
+YUV2RGBFUNC(yuv2rgb_c_bgr48, uint8_t, 0)
+    LOADCHROMA(0);
+    PUTBGR48(dst_1,py_1,0);
+    PUTBGR48(dst_2,py_2,0);
+
+    LOADCHROMA(1);
+    PUTBGR48(dst_2,py_2,1);
+    PUTBGR48(dst_1,py_1,1);
+
+    LOADCHROMA(2);
+    PUTBGR48(dst_1,py_1,2);
+    PUTBGR48(dst_2,py_2,2);
+
+    LOADCHROMA(3);
+    PUTBGR48(dst_2,py_2,3);
+    PUTBGR48(dst_1,py_1,3);
+ENDYUV2RGBLINE(48)
+    LOADCHROMA(0);
+    PUTBGR48(dst_1,py_1,0);
+    PUTBGR48(dst_2,py_2,0);
+
+    LOADCHROMA(1);
+    PUTBGR48(dst_2,py_2,1);
+    PUTBGR48(dst_1,py_1,1);
+ENDYUV2RGBFUNC()
+
 YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0)
     LOADCHROMA(0);
     PUTRGB(dst_1,py_1,0);
@@ -543,24 +579,18 @@ CLOSEYUV2RGBFUNC(1)
 SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
 {
     SwsFunc t = NULL;
-#if HAVE_MMX
-     t = ff_yuv2rgb_init_mmx(c);
-#endif
-#if HAVE_VIS
-    t = ff_yuv2rgb_init_vis(c);
-#endif
-#if CONFIG_MLIB
-    t = ff_yuv2rgb_init_mlib(c);
-#endif
-#if HAVE_ALTIVEC
-    if (c->flags & SWS_CPU_CAPS_ALTIVEC)
-        t = ff_yuv2rgb_init_altivec(c);
-#endif
 
-#if ARCH_BFIN
-    if (c->flags & SWS_CPU_CAPS_BFIN)
+    if (HAVE_MMX) {
+        t = ff_yuv2rgb_init_mmx(c);
+    } else if (HAVE_VIS) {
+        t = ff_yuv2rgb_init_vis(c);
+    } else if (CONFIG_MLIB) {
+        t = ff_yuv2rgb_init_mlib(c);
+    } else if (HAVE_ALTIVEC) {
+        t = ff_yuv2rgb_init_altivec(c);
+    } else if (ARCH_BFIN) {
         t = ff_yuv2rgb_get_func_ptr_bfin(c);
-#endif
+    }
 
     if (t)
         return t;
@@ -568,6 +598,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
     av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found from %s to %s.\n", sws_format_name(c->srcFormat), sws_format_name(c->dstFormat));
 
     switch (c->dstFormat) {
+    case PIX_FMT_BGR48BE:
+    case PIX_FMT_BGR48LE:    return yuv2rgb_c_bgr48;
     case PIX_FMT_RGB48BE:
     case PIX_FMT_RGB48LE:    return yuv2rgb_c_48;
     case PIX_FMT_ARGB: