First public contribution.
2 * Copyright © 2004 Red Hat, Inc.
3 * Copyright © 2005 Trolltech AS
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Red Hat not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. Red Hat makes no representations about the
12 * suitability of this software for any purpose. It is provided "as is"
13 * without express or implied warranty.
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
20 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
21 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
24 * Author: Søren Sandmann (sandmann@redhat.com)
25 * Lars Knoll (lars@trolltech.com)
27 * Based on work by Owen Taylor
31 #define MmxNegate(x) _mm_xor_si64((x), mmx_4x00ff)
32 #define MmxAlpha(x) _mm_shuffle_pi16 ((x), _MM_SHUFFLE(3, 3, 3, 3));
33 #define MmxTo(x) _mm_unpacklo_pi8 (_mm_cvtsi32_si64((x)), mmx_0)
34 #define MmxFrom(x) (uint32_t)_mm_cvtsi64_si32(_mm_packs_pu16((x), mmx_0))
35 #define MmxAdd(x, y) _mm_adds_pu16 ((x), (y))
37 #define MmxMulAdd(x, a, y) do { \
38 x = _mm_mullo_pi16 (x, a); \
39 x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); \
40 x = _mm_adds_pu16 (x, mmx_4x0080); \
41 x = _mm_srli_pi16 (x, 8); \
42 x = _mm_adds_pu16(x, y); \
45 #define MmxMul(x, a) do { \
46 x = _mm_mullo_pi16 (x, a); \
47 x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); \
48 x = _mm_adds_pu16 (x, mmx_4x0080); \
49 x = _mm_srli_pi16 (x, 8); \
52 #define MmxAddMul(x, a, y, b) do { \
53 x = _mm_mullo_pi16 (x, a); \
54 y = _mm_mullo_pi16 (y, b); \
55 x = _mm_srli_pi16(x, 1); \
56 y = _mm_srli_pi16(y, 1); \
57 x = _mm_adds_pu16 (x, y); \
58 x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); \
59 x = _mm_adds_pu16 (x, mmx_4x0080); \
60 x = _mm_srli_pi16 (x, 7); \