]> git.sesse.net Git - ffmpeg/blobdiff - postproc/rgb2rgb.c
support the LE reader, so it can be tested a little
[ffmpeg] / postproc / rgb2rgb.c
index d12b421f6cc0f7263b67dbbd76a198e22c6faf09..fc87b9c02ca992b92ab9265052fdd9018780dc65 100644 (file)
@@ -11,6 +11,7 @@
 #include "../config.h"
 #include "rgb2rgb.h"
 #include "swscale.h"
+#include "../cpudetect.h"
 #include "../mangle.h"
 #include "../bswap.h"
 #include "../libvo/fastmemcpy.h"
@@ -41,6 +42,9 @@ void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size);
 void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
        unsigned int width, unsigned int height,
        int lumStride, int chromStride, int dstStride);
+void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
+       unsigned int width, unsigned int height,
+       int lumStride, int chromStride, int dstStride);
 void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
        unsigned int width, unsigned int height,
        int lumStride, int chromStride, int dstStride);
@@ -65,21 +69,21 @@ void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *sr
                        int srcStride1, int srcStride2,
                        int srcStride3, int dstStride);
 
-#ifdef ARCH_X86
+#if defined(ARCH_X86) || defined(ARCH_X86_64)
 static const uint64_t mmx_null  __attribute__((aligned(8))) = 0x0000000000000000ULL;
 static const uint64_t mmx_one   __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL;
-static const uint64_t mask32b  __attribute__((aligned(8))) = 0x000000FF000000FFULL;
-static const uint64_t mask32g  __attribute__((aligned(8))) = 0x0000FF000000FF00ULL;
-static const uint64_t mask32r  __attribute__((aligned(8))) = 0x00FF000000FF0000ULL;
+static const uint64_t mask32b  attribute_used __attribute__((aligned(8))) = 0x000000FF000000FFULL;
+static const uint64_t mask32g  attribute_used __attribute__((aligned(8))) = 0x0000FF000000FF00ULL;
+static const uint64_t mask32r  attribute_used __attribute__((aligned(8))) = 0x00FF000000FF0000ULL;
 static const uint64_t mask32   __attribute__((aligned(8))) = 0x00FFFFFF00FFFFFFULL;
 static const uint64_t mask3216br __attribute__((aligned(8)))=0x00F800F800F800F8ULL;
 static const uint64_t mask3216g  __attribute__((aligned(8)))=0x0000FC000000FC00ULL;
 static const uint64_t mask3215g  __attribute__((aligned(8)))=0x0000F8000000F800ULL;
 static const uint64_t mul3216  __attribute__((aligned(8))) = 0x2000000420000004ULL;
 static const uint64_t mul3215  __attribute__((aligned(8))) = 0x2000000820000008ULL;
-static const uint64_t mask24b  __attribute__((aligned(8))) = 0x00FF0000FF0000FFULL;
-static const uint64_t mask24g  __attribute__((aligned(8))) = 0xFF0000FF0000FF00ULL;
-static const uint64_t mask24r  __attribute__((aligned(8))) = 0x0000FF0000FF0000ULL;
+static const uint64_t mask24b  attribute_used __attribute__((aligned(8))) = 0x00FF0000FF0000FFULL;
+static const uint64_t mask24g  attribute_used __attribute__((aligned(8))) = 0xFF0000FF0000FF00ULL;
+static const uint64_t mask24r  attribute_used __attribute__((aligned(8))) = 0x0000FF0000FF0000ULL;
 static const uint64_t mask24l  __attribute__((aligned(8))) = 0x0000000000FFFFFFULL;
 static const uint64_t mask24h  __attribute__((aligned(8))) = 0x0000FFFFFF000000ULL;
 static const uint64_t mask24hh  __attribute__((aligned(8))) = 0xffff000000000000ULL;
@@ -101,17 +105,17 @@ static const uint64_t green_15mask __attribute__((aligned(8)))= 0x000003e0000007
 static const uint64_t blue_15mask __attribute__((aligned(8))) = 0x0000001f0000001fULL;
 
 #ifdef FAST_BGR2YV12
