indent doesn't know how to handle inline asm
authorSam Lantinga <slouken@libsdl.org>
Wed, 11 Jul 2007 04:47:25 +0000
changeset 21678f2174e22cd5
parent 2166 711bea885c1e
child 2168 07f084fe97d0
indent doesn't know how to handle inline asm
src/video/SDL_yuv_mmx.c
     1.1 --- a/src/video/SDL_yuv_mmx.c	Tue Jul 10 20:16:35 2007 +0000
     1.2 +++ b/src/video/SDL_yuv_mmx.c	Wed Jul 11 04:47:25 2007 +0000
     1.3 @@ -21,55 +21,38 @@
     1.4  */
     1.5  #include "SDL_config.h"
     1.6  
     1.7 -#if 0                           /* FIXME: This code needs to be rewritten to reference the static data using relocatable addresses (e.g. http://www.gentoo.org/proj/en/hardened/pic-fix-guide.xml or http://nasm.sourceforge.net/doc/html/nasmdoc8.html#section-8.2) This code currently breaks on systems with readonly text segments (hardened Linux / Intel Mac) */
     1.8 +/* *INDENT-OFF* */
     1.9 +
    1.10 +#if 0 /* FIXME: This code needs to be rewritten to reference the static data using relocatable addresses (e.g. http://www.gentoo.org/proj/en/hardened/pic-fix-guide.xml or http://nasm.sourceforge.net/doc/html/nasmdoc8.html#section-8.2) This code currently breaks on systems with readonly text segments (hardened Linux / Intel Mac) */
    1.11  #if defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES
    1.12  
    1.13  #include "SDL_stdinc.h"
    1.14  
    1.15  #define ASM_ARRAY(x) x[] __asm__("_" #x) __attribute__((used))
    1.16 + 
    1.17 +static unsigned int  ASM_ARRAY(MMX_0080w)    = {0x00800080, 0x00800080};
    1.18 +static unsigned int  ASM_ARRAY(MMX_00FFw)    = {0x00ff00ff, 0x00ff00ff};
    1.19 +static unsigned int  ASM_ARRAY(MMX_FF00w)    = {0xff00ff00, 0xff00ff00};
    1.20  
    1.21 -static unsigned int ASM_ARRAY(MMX_0080w) = {
    1.22 -0x00800080, 0x00800080};
    1.23 -static unsigned int ASM_ARRAY(MMX_00FFw) = {
    1.24 -0x00ff00ff, 0x00ff00ff};
    1.25 -static unsigned int ASM_ARRAY(MMX_FF00w) = {
    1.26 -0xff00ff00, 0xff00ff00};
    1.27 +static unsigned short ASM_ARRAY(MMX_Ycoeff)  = {0x004a, 0x004a, 0x004a, 0x004a};
    1.28  
    1.29 -static unsigned short ASM_ARRAY(MMX_Ycoeff) = {
    1.30 -0x004a, 0x004a, 0x004a, 0x004a};
    1.31 +static unsigned short ASM_ARRAY(MMX_UbluRGB) = {0x0072, 0x0072, 0x0072, 0x0072};
    1.32 +static unsigned short ASM_ARRAY(MMX_VredRGB) = {0x0059, 0x0059, 0x0059, 0x0059};
    1.33 +static unsigned short ASM_ARRAY(MMX_UgrnRGB) = {0xffea, 0xffea, 0xffea, 0xffea};
    1.34 +static unsigned short ASM_ARRAY(MMX_VgrnRGB) = {0xffd2, 0xffd2, 0xffd2, 0xffd2};
    1.35  
    1.36 -static unsigned short ASM_ARRAY(MMX_UbluRGB) = {
    1.37 -0x0072, 0x0072, 0x0072, 0x0072};
    1.38 -static unsigned short ASM_ARRAY(MMX_VredRGB) = {
    1.39 -0x0059, 0x0059, 0x0059, 0x0059};
    1.40 -static unsigned short ASM_ARRAY(MMX_UgrnRGB) = {
    1.41 -0xffea, 0xffea, 0xffea, 0xffea};
    1.42 -static unsigned short ASM_ARRAY(MMX_VgrnRGB) = {
    1.43 -0xffd2, 0xffd2, 0xffd2, 0xffd2};
    1.44 +static unsigned short ASM_ARRAY(MMX_Ublu5x5) = {0x0081, 0x0081, 0x0081, 0x0081};
    1.45 +static unsigned short ASM_ARRAY(MMX_Vred5x5) = {0x0066, 0x0066, 0x0066, 0x0066};
    1.46 +static unsigned short ASM_ARRAY(MMX_Ugrn555) = {0xffe7, 0xffe7, 0xffe7, 0xffe7};
    1.47 +static unsigned short ASM_ARRAY(MMX_Vgrn555) = {0xffcc, 0xffcc, 0xffcc, 0xffcc};
    1.48 +static unsigned short ASM_ARRAY(MMX_Ugrn565) = {0xffe8, 0xffe8, 0xffe8, 0xffe8};
    1.49 +static unsigned short ASM_ARRAY(MMX_Vgrn565) = {0xffcd, 0xffcd, 0xffcd, 0xffcd};
    1.50  
    1.51 -static unsigned short ASM_ARRAY(MMX_Ublu5x5) = {
    1.52 -0x0081, 0x0081, 0x0081, 0x0081};
    1.53 -static unsigned short ASM_ARRAY(MMX_Vred5x5) = {
    1.54 -0x0066, 0x0066, 0x0066, 0x0066};
    1.55 -static unsigned short ASM_ARRAY(MMX_Ugrn555) = {
    1.56 -0xffe7, 0xffe7, 0xffe7, 0xffe7};
    1.57 -static unsigned short ASM_ARRAY(MMX_Vgrn555) = {
    1.58 -0xffcc, 0xffcc, 0xffcc, 0xffcc};
    1.59 -static unsigned short ASM_ARRAY(MMX_Ugrn565) = {
    1.60 -0xffe8, 0xffe8, 0xffe8, 0xffe8};
    1.61 -static unsigned short ASM_ARRAY(MMX_Vgrn565) = {
    1.62 -0xffcd, 0xffcd, 0xffcd, 0xffcd};
    1.63 -
    1.64 -static unsigned short ASM_ARRAY(MMX_red555) = {
    1.65 -0x7c00, 0x7c00, 0x7c00, 0x7c00};
    1.66 -static unsigned short ASM_ARRAY(MMX_red565) = {
    1.67 -0xf800, 0xf800, 0xf800, 0xf800};
    1.68 -static unsigned short ASM_ARRAY(MMX_grn555) = {
    1.69 -0x03e0, 0x03e0, 0x03e0, 0x03e0};
    1.70 -static unsigned short ASM_ARRAY(MMX_grn565) = {
    1.71 -0x07e0, 0x07e0, 0x07e0, 0x07e0};
    1.72 -static unsigned short ASM_ARRAY(MMX_blu5x5) = {
    1.73 -0x001f, 0x001f, 0x001f, 0x001f};
    1.74 +static unsigned short ASM_ARRAY(MMX_red555)  = {0x7c00, 0x7c00, 0x7c00, 0x7c00};
    1.75 +static unsigned short ASM_ARRAY(MMX_red565)  = {0xf800, 0xf800, 0xf800, 0xf800};
    1.76 +static unsigned short ASM_ARRAY(MMX_grn555)  = {0x03e0, 0x03e0, 0x03e0, 0x03e0};
    1.77 +static unsigned short ASM_ARRAY(MMX_grn565)  = {0x07e0, 0x07e0, 0x07e0, 0x07e0};
    1.78 +static unsigned short ASM_ARRAY(MMX_blu5x5)  = {0x001f, 0x001f, 0x001f, 0x001f};
    1.79  
    1.80  /**
    1.81     This MMX assembler is my first assembler/MMX program ever.
    1.82 @@ -100,234 +83,334 @@
    1.83  
    1.84  */
    1.85  
    1.86 -void
    1.87 -ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
    1.88 -                        unsigned char *lum, unsigned char *cr,
    1.89 -                        unsigned char *cb, unsigned char *out,
    1.90 -                        int rows, int cols, int mod)
    1.91 +void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
    1.92 +                              unsigned char *lum, unsigned char *cr,
    1.93 +                              unsigned char *cb, unsigned char *out,
    1.94 +                              int rows, int cols, int mod )
    1.95  {
    1.96      Uint32 *row1;
    1.97      Uint32 *row2;
    1.98  
    1.99 -    unsigned char *y = lum + cols * rows;       // Pointer to the end
   1.100 -    int x = 0;
   1.101 -    row1 = (Uint32 *) out;      // 32 bit target
   1.102 -    row2 = (Uint32 *) out + cols + mod; // start of second row 
   1.103 -    mod = (mod + cols + mod) * 4;       // increment for row1 in byte
   1.104 +    unsigned char* y = lum +cols*rows;    // Pointer to the end
   1.105 +    int x=0;
   1.106 +    row1 = (Uint32 *)out;                 // 32 bit target
   1.107 +    row2 = (Uint32 *)out+cols+mod;        // start of second row 
   1.108 +    mod = (mod+cols+mod)*4;               // increment for row1 in byte
   1.109  
   1.110 -    __asm__ __volatile__(
   1.111 +    __asm__ __volatile__ (
   1.112  /* We don't really care about PIC - the code should be rewritten to use
   1.113     relative addressing for the static tables, so right now we take the
   1.114     COW hit on the pages this code resides. Big deal.
   1.115     This spill is just to reduce register pressure in the PIC case. */
   1.116 -                            "pushl %%ebx\n"
   1.117 -                            "movl %0, %%ebx\n" ".align 8\n" "1:\n"
   1.118 -                            // create Cr (result in mm1)
   1.119 -                            "movd (%%ebx), %%mm1\n"     //         0  0  0  0  v3 v2 v1 v0
   1.120 -                            "pxor %%mm7,%%mm7\n"        //         00 00 00 00 00 00 00 00
   1.121 -                            "movd (%2), %%mm2\n"        //    0  0  0  0 l3 l2 l1 l0
   1.122 -                            "punpcklbw %%mm7,%%mm1\n"   //         0  v3 0  v2 00 v1 00 v0
   1.123 -                            "punpckldq %%mm1,%%mm1\n"   //         00 v1 00 v0 00 v1 00 v0
   1.124 -                            "psubw _MMX_0080w,%%mm1\n"  // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 
   1.125 -                            // create Cr_g (result in mm0)
   1.126 -                            "movq %%mm1,%%mm0\n"        // r1 r1 r0 r0 r1 r1 r0 r0
   1.127 -                            "pmullw _MMX_VgrnRGB,%%mm0\n"       // red*-46dec=0.7136*64
   1.128 -                            "pmullw _MMX_VredRGB,%%mm1\n"       // red*89dec=1.4013*64
   1.129 -                            "psraw  $6, %%mm0\n"        // red=red/64
   1.130 -                            "psraw  $6, %%mm1\n"        // red=red/64
   1.131 -                            // create L1 L2 (result in mm2,mm4)
   1.132 -                            // L2=lum+cols
   1.133 -                            "movq (%2,%4),%%mm3\n"      //    0  0  0  0 L3 L2 L1 L0
   1.134 -                            "punpckldq %%mm3,%%mm2\n"   //   L3 L2 L1 L0 l3 l2 l1 l0
   1.135 -                            "movq %%mm2,%%mm4\n"        //   L3 L2 L1 L0 l3 l2 l1 l0
   1.136 -                            "pand _MMX_FF00w,%%mm2\n"   //   L3 0  L1  0 l3  0 l1  0
   1.137 -                            "pand _MMX_00FFw,%%mm4\n"   //   0  L2  0 L0  0 l2  0 l0
   1.138 -                            "psrlw $8,%%mm2\n"  //   0  L3  0 L1  0 l3  0 l1
   1.139 -                            // create R (result in mm6)
   1.140 -                            "movq %%mm2,%%mm5\n"        //   0 L3  0 L1  0 l3  0 l1
   1.141 -                            "movq %%mm4,%%mm6\n"        //   0 L2  0 L0  0 l2  0 l0
   1.142 -                            "paddsw  %%mm1, %%mm5\n"    // lum1+red:x R3 x R1 x r3 x r1
   1.143 -                            "paddsw  %%mm1, %%mm6\n"    // lum1+red:x R2 x R0 x r2 x r0
   1.144 -                            "packuswb %%mm5,%%mm5\n"    //  R3 R1 r3 r1 R3 R1 r3 r1
   1.145 -                            "packuswb %%mm6,%%mm6\n"    //  R2 R0 r2 r0 R2 R0 r2 r0
   1.146 -                            "pxor %%mm7,%%mm7\n"        //         00 00 00 00 00 00 00 00
   1.147 -                            "punpcklbw %%mm5,%%mm6\n"   //  R3 R2 R1 R0 r3 r2 r1 r0
   1.148 -                            // create Cb (result in mm1)
   1.149 -                            "movd (%1), %%mm1\n"        //         0  0  0  0  u3 u2 u1 u0
   1.150 -                            "punpcklbw %%mm7,%%mm1\n"   //         0  u3 0  u2 00 u1 00 u0
   1.151 -                            "punpckldq %%mm1,%%mm1\n"   //         00 u1 00 u0 00 u1 00 u0
   1.152 -                            "psubw _MMX_0080w,%%mm1\n"  // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 
   1.153 -                            // create Cb_g (result in mm5)
   1.154 -                            "movq %%mm1,%%mm5\n"        // u1 u1 u0 u0 u1 u1 u0 u0
   1.155 -                            "pmullw _MMX_UgrnRGB,%%mm5\n"       // blue*-109dec=1.7129*64
   1.156 -                            "pmullw _MMX_UbluRGB,%%mm1\n"       // blue*114dec=1.78125*64
   1.157 -                            "psraw  $6, %%mm5\n"        // blue=red/64
   1.158 -                            "psraw  $6, %%mm1\n"        // blue=blue/64
   1.159 -                            // create G (result in mm7)
   1.160 -                            "movq %%mm2,%%mm3\n"        //   0  L3  0 L1  0 l3  0 l1
   1.161 -                            "movq %%mm4,%%mm7\n"        //   0  L2  0 L0  0 l2  0 l1
   1.162 -                            "paddsw  %%mm5, %%mm3\n"    // lum1+Cb_g:x G3t x G1t x g3t x g1t
   1.163 -                            "paddsw  %%mm5, %%mm7\n"    // lum1+Cb_g:x G2t x G0t x g2t x g0t
   1.164 -                            "paddsw  %%mm0, %%mm3\n"    // lum1+Cr_g:x G3  x G1  x g3  x g1
   1.165 -                            "paddsw  %%mm0, %%mm7\n"    // lum1+blue:x G2  x G0  x g2  x g0
   1.166 -                            "packuswb %%mm3,%%mm3\n"    // G3 G1 g3 g1 G3 G1 g3 g1
   1.167 -                            "packuswb %%mm7,%%mm7\n"    // G2 G0 g2 g0 G2 G0 g2 g0
   1.168 -                            "punpcklbw %%mm3,%%mm7\n"   // G3 G2 G1 G0 g3 g2 g1 g0
   1.169 -                            // create B (result in mm5)
   1.170 -                            "movq %%mm2,%%mm3\n"        //   0  L3  0 L1  0 l3  0 l1
   1.171 -                            "movq %%mm4,%%mm5\n"        //   0  L2  0 L0  0 l2  0 l1
   1.172 -                            "paddsw  %%mm1, %%mm3\n"    // lum1+blue:x B3 x B1 x b3 x b1
   1.173 -                            "paddsw  %%mm1, %%mm5\n"    // lum1+blue:x B2 x B0 x b2 x b0
   1.174 -                            "packuswb %%mm3,%%mm3\n"    // B3 B1 b3 b1 B3 B1 b3 b1
   1.175 -                            "packuswb %%mm5,%%mm5\n"    // B2 B0 b2 b0 B2 B0 b2 b0
   1.176 -                            "punpcklbw %%mm3,%%mm5\n"   // B3 B2 B1 B0 b3 b2 b1 b0
   1.177 -                            // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
   1.178 -                            "pxor %%mm2,%%mm2\n"        //  0  0  0  0  0  0  0  0
   1.179 -                            "pxor %%mm4,%%mm4\n"        //  0  0  0  0  0  0  0  0
   1.180 -                            "movq %%mm6,%%mm1\n"        // R3 R2 R1 R0 r3 r2 r1 r0
   1.181 -                            "movq %%mm5,%%mm3\n"        // B3 B2 B1 B0 b3 b2 b1 b0
   1.182 -                            // process lower lum
   1.183 -                            "punpcklbw %%mm4,%%mm1\n"   //  0 r3  0 r2  0 r1  0 r0
   1.184 -                            "punpcklbw %%mm4,%%mm3\n"   //  0 b3  0 b2  0 b1  0 b0
   1.185 -                            "movq %%mm1,%%mm2\n"        //  0 r3  0 r2  0 r1  0 r0
   1.186 -                            "movq %%mm3,%%mm0\n"        //  0 b3  0 b2  0 b1  0 b0
   1.187 -                            "punpcklwd %%mm1,%%mm3\n"   //  0 r1  0 b1  0 r0  0 b0
   1.188 -                            "punpckhwd %%mm2,%%mm0\n"   //  0 r3  0 b3  0 r2  0 b2
   1.189 -                            "pxor %%mm2,%%mm2\n"        //  0  0  0  0  0  0  0  0
   1.190 -                            "movq %%mm7,%%mm1\n"        // G3 G2 G1 G0 g3 g2 g1 g0
   1.191 -                            "punpcklbw %%mm1,%%mm2\n"   // g3  0 g2  0 g1  0 g0  0
   1.192 -                            "punpcklwd %%mm4,%%mm2\n"   //  0  0 g1  0  0  0 g0  0 
   1.193 -                            "por  %%mm3, %%mm2\n"       //  0 r1 g1 b1  0 r0 g0 b0
   1.194 -                            "movq   %%mm2,(%3)\n"       // wrote out ! row1
   1.195 -                            "pxor %%mm2,%%mm2\n"        //  0  0  0  0  0  0  0  0
   1.196 -                            "punpcklbw %%mm1,%%mm4\n"   // g3  0 g2  0 g1  0 g0  0
   1.197 -                            "punpckhwd %%mm2,%%mm4\n"   //  0  0 g3  0  0  0 g2  0 
   1.198 -                            "por  %%mm0, %%mm4\n"       //  0 r3 g3 b3  0 r2 g2 b2
   1.199 -                            "movq   %%mm4,8(%3)\n"      // wrote out ! row1
   1.200 -                            // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
   1.201 -                            // this can be done "destructive"
   1.202 -                            "pxor %%mm2,%%mm2\n"        //  0  0  0  0  0  0  0  0
   1.203 -                            "punpckhbw %%mm2,%%mm6\n"   //  0 R3  0 R2  0 R1  0 R0
   1.204 -                            "punpckhbw %%mm1,%%mm5\n"   // G3 B3 G2 B2 G1 B1 G0 B0
   1.205 -                            "movq %%mm5,%%mm1\n"        // G3 B3 G2 B2 G1 B1 G0 B0
   1.206 -                            "punpcklwd %%mm6,%%mm1\n"   //  0 R1 G1 B1  0 R0 G0 B0
   1.207 -                            "movq   %%mm1,(%5)\n"       // wrote out ! row2
   1.208 -                            "punpckhwd %%mm6,%%mm5\n"   //  0 R3 G3 B3  0 R2 G2 B2
   1.209 -                            "movq   %%mm5,8(%5)\n"      // wrote out ! row2
   1.210 -                            "addl  $4,%2\n"     // lum+4
   1.211 -                            "leal  16(%3),%3\n" // row1+16
   1.212 -                            "leal  16(%5),%5\n" // row2+16
   1.213 -                            "addl  $2, %%ebx\n" // cr+2
   1.214 -                            "addl  $2, %1\n"    // cb+2
   1.215 -                            "addl  $4,%6\n"     // x+4
   1.216 -                            "cmpl  %4,%6\n" "jl    1b\n" "addl           %4,     %2\n"  // lum += cols 
   1.217 -                            "addl           %8,     %3\n"       // row1+= mod
   1.218 -                            "addl           %8,     %5\n"       // row2+= mod
   1.219 -                            "movl           $0,     %6\n"       // x=0
   1.220 -                            "cmpl           %7,     %2\n"
   1.221 -                            "jl             1b\n"
   1.222 -                            "emms\n"
   1.223 -                            "popl %%ebx\n"::"m"(cr), "r"(cb), "r"(lum),
   1.224 -                            "r"(row1), "r"(cols), "r"(row2), "m"(x),
   1.225 -                            "m"(y), "m"(mod));
   1.226 +		 "pushl %%ebx\n"
   1.227 +		 "movl %0, %%ebx\n"
   1.228 +
   1.229 +	         ".align 8\n"
   1.230 +		 "1:\n"
   1.231 +		
   1.232 +		 // create Cr (result in mm1)
   1.233 +		 "movd (%%ebx), %%mm1\n"   //         0  0  0  0  v3 v2 v1 v0
   1.234 +		 "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
   1.235 +		 "movd (%2), %%mm2\n"           //    0  0  0  0 l3 l2 l1 l0
   1.236 +		 "punpcklbw %%mm7,%%mm1\n" //         0  v3 0  v2 00 v1 00 v0
   1.237 +		 "punpckldq %%mm1,%%mm1\n" //         00 v1 00 v0 00 v1 00 v0
   1.238 +		 "psubw _MMX_0080w,%%mm1\n"  // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 
   1.239 +
   1.240 +		 // create Cr_g (result in mm0)
   1.241 +		 "movq %%mm1,%%mm0\n"           // r1 r1 r0 r0 r1 r1 r0 r0
   1.242 +		 "pmullw _MMX_VgrnRGB,%%mm0\n"// red*-46dec=0.7136*64
   1.243 +		 "pmullw _MMX_VredRGB,%%mm1\n"// red*89dec=1.4013*64
   1.244 +		 "psraw  $6, %%mm0\n"           // red=red/64
   1.245 +		 "psraw  $6, %%mm1\n"           // red=red/64
   1.246 +		 
   1.247 +		 // create L1 L2 (result in mm2,mm4)
   1.248 +		 // L2=lum+cols
   1.249 +		 "movq (%2,%4),%%mm3\n"         //    0  0  0  0 L3 L2 L1 L0
   1.250 +		 "punpckldq %%mm3,%%mm2\n"      //   L3 L2 L1 L0 l3 l2 l1 l0
   1.251 +		 "movq %%mm2,%%mm4\n"           //   L3 L2 L1 L0 l3 l2 l1 l0
   1.252 +		 "pand _MMX_FF00w,%%mm2\n"      //   L3 0  L1  0 l3  0 l1  0
   1.253 +		 "pand _MMX_00FFw,%%mm4\n"      //   0  L2  0 L0  0 l2  0 l0
   1.254 +		 "psrlw $8,%%mm2\n"             //   0  L3  0 L1  0 l3  0 l1
   1.255 +
   1.256 +		 // create R (result in mm6)
   1.257 +		 "movq %%mm2,%%mm5\n"           //   0 L3  0 L1  0 l3  0 l1
   1.258 +		 "movq %%mm4,%%mm6\n"           //   0 L2  0 L0  0 l2  0 l0
   1.259 +		 "paddsw  %%mm1, %%mm5\n"       // lum1+red:x R3 x R1 x r3 x r1
   1.260 +		 "paddsw  %%mm1, %%mm6\n"       // lum1+red:x R2 x R0 x r2 x r0
   1.261 +		 "packuswb %%mm5,%%mm5\n"       //  R3 R1 r3 r1 R3 R1 r3 r1
   1.262 +		 "packuswb %%mm6,%%mm6\n"       //  R2 R0 r2 r0 R2 R0 r2 r0
   1.263 +		 "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
   1.264 +		 "punpcklbw %%mm5,%%mm6\n"      //  R3 R2 R1 R0 r3 r2 r1 r0
   1.265 +
   1.266 +		 // create Cb (result in mm1)
   1.267 +		 "movd (%1), %%mm1\n"      //         0  0  0  0  u3 u2 u1 u0
   1.268 +		 "punpcklbw %%mm7,%%mm1\n" //         0  u3 0  u2 00 u1 00 u0
   1.269 +		 "punpckldq %%mm1,%%mm1\n" //         00 u1 00 u0 00 u1 00 u0
   1.270 +		 "psubw _MMX_0080w,%%mm1\n"  // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 
   1.271 +		 // create Cb_g (result in mm5)
   1.272 +		 "movq %%mm1,%%mm5\n"            // u1 u1 u0 u0 u1 u1 u0 u0
   1.273 +		 "pmullw _MMX_UgrnRGB,%%mm5\n"    // blue*-109dec=1.7129*64
   1.274 +		 "pmullw _MMX_UbluRGB,%%mm1\n"    // blue*114dec=1.78125*64
   1.275 +		 "psraw  $6, %%mm5\n"            // blue=red/64
   1.276 +		 "psraw  $6, %%mm1\n"            // blue=blue/64
   1.277 +
   1.278 +		 // create G (result in mm7)
   1.279 +		 "movq %%mm2,%%mm3\n"      //   0  L3  0 L1  0 l3  0 l1
   1.280 +		 "movq %%mm4,%%mm7\n"      //   0  L2  0 L0  0 l2  0 l1
   1.281 +		 "paddsw  %%mm5, %%mm3\n"  // lum1+Cb_g:x G3t x G1t x g3t x g1t
   1.282 +		 "paddsw  %%mm5, %%mm7\n"  // lum1+Cb_g:x G2t x G0t x g2t x g0t
   1.283 +		 "paddsw  %%mm0, %%mm3\n"  // lum1+Cr_g:x G3  x G1  x g3  x g1
   1.284 +		 "paddsw  %%mm0, %%mm7\n"  // lum1+blue:x G2  x G0  x g2  x g0
   1.285 +		 "packuswb %%mm3,%%mm3\n"  // G3 G1 g3 g1 G3 G1 g3 g1
   1.286 +		 "packuswb %%mm7,%%mm7\n"  // G2 G0 g2 g0 G2 G0 g2 g0
   1.287 +		 "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0
   1.288 +		 
   1.289 +		 // create B (result in mm5)
   1.290 +		 "movq %%mm2,%%mm3\n"         //   0  L3  0 L1  0 l3  0 l1
   1.291 +		 "movq %%mm4,%%mm5\n"         //   0  L2  0 L0  0 l2  0 l1
   1.292 +		 "paddsw  %%mm1, %%mm3\n"     // lum1+blue:x B3 x B1 x b3 x b1
   1.293 +		 "paddsw  %%mm1, %%mm5\n"     // lum1+blue:x B2 x B0 x b2 x b0
   1.294 +		 "packuswb %%mm3,%%mm3\n"     // B3 B1 b3 b1 B3 B1 b3 b1
   1.295 +		 "packuswb %%mm5,%%mm5\n"     // B2 B0 b2 b0 B2 B0 b2 b0
   1.296 +		 "punpcklbw %%mm3,%%mm5\n"    // B3 B2 B1 B0 b3 b2 b1 b0
   1.297 +
   1.298 +		 // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
   1.299 +
   1.300 +		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
   1.301 +		 "pxor %%mm4,%%mm4\n"           //  0  0  0  0  0  0  0  0
   1.302 +		 "movq %%mm6,%%mm1\n"           // R3 R2 R1 R0 r3 r2 r1 r0
   1.303 +		 "movq %%mm5,%%mm3\n"           // B3 B2 B1 B0 b3 b2 b1 b0
   1.304 +		 // process lower lum
   1.305 +		 "punpcklbw %%mm4,%%mm1\n"      //  0 r3  0 r2  0 r1  0 r0
   1.306 +		 "punpcklbw %%mm4,%%mm3\n"      //  0 b3  0 b2  0 b1  0 b0
   1.307 +		 "movq %%mm1,%%mm2\n"           //  0 r3  0 r2  0 r1  0 r0
   1.308 +		 "movq %%mm3,%%mm0\n"           //  0 b3  0 b2  0 b1  0 b0
   1.309 +		 "punpcklwd %%mm1,%%mm3\n"      //  0 r1  0 b1  0 r0  0 b0
   1.310 +		 "punpckhwd %%mm2,%%mm0\n"      //  0 r3  0 b3  0 r2  0 b2
   1.311 +
   1.312 +		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
   1.313 +		 "movq %%mm7,%%mm1\n"           // G3 G2 G1 G0 g3 g2 g1 g0
   1.314 +		 "punpcklbw %%mm1,%%mm2\n"      // g3  0 g2  0 g1  0 g0  0
   1.315 +		 "punpcklwd %%mm4,%%mm2\n"      //  0  0 g1  0  0  0 g0  0 
   1.316 +		 "por  %%mm3, %%mm2\n"          //  0 r1 g1 b1  0 r0 g0 b0
   1.317 +		 "movq   %%mm2,(%3)\n"          // wrote out ! row1
   1.318 +
   1.319 +		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
   1.320 +		 "punpcklbw %%mm1,%%mm4\n"      // g3  0 g2  0 g1  0 g0  0
   1.321 +		 "punpckhwd %%mm2,%%mm4\n"      //  0  0 g3  0  0  0 g2  0 
   1.322 +		 "por  %%mm0, %%mm4\n"          //  0 r3 g3 b3  0 r2 g2 b2
   1.323 +		 "movq   %%mm4,8(%3)\n"         // wrote out ! row1
   1.324 +		 
   1.325 +		 // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
   1.326 +		 // this can be done "destructive"
   1.327 +		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
   1.328 +		 "punpckhbw %%mm2,%%mm6\n"      //  0 R3  0 R2  0 R1  0 R0
   1.329 +		 "punpckhbw %%mm1,%%mm5\n"      // G3 B3 G2 B2 G1 B1 G0 B0
   1.330 +		 "movq %%mm5,%%mm1\n"           // G3 B3 G2 B2 G1 B1 G0 B0
   1.331 +		 "punpcklwd %%mm6,%%mm1\n"      //  0 R1 G1 B1  0 R0 G0 B0
   1.332 +		 "movq   %%mm1,(%5)\n"          // wrote out ! row2
   1.333 +		 "punpckhwd %%mm6,%%mm5\n"      //  0 R3 G3 B3  0 R2 G2 B2
   1.334 +		 "movq   %%mm5,8(%5)\n"         // wrote out ! row2
   1.335 +		 
   1.336 +		 "addl  $4,%2\n"            // lum+4
   1.337 +		 "leal  16(%3),%3\n"        // row1+16
   1.338 +		 "leal  16(%5),%5\n"        // row2+16
   1.339 +		 "addl  $2, %%ebx\n"        // cr+2
   1.340 +		 "addl  $2, %1\n"           // cb+2
   1.341 +
   1.342 +		 "addl  $4,%6\n"            // x+4
   1.343 +		 "cmpl  %4,%6\n"
   1.344 +
   1.345 +		 "jl    1b\n"
   1.346 +		 "addl           %4,     %2\n" // lum += cols 
   1.347 +		 "addl           %8,     %3\n" // row1+= mod
   1.348 +		 "addl           %8,     %5\n" // row2+= mod
   1.349 +		 "movl           $0,     %6\n" // x=0
   1.350 +		 "cmpl           %7,     %2\n"
   1.351 +		 "jl             1b\n"
   1.352 +		 "emms\n"
   1.353 +		 "popl %%ebx\n"
   1.354 +		 :
   1.355 +		 : "m" (cr), "r"(cb),"r"(lum),
   1.356 +		 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
   1.357  }
   1.358  
   1.359 -void
   1.360 -Color565DitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
   1.361 -                        unsigned char *lum, unsigned char *cr,
   1.362 -                        unsigned char *cb, unsigned char *out,
   1.363 -                        int rows, int cols, int mod)
   1.364 +void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
   1.365 +                             unsigned char *lum, unsigned char *cr,
   1.366 +                             unsigned char *cb, unsigned char *out,
   1.367 +                             int rows, int cols, int mod )
   1.368  {
   1.369      Uint16 *row1;
   1.370      Uint16 *row2;
   1.371  
   1.372 -    unsigned char *y = lum + cols * rows;       /* Pointer to the end */
   1.373 -    int x = 0;
   1.374 -    row1 = (Uint16 *) out;      /* 16 bit target */
   1.375 -    row2 = (Uint16 *) out + cols + mod; /* start of second row  */
   1.376 -    mod = (mod + cols + mod) * 2;       /* increment for row1 in byte */
   1.377 +    unsigned char* y = lum +cols*rows;    /* Pointer to the end */
   1.378 +    int x=0;
   1.379 +    row1 = (Uint16 *)out;                 /* 16 bit target */
   1.380 +    row2 = (Uint16 *)out+cols+mod;        /* start of second row  */
   1.381 +    mod = (mod+cols+mod)*2;               /* increment for row1 in byte */
   1.382  
   1.383  
   1.384 -    __asm__ __volatile__("pushl %%ebx\n" "movl %0, %%ebx\n" ".align 8\n" "1:\n" "movd           (%1),                   %%mm0\n"        // 4 Cb         0  0  0  0 u3 u2 u1 u0
   1.385 -                         "pxor           %%mm7,                  %%mm7\n" "movd           (%%ebx),                %%mm1\n"      // 4 Cr                0  0  0  0 v3 v2 v1 v0
   1.386 -                         "punpcklbw      %%mm7,                  %%mm0\n"       // 4 W cb   0 u3  0 u2  0 u1  0 u0
   1.387 -                         "punpcklbw      %%mm7,                  %%mm1\n"       // 4 W cr   0 v3  0 v2  0 v1  0 v0
   1.388 -                         "psubw          _MMX_0080w,             %%mm0\n" "psubw          _MMX_0080w,             %%mm1\n" "movq           %%mm0,                  %%mm2\n"     // Cb                   0 u3  0 u2  0 u1  0 u0
   1.389 -                         "movq           %%mm1,                  %%mm3\n"       // Cr
   1.390 -                         "pmullw         _MMX_Ugrn565,           %%mm2\n"       // Cb2green 0 R3  0 R2  0 R1  0 R0
   1.391 -                         "movq           (%2),                   %%mm6\n"       // L1      l7 L6 L5 L4 L3 L2 L1 L0
   1.392 -                         "pmullw         _MMX_Ublu5x5,           %%mm0\n"       // Cb2blue
   1.393 -                         "pand           _MMX_00FFw,             %%mm6\n"       // L1      00 L6 00 L4 00 L2 00 L0
   1.394 -                         "pmullw         _MMX_Vgrn565,           %%mm3\n"       // Cr2green
   1.395 -                         "movq           (%2),                   %%mm7\n"       // L2
   1.396 -                         "pmullw         _MMX_Vred5x5,           %%mm1\n"       // Cr2red
   1.397 -                         "psrlw          $8,                     %%mm7\n"       // L2           00 L7 00 L5 00 L3 00 L1
   1.398 -                         "pmullw         _MMX_Ycoeff,            %%mm6\n"       // lum1
   1.399 -                         "paddw          %%mm3,                  %%mm2\n"       // Cb2green + Cr2green == green
   1.400 -                         "pmullw         _MMX_Ycoeff,            %%mm7\n"       // lum2
   1.401 -                         "movq           %%mm6,                  %%mm4\n"       // lum1
   1.402 -                         "paddw          %%mm0,                  %%mm6\n"       // lum1 +blue 00 B6 00 B4 00 B2 00 B0
   1.403 -                         "movq           %%mm4,                  %%mm5\n"       // lum1
   1.404 -                         "paddw          %%mm1,                  %%mm4\n"       // lum1 +red  00 R6 00 R4 00 R2 00 R0
   1.405 -                         "paddw          %%mm2,                  %%mm5\n"       // lum1 +green 00 G6 00 G4 00 G2 00 G0
   1.406 -                         "psraw          $6,                     %%mm4\n"       // R1 0 .. 64
   1.407 -                         "movq           %%mm7,                  %%mm3\n"       // lum2                       00 L7 00 L5 00 L3 00 L1
   1.408 -                         "psraw          $6,                     %%mm5\n"       // G1  - .. +
   1.409 -                         "paddw          %%mm0,                  %%mm7\n"       // Lum2 +blue 00 B7 00 B5 00 B3 00 B1
   1.410 -                         "psraw          $6,                     %%mm6\n"       // B1         0 .. 64
   1.411 -                         "packuswb       %%mm4,                  %%mm4\n"       // R1 R1
   1.412 -                         "packuswb       %%mm5,                  %%mm5\n"       // G1 G1
   1.413 -                         "packuswb       %%mm6,                  %%mm6\n"       // B1 B1
   1.414 -                         "punpcklbw      %%mm4,                  %%mm4\n" "punpcklbw      %%mm5,                  %%mm5\n" "pand           _MMX_red565,            %%mm4\n" "psllw          $3,                     %%mm5\n"    // GREEN       1
   1.415 -                         "punpcklbw      %%mm6,                  %%mm6\n" "pand           _MMX_grn565,            %%mm5\n" "pand           _MMX_red565,            %%mm6\n" "por            %%mm5,                  %%mm4\n"    //
   1.416 -                         "psrlw          $11,                    %%mm6\n"       // BLUE        1
   1.417 -                         "movq           %%mm3,                  %%mm5\n"       // lum2
   1.418 -                         "paddw          %%mm1,                  %%mm3\n"       // lum2 +red      00 R7 00 R5 00 R3 00 R1
   1.419 -                         "paddw          %%mm2,                  %%mm5\n"       // lum2 +green 00 G7 00 G5 00 G3 00 G1
   1.420 -                         "psraw          $6,                     %%mm3\n"       // R2
   1.421 -                         "por            %%mm6,                  %%mm4\n"       // MM4
   1.422 -                         "psraw          $6,                     %%mm5\n"       // G2
   1.423 -                         "movq           (%2, %4),               %%mm6\n"       // L3 load lum2
   1.424 -                         "psraw          $6,                     %%mm7\n" "packuswb       %%mm3,                  %%mm3\n" "packuswb       %%mm5,                  %%mm5\n" "packuswb       %%mm7,                  %%mm7\n" "pand           _MMX_00FFw,             %%mm6\n"   // L3
   1.425 -                         "punpcklbw      %%mm3,                  %%mm3\n" "punpcklbw      %%mm5,                  %%mm5\n" "pmullw         _MMX_Ycoeff,            %%mm6\n"     // lum3
   1.426 -                         "punpcklbw      %%mm7,                  %%mm7\n" "psllw          $3,                     %%mm5\n"      // GREEN 2
   1.427 -                         "pand           _MMX_red565,            %%mm7\n" "pand           _MMX_red565,            %%mm3\n" "psrlw          $11,                    %%mm7\n"     // BLUE  2
   1.428 -                         "pand           _MMX_grn565,            %%mm5\n" "por            %%mm7,                  %%mm3\n" "movq           (%2,%4),                %%mm7\n"     // L4 load lum2
   1.429 -                         "por            %%mm5,                  %%mm3\n"       //
   1.430 -                         "psrlw          $8,                     %%mm7\n"       // L4
   1.431 -                         "movq           %%mm4,                  %%mm5\n" "punpcklwd      %%mm3,                  %%mm4\n" "pmullw         _MMX_Ycoeff,            %%mm7\n"     // lum4
   1.432 -                         "punpckhwd      %%mm3,                  %%mm5\n" "movq           %%mm4,                  (%3)\n"       // write row1
   1.433 -                         "movq           %%mm5,                  8(%3)\n"       // write row1
   1.434 -                         "movq           %%mm6,                  %%mm4\n"       // Lum3
   1.435 -                         "paddw          %%mm0,                  %%mm6\n"       // Lum3 +blue
   1.436 -                         "movq           %%mm4,                  %%mm5\n"       // Lum3
   1.437 -                         "paddw          %%mm1,                  %%mm4\n"       // Lum3 +red
   1.438 -                         "paddw          %%mm2,                  %%mm5\n"       // Lum3 +green
   1.439 -                         "psraw          $6,                     %%mm4\n" "movq           %%mm7,                  %%mm3\n"      // Lum4
   1.440 -                         "psraw          $6,                     %%mm5\n" "paddw          %%mm0,                  %%mm7\n"      // Lum4 +blue
   1.441 -                         "psraw          $6,                     %%mm6\n"       // Lum3 +blue
   1.442 -                         "movq           %%mm3,                  %%mm0\n"       // Lum4
   1.443 -                         "packuswb       %%mm4,                  %%mm4\n" "paddw          %%mm1,                  %%mm3\n"      // Lum4 +red
   1.444 -                         "packuswb       %%mm5,                  %%mm5\n" "paddw          %%mm2,                  %%mm0\n"      // Lum4 +green
   1.445 -                         "packuswb       %%mm6,                  %%mm6\n" "punpcklbw      %%mm4,                  %%mm4\n" "punpcklbw      %%mm5,                  %%mm5\n" "punpcklbw      %%mm6,                  %%mm6\n" "psllw          $3,                     %%mm5\n"   // GREEN 3
   1.446 -                         "pand           _MMX_red565,            %%mm4\n" "psraw          $6,                     %%mm3\n"      // psr 6
   1.447 -                         "psraw          $6,                     %%mm0\n" "pand           _MMX_red565,            %%mm6\n"      // BLUE
   1.448 -                         "pand           _MMX_grn565,            %%mm5\n" "psrlw          $11,                    %%mm6\n"      // BLUE  3
   1.449 -                         "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"     // BLUE
   1.450 -                         "psllw          $3,                     %%mm0\n"       // GREEN 4
   1.451 -                         "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"    // row2+16
   1.452 -                         "jl             1b\n" "addl           %4,     %2\n"    // lum += cols 
   1.453 -                         "addl           %8,     %3\n"  // row1+= mod
   1.454 -                         "addl           %8,     %5\n"  // row2+= mod
   1.455 -                         "movl           $0,     %6\n"  // x=0
   1.456 -                         "cmpl           %7,     %2\n"
   1.457 -                         "jl             1b\n"
   1.458 -                         "emms\n"
   1.459 -                         "popl %%ebx\n"::"m"(cr), "r"(cb), "r"(lum),
   1.460 -                         "r"(row1), "r"(cols), "r"(row2), "m"(x),
   1.461 -                         "m"(y), "m"(mod));
   1.462 +      __asm__ __volatile__(
   1.463 +         "pushl %%ebx\n"
   1.464 +	 "movl %0, %%ebx\n"
   1.465 +
   1.466 +         ".align 8\n"
   1.467 +         "1:\n"
   1.468 +         "movd           (%1),                   %%mm0\n" // 4 Cb         0  0  0  0 u3 u2 u1 u0
   1.469 +         "pxor           %%mm7,                  %%mm7\n"
   1.470 +         "movd           (%%ebx),                %%mm1\n" // 4 Cr                0  0  0  0 v3 v2 v1 v0
   1.471 +         "punpcklbw      %%mm7,                  %%mm0\n" // 4 W cb   0 u3  0 u2  0 u1  0 u0
   1.472 +         "punpcklbw      %%mm7,                  %%mm1\n" // 4 W cr   0 v3  0 v2  0 v1  0 v0
   1.473 +         "psubw          _MMX_0080w,             %%mm0\n"
   1.474 +         "psubw          _MMX_0080w,             %%mm1\n"
   1.475 +         "movq           %%mm0,                  %%mm2\n" // Cb                   0 u3  0 u2  0 u1  0 u0
   1.476 +         "movq           %%mm1,                  %%mm3\n" // Cr
   1.477 +         "pmullw         _MMX_Ugrn565,           %%mm2\n" // Cb2green 0 R3  0 R2  0 R1  0 R0
   1.478 +         "movq           (%2),                   %%mm6\n" // L1      l7 L6 L5 L4 L3 L2 L1 L0
   1.479 +         "pmullw         _MMX_Ublu5x5,           %%mm0\n" // Cb2blue
   1.480 +         "pand           _MMX_00FFw,             %%mm6\n" // L1      00 L6 00 L4 00 L2 00 L0
   1.481 +         "pmullw         _MMX_Vgrn565,           %%mm3\n" // Cr2green
   1.482 +         "movq           (%2),                   %%mm7\n" // L2
   1.483 +         "pmullw         _MMX_Vred5x5,           %%mm1\n" // Cr2red
   1.484 +         "psrlw          $8,                     %%mm7\n"        // L2           00 L7 00 L5 00 L3 00 L1
   1.485 +         "pmullw         _MMX_Ycoeff,            %%mm6\n" // lum1
   1.486 +         "paddw          %%mm3,                  %%mm2\n" // Cb2green + Cr2green == green
   1.487 +         "pmullw         _MMX_Ycoeff,            %%mm7\n" // lum2
   1.488 +
   1.489 +         "movq           %%mm6,                  %%mm4\n" // lum1
   1.490 +         "paddw          %%mm0,                  %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0
   1.491 +         "movq           %%mm4,                  %%mm5\n" // lum1
   1.492 +         "paddw          %%mm1,                  %%mm4\n" // lum1 +red  00 R6 00 R4 00 R2 00 R0
   1.493 +         "paddw          %%mm2,                  %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0
   1.494 +         "psraw          $6,                     %%mm4\n" // R1 0 .. 64
   1.495 +         "movq           %%mm7,                  %%mm3\n" // lum2                       00 L7 00 L5 00 L3 00 L1
   1.496 +         "psraw          $6,                     %%mm5\n" // G1  - .. +
   1.497 +         "paddw          %%mm0,                  %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1
   1.498 +         "psraw          $6,                     %%mm6\n" // B1         0 .. 64
   1.499 +         "packuswb       %%mm4,                  %%mm4\n" // R1 R1
   1.500 +         "packuswb       %%mm5,                  %%mm5\n" // G1 G1
   1.501 +         "packuswb       %%mm6,                  %%mm6\n" // B1 B1
   1.502 +         "punpcklbw      %%mm4,                  %%mm4\n"
   1.503 +         "punpcklbw      %%mm5,                  %%mm5\n"
   1.504 +
   1.505 +         "pand           _MMX_red565,            %%mm4\n"
   1.506 +         "psllw          $3,                     %%mm5\n" // GREEN       1
   1.507 +         "punpcklbw      %%mm6,                  %%mm6\n"
   1.508 +         "pand           _MMX_grn565,            %%mm5\n"
   1.509 +         "pand           _MMX_red565,            %%mm6\n"
   1.510 +         "por            %%mm5,                  %%mm4\n" //
   1.511 +         "psrlw          $11,                    %%mm6\n" // BLUE        1
   1.512 +         "movq           %%mm3,                  %%mm5\n" // lum2
   1.513 +         "paddw          %%mm1,                  %%mm3\n" // lum2 +red      00 R7 00 R5 00 R3 00 R1
   1.514 +         "paddw          %%mm2,                  %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1
   1.515 +         "psraw          $6,                     %%mm3\n" // R2
   1.516 +         "por            %%mm6,                  %%mm4\n" // MM4
   1.517 +         "psraw          $6,                     %%mm5\n" // G2
   1.518 +         "movq           (%2, %4),               %%mm6\n" // L3 load lum2
   1.519 +         "psraw          $6,                     %%mm7\n"
   1.520 +         "packuswb       %%mm3,                  %%mm3\n"
   1.521 +         "packuswb       %%mm5,                  %%mm5\n"
   1.522 +         "packuswb       %%mm7,                  %%mm7\n"
   1.523 +         "pand           _MMX_00FFw,             %%mm6\n" // L3
   1.524 +         "punpcklbw      %%mm3,                  %%mm3\n"
   1.525 +         "punpcklbw      %%mm5,                  %%mm5\n"
   1.526 +         "pmullw         _MMX_Ycoeff,            %%mm6\n" // lum3
   1.527 +         "punpcklbw      %%mm7,                  %%mm7\n"
   1.528 +         "psllw          $3,                     %%mm5\n" // GREEN 2
   1.529 +         "pand           _MMX_red565,            %%mm7\n"
   1.530 +         "pand           _MMX_red565,            %%mm3\n"
   1.531 +         "psrlw          $11,                    %%mm7\n" // BLUE  2
   1.532 +         "pand           _MMX_grn565,            %%mm5\n"
   1.533 +         "por            %%mm7,                  %%mm3\n"
   1.534 +         "movq           (%2,%4),                %%mm7\n" // L4 load lum2
   1.535 +         "por            %%mm5,                  %%mm3\n" //
   1.536 +         "psrlw          $8,                     %%mm7\n" // L4
   1.537 +         "movq           %%mm4,                  %%mm5\n"
   1.538 +         "punpcklwd      %%mm3,                  %%mm4\n"
   1.539 +         "pmullw         _MMX_Ycoeff,            %%mm7\n" // lum4
   1.540 +         "punpckhwd      %%mm3,                  %%mm5\n"
   1.541 +
   1.542 +         "movq           %%mm4,                  (%3)\n"  // write row1
   1.543 +         "movq           %%mm5,                  8(%3)\n" // write row1
   1.544 +
   1.545 +         "movq           %%mm6,                  %%mm4\n" // Lum3
   1.546 +         "paddw          %%mm0,                  %%mm6\n" // Lum3 +blue
   1.547 +
   1.548 +         "movq           %%mm4,                  %%mm5\n" // Lum3
   1.549 +         "paddw          %%mm1,                  %%mm4\n" // Lum3 +red
   1.550 +         "paddw          %%mm2,                  %%mm5\n" // Lum3 +green
   1.551 +         "psraw          $6,                     %%mm4\n"
   1.552 +         "movq           %%mm7,                  %%mm3\n" // Lum4
   1.553 +         "psraw          $6,                     %%mm5\n"
   1.554 +         "paddw          %%mm0,                  %%mm7\n" // Lum4 +blue
   1.555 +         "psraw          $6,                     %%mm6\n" // Lum3 +blue
   1.556 +         "movq           %%mm3,                  %%mm0\n" // Lum4
   1.557 +         "packuswb       %%mm4,                  %%mm4\n"
   1.558 +         "paddw          %%mm1,                  %%mm3\n" // Lum4 +red
   1.559 +         "packuswb       %%mm5,                  %%mm5\n"
   1.560 +         "paddw          %%mm2,                  %%mm0\n" // Lum4 +green
   1.561 +         "packuswb       %%mm6,                  %%mm6\n"
   1.562 +         "punpcklbw      %%mm4,                  %%mm4\n"
   1.563 +         "punpcklbw      %%mm5,                  %%mm5\n"
   1.564 +         "punpcklbw      %%mm6,                  %%mm6\n"
   1.565 +         "psllw          $3,                     %%mm5\n" // GREEN 3
   1.566 +         "pand           _MMX_red565,            %%mm4\n"
   1.567 +         "psraw          $6,                     %%mm3\n" // psr 6
   1.568 +         "psraw          $6,                     %%mm0\n"
   1.569 +         "pand           _MMX_red565,            %%mm6\n" // BLUE
   1.570 +         "pand           _MMX_grn565,            %%mm5\n"
   1.571 +         "psrlw          $11,                    %%mm6\n" // BLUE  3
   1.572 +         "por            %%mm5,                  %%mm4\n"
   1.573 +         "psraw          $6,                     %%mm7\n"
   1.574 +         "por            %%mm6,                  %%mm4\n"
   1.575 +         "packuswb       %%mm3,                  %%mm3\n"
   1.576 +         "packuswb       %%mm0,                  %%mm0\n"
   1.577 +         "packuswb       %%mm7,                  %%mm7\n"
   1.578 +         "punpcklbw      %%mm3,                  %%mm3\n"
   1.579 +         "punpcklbw      %%mm0,                  %%mm0\n"
   1.580 +         "punpcklbw      %%mm7,                  %%mm7\n"
   1.581 +         "pand           _MMX_red565,            %%mm3\n"
   1.582 +         "pand           _MMX_red565,            %%mm7\n" // BLUE
   1.583 +         "psllw          $3,                     %%mm0\n" // GREEN 4
   1.584 +         "psrlw          $11,                    %%mm7\n"
   1.585 +         "pand           _MMX_grn565,            %%mm0\n"
   1.586 +         "por            %%mm7,                  %%mm3\n"
   1.587 +         "por            %%mm0,                  %%mm3\n"
   1.588 +
   1.589 +         "movq           %%mm4,                  %%mm5\n"
   1.590 +
   1.591 +         "punpcklwd      %%mm3,                  %%mm4\n"
   1.592 +         "punpckhwd      %%mm3,                  %%mm5\n"
   1.593 +
   1.594 +         "movq           %%mm4,                  (%5)\n"
   1.595 +	 "movq           %%mm5,                  8(%5)\n"
   1.596 +
   1.597 +         "addl           $8,                     %6\n"
   1.598 +         "addl           $8,                     %2\n"
   1.599 +         "addl           $4,                     %%ebx\n"
   1.600 +         "addl           $4,                     %1\n"
   1.601 +         "cmpl           %4,                     %6\n"
   1.602 +         "leal           16(%3),                 %3\n"
   1.603 +	 "leal           16(%5),%5\n" // row2+16
   1.604 +
   1.605 +
   1.606 +         "jl             1b\n"
   1.607 +	 "addl           %4,     %2\n" // lum += cols 
   1.608 +	 "addl           %8,     %3\n" // row1+= mod
   1.609 +	 "addl           %8,     %5\n" // row2+= mod
   1.610 +	 "movl           $0,     %6\n" // x=0
   1.611 +	 "cmpl           %7,     %2\n"
   1.612 +	 "jl             1b\n"
   1.613 +         "emms\n"
   1.614 +	 "popl %%ebx\n"
   1.615 +         :
   1.616 +         :"m" (cr), "r"(cb),"r"(lum),
   1.617 +	 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
   1.618  }
   1.619  
   1.620  #endif /* GCC i386 inline assembly */
   1.621  #endif /* 0 */
   1.622 +
   1.623 +/* *INDENT-ON* */
   1.624 +
   1.625  /* vi: set ts=4 sw=4 expandtab: */