os/ossrv/genericopenlibs/liboil/src/i386/recon8x8_i386.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/i386/recon8x8_i386.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,184 @@
     1.4 +/*
     1.5 + * LIBOIL - Library of Optimized Inner Loops
     1.6 + * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
     1.7 + * All rights reserved.
     1.8 + *
     1.9 + * Redistribution and use in source and binary forms, with or without
    1.10 + * modification, are permitted provided that the following conditions
    1.11 + * are met:
    1.12 + * 1. Redistributions of source code must retain the above copyright
    1.13 + *    notice, this list of conditions and the following disclaimer.
    1.14 + * 2. Redistributions in binary form must reproduce the above copyright
    1.15 + *    notice, this list of conditions and the following disclaimer in the
    1.16 + *    documentation and/or other materials provided with the distribution.
    1.17 + * 
    1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1.20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.21 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    1.22 + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1.23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    1.24 + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.25 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    1.26 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    1.27 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.28 + * POSSIBILITY OF SUCH DAMAGE.
    1.29 + */
    1.30 +//Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    1.31 +
    1.32 +#ifdef HAVE_CONFIG_H
    1.33 +#include "config.h"
    1.34 +#endif
    1.35 +
    1.36 +#include <liboil/liboilfunction.h>
    1.37 +#include "liboil/simdpack/simdpack.h"
    1.38 +
    1.39 +OIL_DECLARE_CLASS (recon8x8_intra);
    1.40 +OIL_DECLARE_CLASS (recon8x8_inter);
    1.41 +OIL_DECLARE_CLASS (recon8x8_inter2);
    1.42 +
    1.43 +const uint8_t c0x80[8] = {
    1.44 +  0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
    1.45 +};
    1.46 +
    1.47 +static void
    1.48 +recon8x8_intra_i386_mmx (uint8_t *dest, int ds, int16_t *change)
    1.49 +{
    1.50 +#if !defined(__WINSCW__) && !defined(__WINS__)      
    1.51 +  __asm__ __volatile__ (
    1.52 +    "  movq        (%3), %%mm0       \n\t" /* Set mm0 to 0x8080808080808080 */
    1.53 +
    1.54 +    "  lea         128(%1), %%edi      \n\t" /* Endpoint in input buffer */
    1.55 +    "1:                                \n\t" 
    1.56 +    "  movq         (%1), %%mm2        \n\t" /* First four input values */
    1.57 +
    1.58 +    "  packsswb    8(%1), %%mm2        \n\t" /* pack with next(high) four values */
    1.59 +    "  por         %%mm0, %%mm0        \n\t" 
    1.60 +    "  pxor        %%mm0, %%mm2        \n\t" /* Convert result to unsigned (same as add 128) */
    1.61 +    "  lea         16(%1), %1          \n\t" /* Step source buffer */
    1.62 +    "  cmp         %%edi, %1           \n\t" /* are we done */
    1.63 +
    1.64 +    "  movq        %%mm2, (%0)         \n\t" /* store results */
    1.65 +
    1.66 +    "  lea         (%0, %2), %0        \n\t" /* Step output buffer */
    1.67 +    "  jc          1b                  \n\t" /* Loop back if we are not done */
    1.68 +    "  emms                            \n\t"
    1.69 +      : "+r" (dest)
    1.70 +      : "r" (change),
    1.71 +        "r" (ds),
    1.72 +        "r" (c0x80)
    1.73 +      : "memory", "edi"
    1.74 +  );
    1.75 +#endif  
    1.76 +}
    1.77 +
    1.78 +OIL_DEFINE_IMPL_FULL (recon8x8_intra_i386_mmx, recon8x8_intra, OIL_IMPL_FLAG_MMX);
    1.79 +
    1.80 +#if 0
    1.81 +static void
    1.82 +recon8x8_inter_i386_mmx (uint8_t *dest, int ds, uint8_t *src, int ss, int16_t *change)
    1.83 +{
    1.84 +  /* FIXME doesn't handle ss */
    1.85 +  __asm__ __volatile__ (
    1.86 +    "  pxor        %%mm0, %%mm0        \n\t"
    1.87 +    "  lea         128(%1), %%edi      \n\t"
    1.88 +
    1.89 +    "1:                                \n\t"
    1.90 +    "  movq        (%2), %%mm2         \n\t" /* (+3 misaligned) 8 reference pixels */
    1.91 +
    1.92 +    "  movq        (%1), %%mm4         \n\t" /* first 4 changes */
    1.93 +    "  movq        %%mm2, %%mm3        \n\t"
    1.94 +    "  movq        8(%1), %%mm5        \n\t" /* last 4 changes */
    1.95 +    "  punpcklbw   %%mm0, %%mm2        \n\t" /* turn first 4 refs into positive 16-bit #s */
    1.96 +    "  paddsw      %%mm4, %%mm2        \n\t" /* add in first 4 changes */
    1.97 +    "  punpckhbw   %%mm0, %%mm3        \n\t" /* turn last 4 refs into positive 16-bit #s */
    1.98 +    "  paddsw      %%mm5, %%mm3        \n\t" /* add in last 4 changes */
    1.99 +    "  add         %3, %2              \n\t" /* next row of reference pixels */
   1.100 +    "  packuswb    %%mm3, %%mm2        \n\t" /* pack result to unsigned 8-bit values */
   1.101 +    "  lea         16(%1), %1          \n\t" /* next row of changes */
   1.102 +    "  cmp         %%edi, %1           \n\t" /* are we done? */
   1.103 +
   1.104 +    "  movq        %%mm2, (%0)         \n\t" /* store result */
   1.105 +
   1.106 +    "  lea         (%0, %3), %0        \n\t" /* next row of output */
   1.107 +    "  jc          1b                  \n\t"
   1.108 +    "  emms                            \n\t"
   1.109 +      : "+r" (dest)
   1.110 +      : "r" (change),
   1.111 +        "r" (src),
   1.112 +        "r" (ds)
   1.113 +      : "memory", "edi"
   1.114 +  );
   1.115 +}
   1.116 +
   1.117 +OIL_DEFINE_IMPL_FULL (recon8x8_inter_i386_mmx, recon8x8_inter, OIL_IMPL_FLAG_MMX);
   1.118 +
   1.119 +static void
   1.120 +recon8x8_inter2_i386_mmx (uint8_t *dest, int ds, uint8_t *s1, int ss1, uint8_t *s2, int ss2, int16_t *change)
   1.121 +{
   1.122 +  /* FIXME doesn't handle ss1, ss2 */
   1.123 +  __asm__ __volatile__ (
   1.124 +    "  pxor        %%mm0, %%mm0        \n\t"
   1.125 +    "  lea         128(%1), %%edi      \n\t"
   1.126 +
   1.127 +    "1:                                \n\t"
   1.128 +    "  movq        (%2), %%mm2         \n\t" /* (+3 misaligned) 8 reference pixels */
   1.129 +    "  movq        (%3), %%mm4         \n\t" /* (+3 misaligned) 8 reference pixels */
   1.130 +
   1.131 +    "  movq        %%mm2, %%mm3        \n\t"
   1.132 +    "  punpcklbw   %%mm0, %%mm2        \n\t" /* mm2 = start ref1 as positive 16-bit #s */
   1.133 +    "  movq        %%mm4, %%mm5        \n\t"
   1.134 +    "  movq        (%1), %%mm6         \n\t" /* first 4 changes */
   1.135 +    "  punpckhbw   %%mm0, %%mm3        \n\t" /* mm3 = end ref1 as positive 16-bit #s */
   1.136 +    "  movq        8(%1), %%mm7        \n\t" /* last 4 changes */
   1.137 +    "  punpcklbw   %%mm0, %%mm4        \n\t" /* mm4 = start ref2 as positive 16-bit #s */
   1.138 +    "  punpckhbw   %%mm0, %%mm5        \n\t" /* mm5 = end ref2 as positive 16-bit #s */
   1.139 +    "  paddw       %%mm4, %%mm2        \n\t" /* mm2 = start (ref1 + ref2) */
   1.140 +    "  paddw       %%mm5, %%mm3        \n\t" /* mm3 = end (ref1 + ref2) */
   1.141 +    "  psrlw       $1, %%mm2           \n\t" /* mm2 = start (ref1 + ref2)/2 */
   1.142 +    "  psrlw       $1, %%mm3           \n\t" /* mm3 = end (ref1 + ref2)/2 */
   1.143 +    "  paddw       %%mm6, %%mm2        \n\t" /* add changes to start */
   1.144 +    "  paddw       %%mm7, %%mm3        \n\t" /* add changes to end */
   1.145 +    "  lea         16(%1), %1          \n\t" /* next row of changes */
   1.146 +    "  packuswb    %%mm3, %%mm2        \n\t" /* pack start|end to unsigned 8-bit */
   1.147 +    "  add         %4, %2              \n\t" /* next row of reference pixels */
   1.148 +    "  add         %4, %3              \n\t" /* next row of reference pixels */
   1.149 +    "  movq        %%mm2, (%0)         \n\t" /* store result */
   1.150 +    "  add         %4, %0              \n\t" /* next row of output */
   1.151 +    "  cmp         %%edi, %1           \n\t" /* are we done? */
   1.152 +    "  jc          1b                  \n\t"
   1.153 +    "  emms                            \n\t"
   1.154 +      : "+r" (dest)
   1.155 +      : "r" (change),
   1.156 +        "r" (s1),
   1.157 +        "r" (s2),
   1.158 +        "m" (ds)
   1.159 +      : "memory", "edi"
   1.160 +  );
   1.161 +}
   1.162 +
   1.163 +OIL_DEFINE_IMPL_FULL (recon8x8_inter2_i386_mmx, recon8x8_inter2, OIL_IMPL_FLAG_MMX);
   1.164 +#endif
   1.165 +
   1.166 +
   1.167 +#ifdef	__SYMBIAN32__
   1.168 + 
   1.169 +OilFunctionImpl* __oil_function_impl_recon8x8_intra_i386_mmx, recon8x8_intra() {
   1.170 +		return &_oil_function_impl_recon8x8_intra_i386_mmx, recon8x8_intra;
   1.171 +}
   1.172 +#endif
   1.173 +
   1.174 +#ifdef	__SYMBIAN32__
   1.175 + 
   1.176 +OilFunctionImpl* __oil_function_impl_recon8x8_inter_i386_mmx, recon8x8_inter() {
   1.177 +		return &_oil_function_impl_recon8x8_inter_i386_mmx, recon8x8_inter;
   1.178 +}
   1.179 +#endif
   1.180 +
   1.181 +#ifdef	__SYMBIAN32__
   1.182 + 
   1.183 +OilFunctionImpl* __oil_function_impl_recon8x8_inter2_i386_mmx, recon8x8_inter2() {
   1.184 +		return &_oil_function_impl_recon8x8_inter2_i386_mmx, recon8x8_inter2;
   1.185 +}
   1.186 +#endif
   1.187 +