|
1 /* |
|
2 * Copyright (c) 2005 |
|
3 * Eric Anholt. All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions |
|
7 * are met: |
|
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. |
|
13 * |
|
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 |
|
24 * SUCH DAMAGE. |
|
25 */ |
|
26 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
27 |
|
28 #ifdef HAVE_CONFIG_H |
|
29 #include "config.h" |
|
30 #endif |
|
31 #include <liboil/liboilclasses.h> |
|
32 #include <liboil/liboilfunction.h> |
|
33 |
|
34 #ifdef HAVE_GCC_ASM |
|
35 #include <mmintrin.h> |
|
36 #endif |
|
37 |
|
38 #ifdef ENABLE_BROKEN_IMPLS |
|
39 union m64_int { |
|
40 __m64 m64; |
|
41 uint64_t ull; |
|
42 }; |
|
43 |
|
44 static const struct _MMXData { |
|
45 union m64_int mmx_4x0080; |
|
46 } c = { |
|
47 .mmx_4x0080.ull = 0x0080008000800080ULL, |
|
48 }; |
|
49 |
|
50 #define MC(x) (c.mmx_##x.m64) |
|
51 |
|
52 static void |
|
53 recon8x8_intra_mmx (uint8_t *dest, int ds, int16_t *change) |
|
54 { |
|
55 int i; |
|
56 __m64 offset = MC(4x0080); |
|
57 |
|
58 for (i = 8; i; i--) { |
|
59 __m64 mm0, mm1, c0, c1; |
|
60 c0 = ((__m64 *)change)[0]; |
|
61 c1 = ((__m64 *)change)[1]; |
|
62 mm0 = _mm_adds_pi16(c0, offset); |
|
63 mm1 = _mm_adds_pi16(c1, offset); |
|
64 *(__m64 *)dest = _mm_packs_pu16(mm0, mm1); |
|
65 |
|
66 dest += ds; |
|
67 change += 8; |
|
68 } |
|
69 _mm_empty(); |
|
70 } |
|
71 OIL_DEFINE_IMPL_FULL (recon8x8_intra_mmx, recon8x8_intra, OIL_IMPL_FLAG_MMX); |
|
72 #endif |
|
73 |
|
74 static void |
|
75 recon8x8_inter_mmx (uint8_t *dest, int ds, uint8_t *src, int ss, |
|
76 int16_t *change, int dss) |
|
77 { |
|
78 #ifdef HAVE_GCC_ASM |
|
79 int i; |
|
80 |
|
81 for (i = 8; i; i--) { |
|
82 __m64 mm0, mm1, c0, c1; |
|
83 c0 = ((__m64 *)change)[0]; |
|
84 c1 = ((__m64 *)change)[1]; |
|
85 mm0 = _mm_unpacklo_pi8(*(__m64 *)src, _mm_setzero_si64()); |
|
86 mm1 = _mm_unpackhi_pi8(*(__m64 *)src, _mm_setzero_si64()); |
|
87 mm0 = _mm_adds_pi16(mm0, c0); |
|
88 mm1 = _mm_adds_pi16(mm1, c1); |
|
89 *(__m64 *)dest = _mm_packs_pu16(mm0, mm1); |
|
90 |
|
91 change += 8; |
|
92 dest += ds; |
|
93 src += ss; |
|
94 } |
|
95 _mm_empty(); |
|
96 #endif |
|
97 } |
|
98 OIL_DEFINE_IMPL_FULL (recon8x8_inter_mmx, recon8x8_inter, OIL_IMPL_FLAG_MMX); |
|
99 |
|
100 static void |
|
101 recon8x8_inter2_mmx (uint8_t *dest, int ds, uint8_t *s1, int ss1, uint8_t *s2, |
|
102 int ss2, int16_t *change) |
|
103 { |
|
104 int i; |
|
105 #ifdef HAVE_GCC_ASM |
|
106 for (i = 8; i; i--) { |
|
107 __m64 mm0, mm1, c0, c1; |
|
108 mm0 = _mm_adds_pu16( |
|
109 _mm_unpacklo_pi8(*(__m64 *)s1, _mm_setzero_si64()), |
|
110 _mm_unpacklo_pi8(*(__m64 *)s2, _mm_setzero_si64())); |
|
111 mm1 = _mm_adds_pu16( |
|
112 _mm_unpackhi_pi8(*(__m64 *)s1, _mm_setzero_si64()), |
|
113 _mm_unpackhi_pi8(*(__m64 *)s2, _mm_setzero_si64())); |
|
114 c0 = ((__m64 *)change)[0]; |
|
115 c1 = ((__m64 *)change)[1]; |
|
116 mm0 = _mm_srli_pi16(mm0, 1); |
|
117 mm1 = _mm_srli_pi16(mm1, 1); |
|
118 mm0 = _mm_adds_pi16(mm0, c0); |
|
119 mm1 = _mm_adds_pi16(mm1, c1); |
|
120 *(__m64 *)dest = _mm_packs_pu16(mm0, mm1); |
|
121 change += 8; |
|
122 dest += ds; |
|
123 s1 += ss1; |
|
124 s2 += ss2; |
|
125 } |
|
126 _mm_empty(); |
|
127 #endif |
|
128 } |
|
129 OIL_DEFINE_IMPL_FULL (recon8x8_inter2_mmx, recon8x8_inter2, OIL_IMPL_FLAG_MMX); |
|
130 |
|
131 #if 0 |
|
132 #ifdef __SYMBIAN32__ |
|
133 |
|
134 OilFunctionImpl* __oil_function_impl_recon8x8_intra_mmx() { |
|
135 return &_oil_function_impl_recon8x8_intra_mmx; |
|
136 } |
|
137 #endif |
|
138 #endif |
|
139 #ifdef __SYMBIAN32__ |
|
140 |
|
141 OilFunctionImpl* __oil_function_impl_recon8x8_inter_mmx() { |
|
142 return &_oil_function_impl_recon8x8_inter_mmx; |
|
143 } |
|
144 #endif |
|
145 |
|
146 #ifdef __SYMBIAN32__ |
|
147 |
|
148 OilFunctionImpl* __oil_function_impl_recon8x8_inter2_mmx() { |
|
149 return &_oil_function_impl_recon8x8_inter2_mmx; |
|
150 } |
|
151 #endif |
|
152 |