-static const uint64_t bgr2YCoeff  __attribute__((aligned(8))) = 0x000000210041000DULL;
-static const uint64_t bgr2UCoeff  __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL;
-static const uint64_t bgr2VCoeff  __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL;
+static const uint64_t bgr2YCoeff  attribute_used __attribute__((aligned(8))) = 0x000000210041000DULL;
+static const uint64_t bgr2UCoeff  attribute_used __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL;
+static const uint64_t bgr2VCoeff  attribute_used __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL;
 #else
-static const uint64_t bgr2YCoeff  __attribute__((aligned(8))) = 0x000020E540830C8BULL;
-static const uint64_t bgr2UCoeff  __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL;
-static const uint64_t bgr2VCoeff  __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL;
+static const uint64_t bgr2YCoeff  attribute_used __attribute__((aligned(8))) = 0x000020E540830C8BULL;
+static const uint64_t bgr2UCoeff  attribute_used __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL;
+static const uint64_t bgr2VCoeff  attribute_used __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL;
 #endif
-static const uint64_t bgr2YOffset __attribute__((aligned(8))) = 0x1010101010101010ULL;
-static const uint64_t bgr2UVOffset __attribute__((aligned(8)))= 0x8080808080808080ULL;
-static const uint64_t w1111       __attribute__((aligned(8))) = 0x0001000100010001ULL;
+static const uint64_t bgr2YOffset attribute_used __attribute__((aligned(8))) = 0x1010101010101010ULL;
+static const uint64_t bgr2UVOffset attribute_used __attribute__((aligned(8)))= 0x8080808080808080ULL;
+static const uint64_t w1111       attribute_used __attribute__((aligned(8))) = 0x0001000100010001ULL;
 
 #if 0
 static volatile uint64_t __attribute__((aligned(8))) b5Dither;
@@ -145,12 +149,11 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
 #undef HAVE_MMX
 #undef HAVE_MMX2
 #undef HAVE_3DNOW
-#undef ARCH_X86
 #undef HAVE_SSE2
 #define RENAME(a) a ## _C
 #include "rgb2rgb_template.c"
 
-#ifdef ARCH_X86
+#if defined(ARCH_X86) || defined(ARCH_X86_64)
 
 //MMX versions
 #undef RENAME
@@ -158,7 +161,6 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
 #undef HAVE_MMX2
 #undef HAVE_3DNOW
 #undef HAVE_SSE2
-#define ARCH_X86
 #define RENAME(a) a ## _MMX
 #include "rgb2rgb_template.c"
 
@@ -168,7 +170,6 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
 #define HAVE_MMX2
 #undef HAVE_3DNOW
 #undef HAVE_SSE2
-#define ARCH_X86
 #define RENAME(a) a ## _MMX2
 #include "rgb2rgb_template.c"
 
@@ -178,11 +179,10 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
 #undef HAVE_MMX2
 #define HAVE_3DNOW
 #undef HAVE_SSE2
-#define ARCH_X86
-#define RENAME(a) a ## _3DNow
+#define RENAME(a) a ## _3DNOW
 #include "rgb2rgb_template.c"
 
