Mercurial > libavcodec.hg
annotate i386/cavsdsp_mmx.c @ 6126:c24cd5282108 libavcodec
split out init of downmix coeffs into a separate function that can be called
only when needed
author | jbr |
---|---|
date | Mon, 07 Jan 2008 00:18:02 +0000 |
parents | 15ed47af1838 |
children | 1c67967d893b |
rev | line source |
---|---|
3524 | 1 /* |
2 * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. | |
3 * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> | |
4 * | |
5967
15ed47af1838
Misc spelling fixes, prefer American over British English.
diego
parents:
5963
diff
changeset
|
5 * MMX-optimized DSP functions, based on H.264 optimizations by |
3524 | 6 * Michael Niedermayer and Loren Merritt |
7 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3524
diff
changeset
|
8 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3524
diff
changeset
|
9 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3524
diff
changeset
|
10 * FFmpeg is free software; you can redistribute it and/or |
3524 | 11 * modify it under the terms of the GNU Lesser General Public |
12 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3524
diff
changeset
|
13 * version 2.1 of the License, or (at your option) any later version. |
3524 | 14 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3524
diff
changeset
|
15 * FFmpeg is distributed in the hope that it will be useful, |
3524 | 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 * Lesser General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3524
diff
changeset
|
21 * License along with FFmpeg; if not, write to the Free Software |
5215 | 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3524 | 23 */ |
24 | |
5010
d5ba514e3f4a
Add libavcodec to compiler include flags in order to simplify header
diego
parents:
3947
diff
changeset
|
25 #include "dsputil.h" |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
5215
diff
changeset
|
26 #include "dsputil_mmx.h" |
3524 | 27 #include "common.h" |
28 | |
29 /***************************************************************************** | |
30 * | |
31 * inverse transform | |
32 * | |
33 ****************************************************************************/ | |
34 | |
35 #define SUMSUB_BA( a, b ) \ | |
36 "paddw "#b", "#a" \n\t"\ | |
37 "paddw "#b", "#b" \n\t"\ | |
38 "psubw "#a", "#b" \n\t" | |
39 | |
40 #define SBUTTERFLY(a,b,t,n)\ | |
41 "movq " #a ", " #t " \n\t" /* abcd */\ | |
42 "punpckl" #n " " #b ", " #a " \n\t" /* aebf */\ | |
43 "punpckh" #n " " #b ", " #t " \n\t" /* cgdh */ | |
44 | |
45 #define TRANSPOSE4(a,b,c,d,t)\ | |
46 SBUTTERFLY(a,b,t,wd) /* a=aebf t=cgdh */\ | |
47 SBUTTERFLY(c,d,b,wd) /* c=imjn b=kolp */\ | |
48 SBUTTERFLY(a,c,d,dq) /* a=aeim d=bfjn */\ | |
49 SBUTTERFLY(t,b,c,dq) /* t=cgko c=dhlp */ | |
50 | |
51 static inline void cavs_idct8_1d(int16_t *block, uint64_t bias) | |
52 { | |
53 asm volatile( | |
54 "movq 112(%0), %%mm4 \n\t" /* mm4 = src7 */ | |
55 "movq 16(%0), %%mm5 \n\t" /* mm5 = src1 */ | |
56 "movq 80(%0), %%mm2 \n\t" /* mm2 = src5 */ | |
57 "movq 48(%0), %%mm7 \n\t" /* mm7 = src3 */ | |
58 "movq %%mm4, %%mm0 \n\t" | |
59 "movq %%mm5, %%mm3 \n\t" | |
60 "movq %%mm2, %%mm6 \n\t" | |
61 "movq %%mm7, %%mm1 \n\t" | |
62 | |
63 "paddw %%mm4, %%mm4 \n\t" /* mm4 = 2*src7 */ | |
64 "paddw %%mm3, %%mm3 \n\t" /* mm3 = 2*src1 */ | |
65 "paddw %%mm6, %%mm6 \n\t" /* mm6 = 2*src5 */ | |
66 "paddw %%mm1, %%mm1 \n\t" /* mm1 = 2*src3 */ | |
67 "paddw %%mm4, %%mm0 \n\t" /* mm0 = 3*src7 */ | |
68 "paddw %%mm3, %%mm5 \n\t" /* mm5 = 3*src1 */ | |
69 "paddw %%mm6, %%mm2 \n\t" /* mm2 = 3*src5 */ | |
70 "paddw %%mm1, %%mm7 \n\t" /* mm7 = 3*src3 */ | |
71 "psubw %%mm4, %%mm5 \n\t" /* mm5 = 3*src1 - 2*src7 = a0 */ | |
72 "paddw %%mm6, %%mm7 \n\t" /* mm7 = 3*src3 + 2*src5 = a1 */ | |
73 "psubw %%mm2, %%mm1 \n\t" /* mm1 = 2*src3 - 3*src5 = a2 */ | |
74 "paddw %%mm0, %%mm3 \n\t" /* mm3 = 2*src1 + 3*src7 = a3 */ | |
75 | |
76 "movq %%mm5, %%mm4 \n\t" | |
77 "movq %%mm7, %%mm6 \n\t" | |
78 "movq %%mm3, %%mm0 \n\t" | |
79 "movq %%mm1, %%mm2 \n\t" | |
80 SUMSUB_BA( %%mm7, %%mm5 ) /* mm7 = a0 + a1 mm5 = a0 - a1 */ | |
81 "paddw %%mm3, %%mm7 \n\t" /* mm7 = a0 + a1 + a3 */ | |
82 "paddw %%mm1, %%mm5 \n\t" /* mm5 = a0 - a1 + a2 */ | |
83 "paddw %%mm7, %%mm7 \n\t" | |
84 "paddw %%mm5, %%mm5 \n\t" | |
85 "paddw %%mm6, %%mm7 \n\t" /* mm7 = b4 */ | |
86 "paddw %%mm4, %%mm5 \n\t" /* mm5 = b5 */ | |
87 | |
88 SUMSUB_BA( %%mm1, %%mm3 ) /* mm1 = a3 + a2 mm3 = a3 - a2 */ | |
89 "psubw %%mm1, %%mm4 \n\t" /* mm4 = a0 - a2 - a3 */ | |
90 "movq %%mm4, %%mm1 \n\t" /* mm1 = a0 - a2 - a3 */ | |
91 "psubw %%mm6, %%mm3 \n\t" /* mm3 = a3 - a2 - a1 */ | |
92 "paddw %%mm1, %%mm1 \n\t" | |
93 "paddw %%mm3, %%mm3 \n\t" | |
94 "psubw %%mm2, %%mm1 \n\t" /* mm1 = b7 */ | |
95 "paddw %%mm0, %%mm3 \n\t" /* mm3 = b6 */ | |
96 | |
97 "movq 32(%0), %%mm2 \n\t" /* mm2 = src2 */ | |
98 "movq 96(%0), %%mm6 \n\t" /* mm6 = src6 */ | |
99 "movq %%mm2, %%mm4 \n\t" | |
100 "movq %%mm6, %%mm0 \n\t" | |
101 "psllw $2, %%mm4 \n\t" /* mm4 = 4*src2 */ | |
102 "psllw $2, %%mm6 \n\t" /* mm6 = 4*src6 */ | |
103 "paddw %%mm4, %%mm2 \n\t" /* mm2 = 5*src2 */ | |
104 "paddw %%mm6, %%mm0 \n\t" /* mm0 = 5*src6 */ | |
105 "paddw %%mm2, %%mm2 \n\t" | |
106 "paddw %%mm0, %%mm0 \n\t" | |
107 "psubw %%mm0, %%mm4 \n\t" /* mm4 = 4*src2 - 10*src6 = a7 */ | |
108 "paddw %%mm2, %%mm6 \n\t" /* mm6 = 4*src6 + 10*src2 = a6 */ | |
109 | |
110 "movq (%0), %%mm2 \n\t" /* mm2 = src0 */ | |
111 "movq 64(%0), %%mm0 \n\t" /* mm0 = src4 */ | |
112 SUMSUB_BA( %%mm0, %%mm2 ) /* mm0 = src0+src4 mm2 = src0-src4 */ | |
113 "psllw $3, %%mm0 \n\t" | |
114 "psllw $3, %%mm2 \n\t" | |
115 "paddw %1, %%mm0 \n\t" /* add rounding bias */ | |
116 "paddw %1, %%mm2 \n\t" /* add rounding bias */ | |
117 | |
118 SUMSUB_BA( %%mm6, %%mm0 ) /* mm6 = a4 + a6 mm0 = a4 - a6 */ | |
119 SUMSUB_BA( %%mm4, %%mm2 ) /* mm4 = a5 + a7 mm2 = a5 - a7 */ | |
120 SUMSUB_BA( %%mm7, %%mm6 ) /* mm7 = dst0 mm6 = dst7 */ | |
121 SUMSUB_BA( %%mm5, %%mm4 ) /* mm5 = dst1 mm4 = dst6 */ | |
122 SUMSUB_BA( %%mm3, %%mm2 ) /* mm3 = dst2 mm2 = dst5 */ | |
123 SUMSUB_BA( %%mm1, %%mm0 ) /* mm1 = dst3 mm0 = dst4 */ | |
124 :: "r"(block), "m"(bias) | |
125 ); | |
126 } | |
127 | |
128 static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride) | |
129 { | |
130 int i; | |
131 DECLARE_ALIGNED_8(int16_t, b2[64]); | |
132 | |
133 for(i=0; i<2; i++){ | |
134 DECLARE_ALIGNED_8(uint64_t, tmp); | |
135 | |
136 cavs_idct8_1d(block+4*i, ff_pw_4); | |
137 | |
138 asm volatile( | |
139 "psraw $3, %%mm7 \n\t" | |
140 "psraw $3, %%mm6 \n\t" | |
141 "psraw $3, %%mm5 \n\t" | |
142 "psraw $3, %%mm4 \n\t" | |
143 "psraw $3, %%mm3 \n\t" | |
144 "psraw $3, %%mm2 \n\t" | |
145 "psraw $3, %%mm1 \n\t" | |
146 "psraw $3, %%mm0 \n\t" | |
147 "movq %%mm7, %0 \n\t" | |
148 TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 ) | |
149 "movq %%mm0, 8(%1) \n\t" | |
150 "movq %%mm6, 24(%1) \n\t" | |
151 "movq %%mm7, 40(%1) \n\t" | |
152 "movq %%mm4, 56(%1) \n\t" | |
153 "movq %0, %%mm7 \n\t" | |
154 TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 ) | |
155 "movq %%mm7, (%1) \n\t" | |
156 "movq %%mm1, 16(%1) \n\t" | |
157 "movq %%mm0, 32(%1) \n\t" | |
158 "movq %%mm3, 48(%1) \n\t" | |
159 : "=m"(tmp) | |
160 : "r"(b2+32*i) | |
161 : "memory" | |
162 ); | |
163 } | |
164 | |
165 for(i=0; i<2; i++){ | |
166 cavs_idct8_1d(b2+4*i, ff_pw_64); | |
167 | |
168 asm volatile( | |
169 "psraw $7, %%mm7 \n\t" | |
170 "psraw $7, %%mm6 \n\t" | |
171 "psraw $7, %%mm5 \n\t" | |
172 "psraw $7, %%mm4 \n\t" | |
173 "psraw $7, %%mm3 \n\t" | |
174 "psraw $7, %%mm2 \n\t" | |
175 "psraw $7, %%mm1 \n\t" | |
176 "psraw $7, %%mm0 \n\t" | |
177 "movq %%mm7, (%0) \n\t" | |
178 "movq %%mm5, 16(%0) \n\t" | |
179 "movq %%mm3, 32(%0) \n\t" | |
180 "movq %%mm1, 48(%0) \n\t" | |
181 "movq %%mm0, 64(%0) \n\t" | |
182 "movq %%mm2, 80(%0) \n\t" | |
183 "movq %%mm4, 96(%0) \n\t" | |
184 "movq %%mm6, 112(%0) \n\t" | |
185 :: "r"(b2+4*i) | |
186 : "memory" | |
187 ); | |
188 } | |
189 | |
190 add_pixels_clamped_mmx(b2, dst, stride); | |
191 | |
192 /* clear block */ | |
193 asm volatile( | |
194 "pxor %%mm7, %%mm7 \n\t" | |
195 "movq %%mm7, (%0) \n\t" | |
196 "movq %%mm7, 8(%0) \n\t" | |
197 "movq %%mm7, 16(%0) \n\t" | |
198 "movq %%mm7, 24(%0) \n\t" | |
199 "movq %%mm7, 32(%0) \n\t" | |
200 "movq %%mm7, 40(%0) \n\t" | |
201 "movq %%mm7, 48(%0) \n\t" | |
202 "movq %%mm7, 56(%0) \n\t" | |
203 "movq %%mm7, 64(%0) \n\t" | |
204 "movq %%mm7, 72(%0) \n\t" | |
205 "movq %%mm7, 80(%0) \n\t" | |
206 "movq %%mm7, 88(%0) \n\t" | |
207 "movq %%mm7, 96(%0) \n\t" | |
208 "movq %%mm7, 104(%0) \n\t" | |
209 "movq %%mm7, 112(%0) \n\t" | |
210 "movq %%mm7, 120(%0) \n\t" | |
211 :: "r" (block) | |
212 ); | |
213 } | |
214 | |
215 /***************************************************************************** | |
216 * | |
217 * motion compensation | |
218 * | |
219 ****************************************************************************/ | |
220 | |
221 /* vertical filter [-1 -2 96 42 -7 0] */ | |
222 #define QPEL_CAVSV1(A,B,C,D,E,F,OP) \ | |
223 "movd (%0), "#F" \n\t"\ | |
224 "movq "#C", %%mm6 \n\t"\ | |
225 "pmullw %5, %%mm6 \n\t"\ | |
226 "movq "#D", %%mm7 \n\t"\ | |
227 "pmullw %6, %%mm7 \n\t"\ | |
228 "psllw $3, "#E" \n\t"\ | |
229 "psubw "#E", %%mm6 \n\t"\ | |
230 "psraw $3, "#E" \n\t"\ | |
231 "paddw %%mm7, %%mm6 \n\t"\ | |
232 "paddw "#E", %%mm6 \n\t"\ | |
233 "paddw "#B", "#B" \n\t"\ | |
234 "pxor %%mm7, %%mm7 \n\t"\ | |
235 "add %2, %0 \n\t"\ | |
236 "punpcklbw %%mm7, "#F" \n\t"\ | |
237 "psubw "#B", %%mm6 \n\t"\ | |
238 "psraw $1, "#B" \n\t"\ | |
239 "psubw "#A", %%mm6 \n\t"\ | |
240 "paddw %4, %%mm6 \n\t"\ | |
241 "psraw $7, %%mm6 \n\t"\ | |
242 "packuswb %%mm6, %%mm6 \n\t"\ | |
243 OP(%%mm6, (%1), A, d) \ | |
244 "add %3, %1 \n\t" | |
245 | |
246 /* vertical filter [ 0 -1 5 5 -1 0] */ | |
247 #define QPEL_CAVSV2(A,B,C,D,E,F,OP) \ | |
248 "movd (%0), "#F" \n\t"\ | |
249 "movq "#C", %%mm6 \n\t"\ | |
250 "paddw "#D", %%mm6 \n\t"\ | |
251 "pmullw %5, %%mm6 \n\t"\ | |
252 "add %2, %0 \n\t"\ | |
253 "punpcklbw %%mm7, "#F" \n\t"\ | |
254 "psubw "#B", %%mm6 \n\t"\ | |
255 "psubw "#E", %%mm6 \n\t"\ | |
256 "paddw %4, %%mm6 \n\t"\ | |
257 "psraw $3, %%mm6 \n\t"\ | |
258 "packuswb %%mm6, %%mm6 \n\t"\ | |
259 OP(%%mm6, (%1), A, d) \ | |
260 "add %3, %1 \n\t" | |
261 | |
262 /* vertical filter [ 0 -7 42 96 -2 -1] */ | |
263 #define QPEL_CAVSV3(A,B,C,D,E,F,OP) \ | |
264 "movd (%0), "#F" \n\t"\ | |
265 "movq "#C", %%mm6 \n\t"\ | |
266 "pmullw %6, %%mm6 \n\t"\ | |
267 "movq "#D", %%mm7 \n\t"\ | |
268 "pmullw %5, %%mm7 \n\t"\ | |
269 "psllw $3, "#B" \n\t"\ | |
270 "psubw "#B", %%mm6 \n\t"\ | |
271 "psraw $3, "#B" \n\t"\ | |
272 "paddw %%mm7, %%mm6 \n\t"\ | |
273 "paddw "#B", %%mm6 \n\t"\ | |
274 "paddw "#E", "#E" \n\t"\ | |
275 "pxor %%mm7, %%mm7 \n\t"\ | |
276 "add %2, %0 \n\t"\ | |
277 "punpcklbw %%mm7, "#F" \n\t"\ | |
278 "psubw "#E", %%mm6 \n\t"\ | |
279 "psraw $1, "#E" \n\t"\ | |
280 "psubw "#F", %%mm6 \n\t"\ | |
281 "paddw %4, %%mm6 \n\t"\ | |
282 "psraw $7, %%mm6 \n\t"\ | |
283 "packuswb %%mm6, %%mm6 \n\t"\ | |
284 OP(%%mm6, (%1), A, d) \ | |
285 "add %3, %1 \n\t" | |
286 | |
287 | |
288 #define QPEL_CAVSVNUM(VOP,OP,ADD,MUL1,MUL2)\ | |
289 int w= 2;\ | |
290 src -= 2*srcStride;\ | |
291 \ | |
292 while(w--){\ | |
293 asm volatile(\ | |
294 "pxor %%mm7, %%mm7 \n\t"\ | |
295 "movd (%0), %%mm0 \n\t"\ | |
296 "add %2, %0 \n\t"\ | |
297 "movd (%0), %%mm1 \n\t"\ | |
298 "add %2, %0 \n\t"\ | |
299 "movd (%0), %%mm2 \n\t"\ | |
300 "add %2, %0 \n\t"\ | |
301 "movd (%0), %%mm3 \n\t"\ | |
302 "add %2, %0 \n\t"\ | |
303 "movd (%0), %%mm4 \n\t"\ | |
304 "add %2, %0 \n\t"\ | |
305 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
306 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
307 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
308 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
309 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
310 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
311 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
312 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
313 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
314 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
315 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
316 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
317 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
318 \ | |
319 : "+a"(src), "+c"(dst)\ | |
320 : "S"((long)srcStride), "D"((long)dstStride), "m"(ADD), "m"(MUL1), "m"(MUL2)\ | |
321 : "memory"\ | |
322 );\ | |
323 if(h==16){\ | |
324 asm volatile(\ | |
325 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
326 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
327 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
328 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
329 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
330 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
331 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
332 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
333 \ | |
334 : "+a"(src), "+c"(dst)\ | |
335 : "S"((long)srcStride), "D"((long)dstStride), "m"(ADD), "m"(MUL1), "m"(MUL2)\ | |
336 : "memory"\ | |
337 );\ | |
338 }\ | |
339 src += 4-(h+5)*srcStride;\ | |
340 dst += 4-h*dstStride;\ | |
341 } | |
342 | |
343 #define QPEL_CAVS(OPNAME, OP, MMX)\ | |
344 static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
345 int h=8;\ | |
346 asm volatile(\ | |
347 "pxor %%mm7, %%mm7 \n\t"\ | |
348 "movq %5, %%mm6 \n\t"\ | |
349 "1: \n\t"\ | |
350 "movq (%0), %%mm0 \n\t"\ | |
351 "movq 1(%0), %%mm2 \n\t"\ | |
352 "movq %%mm0, %%mm1 \n\t"\ | |
353 "movq %%mm2, %%mm3 \n\t"\ | |
354 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
355 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
356 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
357 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
358 "paddw %%mm2, %%mm0 \n\t"\ | |
359 "paddw %%mm3, %%mm1 \n\t"\ | |
360 "pmullw %%mm6, %%mm0 \n\t"\ | |
361 "pmullw %%mm6, %%mm1 \n\t"\ | |
362 "movq -1(%0), %%mm2 \n\t"\ | |
363 "movq 2(%0), %%mm4 \n\t"\ | |
364 "movq %%mm2, %%mm3 \n\t"\ | |
365 "movq %%mm4, %%mm5 \n\t"\ | |
366 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
367 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
368 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
369 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
370 "paddw %%mm4, %%mm2 \n\t"\ | |
371 "paddw %%mm3, %%mm5 \n\t"\ | |
372 "psubw %%mm2, %%mm0 \n\t"\ | |
373 "psubw %%mm5, %%mm1 \n\t"\ | |
374 "movq %6, %%mm5 \n\t"\ | |
375 "paddw %%mm5, %%mm0 \n\t"\ | |
376 "paddw %%mm5, %%mm1 \n\t"\ | |
377 "psraw $3, %%mm0 \n\t"\ | |
378 "psraw $3, %%mm1 \n\t"\ | |
379 "packuswb %%mm1, %%mm0 \n\t"\ | |
380 OP(%%mm0, (%1),%%mm5, q) \ | |
381 "add %3, %0 \n\t"\ | |
382 "add %4, %1 \n\t"\ | |
383 "decl %2 \n\t"\ | |
384 " jnz 1b \n\t"\ | |
385 : "+a"(src), "+c"(dst), "+m"(h)\ | |
386 : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_4)\ | |
387 : "memory"\ | |
388 );\ | |
389 }\ | |
390 \ | |
391 static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
392 QPEL_CAVSVNUM(QPEL_CAVSV1,OP,ff_pw_64,ff_pw_96,ff_pw_42) \ | |
393 }\ | |
394 \ | |
395 static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
396 QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_5) \ | |
397 }\ | |
398 \ | |
399 static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
400 QPEL_CAVSVNUM(QPEL_CAVSV3,OP,ff_pw_64,ff_pw_96,ff_pw_42) \ | |
401 }\ | |
402 \ | |
403 static void OPNAME ## cavs_qpel8_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
404 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 8);\ | |
405 }\ | |
406 static void OPNAME ## cavs_qpel16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
407 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 16);\ | |
408 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\ | |
409 }\ | |
410 \ | |
411 static void OPNAME ## cavs_qpel8_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
412 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 8);\ | |
413 }\ | |
414 static void OPNAME ## cavs_qpel16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
415 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 16);\ | |
416 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\ | |
417 }\ | |
418 \ | |
419 static void OPNAME ## cavs_qpel8_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
420 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 8);\ | |
421 }\ | |
422 static void OPNAME ## cavs_qpel16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
423 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 16);\ | |
424 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\ | |
425 }\ | |
426 \ | |
427 static void OPNAME ## cavs_qpel16_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
428 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\ | |
429 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
430 src += 8*srcStride;\ | |
431 dst += 8*dstStride;\ | |
432 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\ | |
433 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
434 }\ | |
435 | |
436 #define CAVS_MC(OPNAME, SIZE, MMX) \ | |
437 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
438 OPNAME ## cavs_qpel ## SIZE ## _h_ ## MMX(dst, src, stride, stride);\ | |
439 }\ | |
440 \ | |
441 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
442 OPNAME ## cavs_qpel ## SIZE ## _v1_ ## MMX(dst, src, stride, stride);\ | |
443 }\ | |
444 \ | |
445 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
446 OPNAME ## cavs_qpel ## SIZE ## _v2_ ## MMX(dst, src, stride, stride);\ | |
447 }\ | |
448 \ | |
449 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
450 OPNAME ## cavs_qpel ## SIZE ## _v3_ ## MMX(dst, src, stride, stride);\ | |
451 }\ | |
452 | |
453 #define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t" | |
454 #define AVG_3DNOW_OP(a,b,temp, size) \ | |
455 "mov" #size " " #b ", " #temp " \n\t"\ | |
456 "pavgusb " #temp ", " #a " \n\t"\ | |
457 "mov" #size " " #a ", " #b " \n\t" | |
458 #define AVG_MMX2_OP(a,b,temp, size) \ | |
459 "mov" #size " " #b ", " #temp " \n\t"\ | |
460 "pavgb " #temp ", " #a " \n\t"\ | |
461 "mov" #size " " #a ", " #b " \n\t" | |
462 | |
463 QPEL_CAVS(put_, PUT_OP, 3dnow) | |
464 QPEL_CAVS(avg_, AVG_3DNOW_OP, 3dnow) | |
465 QPEL_CAVS(put_, PUT_OP, mmx2) | |
466 QPEL_CAVS(avg_, AVG_MMX2_OP, mmx2) | |
467 | |
468 CAVS_MC(put_, 8, 3dnow) | |
469 CAVS_MC(put_, 16,3dnow) | |
470 CAVS_MC(avg_, 8, 3dnow) | |
471 CAVS_MC(avg_, 16,3dnow) | |
472 CAVS_MC(put_, 8, mmx2) | |
473 CAVS_MC(put_, 16,mmx2) | |
474 CAVS_MC(avg_, 8, mmx2) | |
475 CAVS_MC(avg_, 16,mmx2) | |
476 | |
477 void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); | |
478 void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); | |
479 void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); | |
480 void ff_avg_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); | |
481 | |
482 void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx) { | |
483 #define dspfunc(PFX, IDX, NUM) \ | |
484 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \ | |
485 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmx2; \ | |
486 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_mmx2; \ | |
487 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_mmx2; \ | |
488 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_mmx2; \ | |
489 | |
490 dspfunc(put_cavs_qpel, 0, 16); | |
491 dspfunc(put_cavs_qpel, 1, 8); | |
492 dspfunc(avg_cavs_qpel, 0, 16); | |
493 dspfunc(avg_cavs_qpel, 1, 8); | |
494 #undef dspfunc | |
495 c->cavs_idct8_add = cavs_idct8_add_mmx; | |
496 } | |
497 | |
498 void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx) { | |
499 #define dspfunc(PFX, IDX, NUM) \ | |
500 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \ | |
501 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \ | |
502 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_3dnow; \ | |
503 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_3dnow; \ | |
504 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_3dnow; \ | |
505 | |
506 dspfunc(put_cavs_qpel, 0, 16); | |
507 dspfunc(put_cavs_qpel, 1, 8); | |
508 dspfunc(avg_cavs_qpel, 0, 16); | |
509 dspfunc(avg_cavs_qpel, 1, 8); | |
510 #undef dspfunc | |
511 c->cavs_idct8_add = cavs_idct8_add_mmx; | |
512 } |