sl@0
|
1 |
/*
|
sl@0
|
2 |
* LIBOIL - Library of Optimized Inner Loops
|
sl@0
|
3 |
* Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
|
sl@0
|
4 |
* All rights reserved.
|
sl@0
|
5 |
*
|
sl@0
|
6 |
* Redistribution and use in source and binary forms, with or without
|
sl@0
|
7 |
* modification, are permitted provided that the following conditions
|
sl@0
|
8 |
* are met:
|
sl@0
|
9 |
* 1. Redistributions of source code must retain the above copyright
|
sl@0
|
10 |
* notice, this list of conditions and the following disclaimer.
|
sl@0
|
11 |
* 2. Redistributions in binary form must reproduce the above copyright
|
sl@0
|
12 |
* notice, this list of conditions and the following disclaimer in the
|
sl@0
|
13 |
* documentation and/or other materials provided with the distribution.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
sl@0
|
16 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
sl@0
|
17 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
sl@0
|
18 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
sl@0
|
19 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
sl@0
|
20 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
sl@0
|
21 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
sl@0
|
22 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
sl@0
|
23 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
sl@0
|
24 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
sl@0
|
25 |
* POSSIBILITY OF SUCH DAMAGE.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
sl@0
|
28 |
|
sl@0
|
29 |
#ifdef HAVE_CONFIG_H
|
sl@0
|
30 |
#include "config.h"
|
sl@0
|
31 |
#endif
|
sl@0
|
32 |
|
sl@0
|
33 |
#include <liboil/liboilfunction.h>
|
sl@0
|
34 |
|
sl@0
|
35 |
OIL_DECLARE_CLASS (diff8x8_s16_u8);
|
sl@0
|
36 |
OIL_DECLARE_CLASS (diff8x8_const128_s16_u8);
|
sl@0
|
37 |
OIL_DECLARE_CLASS (diff8x8_average_s16_u8);
|
sl@0
|
38 |
|
sl@0
|
39 |
|
sl@0
|
40 |
static void
|
sl@0
|
41 |
diff8x8_s16_u8_mmx (int16_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
#if !defined(__WINSCW__) && !defined(__WINS__)
|
sl@0
|
44 |
__asm__ __volatile__ (
|
sl@0
|
45 |
" pxor %%mm7, %%mm7 \n\t"
|
sl@0
|
46 |
|
sl@0
|
47 |
#define LOOP \
|
sl@0
|
48 |
" movq (%0), %%mm0 \n\t" /* mm0 = FiltPtr */ \
|
sl@0
|
49 |
" movq (%1), %%mm1 \n\t" /* mm1 = ReconPtr */ \
|
sl@0
|
50 |
" movq %%mm0, %%mm2 \n\t" /* dup to prepare for up conversion */ \
|
sl@0
|
51 |
" movq %%mm1, %%mm3 \n\t" /* dup to prepare for up conversion */ \
|
sl@0
|
52 |
/* convert from UINT8 to INT16 */ \
|
sl@0
|
53 |
" punpcklbw %%mm7, %%mm0 \n\t" /* mm0 = INT16(FiltPtr) */ \
|
sl@0
|
54 |
" punpcklbw %%mm7, %%mm1 \n\t" /* mm1 = INT16(ReconPtr) */ \
|
sl@0
|
55 |
" punpckhbw %%mm7, %%mm2 \n\t" /* mm2 = INT16(FiltPtr) */ \
|
sl@0
|
56 |
" punpckhbw %%mm7, %%mm3 \n\t" /* mm3 = INT16(ReconPtr) */ \
|
sl@0
|
57 |
/* start calculation */ \
|
sl@0
|
58 |
" psubw %%mm1, %%mm0 \n\t" /* mm0 = FiltPtr - ReconPtr */ \
|
sl@0
|
59 |
" psubw %%mm3, %%mm2 \n\t" /* mm2 = FiltPtr - ReconPtr */ \
|
sl@0
|
60 |
" movq %%mm0, (%2) \n\t" /* write answer out */ \
|
sl@0
|
61 |
" movq %%mm2, 8(%2) \n\t" /* write answer out */ \
|
sl@0
|
62 |
/* Increment pointers */ \
|
sl@0
|
63 |
" add $16, %2 \n\t" \
|
sl@0
|
64 |
" add %3, %0 \n\t" \
|
sl@0
|
65 |
" add %4, %1 \n\t"
|
sl@0
|
66 |
|
sl@0
|
67 |
LOOP
|
sl@0
|
68 |
LOOP
|
sl@0
|
69 |
LOOP
|
sl@0
|
70 |
LOOP
|
sl@0
|
71 |
LOOP
|
sl@0
|
72 |
LOOP
|
sl@0
|
73 |
LOOP
|
sl@0
|
74 |
LOOP
|
sl@0
|
75 |
#undef LOOP
|
sl@0
|
76 |
|
sl@0
|
77 |
" emms \n\t"
|
sl@0
|
78 |
|
sl@0
|
79 |
: "+r" (src1),
|
sl@0
|
80 |
"+r" (src2),
|
sl@0
|
81 |
"+r" (dest)
|
sl@0
|
82 |
: "m" (ss1),
|
sl@0
|
83 |
"m" (ss2)
|
sl@0
|
84 |
: "memory"
|
sl@0
|
85 |
);
|
sl@0
|
86 |
#endif
|
sl@0
|
87 |
}
|
sl@0
|
88 |
OIL_DEFINE_IMPL_FULL (diff8x8_s16_u8_mmx, diff8x8_s16_u8, OIL_IMPL_FLAG_MMX);
|
sl@0
|
89 |
|
sl@0
|
90 |
static void
|
sl@0
|
91 |
diff8x8_const128_s16_u8_mmx (int16_t *dest, uint8_t *src1, int ss1)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
#if !defined(__WINSCW__) && !defined(__WINS__)
|
sl@0
|
94 |
const int16_t tmp[4] = { 0x0080, 0x0080, 0x0080, 0x0080 };
|
sl@0
|
95 |
|
sl@0
|
96 |
__asm__ __volatile__ (
|
sl@0
|
97 |
" pxor %%mm7, %%mm7 \n\t"
|
sl@0
|
98 |
" movq (%3), %%mm1 \n\t"
|
sl@0
|
99 |
|
sl@0
|
100 |
#define LOOP \
|
sl@0
|
101 |
" movq (%0), %%mm0 \n\t" /* mm0 = FiltPtr */ \
|
sl@0
|
102 |
" movq %%mm0, %%mm2 \n\t" /* dup to prepare for up conversion */ \
|
sl@0
|
103 |
/* convert from UINT8 to INT16 */ \
|
sl@0
|
104 |
" punpcklbw %%mm7, %%mm0 \n\t" /* mm0 = INT16(FiltPtr) */ \
|
sl@0
|
105 |
" punpckhbw %%mm7, %%mm2 \n\t" /* mm2 = INT16(FiltPtr) */ \
|
sl@0
|
106 |
/* start calculation */ \
|
sl@0
|
107 |
" psubw %%mm1, %%mm0 \n\t" /* mm0 = FiltPtr - 128 */ \
|
sl@0
|
108 |
" psubw %%mm1, %%mm2 \n\t" /* mm2 = FiltPtr - 128 */ \
|
sl@0
|
109 |
" movq %%mm0, (%1) \n\t" /* write answer out */ \
|
sl@0
|
110 |
" movq %%mm2, 8(%1) \n\t" /* write answer out */ \
|
sl@0
|
111 |
/* Increment pointers */ \
|
sl@0
|
112 |
" add $16, %1 \n\t" \
|
sl@0
|
113 |
" add %2, %0 \n\t"
|
sl@0
|
114 |
|
sl@0
|
115 |
LOOP
|
sl@0
|
116 |
LOOP
|
sl@0
|
117 |
LOOP
|
sl@0
|
118 |
LOOP
|
sl@0
|
119 |
LOOP
|
sl@0
|
120 |
LOOP
|
sl@0
|
121 |
LOOP
|
sl@0
|
122 |
LOOP
|
sl@0
|
123 |
#undef LOOP
|
sl@0
|
124 |
|
sl@0
|
125 |
" emms \n\t"
|
sl@0
|
126 |
|
sl@0
|
127 |
: "+r" (src1),
|
sl@0
|
128 |
"+r" (dest)
|
sl@0
|
129 |
: "r" (ss1),
|
sl@0
|
130 |
"r" (tmp)
|
sl@0
|
131 |
: "memory"
|
sl@0
|
132 |
);
|
sl@0
|
133 |
#endif
|
sl@0
|
134 |
}
|
sl@0
|
135 |
OIL_DEFINE_IMPL_FULL (diff8x8_const128_s16_u8_mmx, diff8x8_const128_s16_u8, OIL_IMPL_FLAG_MMX);
|
sl@0
|
136 |
|
sl@0
|
137 |
static void
|
sl@0
|
138 |
diff8x8_average_s16_u8_mmx (int16_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2, uint8_t *src3)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
#if !defined(__WINSCW__) && !defined(__WINS__)
|
sl@0
|
141 |
__asm__ __volatile__ (
|
sl@0
|
142 |
" pxor %%mm7, %%mm7 \n\t"
|
sl@0
|
143 |
|
sl@0
|
144 |
#define LOOP \
|
sl@0
|
145 |
" movq (%0), %%mm0 \n\t" /* mm0 = FiltPtr */ \
|
sl@0
|
146 |
" movq (%1), %%mm1 \n\t" /* mm1 = ReconPtr1 */ \
|
sl@0
|
147 |
" movq (%2), %%mm4 \n\t" /* mm1 = ReconPtr2 */ \
|
sl@0
|
148 |
" movq %%mm0, %%mm2 \n\t" /* dup to prepare for up conversion */ \
|
sl@0
|
149 |
" movq %%mm1, %%mm3 \n\t" /* dup to prepare for up conversion */ \
|
sl@0
|
150 |
" movq %%mm4, %%mm5 \n\t" /* dup to prepare for up conversion */ \
|
sl@0
|
151 |
/* convert from UINT8 to INT16 */ \
|
sl@0
|
152 |
" punpcklbw %%mm7, %%mm0 \n\t" /* mm0 = INT16(FiltPtr) */ \
|
sl@0
|
153 |
" punpcklbw %%mm7, %%mm1 \n\t" /* mm1 = INT16(ReconPtr1) */ \
|
sl@0
|
154 |
" punpcklbw %%mm7, %%mm4 \n\t" /* mm1 = INT16(ReconPtr2) */ \
|
sl@0
|
155 |
" punpckhbw %%mm7, %%mm2 \n\t" /* mm2 = INT16(FiltPtr) */ \
|
sl@0
|
156 |
" punpckhbw %%mm7, %%mm3 \n\t" /* mm3 = INT16(ReconPtr1) */ \
|
sl@0
|
157 |
" punpckhbw %%mm7, %%mm5 \n\t" /* mm3 = INT16(ReconPtr2) */ \
|
sl@0
|
158 |
/* average ReconPtr1 and ReconPtr2 */ \
|
sl@0
|
159 |
" paddw %%mm4, %%mm1 \n\t" /* mm1 = ReconPtr1 + ReconPtr2 */ \
|
sl@0
|
160 |
" paddw %%mm5, %%mm3 \n\t" /* mm3 = ReconPtr1 + ReconPtr2 */ \
|
sl@0
|
161 |
" psrlw $1, %%mm1 \n\t" /* mm1 = (ReconPtr1 + ReconPtr2) / 2 */ \
|
sl@0
|
162 |
" psrlw $1, %%mm3 \n\t" /* mm3 = (ReconPtr1 + ReconPtr2) / 2 */ \
|
sl@0
|
163 |
" psubw %%mm1, %%mm0 \n\t" /* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */ \
|
sl@0
|
164 |
" psubw %%mm3, %%mm2 \n\t" /* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */ \
|
sl@0
|
165 |
" movq %%mm0, (%3) \n\t" /* write answer out */ \
|
sl@0
|
166 |
" movq %%mm2, 8(%3) \n\t" /* write answer out */ \
|
sl@0
|
167 |
/* Increment pointers */ \
|
sl@0
|
168 |
" add $16, %3 \n\t" \
|
sl@0
|
169 |
" add %4, %0 \n\t" \
|
sl@0
|
170 |
" add %5, %1 \n\t" \
|
sl@0
|
171 |
" add %5, %2 \n\t"
|
sl@0
|
172 |
|
sl@0
|
173 |
LOOP
|
sl@0
|
174 |
LOOP
|
sl@0
|
175 |
LOOP
|
sl@0
|
176 |
LOOP
|
sl@0
|
177 |
LOOP
|
sl@0
|
178 |
LOOP
|
sl@0
|
179 |
LOOP
|
sl@0
|
180 |
LOOP
|
sl@0
|
181 |
#undef LOOP
|
sl@0
|
182 |
|
sl@0
|
183 |
" emms \n\t"
|
sl@0
|
184 |
|
sl@0
|
185 |
: "+r" (src1),
|
sl@0
|
186 |
"+r" (src2),
|
sl@0
|
187 |
"+r" (src3),
|
sl@0
|
188 |
"+r" (dest)
|
sl@0
|
189 |
: "m" (ss1),
|
sl@0
|
190 |
"m" (ss2)
|
sl@0
|
191 |
: "memory"
|
sl@0
|
192 |
);
|
sl@0
|
193 |
#endif
|
sl@0
|
194 |
}
|
sl@0
|
195 |
OIL_DEFINE_IMPL_FULL (diff8x8_average_s16_u8_mmx, diff8x8_average_s16_u8, OIL_IMPL_FLAG_MMX);
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
|
sl@0
|
199 |
#ifdef __SYMBIAN32__
|
sl@0
|
200 |
|
sl@0
|
201 |
OilFunctionImpl* __oil_function_impl_diff8x8_s16_u8_mmx, diff8x8_s16_u8() {
|
sl@0
|
202 |
return &_oil_function_impl_diff8x8_s16_u8_mmx, diff8x8_s16_u8;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
#endif
|
sl@0
|
205 |
|
sl@0
|
206 |
#ifdef __SYMBIAN32__
|
sl@0
|
207 |
|
sl@0
|
208 |
OilFunctionImpl* __oil_function_impl_diff8x8_const128_s16_u8_mmx, diff8x8_const128_s16_u8() {
|
sl@0
|
209 |
return &_oil_function_impl_diff8x8_const128_s16_u8_mmx, diff8x8_const128_s16_u8;
|
sl@0
|
210 |
}
|
sl@0
|
211 |
#endif
|
sl@0
|
212 |
|
sl@0
|
213 |
#ifdef __SYMBIAN32__
|
sl@0
|
214 |
|
sl@0
|
215 |
OilFunctionImpl* __oil_function_impl_diff8x8_average_s16_u8_mmx, diff8x8_average_s16_u8() {
|
sl@0
|
216 |
return &_oil_function_impl_diff8x8_average_s16_u8_mmx, diff8x8_average_s16_u8;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
#endif
|
sl@0
|
219 |
|