src/render/SDL_yuv_mmx.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 09 Apr 2015 22:33:39 -0400
branchiOS-improvements
changeset 9542 618662dc9e82
parent 8149 681eb46b8ac4
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Closing the iOS-improvements branch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8093
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     7
  arising from the use of this software.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    11
  freely, subject to the following restrictions:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 7191
diff changeset
    21
#include "../SDL_internal.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
2197
2ff40f30af31 Merged r3261:3262 from branches/SDL-1.2: MMX/YUV with __OPTIMIZE__.
Ryan C. Gordon <icculus@icculus.org>
parents: 2195
diff changeset
    23
#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    24
1407
0c6941483cc6 Whoops, forgot to check in this fix
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    25
#include "SDL_stdinc.h"
0c6941483cc6 Whoops, forgot to check in this fix
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    26
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    27
#include "mmx.h"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    28
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    29
/* *INDENT-OFF* */
1148
63fb2da89a4b Patched inline assembly to compile on gcc 4.0.1. Details are here:
Ryan C. Gordon <icculus@icculus.org>
parents: 1038
diff changeset
    30
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    31
static mmx_t MMX_0080w    = { .ud = {0x00800080, 0x00800080} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    32
static mmx_t MMX_00FFw    = { .ud = {0x00ff00ff, 0x00ff00ff} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    33
static mmx_t MMX_FF00w    = { .ud = {0xff00ff00, 0xff00ff00} };
1148
63fb2da89a4b Patched inline assembly to compile on gcc 4.0.1. Details are here:
Ryan C. Gordon <icculus@icculus.org>
parents: 1038
diff changeset
    34
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    35
static mmx_t MMX_Ycoeff   = { .uw = {0x004a, 0x004a, 0x004a, 0x004a} };
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    36
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    37
static mmx_t MMX_UbluRGB  = { .uw = {0x0072, 0x0072, 0x0072, 0x0072} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    38
static mmx_t MMX_VredRGB  = { .uw = {0x0059, 0x0059, 0x0059, 0x0059} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    39
static mmx_t MMX_UgrnRGB  = { .uw = {0xffea, 0xffea, 0xffea, 0xffea} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    40
static mmx_t MMX_VgrnRGB  = { .uw = {0xffd2, 0xffd2, 0xffd2, 0xffd2} };
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    41
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    42
static mmx_t MMX_Ublu5x5  = { .uw = {0x0081, 0x0081, 0x0081, 0x0081} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    43
static mmx_t MMX_Vred5x5  = { .uw = {0x0066, 0x0066, 0x0066, 0x0066} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    44
static mmx_t MMX_Ugrn565  = { .uw = {0xffe8, 0xffe8, 0xffe8, 0xffe8} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    45
static mmx_t MMX_Vgrn565  = { .uw = {0xffcd, 0xffcd, 0xffcd, 0xffcd} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    46
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    47
static mmx_t MMX_red565   = { .uw = {0xf800, 0xf800, 0xf800, 0xf800} };
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    48
static mmx_t MMX_grn565   = { .uw = {0x07e0, 0x07e0, 0x07e0, 0x07e0} };
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    49
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    50
/**
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    51
   This MMX assembler is my first assembler/MMX program ever.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    52
   Thus it maybe buggy.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    53
   Send patches to:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    54
   mvogt@rhrk.uni-kl.de
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    55
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    56
   After it worked fine I have "obfuscated" the code a bit to have
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    57
   more parallism in the MMX units. This means I moved
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    58
   initilisation around and delayed other instruction.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    59
   Performance measurement did not show that this brought any advantage
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    60
   but in theory it _should_ be faster this way.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    61
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    62
   The overall performanve gain to the C based dither was 30%-40%.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    63
   The MMX routine calculates 256bit=8RGB values in each cycle
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    64
   (4 for row1 & 4 for row2)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    65
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    66
   The red/green/blue.. coefficents are taken from the mpeg_play
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    67
   player. They look nice, but I dont know if you can have
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    68
   better values, to avoid integer rounding errors.
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    69
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    70
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    71
   IMPORTANT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    72
   ==========
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    73
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    74
   It is a requirement that the cr/cb/lum are 8 byte aligned and
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    75
   the out are 16byte aligned or you will/may get segfaults
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    76
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    77
*/
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    78
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    79
void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    80
                              unsigned char *lum, unsigned char *cr,
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    81
                              unsigned char *cb, unsigned char *out,
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    82
                              int rows, int cols, int mod )
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    83
{
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    84
    Uint32 *row1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    85
    Uint32 *row2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    86
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    87
    unsigned char* y = lum +cols*rows;    /* Pointer to the end */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
    88
    int x = 0;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    89
    row1 = (Uint32 *)out;                 /* 32 bit target */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    90
    row2 = (Uint32 *)out+cols+mod;        /* start of second row */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    91
    mod = (mod+cols+mod)*4;               /* increment for row1 in byte */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    92
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    93
    __asm__ __volatile__ (
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    94
        /* tap dance to workaround the inability to use %%ebx at will... */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    95
        /*  move one thing to the stack... */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    96
        "pushl $0\n"  /* save a slot on the stack. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    97
        "pushl %%ebx\n"  /* save %%ebx. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    98
        "movl %0, %%ebx\n"  /* put the thing in ebx. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    99
        "movl %%ebx,4(%%esp)\n"  /* put the thing in the stack slot. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   100
        "popl %%ebx\n"  /* get back %%ebx (the PIC register). */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   101
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   102
        ".align 8\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   103
        "1:\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   104
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   105
        /* create Cr (result in mm1) */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   106
        "pushl %%ebx\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   107
        "movl 4(%%esp),%%ebx\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   108
        "movd (%%ebx),%%mm1\n"   /*         0  0  0  0  v3 v2 v1 v0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   109
        "popl %%ebx\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   110
        "pxor %%mm7,%%mm7\n"      /*         00 00 00 00 00 00 00 00 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   111
        "movd (%2), %%mm2\n"           /*    0  0  0  0 l3 l2 l1 l0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   112
        "punpcklbw %%mm7,%%mm1\n" /*         0  v3 0  v2 00 v1 00 v0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   113
        "punpckldq %%mm1,%%mm1\n" /*         00 v1 00 v0 00 v1 00 v0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   114
        "psubw %9,%%mm1\n"        /* mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   115
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   116
        /* create Cr_g (result in mm0) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   117
        "movq %%mm1,%%mm0\n"           /* r1 r1 r0 r0 r1 r1 r0 r0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   118
        "pmullw %10,%%mm0\n"           /* red*-46dec=0.7136*64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   119
        "pmullw %11,%%mm1\n"           /* red*89dec=1.4013*64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   120
        "psraw  $6, %%mm0\n"           /* red=red/64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   121
        "psraw  $6, %%mm1\n"           /* red=red/64 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   122
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   123
        /* create L1 L2 (result in mm2,mm4) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   124
        /* L2=lum+cols */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   125
        "movq (%2,%4),%%mm3\n"         /*    0  0  0  0 L3 L2 L1 L0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   126
        "punpckldq %%mm3,%%mm2\n"      /*   L3 L2 L1 L0 l3 l2 l1 l0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   127
        "movq %%mm2,%%mm4\n"           /*   L3 L2 L1 L0 l3 l2 l1 l0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   128
        "pand %12,%%mm2\n"             /*   L3 0  L1  0 l3  0 l1  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   129
        "pand %13,%%mm4\n"             /*   0  L2  0 L0  0 l2  0 l0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   130
        "psrlw $8,%%mm2\n"             /*   0  L3  0 L1  0 l3  0 l1 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   131
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   132
        /* create R (result in mm6) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   133
        "movq %%mm2,%%mm5\n"           /*   0 L3  0 L1  0 l3  0 l1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   134
        "movq %%mm4,%%mm6\n"           /*   0 L2  0 L0  0 l2  0 l0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   135
        "paddsw  %%mm1, %%mm5\n"       /* lum1+red:x R3 x R1 x r3 x r1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   136
        "paddsw  %%mm1, %%mm6\n"       /* lum1+red:x R2 x R0 x r2 x r0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   137
        "packuswb %%mm5,%%mm5\n"       /*  R3 R1 r3 r1 R3 R1 r3 r1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   138
        "packuswb %%mm6,%%mm6\n"       /*  R2 R0 r2 r0 R2 R0 r2 r0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   139
        "pxor %%mm7,%%mm7\n"      /*         00 00 00 00 00 00 00 00 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   140
        "punpcklbw %%mm5,%%mm6\n"      /*  R3 R2 R1 R0 r3 r2 r1 r0 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   141
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   142
        /* create Cb (result in mm1) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   143
        "movd (%1), %%mm1\n"      /*         0  0  0  0  u3 u2 u1 u0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   144
        "punpcklbw %%mm7,%%mm1\n" /*         0  u3 0  u2 00 u1 00 u0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   145
        "punpckldq %%mm1,%%mm1\n" /*         00 u1 00 u0 00 u1 00 u0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   146
        "psubw %9,%%mm1\n"        /* mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   147
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   148
        /* create Cb_g (result in mm5) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   149
        "movq %%mm1,%%mm5\n"            /* u1 u1 u0 u0 u1 u1 u0 u0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   150
        "pmullw %14,%%mm5\n"            /* blue*-109dec=1.7129*64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   151
        "pmullw %15,%%mm1\n"            /* blue*114dec=1.78125*64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   152
        "psraw  $6, %%mm5\n"            /* blue=red/64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   153
        "psraw  $6, %%mm1\n"            /* blue=blue/64 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   154
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   155
        /* create G (result in mm7) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   156
        "movq %%mm2,%%mm3\n"      /*   0  L3  0 L1  0 l3  0 l1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   157
        "movq %%mm4,%%mm7\n"      /*   0  L2  0 L0  0 l2  0 l1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   158
        "paddsw  %%mm5, %%mm3\n"  /* lum1+Cb_g:x G3t x G1t x g3t x g1t */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   159
        "paddsw  %%mm5, %%mm7\n"  /* lum1+Cb_g:x G2t x G0t x g2t x g0t */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   160
        "paddsw  %%mm0, %%mm3\n"  /* lum1+Cr_g:x G3  x G1  x g3  x g1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   161
        "paddsw  %%mm0, %%mm7\n"  /* lum1+blue:x G2  x G0  x g2  x g0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   162
        "packuswb %%mm3,%%mm3\n"  /* G3 G1 g3 g1 G3 G1 g3 g1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   163
        "packuswb %%mm7,%%mm7\n"  /* G2 G0 g2 g0 G2 G0 g2 g0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   164
        "punpcklbw %%mm3,%%mm7\n" /* G3 G2 G1 G0 g3 g2 g1 g0 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   165
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   166
        /* create B (result in mm5) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   167
        "movq %%mm2,%%mm3\n"         /*   0  L3  0 L1  0 l3  0 l1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   168
        "movq %%mm4,%%mm5\n"         /*   0  L2  0 L0  0 l2  0 l1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   169
        "paddsw  %%mm1, %%mm3\n"     /* lum1+blue:x B3 x B1 x b3 x b1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   170
        "paddsw  %%mm1, %%mm5\n"     /* lum1+blue:x B2 x B0 x b2 x b0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   171
        "packuswb %%mm3,%%mm3\n"     /* B3 B1 b3 b1 B3 B1 b3 b1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   172
        "packuswb %%mm5,%%mm5\n"     /* B2 B0 b2 b0 B2 B0 b2 b0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   173
        "punpcklbw %%mm3,%%mm5\n"    /* B3 B2 B1 B0 b3 b2 b1 b0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   174
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   175
        /* fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   176
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   177
        "pxor %%mm2,%%mm2\n"           /*  0  0  0  0  0  0  0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   178
        "pxor %%mm4,%%mm4\n"           /*  0  0  0  0  0  0  0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   179
        "movq %%mm6,%%mm1\n"           /* R3 R2 R1 R0 r3 r2 r1 r0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   180
        "movq %%mm5,%%mm3\n"           /* B3 B2 B1 B0 b3 b2 b1 b0 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   181
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   182
        /* process lower lum */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   183
        "punpcklbw %%mm4,%%mm1\n"      /*  0 r3  0 r2  0 r1  0 r0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   184
        "punpcklbw %%mm4,%%mm3\n"      /*  0 b3  0 b2  0 b1  0 b0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   185
        "movq %%mm1,%%mm2\n"           /*  0 r3  0 r2  0 r1  0 r0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   186
        "movq %%mm3,%%mm0\n"           /*  0 b3  0 b2  0 b1  0 b0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   187
        "punpcklwd %%mm1,%%mm3\n"      /*  0 r1  0 b1  0 r0  0 b0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   188
        "punpckhwd %%mm2,%%mm0\n"      /*  0 r3  0 b3  0 r2  0 b2 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   189
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   190
        "pxor %%mm2,%%mm2\n"           /*  0  0  0  0  0  0  0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   191
        "movq %%mm7,%%mm1\n"           /* G3 G2 G1 G0 g3 g2 g1 g0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   192
        "punpcklbw %%mm1,%%mm2\n"      /* g3  0 g2  0 g1  0 g0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   193
        "punpcklwd %%mm4,%%mm2\n"      /*  0  0 g1  0  0  0 g0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   194
        "por %%mm3, %%mm2\n"          /*  0 r1 g1 b1  0 r0 g0 b0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   195
        "movq %%mm2,(%3)\n"          /* wrote out ! row1 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   196
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   197
        "pxor %%mm2,%%mm2\n"           /*  0  0  0  0  0  0  0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   198
        "punpcklbw %%mm1,%%mm4\n"      /* g3  0 g2  0 g1  0 g0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   199
        "punpckhwd %%mm2,%%mm4\n"      /*  0  0 g3  0  0  0 g2  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   200
        "por %%mm0, %%mm4\n"          /*  0 r3 g3 b3  0 r2 g2 b2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   201
        "movq %%mm4,8(%3)\n"         /* wrote out ! row1 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   202
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   203
        /* fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   204
        /* this can be done "destructive" */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   205
        "pxor %%mm2,%%mm2\n"           /*  0  0  0  0  0  0  0  0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   206
        "punpckhbw %%mm2,%%mm6\n"      /*  0 R3  0 R2  0 R1  0 R0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   207
        "punpckhbw %%mm1,%%mm5\n"      /* G3 B3 G2 B2 G1 B1 G0 B0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   208
        "movq %%mm5,%%mm1\n"           /* G3 B3 G2 B2 G1 B1 G0 B0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   209
        "punpcklwd %%mm6,%%mm1\n"      /*  0 R1 G1 B1  0 R0 G0 B0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   210
        "movq %%mm1,(%5)\n"          /* wrote out ! row2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   211
        "punpckhwd %%mm6,%%mm5\n"      /*  0 R3 G3 B3  0 R2 G2 B2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   212
        "movq %%mm5,8(%5)\n"         /* wrote out ! row2 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   213
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   214
        "addl $4,%2\n"            /* lum+4 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   215
        "leal 16(%3),%3\n"        /* row1+16 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   216
        "leal 16(%5),%5\n"        /* row2+16 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   217
        "addl $2,(%%esp)\n"        /* cr+2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   218
        "addl $2,%1\n"           /* cb+2 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   219
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   220
        "addl $4,%6\n"            /* x+4 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   221
        "cmpl %4,%6\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   222
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   223
        "jl 1b\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   224
        "addl %4,%2\n" /* lum += cols */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   225
        "addl %8,%3\n" /* row1+= mod */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   226
        "addl %8,%5\n" /* row2+= mod */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   227
        "movl $0,%6\n" /* x=0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   228
        "cmpl %7,%2\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   229
        "jl 1b\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   230
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   231
        "addl $4,%%esp\n"  /* get rid of the stack slot we reserved. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   232
        "emms\n"  /* reset MMX registers. */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   233
        :
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   234
        : "m" (cr), "r"(cb),"r"(lum),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   235
          "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   236
          "m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   237
          "m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   238
          "m"(MMX_UbluRGB)
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   239
    );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   240
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   241
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   242
void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   243
                             unsigned char *lum, unsigned char *cr,
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   244
                             unsigned char *cb, unsigned char *out,
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   245
                             int rows, int cols, int mod )
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   246
{
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   247
    Uint16 *row1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   248
    Uint16 *row2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   249
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   250
    unsigned char* y = lum +cols*rows;    /* Pointer to the end */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   251
    int x = 0;
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   252
    row1 = (Uint16 *)out;                 /* 16 bit target */
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   253
    row2 = (Uint16 *)out+cols+mod;        /* start of second row  */
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   254
    mod = (mod+cols+mod)*2;               /* increment for row1 in byte */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   255
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   256
    __asm__ __volatile__(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   257
        /* tap dance to workaround the inability to use %%ebx at will... */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   258
        /*  move one thing to the stack... */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   259
        "pushl $0\n"  /* save a slot on the stack. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   260
        "pushl %%ebx\n"  /* save %%ebx. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   261
        "movl %0, %%ebx\n"  /* put the thing in ebx. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   262
        "movl %%ebx, 4(%%esp)\n"  /* put the thing in the stack slot. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   263
        "popl %%ebx\n"  /* get back %%ebx (the PIC register). */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   264
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   265
        ".align 8\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   266
        "1:\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   267
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   268
        "movd           (%1),                   %%mm0\n" /* 4 Cb         0  0  0  0 u3 u2 u1 u0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   269
        "pxor           %%mm7,                  %%mm7\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   270
        "pushl %%ebx\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   271
        "movl 4(%%esp), %%ebx\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   272
        "movd (%%ebx), %%mm1\n"   /* 4 Cr                0  0  0  0 v3 v2 v1 v0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   273
        "popl %%ebx\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   274
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   275
        "punpcklbw      %%mm7,                  %%mm0\n" /* 4 W cb   0 u3  0 u2  0 u1  0 u0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   276
        "punpcklbw      %%mm7,                  %%mm1\n" /* 4 W cr   0 v3  0 v2  0 v1  0 v0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   277
        "psubw          %9,                     %%mm0\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   278
        "psubw          %9,                     %%mm1\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   279
        "movq           %%mm0,                  %%mm2\n" /* Cb                   0 u3  0 u2  0 u1  0 u0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   280
        "movq           %%mm1,                  %%mm3\n" /* Cr */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   281
        "pmullw         %10,                    %%mm2\n" /* Cb2green 0 R3  0 R2  0 R1  0 R0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   282
        "movq           (%2),                   %%mm6\n" /* L1      l7 L6 L5 L4 L3 L2 L1 L0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   283
        "pmullw         %11,                    %%mm0\n" /* Cb2blue */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   284
        "pand           %12,                    %%mm6\n" /* L1      00 L6 00 L4 00 L2 00 L0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   285
        "pmullw         %13,                    %%mm3\n" /* Cr2green */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   286
        "movq           (%2),                   %%mm7\n" /* L2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   287
        "pmullw         %14,                    %%mm1\n" /* Cr2red */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   288
        "psrlw          $8,                     %%mm7\n"        /* L2           00 L7 00 L5 00 L3 00 L1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   289
        "pmullw         %15,                    %%mm6\n" /* lum1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   290
        "paddw          %%mm3,                  %%mm2\n" /* Cb2green + Cr2green == green */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   291
        "pmullw         %15,                    %%mm7\n" /* lum2 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   292
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   293
        "movq           %%mm6,                  %%mm4\n" /* lum1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   294
        "paddw          %%mm0,                  %%mm6\n" /* lum1 +blue 00 B6 00 B4 00 B2 00 B0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   295
        "movq           %%mm4,                  %%mm5\n" /* lum1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   296
        "paddw          %%mm1,                  %%mm4\n" /* lum1 +red  00 R6 00 R4 00 R2 00 R0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   297
        "paddw          %%mm2,                  %%mm5\n" /* lum1 +green 00 G6 00 G4 00 G2 00 G0 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   298
        "psraw          $6,                     %%mm4\n" /* R1 0 .. 64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   299
        "movq           %%mm7,                  %%mm3\n" /* lum2                       00 L7 00 L5 00 L3 00 L1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   300
        "psraw          $6,                     %%mm5\n" /* G1  - .. + */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   301
        "paddw          %%mm0,                  %%mm7\n" /* Lum2 +blue 00 B7 00 B5 00 B3 00 B1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   302
        "psraw          $6,                     %%mm6\n" /* B1         0 .. 64 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   303
        "packuswb       %%mm4,                  %%mm4\n" /* R1 R1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   304
        "packuswb       %%mm5,                  %%mm5\n" /* G1 G1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   305
        "packuswb       %%mm6,                  %%mm6\n" /* B1 B1 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   306
        "punpcklbw      %%mm4,                  %%mm4\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   307
        "punpcklbw      %%mm5,                  %%mm5\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   308
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   309
        "pand           %16,                    %%mm4\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   310
        "psllw          $3,                     %%mm5\n" /* GREEN       1 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   311
        "punpcklbw      %%mm6,                  %%mm6\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   312
        "pand           %17,                    %%mm5\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   313
        "pand           %16,                    %%mm6\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   314
        "por            %%mm5,                  %%mm4\n" /* */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   315
        "psrlw          $11,                    %%mm6\n" /* BLUE        1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   316
        "movq           %%mm3,                  %%mm5\n" /* lum2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   317
        "paddw          %%mm1,                  %%mm3\n" /* lum2 +red      00 R7 00 R5 00 R3 00 R1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   318
        "paddw          %%mm2,                  %%mm5\n" /* lum2 +green 00 G7 00 G5 00 G3 00 G1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   319
        "psraw          $6,                     %%mm3\n" /* R2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   320
        "por            %%mm6,                  %%mm4\n" /* MM4 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   321
        "psraw          $6,                     %%mm5\n" /* G2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   322
        "movq           (%2, %4),               %%mm6\n" /* L3 load lum2 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   323
        "psraw          $6,                     %%mm7\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   324
        "packuswb       %%mm3,                  %%mm3\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   325
        "packuswb       %%mm5,                  %%mm5\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   326
        "packuswb       %%mm7,                  %%mm7\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   327
        "pand           %12,                    %%mm6\n" /* L3 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   328
        "punpcklbw      %%mm3,                  %%mm3\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   329
        "punpcklbw      %%mm5,                  %%mm5\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   330
        "pmullw         %15,                    %%mm6\n" /* lum3 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   331
        "punpcklbw      %%mm7,                  %%mm7\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   332
        "psllw          $3,                     %%mm5\n" /* GREEN 2 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   333
        "pand           %16,                    %%mm7\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   334
        "pand           %16,                    %%mm3\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   335
        "psrlw          $11,                    %%mm7\n" /* BLUE  2 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   336
        "pand           %17,                    %%mm5\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   337
        "por            %%mm7,                  %%mm3\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   338
        "movq           (%2,%4),                %%mm7\n" /* L4 load lum2 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   339
        "por            %%mm5,                  %%mm3\n"
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   340
        "psrlw          $8,                     %%mm7\n" /* L4 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   341
        "movq           %%mm4,                  %%mm5\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   342
        "punpcklwd      %%mm3,                  %%mm4\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   343
        "pmullw         %15,                    %%mm7\n" /* lum4 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   344
        "punpckhwd      %%mm3,                  %%mm5\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   345
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   346
        "movq           %%mm4,                  (%3)\n"  /* write row1 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   347
        "movq           %%mm5,                  8(%3)\n" /* write row1 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   348
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   349
        "movq           %%mm6,                  %%mm4\n" /* Lum3 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   350
        "paddw          %%mm0,                  %%mm6\n" /* Lum3 +blue */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   351
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   352
        "movq           %%mm4,                  %%mm5\n" /* Lum3 */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   353
        "paddw          %%mm1,                  %%mm4\n" /* Lum3 +red */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   354
        "paddw          %%mm2,                  %%mm5\n" /* Lum3 +green */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   355
        "psraw          $6,                     %%mm4\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   356
        "movq           %%mm7,                  %%mm3\n" /* Lum4 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   357
        "psraw          $6,                     %%mm5\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   358
        "paddw          %%mm0,                  %%mm7\n" /* Lum4 +blue */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   359
        "psraw          $6,                     %%mm6\n" /* Lum3 +blue */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   360
        "movq           %%mm3,                  %%mm0\n" /* Lum4 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   361
        "packuswb       %%mm4,                  %%mm4\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   362
        "paddw          %%mm1,                  %%mm3\n" /* Lum4 +red */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   363
        "packuswb       %%mm5,                  %%mm5\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   364
        "paddw          %%mm2,                  %%mm0\n" /* Lum4 +green */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   365
        "packuswb       %%mm6,                  %%mm6\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   366
        "punpcklbw      %%mm4,                  %%mm4\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   367
        "punpcklbw      %%mm5,                  %%mm5\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   368
        "punpcklbw      %%mm6,                  %%mm6\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   369
        "psllw          $3,                     %%mm5\n" /* GREEN 3 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   370
        "pand           %16,                    %%mm4\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   371
        "psraw          $6,                     %%mm3\n" /* psr 6 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   372
        "psraw          $6,                     %%mm0\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   373
        "pand           %16,                    %%mm6\n" /* BLUE */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   374
        "pand           %17,                    %%mm5\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   375
        "psrlw          $11,                    %%mm6\n" /* BLUE  3 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   376
        "por            %%mm5,                  %%mm4\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   377
        "psraw          $6,                     %%mm7\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   378
        "por            %%mm6,                  %%mm4\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   379
        "packuswb       %%mm3,                  %%mm3\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   380
        "packuswb       %%mm0,                  %%mm0\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   381
        "packuswb       %%mm7,                  %%mm7\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   382
        "punpcklbw      %%mm3,                  %%mm3\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   383
        "punpcklbw      %%mm0,                  %%mm0\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   384
        "punpcklbw      %%mm7,                  %%mm7\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   385
        "pand           %16,                    %%mm3\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   386
        "pand           %16,                    %%mm7\n" /* BLUE */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   387
        "psllw          $3,                     %%mm0\n" /* GREEN 4 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   388
        "psrlw          $11,                    %%mm7\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   389
        "pand           %17,                    %%mm0\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   390
        "por            %%mm7,                  %%mm3\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   391
        "por            %%mm0,                  %%mm3\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   392
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   393
        "movq           %%mm4,                  %%mm5\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   394
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   395
        "punpcklwd      %%mm3,                  %%mm4\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   396
        "punpckhwd      %%mm3,                  %%mm5\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   397
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   398
        "movq           %%mm4,                  (%5)\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   399
        "movq           %%mm5,                  8(%5)\n"
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   400
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   401
        "addl           $8,                     %6\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   402
        "addl           $8,                     %2\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   403
        "addl           $4,                     (%%esp)\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   404
        "addl           $4,                     %1\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   405
        "cmpl           %4,                     %6\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   406
        "leal           16(%3),                 %3\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   407
        "leal           16(%5),%5\n" /* row2+16 */
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   408
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   409
        "jl             1b\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   410
        "addl           %4,     %2\n" /* lum += cols */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   411
        "addl           %8,     %3\n" /* row1+= mod */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   412
        "addl           %8,     %5\n" /* row2+= mod */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   413
        "movl           $0,     %6\n" /* x=0 */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   414
        "cmpl           %7,     %2\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   415
        "jl             1b\n"
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   416
        "addl $4, %%esp\n"  /* get rid of the stack slot we reserved. */
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   417
        "emms\n"
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   418
        :
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   419
        : "m" (cr), "r"(cb),"r"(lum),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   420
          "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   421
          "m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   422
          "m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5),
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   423
          "m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565)
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   424
    );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   425
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   426
2167
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   427
/* *INDENT-ON* */
8f2174e22cd5 indent doesn't know how to handle inline asm
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   428
2168
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   429
#endif /* GCC3 i386 inline assembly */
07f084fe97d0 Merged r3211:3213 from branches/SDL-1.2: YUV MMX inline asm for GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 2167
diff changeset
   430
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1413
diff changeset
   431
/* vi: set ts=4 sw=4 expandtab: */