Update contrib.
3 * Eric Anholt. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <liboil/liboilclasses.h>
31 #include <liboil/liboilfunction.h>
32 #include <emmintrin.h>
34 #define SSE_FUNCTION __attribute__((force_align_arg_pointer))
36 #ifdef ENABLE_BROKEN_IMPLS
43 SSE_FUNCTION static void
44 sad8x8_u8_sse (uint32_t *dest, uint8_t *src1, int sstr1, uint8_t *src2,
48 __m128i sum = _mm_setzero_si128();
51 for (i = 0; i < 4; i++) {
52 __m128i xmm0, xmm1, xmm2, xmm3;
53 xmm0 = _mm_loadl_epi64((__m128i *)src1);
54 xmm1 = _mm_loadl_epi64((__m128i *)(src1 + sstr1));
55 xmm2 = _mm_loadl_epi64((__m128i *)src2);
56 xmm3 = _mm_loadl_epi64((__m128i *)(src2 + sstr2));
57 xmm0 = _mm_unpacklo_epi8(xmm0, xmm1);
58 xmm2 = _mm_unpacklo_epi8(xmm2, xmm3);
59 sum = _mm_add_epi64(sum, _mm_sad_epu8(xmm0, xmm2));
64 *dest = sumi.i[0] + sumi.i[2];
66 OIL_DEFINE_IMPL_FULL_WRAPPER(sad8x8_u8_sse, sad8x8_u8, OIL_IMPL_FLAG_SSE2);