-#endif //ARCH_X86
+#endif //ARCH_X86 || ARCH_X86_64
 
 /*
  rgb15->rgb16 Original by Strepto/Astral
@@ -192,7 +192,7 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
 */
 
 void sws_rgb2rgb_init(int flags){
-#ifdef ARCH_X86
+#if defined(ARCH_X86) || defined(ARCH_X86_64)
        if(flags & SWS_CPU_CAPS_MMX2){
                rgb15to16= rgb15to16_MMX2;
                rgb15to24= rgb15to24_MMX2;
@@ -213,10 +213,11 @@ void sws_rgb2rgb_init(int flags){
                rgb32tobgr16= rgb32tobgr16_MMX2;
                rgb32tobgr15= rgb32tobgr15_MMX2;
                yv12toyuy2= yv12toyuy2_MMX2;
+               yv12touyvy= yv12touyvy_MMX2;
                yuv422ptoyuy2= yuv422ptoyuy2_MMX2;
                yuy2toyv12= yuy2toyv12_MMX2;
-               uyvytoyv12= uyvytoyv12_MMX2;
-               yvu9toyv12= yvu9toyv12_MMX2;
+//             uyvytoyv12= uyvytoyv12_MMX2;
+//             yvu9toyv12= yvu9toyv12_MMX2;
                planar2x= planar2x_MMX2;
                rgb24toyv12= rgb24toyv12_MMX2;
                interleaveBytes= interleaveBytes_MMX2;
@@ -242,10 +243,11 @@ void sws_rgb2rgb_init(int flags){
                rgb32tobgr16= rgb32tobgr16_3DNOW;
                rgb32tobgr15= rgb32tobgr15_3DNOW;
                yv12toyuy2= yv12toyuy2_3DNOW;
+               yv12touyvy= yv12touyvy_3DNOW;
                yuv422ptoyuy2= yuv422ptoyuy2_3DNOW;
                yuy2toyv12= yuy2toyv12_3DNOW;
-               uyvytoyv12= uyvytoyv12_3DNOW;
-               yvu9toyv12= yvu9toyv12_3DNOW;
+//             uyvytoyv12= uyvytoyv12_3DNOW;
+//             yvu9toyv12= yvu9toyv12_3DNOW;
                planar2x= planar2x_3DNOW;
                rgb24toyv12= rgb24toyv12_3DNOW;
                interleaveBytes= interleaveBytes_3DNOW;
@@ -271,10 +273,11 @@ void sws_rgb2rgb_init(int flags){
                rgb32tobgr16= rgb32tobgr16_MMX;
                rgb32tobgr15= rgb32tobgr15_MMX;
                yv12toyuy2= yv12toyuy2_MMX;
+               yv12touyvy= yv12touyvy_MMX;
                yuv422ptoyuy2= yuv422ptoyuy2_MMX;
                yuy2toyv12= yuy2toyv12_MMX;
-               uyvytoyv12= uyvytoyv12_MMX;
-               yvu9toyv12= yvu9toyv12_MMX;
+//             uyvytoyv12= uyvytoyv12_MMX;
+//             yvu9toyv12= yvu9toyv12_MMX;
                planar2x= planar2x_MMX;
                rgb24toyv12= rgb24toyv12_MMX;
                interleaveBytes= interleaveBytes_MMX;
@@ -302,6 +305,7 @@ void sws_rgb2rgb_init(int flags){
                rgb32tobgr16= rgb32tobgr16_C;
                rgb32tobgr15= rgb32tobgr15_C;
                yv12toyuy2= yv12toyuy2_C;
+               yv12touyvy= yv12touyvy_C;
                yuv422ptoyuy2= yuv422ptoyuy2_C;
                yuy2toyv12= yuy2toyv12_C;
 //             uyvytoyv12= uyvytoyv12_C;
@@ -328,11 +332,17 @@ void palette8torgb32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, cons
 
        for(i=0; i<num_pixels; i++)
        {
+               #ifdef WORDS_BIGENDIAN
+               dst[3]= palette[ src[i]*4+2 ];
+               dst[2]= palette[ src[i]*4+1 ];
+               dst[1]= palette[ src[i]*4+0 ];
+               #else
                //FIXME slow?
                dst[0]= palette[ src[i]*4+2 ];
                dst[1]= palette[ src[i]*4+1 ];
                dst[2]= palette[ src[i]*4+0 ];
 //             dst[3]= 0; /* do we need this cleansing? */
+               #endif
                dst+= 4;
        }
 }
@@ -342,11 +352,18 @@ void palette8tobgr32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, cons
        unsigned i;
        for(i=0; i<num_pixels; i++)
        {
+               #ifdef WORDS_BIGENDIAN
+               dst[3]= palette[ src[i]*4+0 ];
+               dst[2]= palette[ src[i]*4+1 ];
+               dst[1]= palette[ src[i]*4+2 ];
+               #else
                //FIXME slow?
                dst[0]= palette[ src[i]*4+0 ];
                dst[1]= palette[ src[i]*4+1 ];
                dst[2]= palette[ src[i]*4+2 ];
 //             dst[3]= 0; /* do we need this cleansing? */
+               #endif
+               
                dst+= 4;
        }
 }