1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/sad8x8_sse.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,68 @@
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 +
1.30 +#ifdef HAVE_CONFIG_H
1.31 +#include "config.h"
1.32 +#endif
1.33 +#include <liboil/liboilclasses.h>
1.34 +#include <liboil/liboilfunction.h>
1.35 +#include <emmintrin.h>
1.36 +
1.37 +#define SSE_FUNCTION __attribute__((force_align_arg_pointer))
1.38 +
1.39 +#ifdef ENABLE_BROKEN_IMPLS
1.40 +union m128_int {
1.41 + __m128i m128;
1.42 + uint32_t i[4];
1.43 + uint16_t s[8];
1.44 +};
1.45 +
1.46 +SSE_FUNCTION static void
1.47 +sad8x8_u8_sse (uint32_t *dest, uint8_t *src1, int sstr1, uint8_t *src2,
1.48 + int sstr2)
1.49 +{
1.50 + int i;
1.51 + __m128i sum = _mm_setzero_si128();
1.52 + union m128_int sumi;
1.53 +
1.54 + for (i = 0; i < 4; i++) {
1.55 + __m128i xmm0, xmm1, xmm2, xmm3;
1.56 + xmm0 = _mm_loadl_epi64((__m128i *)src1);
1.57 + xmm1 = _mm_loadl_epi64((__m128i *)(src1 + sstr1));
1.58 + xmm2 = _mm_loadl_epi64((__m128i *)src2);
1.59 + xmm3 = _mm_loadl_epi64((__m128i *)(src2 + sstr2));
1.60 + xmm0 = _mm_unpacklo_epi8(xmm0, xmm1);
1.61 + xmm2 = _mm_unpacklo_epi8(xmm2, xmm3);
1.62 + sum = _mm_add_epi64(sum, _mm_sad_epu8(xmm0, xmm2));
1.63 + src1 += 2 * sstr1;
1.64 + src2 += 2 * sstr2;
1.65 + }
1.66 + sumi.m128 = sum;
1.67 + *dest = sumi.i[0] + sumi.i[2];
1.68 +}
1.69 +OIL_DEFINE_IMPL_FULL_WRAPPER(sad8x8_u8_sse, sad8x8_u8, OIL_IMPL_FLAG_SSE2);
1.70 +#endif
1.71 +