1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/mmx/recon8x8_mmx.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,152 @@
1.4 +/*
1.5 + * Copyright (c) 2005
1.6 + * Eric Anholt. All rights reserved.
1.7 + *
1.8 + * Redistribution and use in source and binary forms, with or without
1.9 + * modification, are permitted provided that the following conditions
1.10 + * are met:
1.11 + * 1. Redistributions of source code must retain the above copyright
1.12 + * notice, this list of conditions and the following disclaimer.
1.13 + * 2. Redistributions in binary form must reproduce the above copyright
1.14 + * notice, this list of conditions and the following disclaimer in the
1.15 + * documentation and/or other materials provided with the distribution.
1.16 + *
1.17 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
1.18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.20 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
1.21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.27 + * SUCH DAMAGE.
1.28 + */
1.29 +//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.30 +
1.31 +#ifdef HAVE_CONFIG_H
1.32 +#include "config.h"
1.33 +#endif
1.34 +#include <liboil/liboilclasses.h>
1.35 +#include <liboil/liboilfunction.h>
1.36 +
1.37 +#ifdef HAVE_GCC_ASM
1.38 +#include <mmintrin.h>
1.39 +#endif
1.40 +
1.41 +#ifdef ENABLE_BROKEN_IMPLS
1.42 +union m64_int {
1.43 + __m64 m64;
1.44 + uint64_t ull;
1.45 +};
1.46 +
1.47 +static const struct _MMXData {
1.48 + union m64_int mmx_4x0080;
1.49 +} c = {
1.50 + .mmx_4x0080.ull = 0x0080008000800080ULL,
1.51 +};
1.52 +
1.53 +#define MC(x) (c.mmx_##x.m64)
1.54 +
1.55 +static void
1.56 +recon8x8_intra_mmx (uint8_t *dest, int ds, int16_t *change)
1.57 +{
1.58 + int i;
1.59 + __m64 offset = MC(4x0080);
1.60 +
1.61 + for (i = 8; i; i--) {
1.62 + __m64 mm0, mm1, c0, c1;
1.63 + c0 = ((__m64 *)change)[0];
1.64 + c1 = ((__m64 *)change)[1];
1.65 + mm0 = _mm_adds_pi16(c0, offset);
1.66 + mm1 = _mm_adds_pi16(c1, offset);
1.67 + *(__m64 *)dest = _mm_packs_pu16(mm0, mm1);
1.68 +
1.69 + dest += ds;
1.70 + change += 8;
1.71 + }
1.72 + _mm_empty();
1.73 +}
1.74 +OIL_DEFINE_IMPL_FULL (recon8x8_intra_mmx, recon8x8_intra, OIL_IMPL_FLAG_MMX);
1.75 +#endif
1.76 +
1.77 +static void
1.78 +recon8x8_inter_mmx (uint8_t *dest, int ds, uint8_t *src, int ss,
1.79 + int16_t *change, int dss)
1.80 +{
1.81 +#ifdef HAVE_GCC_ASM
1.82 + int i;
1.83 +
1.84 + for (i = 8; i; i--) {
1.85 + __m64 mm0, mm1, c0, c1;
1.86 + c0 = ((__m64 *)change)[0];
1.87 + c1 = ((__m64 *)change)[1];
1.88 + mm0 = _mm_unpacklo_pi8(*(__m64 *)src, _mm_setzero_si64());
1.89 + mm1 = _mm_unpackhi_pi8(*(__m64 *)src, _mm_setzero_si64());
1.90 + mm0 = _mm_adds_pi16(mm0, c0);
1.91 + mm1 = _mm_adds_pi16(mm1, c1);
1.92 + *(__m64 *)dest = _mm_packs_pu16(mm0, mm1);
1.93 +
1.94 + change += 8;
1.95 + dest += ds;
1.96 + src += ss;
1.97 + }
1.98 + _mm_empty();
1.99 +#endif
1.100 +}
1.101 +OIL_DEFINE_IMPL_FULL (recon8x8_inter_mmx, recon8x8_inter, OIL_IMPL_FLAG_MMX);
1.102 +
1.103 +static void
1.104 +recon8x8_inter2_mmx (uint8_t *dest, int ds, uint8_t *s1, int ss1, uint8_t *s2,
1.105 + int ss2, int16_t *change)
1.106 +{
1.107 + int i;
1.108 +#ifdef HAVE_GCC_ASM
1.109 + for (i = 8; i; i--) {
1.110 + __m64 mm0, mm1, c0, c1;
1.111 + mm0 = _mm_adds_pu16(
1.112 + _mm_unpacklo_pi8(*(__m64 *)s1, _mm_setzero_si64()),
1.113 + _mm_unpacklo_pi8(*(__m64 *)s2, _mm_setzero_si64()));
1.114 + mm1 = _mm_adds_pu16(
1.115 + _mm_unpackhi_pi8(*(__m64 *)s1, _mm_setzero_si64()),
1.116 + _mm_unpackhi_pi8(*(__m64 *)s2, _mm_setzero_si64()));
1.117 + c0 = ((__m64 *)change)[0];
1.118 + c1 = ((__m64 *)change)[1];
1.119 + mm0 = _mm_srli_pi16(mm0, 1);
1.120 + mm1 = _mm_srli_pi16(mm1, 1);
1.121 + mm0 = _mm_adds_pi16(mm0, c0);
1.122 + mm1 = _mm_adds_pi16(mm1, c1);
1.123 + *(__m64 *)dest = _mm_packs_pu16(mm0, mm1);
1.124 + change += 8;
1.125 + dest += ds;
1.126 + s1 += ss1;
1.127 + s2 += ss2;
1.128 + }
1.129 + _mm_empty();
1.130 +#endif
1.131 +}
1.132 +OIL_DEFINE_IMPL_FULL (recon8x8_inter2_mmx, recon8x8_inter2, OIL_IMPL_FLAG_MMX);
1.133 +
1.134 +#if 0
1.135 +#ifdef __SYMBIAN32__
1.136 +
1.137 +OilFunctionImpl* __oil_function_impl_recon8x8_intra_mmx() {
1.138 + return &_oil_function_impl_recon8x8_intra_mmx;
1.139 +}
1.140 +#endif
1.141 +#endif
1.142 +#ifdef __SYMBIAN32__
1.143 +
1.144 +OilFunctionImpl* __oil_function_impl_recon8x8_inter_mmx() {
1.145 + return &_oil_function_impl_recon8x8_inter_mmx;
1.146 +}
1.147 +#endif
1.148 +
1.149 +#ifdef __SYMBIAN32__
1.150 +
1.151 +OilFunctionImpl* __oil_function_impl_recon8x8_inter2_mmx() {
1.152 + return &_oil_function_impl_recon8x8_inter2_mmx;
1.153 +}
1.154 +#endif
1.155 +