os/ossrv/genericopenlibs/liboil/src/i386/ayuv2argb_i386.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2  * LIBOIL - Library of Optimized Inner Loops
     3  * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
     4  * All rights reserved.
     5  *
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions
     8  * are met:
     9  * 1. Redistributions of source code must retain the above copyright
    10  *    notice, this list of conditions and the following disclaimer.
    11  * 2. Redistributions in binary form must reproduce the above copyright
    12  *    notice, this list of conditions and the following disclaimer in the
    13  *    documentation and/or other materials provided with the distribution.
    14  * 
    15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    25  * POSSIBILITY OF SUCH DAMAGE.
    26  */
    27 //Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    28 
    29 #ifdef HAVE_CONFIG_H
    30 #include "config.h"
    31 #endif
    32 
    33 #include <liboil/liboil.h>
    34 #include <liboil/liboilfunction.h>
    35 #include <liboil/liboilclasses.h>
    36 
    37 
    38 #if 0
    39 static int16_t matrix[][4] = {
    40   { 0,      0,      -8192,   -8192  },
    41   { 16384,  0,      0,       0      },
    42   { 0,      16384,  16384,   16384  },
    43   { 0,      0,      -5638,   29032  },
    44   { 0,      22970,  -11700,  0      },
    45   { 0, 0, 0, 0 } 
    46 #if 0
    47   { 0, 0, 0, 0 },
    48   { 16384,  0,      0,       0      },
    49   { 0, 16384,  0,      0,        },
    50   { 0, 0, 16384,  0,         },
    51   { 0, 0, 0, 16384,    },
    52   { 0, 0, 0, 0 } 
    53 #endif
    54 };
    55 #endif
    56 
    57 static void
    58 colorspace_argb_mmx (uint32_t *argb, uint32_t *ayuv, int16_t *matrix, int n)
    59 {
    60 #if !defined(__WINSCW__) && !defined(__WINS__)      
    61   asm volatile (
    62       "  sub $48, %%esp\n"
    63       "  pshufw $0x1b, 0(%3), %%mm0\n"
    64       "  movq %%mm0, 0(%%esp)\n"
    65       "  pshufw $0x1b, 8(%3), %%mm0\n"
    66       "  movq %%mm0, 8(%%esp)\n"
    67       "  pshufw $0x1b, 16(%3), %%mm0\n"
    68       "  movq %%mm0, 16(%%esp)\n"
    69       "  pshufw $0x1b, 16(%3), %%mm0\n"
    70       "  movq %%mm0, 16(%%esp)\n"
    71       "  pshufw $0x1b, 24(%3), %%mm0\n"
    72       "  movq %%mm0, 24(%%esp)\n"
    73       "  pshufw $0x1b, 32(%3), %%mm0\n"
    74       "  movq %%mm0, 32(%%esp)\n"
    75       "  pshufw $0x1b, 40(%3), %%mm7\n"
    76       "  pxor %%mm0, %%mm0\n"
    77       "  mov $0x08080808, %%eax\n"
    78       "  movd %%eax, %%mm1\n"
    79       "  punpcklbw %%mm0, %%mm1\n"
    80       "  paddw %%mm1, %%mm7\n"
    81       "1:\n"
    82       "  movd (%1), %%mm1\n"
    83       "  add $4, %1\n"
    84       "  punpcklbw %%mm0, %%mm1\n"
    85       "  psllw $6, %%mm1\n"
    86       "  paddw 0(%%esp), %%mm1\n"
    87       "  pshufw $0x00, %%mm1, %%mm4\n"
    88       "  pshufw $0x55, %%mm1, %%mm3\n"
    89       "  pshufw $0xaa, %%mm1, %%mm2\n"
    90       "  pshufw $0xff, %%mm1, %%mm1\n"
    91       "  pmulhw 8(%%esp), %%mm1\n"
    92       "  pmulhw 16(%%esp), %%mm2\n"
    93       "  pmulhw 24(%%esp), %%mm3\n"
    94       "  pmulhw 32(%%esp), %%mm4\n"
    95       "  paddsw %%mm2, %%mm1\n"
    96       "  paddsw %%mm4, %%mm3\n"
    97       "  paddsw %%mm3, %%mm1\n"
    98       "  paddsw %%mm7, %%mm1\n"
    99       "  psraw $4, %%mm1\n"
   100       "  packuswb %%mm0, %%mm1\n"
   101       "  movd %%mm1, (%0)\n"
   102       "  add $4, %0\n"
   103       "  decl %2\n"
   104       "  jne 1b\n"
   105       "  emms\n"
   106       "  add $48, %%esp\n"
   107       : "+r" (argb), "+r" (ayuv), "+r" (n)
   108       : "r" (matrix)
   109       : "eax" );
   110 #endif
   111 }
   112 OIL_DEFINE_IMPL_FULL (colorspace_argb_mmx, colorspace_argb, OIL_IMPL_FLAG_MMX|OIL_IMPL_FLAG_MMXEXT);
   113 
   114 
   115 
   116 #ifdef	__SYMBIAN32__
   117  
   118 OilFunctionImpl* __oil_function_impl_colorspace_argb_mmx, colorspace_argb() {
   119 		return &_oil_function_impl_colorspace_argb_mmx, colorspace_argb;
   120 }
   121 #endif
   122