slouken@libsdl.org
#include "SDL_config.h"
#if 0 FIXME:http://www.gentoo.org/proj/en/hardened/pic-fix-guide.xmlhttp://nasm.sourceforge.net/doc/html/nasmdoc8.html
#if defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES
#include "SDL_stdinc.h"
#define ASM_ARRAY(x) x[] __asm__("_" #x) __attribute__((used))
static unsigned int ASM_ARRAY(MMX_0080w) = {0x00800080, 0x00800080};
static unsigned int ASM_ARRAY(MMX_00FFw) = {0x00ff00ff, 0x00ff00ff};
static unsigned int ASM_ARRAY(MMX_FF00w) = {0xff00ff00, 0xff00ff00};
static unsigned short ASM_ARRAY(MMX_Ycoeff) = {0x004a, 0x004a, 0x004a, 0x004a};
static unsigned short ASM_ARRAY(MMX_UbluRGB) = {0x0072, 0x0072, 0x0072, 0x0072};
static unsigned short ASM_ARRAY(MMX_VredRGB) = {0x0059, 0x0059, 0x0059, 0x0059};
static unsigned short ASM_ARRAY(MMX_UgrnRGB) = {0xffea, 0xffea, 0xffea, 0xffea};
static unsigned short ASM_ARRAY(MMX_VgrnRGB) = {0xffd2, 0xffd2, 0xffd2, 0xffd2};
static unsigned short ASM_ARRAY(MMX_Ublu5x5) = {0x0081, 0x0081, 0x0081, 0x0081};
static unsigned short ASM_ARRAY(MMX_Vred5x5) = {0x0066, 0x0066, 0x0066, 0x0066};
static unsigned short ASM_ARRAY(MMX_Ugrn555) = {0xffe7, 0xffe7, 0xffe7, 0xffe7};
static unsigned short ASM_ARRAY(MMX_Vgrn555) = {0xffcc, 0xffcc, 0xffcc, 0xffcc};
static unsigned short ASM_ARRAY(MMX_Ugrn565) = {0xffe8, 0xffe8, 0xffe8, 0xffe8};
static unsigned short ASM_ARRAY(MMX_Vgrn565) = {0xffcd, 0xffcd, 0xffcd, 0xffcd};
static unsigned short ASM_ARRAY(MMX_red555) = {0x7c00, 0x7c00, 0x7c00, 0x7c00};
static unsigned short ASM_ARRAY(MMX_red565) = {0xf800, 0xf800, 0xf800, 0xf800};
static unsigned short ASM_ARRAY(MMX_grn555) = {0x03e0, 0x03e0, 0x03e0, 0x03e0};
static unsigned short ASM_ARRAY(MMX_grn565) = {0x07e0, 0x07e0, 0x07e0, 0x07e0};
static unsigned short ASM_ARRAY(MMX_blu5x5) = {0x001f, 0x001f, 0x001f, 0x001f};
mvogt@rhrk.uni-kl.de
void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
unsigned char *lum, unsigned char *cr,
unsigned char *cb, unsigned char *out,
int rows, int cols, int mod )
{
Uint32 *row1;
Uint32 *row2;
unsigned char* y = lum +cols*rows;
int x=0;
row1 = (Uint32 *)out;
row2 = (Uint32 *)out+cols+mod;
mod = (mod+cols+mod)*4;
__asm__ __volatile__ (
"pushl %%ebx\n"
"movl %0, %%ebx\n"
".align 8\n"
"1:\n"
"movd (%%ebx), %%mm1\n"
"pxor %%mm7,%%mm7\n"
"movd (%2), %%mm2\n"
"punpcklbw %%mm7,%%mm1\n"
"punpckldq %%mm1,%%mm1\n"
"psubw _MMX_0080w,%%mm1\n"
"movq %%mm1,%%mm0\n"
"pmullw _MMX_VgrnRGB,%%mm0\n"
"pmullw _MMX_VredRGB,%%mm1\n"
"psraw $6, %%mm0\n"
"psraw $6, %%mm1\n"
"movq (%2,%4),%%mm3\n"
"punpckldq %%mm3,%%mm2\n"
"movq %%mm2,%%mm4\n"
"pand _MMX_FF00w,%%mm2\n"
"pand _MMX_00FFw,%%mm4\n"
"psrlw $8,%%mm2\n"
"movq %%mm2,%%mm5\n"
"movq %%mm4,%%mm6\n"
"paddsw %%mm1, %%mm5\n"
"paddsw %%mm1, %%mm6\n"
"packuswb %%mm5,%%mm5\n"
"packuswb %%mm6,%%mm6\n"
"pxor %%mm7,%%mm7\n"
"punpcklbw %%mm5,%%mm6\n"
"movd (%1), %%mm1\n"
"punpcklbw %%mm7,%%mm1\n"
"punpckldq %%mm1,%%mm1\n"
"psubw _MMX_0080w,%%mm1\n"
"movq %%mm1,%%mm5\n"
"pmullw _MMX_UgrnRGB,%%mm5\n"
"pmullw _MMX_UbluRGB,%%mm1\n"
"psraw $6, %%mm5\n"
"psraw $6, %%mm1\n"
"movq %%mm2,%%mm3\n"
"movq %%mm4,%%mm7\n"
"paddsw %%mm5, %%mm3\n"
"paddsw %%mm5, %%mm7\n"
"paddsw %%mm0, %%mm3\n"
"paddsw %%mm0, %%mm7\n"
"packuswb %%mm3,%%mm3\n"
"packuswb %%mm7,%%mm7\n"
"punpcklbw %%mm3,%%mm7\n"
"movq %%mm2,%%mm3\n"
"movq %%mm4,%%mm5\n"
"paddsw %%mm1, %%mm3\n"
"paddsw %%mm1, %%mm5\n"
"packuswb %%mm3,%%mm3\n"
"packuswb %%mm5,%%mm5\n"
"punpcklbw %%mm3,%%mm5\n"
"pxor %%mm2,%%mm2\n"
"pxor %%mm4,%%mm4\n"
"movq %%mm6,%%mm1\n"
"movq %%mm5,%%mm3\n"
"punpcklbw %%mm4,%%mm1\n"
"punpcklbw %%mm4,%%mm3\n"
"movq %%mm1,%%mm2\n"
"movq %%mm3,%%mm0\n"
"punpcklwd %%mm1,%%mm3\n"
"punpckhwd %%mm2,%%mm0\n"
"pxor %%mm2,%%mm2\n"
"movq %%mm7,%%mm1\n"
"punpcklbw %%mm1,%%mm2\n"
"punpcklwd %%mm4,%%mm2\n"
"por %%mm3, %%mm2\n"
"movq %%mm2,(%3)\n"
"pxor %%mm2,%%mm2\n"
"punpcklbw %%mm1,%%mm4\n"
"punpckhwd %%mm2,%%mm4\n"
"por %%mm0, %%mm4\n"
"movq %%mm4,8(%3)\n"
"pxor %%mm2,%%mm2\n"
"punpckhbw %%mm2,%%mm6\n"
"punpckhbw %%mm1,%%mm5\n"
"movq %%mm5,%%mm1\n"
"punpcklwd %%mm6,%%mm1\n"
"movq %%mm1,(%5)\n"
"punpckhwd %%mm6,%%mm5\n"
"movq %%mm5,8(%5)\n"
"addl $4,%2\n"
"leal 16(%3),%3\n"
"leal 16(%5),%5\n"
"addl $2, %%ebx\n"
"addl $2, %1\n"
"addl $4,%6\n"
"cmpl %4,%6\n"
"jl 1b\n"
"addl %4, %2\n"
"addl %8, %3\n"
"addl %8, %5\n"
"movl $0, %6\n"
"cmpl %7, %2\n"
"jl 1b\n"
"emms\n"
"popl %%ebx\n"
:
: "m" (cr), "r"(cb),"r"(lum),
"r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
}
void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
unsigned char *lum, unsigned char *cr,
unsigned char *cb, unsigned char *out,
int rows, int cols, int mod )
{
Uint16 *row1;
Uint16 *row2;
unsigned char* y = lum +cols*rows;
int x=0;
row1 = (Uint16 *)out;
row2 = (Uint16 *)out+cols+mod;
mod = (mod+cols+mod)*2;
__asm__ __volatile__(
"pushl %%ebx\n"
"movl %0, %%ebx\n"
".align 8\n"
"1:\n"
"movd (%1), %%mm0\n"
"pxor %%mm7, %%mm7\n"
"movd (%%ebx), %%mm1\n"
"punpcklbw %%mm7, %%mm0\n"
"punpcklbw %%mm7, %%mm1\n"
"psubw _MMX_0080w, %%mm0\n"
"psubw _MMX_0080w, %%mm1\n"
"movq %%mm0, %%mm2\n"
"movq %%mm1, %%mm3\n"
"pmullw _MMX_Ugrn565, %%mm2\n"
"movq (%2), %%mm6\n"
"pmullw _MMX_Ublu5x5, %%mm0\n"
"pand _MMX_00FFw, %%mm6\n"
"pmullw _MMX_Vgrn565, %%mm3\n"
"movq (%2), %%mm7\n"
"pmullw _MMX_Vred5x5, %%mm1\n"
"psrlw $8, %%mm7\n"
"pmullw _MMX_Ycoeff, %%mm6\n"
"paddw %%mm3, %%mm2\n"
"pmullw _MMX_Ycoeff, %%mm7\n"
"movq %%mm6, %%mm4\n"
"paddw %%mm0, %%mm6\n"
"movq %%mm4, %%mm5\n"
"paddw %%mm1, %%mm4\n"
"paddw %%mm2, %%mm5\n"
"psraw $6, %%mm4\n"
"movq %%mm7, %%mm3\n"
"psraw $6, %%mm5\n"
"paddw %%mm0, %%mm7\n"
"psraw $6, %%mm6\n"
"packuswb %%mm4, %%mm4\n"
"packuswb %%mm5, %%mm5\n"
"packuswb %%mm6, %%mm6\n"
"punpcklbw %%mm4, %%mm4\n"
"punpcklbw %%mm5, %%mm5\n"
"pand _MMX_red565, %%mm4\n"
"psllw $3, %%mm5\n"
"punpcklbw %%mm6, %%mm6\n"
"pand _MMX_grn565, %%mm5\n"
"pand _MMX_red565, %%mm6\n"
"por %%mm5, %%mm4\n"
"psrlw $11, %%mm6\n"
"movq %%mm3, %%mm5\n"
"paddw %%mm1, %%mm3\n"
"paddw %%mm2, %%mm5\n"
"psraw $6, %%mm3\n"
"por %%mm6, %%mm4\n"
"psraw $6, %%mm5\n"
"movq (%2, %4), %%mm6\n"
"psraw $6, %%mm7\n"
"packuswb %%mm3, %%mm3\n"
"packuswb %%mm5, %%mm5\n"
"packuswb %%mm7, %%mm7\n"
"pand _MMX_00FFw, %%mm6\n"
"punpcklbw %%mm3, %%mm3\n"
"punpcklbw %%mm5, %%mm5\n"
"pmullw _MMX_Ycoeff, %%mm6\n"
"punpcklbw %%mm7, %%mm7\n"
"psllw $3, %%mm5\n"
"pand _MMX_red565, %%mm7\n"
"pand _MMX_red565, %%mm3\n"
"psrlw $11, %%mm7\n"
"pand _MMX_grn565, %%mm5\n"
"por %%mm7, %%mm3\n"
"movq (%2,%4), %%mm7\n"
"por %%mm5, %%mm3\n"
"psrlw $8, %%mm7\n"
"movq %%mm4, %%mm5\n"
"punpcklwd %%mm3, %%mm4\n"
"pmullw _MMX_Ycoeff, %%mm7\n"
"punpckhwd %%mm3, %%mm5\n"
"movq %%mm4, (%3)\n"
"movq %%mm5, 8(%3)\n"
"movq %%mm6, %%mm4\n"
"paddw %%mm0, %%mm6\n"
"movq %%mm4, %%mm5\n"
"paddw %%mm1, %%mm4\n"
"paddw %%mm2, %%mm5\n"
"psraw $6, %%mm4\n"
"movq %%mm7, %%mm3\n"
"psraw $6, %%mm5\n"
"paddw %%mm0, %%mm7\n"
"psraw $6, %%mm6\n"
"movq %%mm3, %%mm0\n"
"packuswb %%mm4, %%mm4\n"
"paddw %%mm1, %%mm3\n"
"packuswb %%mm5, %%mm5\n"
"paddw %%mm2, %%mm0\n"
"packuswb %%mm6, %%mm6\n"
"punpcklbw %%mm4, %%mm4\n"
"punpcklbw %%mm5, %%mm5\n"
"punpcklbw %%mm6, %%mm6\n"
"psllw $3, %%mm5\n"
"pand _MMX_red565, %%mm4\n"
"psraw $6, %%mm3\n"
"psraw $6, %%mm0\n"
"pand _MMX_red565, %%mm6\n"
"pand _MMX_grn565, %%mm5\n"
"psrlw $11, %%mm6\n"
"por %%mm5, %%mm4\n"
"psraw $6, %%mm7\n"
"por %%mm6, %%mm4\n"
"packuswb %%mm3, %%mm3\n"
"packuswb %%mm0, %%mm0\n"
"packuswb %%mm7, %%mm7\n"
"punpcklbw %%mm3, %%mm3\n"
"punpcklbw %%mm0, %%mm0\n"
"punpcklbw %%mm7, %%mm7\n"
"pand _MMX_red565, %%mm3\n"
"pand _MMX_red565, %%mm7\n"
"psllw $3, %%mm0\n"
"psrlw $11, %%mm7\n"
"pand _MMX_grn565, %%mm0\n"
"por %%mm7, %%mm3\n"
"por %%mm0, %%mm3\n"
"movq %%mm4, %%mm5\n"
"punpcklwd %%mm3, %%mm4\n"
"punpckhwd %%mm3, %%mm5\n"
"movq %%mm4, (%5)\n"
"movq %%mm5, 8(%5)\n"
"addl $8, %6\n"
"addl $8, %2\n"
"addl $4, %%ebx\n"
"addl $4, %1\n"
"cmpl %4, %6\n"
"leal 16(%3), %3\n"
"leal 16(%5),%5\n"
"jl 1b\n"
"addl %4, %2\n"
"addl %8, %3\n"
"addl %8, %5\n"
"movl $0, %6\n"
"cmpl %7, %2\n"
"jl 1b\n"
"emms\n"
"popl %%ebx\n"
:
:"m" (cr), "r"(cb),"r"(lum),
"r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
}
#endif
#endif