nsse weight
[libav.git] / libavcodec / i386 / dsputil_mmx.c
CommitLineData
de6d9b64
FB
1/*
2 * MMX optimized DSP utils
ff4ec49e 3 * Copyright (c) 2000, 2001 Fabrice Bellard.
8f2ab833 4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
de6d9b64 5 *
ff4ec49e
FB
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
de6d9b64 10 *
ff4ec49e 11 * This library is distributed in the hope that it will be useful,
de6d9b64 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ff4ec49e
FB
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
de6d9b64 15 *
ff4ec49e
FB
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
de6d9b64
FB
19 *
20 * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
21 */
22
23#include "../dsputil.h"
b0368839 24#include "../simple_idct.h"
f9ed9d85 25#include "mmx.h"
de6d9b64 26
622348f9
MN
27//#undef NDEBUG
28//#include <assert.h>
29
359f98de
MN
30extern const uint8_t ff_h263_loop_filter_strength[32];
31
7d650cb5 32int mm_flags; /* multimedia extension flags */
1457ab52 33
de6d9b64 34/* pixel operations */
5c0513bd
DB
35static const uint64_t mm_bone attribute_used __attribute__ ((aligned(8))) = 0x0101010101010101ULL;
36static const uint64_t mm_wone attribute_used __attribute__ ((aligned(8))) = 0x0001000100010001ULL;
37static const uint64_t mm_wtwo attribute_used __attribute__ ((aligned(8))) = 0x0002000200020002ULL;
de6d9b64 38
5c0513bd
DB
39static const uint64_t ff_pw_20 attribute_used __attribute__ ((aligned(8))) = 0x0014001400140014ULL;
40static const uint64_t ff_pw_3 attribute_used __attribute__ ((aligned(8))) = 0x0003000300030003ULL;
41static const uint64_t ff_pw_16 attribute_used __attribute__ ((aligned(8))) = 0x0010001000100010ULL;
42static const uint64_t ff_pw_15 attribute_used __attribute__ ((aligned(8))) = 0x000F000F000F000FULL;
826f429a 43
5c0513bd 44static const uint64_t ff_pb_FC attribute_used __attribute__ ((aligned(8))) = 0xFCFCFCFCFCFCFCFCULL;
359f98de 45
d6a4c0b1
ZK
46#define JUMPALIGN() __asm __volatile (".balign 8"::)
47#define MOVQ_ZERO(regd) __asm __volatile ("pxor %%" #regd ", %%" #regd ::)
48
fca0f0e5
ZK
49#define MOVQ_WONE(regd) \
50 __asm __volatile ( \
51 "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
52 "psrlw $15, %%" #regd ::)
53
54#define MOVQ_BFE(regd) \
55 __asm __volatile ( \
56 "pcmpeqd %%" #regd ", %%" #regd " \n\t"\
57 "paddb %%" #regd ", %%" #regd " \n\t" ::)
58
d6a4c0b1 59#ifndef PIC
fca0f0e5 60#define MOVQ_BONE(regd) __asm __volatile ("movq %0, %%" #regd " \n\t" ::"m"(mm_bone))
d6a4c0b1
ZK
61#define MOVQ_WTWO(regd) __asm __volatile ("movq %0, %%" #regd " \n\t" ::"m"(mm_wtwo))
62#else
63// for shared library it's better to use this way for accessing constants
64// pcmpeqd -> -1
fca0f0e5 65#define MOVQ_BONE(regd) \
d6a4c0b1 66 __asm __volatile ( \
fca0f0e5
ZK
67 "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
68 "psrlw $15, %%" #regd " \n\t" \
69 "packuswb %%" #regd ", %%" #regd " \n\t" ::)
d6a4c0b1
ZK
70
71#define MOVQ_WTWO(regd) \
72 __asm __volatile ( \
fca0f0e5
ZK
73 "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
74 "psrlw $15, %%" #regd " \n\t" \
75 "psllw $1, %%" #regd " \n\t"::)
a7bd8797 76
d6a4c0b1
ZK
77#endif
78
fca0f0e5 79// using regr as temporary and for the output result
def60345 80// first argument is unmodifed and second is trashed
39825f31
ZK
81// regfe is supposed to contain 0xfefefefefefefefe
82#define PAVGB_MMX_NO_RND(rega, regb, regr, regfe) \
91abb473
ZK
83 "movq " #rega ", " #regr " \n\t"\
84 "pand " #regb ", " #regr " \n\t"\
def60345 85 "pxor " #rega ", " #regb " \n\t"\
39825f31 86 "pand " #regfe "," #regb " \n\t"\
def60345 87 "psrlq $1, " #regb " \n\t"\
91abb473 88 "paddb " #regb ", " #regr " \n\t"
def60345 89
39825f31 90#define PAVGB_MMX(rega, regb, regr, regfe) \
91abb473
ZK
91 "movq " #rega ", " #regr " \n\t"\
92 "por " #regb ", " #regr " \n\t"\
def60345 93 "pxor " #rega ", " #regb " \n\t"\
39825f31 94 "pand " #regfe "," #regb " \n\t"\
def60345 95 "psrlq $1, " #regb " \n\t"\
91abb473 96 "psubb " #regb ", " #regr " \n\t"
def60345 97
39825f31 98// mm6 is supposed to contain 0xfefefefefefefefe
6aa6ea8e
ZK
99#define PAVGBP_MMX_NO_RND(rega, regb, regr, regc, regd, regp) \
100 "movq " #rega ", " #regr " \n\t"\
101 "movq " #regc ", " #regp " \n\t"\
102 "pand " #regb ", " #regr " \n\t"\
103 "pand " #regd ", " #regp " \n\t"\
104 "pxor " #rega ", " #regb " \n\t"\
105 "pxor " #regc ", " #regd " \n\t"\
fca0f0e5
ZK
106 "pand %%mm6, " #regb " \n\t"\
107 "pand %%mm6, " #regd " \n\t"\
6aa6ea8e
ZK
108 "psrlq $1, " #regb " \n\t"\
109 "psrlq $1, " #regd " \n\t"\
110 "paddb " #regb ", " #regr " \n\t"\
111 "paddb " #regd ", " #regp " \n\t"
112
113#define PAVGBP_MMX(rega, regb, regr, regc, regd, regp) \
114 "movq " #rega ", " #regr " \n\t"\
115 "movq " #regc ", " #regp " \n\t"\
116 "por " #regb ", " #regr " \n\t"\
117 "por " #regd ", " #regp " \n\t"\
118 "pxor " #rega ", " #regb " \n\t"\
119 "pxor " #regc ", " #regd " \n\t"\
fca0f0e5
ZK
120 "pand %%mm6, " #regb " \n\t"\
121 "pand %%mm6, " #regd " \n\t"\
6aa6ea8e
ZK
122 "psrlq $1, " #regd " \n\t"\
123 "psrlq $1, " #regb " \n\t"\
124 "psubb " #regb ", " #regr " \n\t"\
125 "psubb " #regd ", " #regp " \n\t"
126
91abb473
ZK
127/***********************************/
128/* MMX no rounding */
129#define DEF(x, y) x ## _no_rnd_ ## y ##_mmx
fca0f0e5 130#define SET_RND MOVQ_WONE
6aa6ea8e 131#define PAVGBP(a, b, c, d, e, f) PAVGBP_MMX_NO_RND(a, b, c, d, e, f)
39825f31 132#define PAVGB(a, b, c, e) PAVGB_MMX_NO_RND(a, b, c, e)
fca0f0e5 133
91abb473
ZK
134#include "dsputil_mmx_rnd.h"
135
136#undef DEF
fca0f0e5 137#undef SET_RND
6aa6ea8e 138#undef PAVGBP
39825f31 139#undef PAVGB
91abb473
ZK
140/***********************************/
141/* MMX rounding */
142
143#define DEF(x, y) x ## _ ## y ##_mmx
fca0f0e5 144#define SET_RND MOVQ_WTWO
6aa6ea8e 145#define PAVGBP(a, b, c, d, e, f) PAVGBP_MMX(a, b, c, d, e, f)
39825f31 146#define PAVGB(a, b, c, e) PAVGB_MMX(a, b, c, e)
fca0f0e5 147
91abb473
ZK
148#include "dsputil_mmx_rnd.h"
149
150#undef DEF
fca0f0e5 151#undef SET_RND
6aa6ea8e 152#undef PAVGBP
39825f31 153#undef PAVGB
a7bd8797 154
de6d9b64
FB
155/***********************************/
156/* 3Dnow specific */
157
158#define DEF(x) x ## _3dnow
159/* for Athlons PAVGUSB is prefered */
160#define PAVGB "pavgusb"
161
162#include "dsputil_mmx_avg.h"
163
164#undef DEF
165#undef PAVGB
166
167/***********************************/
168/* MMX2 specific */
169
607dce96 170#define DEF(x) x ## _mmx2
de6d9b64
FB
171
172/* Introduced only in MMX2 set */
173#define PAVGB "pavgb"
174
175#include "dsputil_mmx_avg.h"
176
177#undef DEF
178#undef PAVGB
179
180/***********************************/
181/* standard MMX */
182
764ef400 183#ifdef CONFIG_ENCODERS
0c1a9eda 184static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
de6d9b64 185{
607dce96
MN
186 asm volatile(
187 "movl $-128, %%eax \n\t"
188 "pxor %%mm7, %%mm7 \n\t"
189 ".balign 16 \n\t"
190 "1: \n\t"
191 "movq (%0), %%mm0 \n\t"
192 "movq (%0, %2), %%mm2 \n\t"
193 "movq %%mm0, %%mm1 \n\t"
194 "movq %%mm2, %%mm3 \n\t"
195 "punpcklbw %%mm7, %%mm0 \n\t"
196 "punpckhbw %%mm7, %%mm1 \n\t"
197 "punpcklbw %%mm7, %%mm2 \n\t"
198 "punpckhbw %%mm7, %%mm3 \n\t"
199 "movq %%mm0, (%1, %%eax)\n\t"
200 "movq %%mm1, 8(%1, %%eax)\n\t"
201 "movq %%mm2, 16(%1, %%eax)\n\t"
202 "movq %%mm3, 24(%1, %%eax)\n\t"
203 "addl %3, %0 \n\t"
204 "addl $32, %%eax \n\t"
205 "js 1b \n\t"
206 : "+r" (pixels)
207 : "r" (block+64), "r" (line_size), "r" (line_size*2)
208 : "%eax"
209 );
de6d9b64
FB
210}
211
0c1a9eda 212static inline void diff_pixels_mmx(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride)
9dbcbd92
MN
213{
214 asm volatile(
607dce96 215 "pxor %%mm7, %%mm7 \n\t"
9dbcbd92 216 "movl $-128, %%eax \n\t"
607dce96 217 ".balign 16 \n\t"
9dbcbd92
MN
218 "1: \n\t"
219 "movq (%0), %%mm0 \n\t"
220 "movq (%1), %%mm2 \n\t"
221 "movq %%mm0, %%mm1 \n\t"
222 "movq %%mm2, %%mm3 \n\t"
223 "punpcklbw %%mm7, %%mm0 \n\t"
224 "punpckhbw %%mm7, %%mm1 \n\t"
225 "punpcklbw %%mm7, %%mm2 \n\t"
226 "punpckhbw %%mm7, %%mm3 \n\t"
227 "psubw %%mm2, %%mm0 \n\t"
228 "psubw %%mm3, %%mm1 \n\t"
229 "movq %%mm0, (%2, %%eax)\n\t"
230 "movq %%mm1, 8(%2, %%eax)\n\t"
231 "addl %3, %0 \n\t"
232 "addl %3, %1 \n\t"
233 "addl $16, %%eax \n\t"
234 "jnz 1b \n\t"
235 : "+r" (s1), "+r" (s2)
236 : "r" (block+64), "r" (stride)
237 : "%eax"
238 );
239}
764ef400 240#endif //CONFIG_ENCODERS
9dbcbd92 241
0c1a9eda 242void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
de6d9b64
FB
243{
244 const DCTELEM *p;
0c1a9eda 245 uint8_t *pix;
de6d9b64
FB
246
247 /* read the pixels */
248 p = block;
249 pix = pixels;
d6a4c0b1 250 /* unrolled loop */
de6d9b64 251 __asm __volatile(
a822a479
NK
252 "movq %3, %%mm0\n\t"
253 "movq 8%3, %%mm1\n\t"
254 "movq 16%3, %%mm2\n\t"
255 "movq 24%3, %%mm3\n\t"
256 "movq 32%3, %%mm4\n\t"
257 "movq 40%3, %%mm5\n\t"
258 "movq 48%3, %%mm6\n\t"
259 "movq 56%3, %%mm7\n\t"
de6d9b64
FB
260 "packuswb %%mm1, %%mm0\n\t"
261 "packuswb %%mm3, %%mm2\n\t"
262 "packuswb %%mm5, %%mm4\n\t"
263 "packuswb %%mm7, %%mm6\n\t"
a822a479
NK
264 "movq %%mm0, (%0)\n\t"
265 "movq %%mm2, (%0, %1)\n\t"
266 "movq %%mm4, (%0, %1, 2)\n\t"
267 "movq %%mm6, (%0, %2)\n\t"
268 ::"r" (pix), "r" (line_size), "r" (line_size*3), "m"(*p)
de6d9b64
FB
269 :"memory");
270 pix += line_size*4;
271 p += 32;
d6a4c0b1
ZK
272
273 // if here would be an exact copy of the code above
274 // compiler would generate some very strange code
275 // thus using "r"
276 __asm __volatile(
277 "movq (%3), %%mm0\n\t"
278 "movq 8(%3), %%mm1\n\t"
279 "movq 16(%3), %%mm2\n\t"
280 "movq 24(%3), %%mm3\n\t"
281 "movq 32(%3), %%mm4\n\t"
282 "movq 40(%3), %%mm5\n\t"
283 "movq 48(%3), %%mm6\n\t"
284 "movq 56(%3), %%mm7\n\t"
285 "packuswb %%mm1, %%mm0\n\t"
286 "packuswb %%mm3, %%mm2\n\t"
287 "packuswb %%mm5, %%mm4\n\t"
288 "packuswb %%mm7, %%mm6\n\t"
289 "movq %%mm0, (%0)\n\t"
290 "movq %%mm2, (%0, %1)\n\t"
291 "movq %%mm4, (%0, %1, 2)\n\t"
292 "movq %%mm6, (%0, %2)\n\t"
293 ::"r" (pix), "r" (line_size), "r" (line_size*3), "r"(p)
294 :"memory");
de6d9b64
FB
295}
296
7daabccb
MM
297static unsigned char __align8 vector128[8] =
298 { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
299
f9ed9d85
MM
300void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
301{
302 int i;
f9ed9d85
MM
303
304 movq_m2r(*vector128, mm1);
305 for (i = 0; i < 8; i++) {
306 movq_m2r(*(block), mm0);
307 packsswb_m2r(*(block + 4), mm0);
308 block += 8;
309 paddb_r2r(mm1, mm0);
310 movq_r2m(mm0, *pixels);
311 pixels += line_size;
312 }
313}
314
0c1a9eda 315void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
de6d9b64
FB
316{
317 const DCTELEM *p;
0c1a9eda 318 uint8_t *pix;
de6d9b64
FB
319 int i;
320
321 /* read the pixels */
322 p = block;
323 pix = pixels;
d6a4c0b1
ZK
324 MOVQ_ZERO(mm7);
325 i = 4;
cd8e5f96 326 do {
de6d9b64 327 __asm __volatile(
cd8e5f96
ZK
328 "movq (%2), %%mm0\n\t"
329 "movq 8(%2), %%mm1\n\t"
330 "movq 16(%2), %%mm2\n\t"
331 "movq 24(%2), %%mm3\n\t"
de6d9b64
FB
332 "movq %0, %%mm4\n\t"
333 "movq %1, %%mm6\n\t"
334 "movq %%mm4, %%mm5\n\t"
335 "punpcklbw %%mm7, %%mm4\n\t"
336 "punpckhbw %%mm7, %%mm5\n\t"
337 "paddsw %%mm4, %%mm0\n\t"
338 "paddsw %%mm5, %%mm1\n\t"
339 "movq %%mm6, %%mm5\n\t"
340 "punpcklbw %%mm7, %%mm6\n\t"
341 "punpckhbw %%mm7, %%mm5\n\t"
342 "paddsw %%mm6, %%mm2\n\t"
343 "paddsw %%mm5, %%mm3\n\t"
344 "packuswb %%mm1, %%mm0\n\t"
345 "packuswb %%mm3, %%mm2\n\t"
346 "movq %%mm0, %0\n\t"
347 "movq %%mm2, %1\n\t"
a822a479 348 :"+m"(*pix), "+m"(*(pix+line_size))
cd8e5f96 349 :"r"(p)
de6d9b64
FB
350 :"memory");
351 pix += line_size*2;
352 p += 16;
cd8e5f96 353 } while (--i);
de6d9b64
FB
354}
355
0c1a9eda 356static void put_pixels8_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h)
de6d9b64 357{
39825f31 358 __asm __volatile(
31ddcf98 359 "lea (%3, %3), %%eax \n\t"
52af45ad 360 ".balign 8 \n\t"
31ddcf98
ZK
361 "1: \n\t"
362 "movq (%1), %%mm0 \n\t"
363 "movq (%1, %3), %%mm1 \n\t"
364 "movq %%mm0, (%2) \n\t"
365 "movq %%mm1, (%2, %3) \n\t"
366 "addl %%eax, %1 \n\t"
367 "addl %%eax, %2 \n\t"
368 "movq (%1), %%mm0 \n\t"
369 "movq (%1, %3), %%mm1 \n\t"
370 "movq %%mm0, (%2) \n\t"
371 "movq %%mm1, (%2, %3) \n\t"
372 "addl %%eax, %1 \n\t"
373 "addl %%eax, %2 \n\t"
374 "subl $4, %0 \n\t"
375 "jnz 1b \n\t"
376 : "+g"(h), "+r" (pixels), "+r" (block)
377 : "r"(line_size)
378 : "%eax", "memory"
379 );
de6d9b64
FB
380}
381
0c1a9eda 382static void put_pixels16_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h)
b3184779
MN
383{
384 __asm __volatile(
385 "lea (%3, %3), %%eax \n\t"
386 ".balign 8 \n\t"
387 "1: \n\t"
388 "movq (%1), %%mm0 \n\t"
389 "movq 8(%1), %%mm4 \n\t"
390 "movq (%1, %3), %%mm1 \n\t"
391 "movq 8(%1, %3), %%mm5 \n\t"
392 "movq %%mm0, (%2) \n\t"
393 "movq %%mm4, 8(%2) \n\t"
394 "movq %%mm1, (%2, %3) \n\t"
395 "movq %%mm5, 8(%2, %3) \n\t"
396 "addl %%eax, %1 \n\t"
397 "addl %%eax, %2 \n\t"
398 "movq (%1), %%mm0 \n\t"
399 "movq 8(%1), %%mm4 \n\t"
400 "movq (%1, %3), %%mm1 \n\t"
401 "movq 8(%1, %3), %%mm5 \n\t"
402 "movq %%mm0, (%2) \n\t"
403 "movq %%mm4, 8(%2) \n\t"
404 "movq %%mm1, (%2, %3) \n\t"
405 "movq %%mm5, 8(%2, %3) \n\t"
406 "addl %%eax, %1 \n\t"
407 "addl %%eax, %2 \n\t"
408 "subl $4, %0 \n\t"
409 "jnz 1b \n\t"
410 : "+g"(h), "+r" (pixels), "+r" (block)
411 : "r"(line_size)
412 : "%eax", "memory"
413 );
414}
415
649c00c9
MN
416static void clear_blocks_mmx(DCTELEM *blocks)
417{
39825f31 418 __asm __volatile(
649c00c9
MN
419 "pxor %%mm7, %%mm7 \n\t"
420 "movl $-128*6, %%eax \n\t"
421 "1: \n\t"
422 "movq %%mm7, (%0, %%eax) \n\t"
423 "movq %%mm7, 8(%0, %%eax) \n\t"
424 "movq %%mm7, 16(%0, %%eax) \n\t"
425 "movq %%mm7, 24(%0, %%eax) \n\t"
426 "addl $32, %%eax \n\t"
427 " js 1b \n\t"
428 : : "r" (((int)blocks)+128*6)
429 : "%eax"
430 );
431}
432
764ef400 433#ifdef CONFIG_ENCODERS
0c1a9eda 434static int pix_sum16_mmx(uint8_t * pix, int line_size){
084c726b
MN
435 const int h=16;
436 int sum;
437 int index= -line_size*h;
438
439 __asm __volatile(
440 "pxor %%mm7, %%mm7 \n\t"
441 "pxor %%mm6, %%mm6 \n\t"
442 "1: \n\t"
443 "movq (%2, %1), %%mm0 \n\t"
444 "movq (%2, %1), %%mm1 \n\t"
445 "movq 8(%2, %1), %%mm2 \n\t"
446 "movq 8(%2, %1), %%mm3 \n\t"
447 "punpcklbw %%mm7, %%mm0 \n\t"
448 "punpckhbw %%mm7, %%mm1 \n\t"
449 "punpcklbw %%mm7, %%mm2 \n\t"
450 "punpckhbw %%mm7, %%mm3 \n\t"
451 "paddw %%mm0, %%mm1 \n\t"
452 "paddw %%mm2, %%mm3 \n\t"
453 "paddw %%mm1, %%mm3 \n\t"
454 "paddw %%mm3, %%mm6 \n\t"
455 "addl %3, %1 \n\t"
456 " js 1b \n\t"
457 "movq %%mm6, %%mm5 \n\t"
458 "psrlq $32, %%mm6 \n\t"
459 "paddw %%mm5, %%mm6 \n\t"
460 "movq %%mm6, %%mm5 \n\t"
461 "psrlq $16, %%mm6 \n\t"
462 "paddw %%mm5, %%mm6 \n\t"
463 "movd %%mm6, %0 \n\t"
464 "andl $0xFFFF, %0 \n\t"
465 : "=&r" (sum), "+r" (index)
466 : "r" (pix - index), "r" (line_size)
467 );
468
469 return sum;
470}
764ef400 471#endif //CONFIG_ENCODERS
084c726b 472
11f18faf
MN
473static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){
474 int i=0;
475 asm volatile(
476 "1: \n\t"
477 "movq (%1, %0), %%mm0 \n\t"
478 "movq (%2, %0), %%mm1 \n\t"
479 "paddb %%mm0, %%mm1 \n\t"
480 "movq %%mm1, (%2, %0) \n\t"
481 "movq 8(%1, %0), %%mm0 \n\t"
482 "movq 8(%2, %0), %%mm1 \n\t"
483 "paddb %%mm0, %%mm1 \n\t"
484 "movq %%mm1, 8(%2, %0) \n\t"
485 "addl $16, %0 \n\t"
486 "cmpl %3, %0 \n\t"
487 " jb 1b \n\t"
488 : "+r" (i)
489 : "r"(src), "r"(dst), "r"(w-15)
490 );
491 for(; i<w; i++)
492 dst[i+0] += src[i+0];
493}
494
3615e2be
MN
495#define H263_LOOP_FILTER \
496 "pxor %%mm7, %%mm7 \n\t"\
497 "movq %0, %%mm0 \n\t"\
498 "movq %0, %%mm1 \n\t"\
499 "movq %3, %%mm2 \n\t"\
500 "movq %3, %%mm3 \n\t"\
501 "punpcklbw %%mm7, %%mm0 \n\t"\
502 "punpckhbw %%mm7, %%mm1 \n\t"\
503 "punpcklbw %%mm7, %%mm2 \n\t"\
504 "punpckhbw %%mm7, %%mm3 \n\t"\
505 "psubw %%mm2, %%mm0 \n\t"\
506 "psubw %%mm3, %%mm1 \n\t"\
507 "movq %1, %%mm2 \n\t"\
508 "movq %1, %%mm3 \n\t"\
509 "movq %2, %%mm4 \n\t"\
510 "movq %2, %%mm5 \n\t"\
511 "punpcklbw %%mm7, %%mm2 \n\t"\
512 "punpckhbw %%mm7, %%mm3 \n\t"\
513 "punpcklbw %%mm7, %%mm4 \n\t"\
514 "punpckhbw %%mm7, %%mm5 \n\t"\
515 "psubw %%mm2, %%mm4 \n\t"\
516 "psubw %%mm3, %%mm5 \n\t"\
517 "psllw $2, %%mm4 \n\t"\
518 "psllw $2, %%mm5 \n\t"\
519 "paddw %%mm0, %%mm4 \n\t"\
520 "paddw %%mm1, %%mm5 \n\t"\
521 "pxor %%mm6, %%mm6 \n\t"\
522 "pcmpgtw %%mm4, %%mm6 \n\t"\
523 "pcmpgtw %%mm5, %%mm7 \n\t"\
524 "pxor %%mm6, %%mm4 \n\t"\
525 "pxor %%mm7, %%mm5 \n\t"\
526 "psubw %%mm6, %%mm4 \n\t"\
527 "psubw %%mm7, %%mm5 \n\t"\
528 "psrlw $3, %%mm4 \n\t"\
529 "psrlw $3, %%mm5 \n\t"\
530 "packuswb %%mm5, %%mm4 \n\t"\
531 "packsswb %%mm7, %%mm6 \n\t"\
532 "pxor %%mm7, %%mm7 \n\t"\
533 "movd %4, %%mm2 \n\t"\
534 "punpcklbw %%mm2, %%mm2 \n\t"\
535 "punpcklbw %%mm2, %%mm2 \n\t"\
536 "punpcklbw %%mm2, %%mm2 \n\t"\
537 "psubusb %%mm4, %%mm2 \n\t"\
538 "movq %%mm2, %%mm3 \n\t"\
539 "psubusb %%mm4, %%mm3 \n\t"\
540 "psubb %%mm3, %%mm2 \n\t"\
541 "movq %1, %%mm3 \n\t"\
542 "movq %2, %%mm4 \n\t"\
543 "pxor %%mm6, %%mm3 \n\t"\
544 "pxor %%mm6, %%mm4 \n\t"\
545 "paddusb %%mm2, %%mm3 \n\t"\
546 "psubusb %%mm2, %%mm4 \n\t"\
547 "pxor %%mm6, %%mm3 \n\t"\
548 "pxor %%mm6, %%mm4 \n\t"\
549 "paddusb %%mm2, %%mm2 \n\t"\
550 "packsswb %%mm1, %%mm0 \n\t"\
551 "pcmpgtb %%mm0, %%mm7 \n\t"\
552 "pxor %%mm7, %%mm0 \n\t"\
553 "psubb %%mm7, %%mm0 \n\t"\
554 "movq %%mm0, %%mm1 \n\t"\
555 "psubusb %%mm2, %%mm0 \n\t"\
556 "psubb %%mm0, %%mm1 \n\t"\
557 "pand %5, %%mm1 \n\t"\
558 "psrlw $2, %%mm1 \n\t"\
559 "pxor %%mm7, %%mm1 \n\t"\
560 "psubb %%mm7, %%mm1 \n\t"\
561 "movq %0, %%mm5 \n\t"\
562 "movq %3, %%mm6 \n\t"\
563 "psubb %%mm1, %%mm5 \n\t"\
564 "paddb %%mm1, %%mm6 \n\t"
565
359f98de
MN
566static void h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale){
567 const int strength= ff_h263_loop_filter_strength[qscale];
568
569 asm volatile(
3615e2be
MN
570
571 H263_LOOP_FILTER
572
359f98de
MN
573 "movq %%mm3, %1 \n\t"
574 "movq %%mm4, %2 \n\t"
3615e2be
MN
575 "movq %%mm5, %0 \n\t"
576 "movq %%mm6, %3 \n\t"
359f98de
MN
577 : "+m" (*(uint64_t*)(src - 2*stride)),
578 "+m" (*(uint64_t*)(src - 1*stride)),
579 "+m" (*(uint64_t*)(src + 0*stride)),
580 "+m" (*(uint64_t*)(src + 1*stride))
581 : "g" (2*strength), "m"(ff_pb_FC)
582 );
583}
584
3615e2be
MN
585static inline void transpose4x4(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride){
586 asm volatile( //FIXME could save 1 instruction if done as 8x4 ...
587 "movd %4, %%mm0 \n\t"
588 "movd %5, %%mm1 \n\t"
589 "movd %6, %%mm2 \n\t"
590 "movd %7, %%mm3 \n\t"
591 "punpcklbw %%mm1, %%mm0 \n\t"
592 "punpcklbw %%mm3, %%mm2 \n\t"
593 "movq %%mm0, %%mm1 \n\t"
594 "punpcklwd %%mm2, %%mm0 \n\t"
595 "punpckhwd %%mm2, %%mm1 \n\t"
596 "movd %%mm0, %0 \n\t"
597 "punpckhdq %%mm0, %%mm0 \n\t"
598 "movd %%mm0, %1 \n\t"
599 "movd %%mm1, %2 \n\t"
600 "punpckhdq %%mm1, %%mm1 \n\t"
601 "movd %%mm1, %3 \n\t"
602
603 : "=m" (*(uint32_t*)(dst + 0*dst_stride)),
604 "=m" (*(uint32_t*)(dst + 1*dst_stride)),
605 "=m" (*(uint32_t*)(dst + 2*dst_stride)),
606 "=m" (*(uint32_t*)(dst + 3*dst_stride))
607 : "m" (*(uint32_t*)(src + 0*src_stride)),
608 "m" (*(uint32_t*)(src + 1*src_stride)),
609 "m" (*(uint32_t*)(src + 2*src_stride)),
610 "m" (*(uint32_t*)(src + 3*src_stride))
611 );
612}
613
614static void h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale){
615 const int strength= ff_h263_loop_filter_strength[qscale];
616 uint64_t temp[4] __attribute__ ((aligned(8)));
617 uint8_t *btemp= (uint8_t*)temp;
618
619 src -= 2;
620
621 transpose4x4(btemp , src , 8, stride);
622 transpose4x4(btemp+4, src + 4*stride, 8, stride);
623 asm volatile(
624 H263_LOOP_FILTER // 5 3 4 6
625
626 : "+m" (temp[0]),
627 "+m" (temp[1]),
628 "+m" (temp[2]),
629 "+m" (temp[3])
630 : "g" (2*strength), "m"(ff_pb_FC)
631 );
632
633 asm volatile(
634 "movq %%mm5, %%mm1 \n\t"
635 "movq %%mm4, %%mm0 \n\t"
636 "punpcklbw %%mm3, %%mm5 \n\t"
637 "punpcklbw %%mm6, %%mm4 \n\t"
638 "punpckhbw %%mm3, %%mm1 \n\t"
639 "punpckhbw %%mm6, %%mm0 \n\t"
640 "movq %%mm5, %%mm3 \n\t"
641 "movq %%mm1, %%mm6 \n\t"
642 "punpcklwd %%mm4, %%mm5 \n\t"
643 "punpcklwd %%mm0, %%mm1 \n\t"
644 "punpckhwd %%mm4, %%mm3 \n\t"
645 "punpckhwd %%mm0, %%mm6 \n\t"
646 "movd %%mm5, %0 \n\t"
647 "punpckhdq %%mm5, %%mm5 \n\t"
648 "movd %%mm5, %1 \n\t"
649 "movd %%mm3, %2 \n\t"
650 "punpckhdq %%mm3, %%mm3 \n\t"
651 "movd %%mm3, %3 \n\t"
652 "movd %%mm1, %4 \n\t"
653 "punpckhdq %%mm1, %%mm1 \n\t"
654 "movd %%mm1, %5 \n\t"
655 "movd %%mm6, %6 \n\t"
656 "punpckhdq %%mm6, %%mm6 \n\t"
657 "movd %%mm6, %7 \n\t"
658 : "=m" (*(uint32_t*)(src + 0*stride)),
659 "=m" (*(uint32_t*)(src + 1*stride)),
660 "=m" (*(uint32_t*)(src + 2*stride)),
661 "=m" (*(uint32_t*)(src + 3*stride)),
662 "=m" (*(uint32_t*)(src + 4*stride)),
663 "=m" (*(uint32_t*)(src + 5*stride)),
664 "=m" (*(uint32_t*)(src + 6*stride)),
665 "=m" (*(uint32_t*)(src + 7*stride))
666 );
667}
668
764ef400 669#ifdef CONFIG_ENCODERS
2a006cd3
FL
670static int pix_norm1_mmx(uint8_t *pix, int line_size) {
671 int tmp;
672 asm volatile (
673 "movl $16,%%ecx\n"
674 "pxor %%mm0,%%mm0\n"
675 "pxor %%mm7,%%mm7\n"
676 "1:\n"
677 "movq (%0),%%mm2\n" /* mm2 = pix[0-7] */
678 "movq 8(%0),%%mm3\n" /* mm3 = pix[8-15] */
679
680 "movq %%mm2,%%mm1\n" /* mm1 = mm2 = pix[0-7] */
681
682 "punpckhbw %%mm0,%%mm1\n" /* mm1 = [pix4-7] */
683 "punpcklbw %%mm0,%%mm2\n" /* mm2 = [pix0-3] */
684
685 "movq %%mm3,%%mm4\n" /* mm4 = mm3 = pix[8-15] */
686 "punpckhbw %%mm0,%%mm3\n" /* mm3 = [pix12-15] */
687 "punpcklbw %%mm0,%%mm4\n" /* mm4 = [pix8-11] */
688
689 "pmaddwd %%mm1,%%mm1\n" /* mm1 = (pix0^2+pix1^2,pix2^2+pix3^2) */
690 "pmaddwd %%mm2,%%mm2\n" /* mm2 = (pix4^2+pix5^2,pix6^2+pix7^2) */
691
692 "pmaddwd %%mm3,%%mm3\n"
693 "pmaddwd %%mm4,%%mm4\n"
694
695 "paddd %%mm1,%%mm2\n" /* mm2 = (pix0^2+pix1^2+pix4^2+pix5^2,
696 pix2^2+pix3^2+pix6^2+pix7^2) */
697 "paddd %%mm3,%%mm4\n"
698 "paddd %%mm2,%%mm7\n"
699
700 "addl %2, %0\n"
701 "paddd %%mm4,%%mm7\n"
702 "dec %%ecx\n"
703 "jnz 1b\n"
704
705 "movq %%mm7,%%mm1\n"
706 "psrlq $32, %%mm7\n" /* shift hi dword to lo */
707 "paddd %%mm7,%%mm1\n"
708 "movd %%mm1,%1\n"
709 : "+r" (pix), "=r"(tmp) : "r" (line_size) : "%ecx" );
710 return tmp;
711}
712
bb198e19 713static int sse16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
2a006cd3
FL
714 int tmp;
715 asm volatile (
bb198e19 716 "movl %4,%%ecx\n"
2a006cd3
FL
717 "pxor %%mm0,%%mm0\n" /* mm0 = 0 */
718 "pxor %%mm7,%%mm7\n" /* mm7 holds the sum */
719 "1:\n"
720 "movq (%0),%%mm1\n" /* mm1 = pix1[0-7] */
721 "movq (%1),%%mm2\n" /* mm2 = pix2[0-7] */
722 "movq 8(%0),%%mm3\n" /* mm3 = pix1[8-15] */
723 "movq 8(%1),%%mm4\n" /* mm4 = pix2[8-15] */
724
725 /* todo: mm1-mm2, mm3-mm4 */
726 /* algo: substract mm1 from mm2 with saturation and vice versa */
727 /* OR the results to get absolute difference */
728 "movq %%mm1,%%mm5\n"
729 "movq %%mm3,%%mm6\n"
730 "psubusb %%mm2,%%mm1\n"
731 "psubusb %%mm4,%%mm3\n"
732 "psubusb %%mm5,%%mm2\n"
733 "psubusb %%mm6,%%mm4\n"
734
735 "por %%mm1,%%mm2\n"
736 "por %%mm3,%%mm4\n"
737
738 /* now convert to 16-bit vectors so we can square them */
739 "movq %%mm2,%%mm1\n"
740 "movq %%mm4,%%mm3\n"
741
742 "punpckhbw %%mm0,%%mm2\n"
743 "punpckhbw %%mm0,%%mm4\n"
744 "punpcklbw %%mm0,%%mm1\n" /* mm1 now spread over (mm1,mm2) */
745 "punpcklbw %%mm0,%%mm3\n" /* mm4 now spread over (mm3,mm4) */
746
747 "pmaddwd %%mm2,%%mm2\n"
748 "pmaddwd %%mm4,%%mm4\n"
749 "pmaddwd %%mm1,%%mm1\n"
750 "pmaddwd %%mm3,%%mm3\n"
751
752 "addl %3,%0\n"
753 "addl %3,%1\n"
754
755 "paddd %%mm2,%%mm1\n"
756 "paddd %%mm4,%%mm3\n"
757 "paddd %%mm1,%%mm7\n"
758 "paddd %%mm3,%%mm7\n"
759
760 "decl %%ecx\n"
761 "jnz 1b\n"
762
763 "movq %%mm7,%%mm1\n"
764 "psrlq $32, %%mm7\n" /* shift hi dword to lo */
765 "paddd %%mm7,%%mm1\n"
766 "movd %%mm1,%2\n"
bb198e19
MN
767 : "+r" (pix1), "+r" (pix2), "=r"(tmp)
768 : "r" (line_size) , "m" (h)
769 : "%ecx");
2a006cd3
FL
770 return tmp;
771}
772
622348f9
MN
773static int vsad_intra16_mmx(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) {
774 int tmp;
775
776 assert( (((int)pix) & 7) == 0);
777 assert((line_size &7) ==0);
778
779#define SUM(in0, in1, out0, out1) \
780 "movq (%0), %%mm2\n"\
781 "movq 8(%0), %%mm3\n"\
782 "addl %2,%0\n"\
783 "movq %%mm2, " #out0 "\n"\
784 "movq %%mm3, " #out1 "\n"\
785 "psubusb " #in0 ", %%mm2\n"\
786 "psubusb " #in1 ", %%mm3\n"\
787 "psubusb " #out0 ", " #in0 "\n"\
788 "psubusb " #out1 ", " #in1 "\n"\
789 "por %%mm2, " #in0 "\n"\
790 "por %%mm3, " #in1 "\n"\
791 "movq " #in0 ", %%mm2\n"\
792 "movq " #in1 ", %%mm3\n"\
793 "punpcklbw %%mm7, " #in0 "\n"\
794 "punpcklbw %%mm7, " #in1 "\n"\
795 "punpckhbw %%mm7, %%mm2\n"\
796 "punpckhbw %%mm7, %%mm3\n"\
797 "paddw " #in1 ", " #in0 "\n"\
798 "paddw %%mm3, %%mm2\n"\
799 "paddw %%mm2, " #in0 "\n"\
800 "paddw " #in0 ", %%mm6\n"
801
802
803 asm volatile (
804 "movl %3,%%ecx\n"
805 "pxor %%mm6,%%mm6\n"
806 "pxor %%mm7,%%mm7\n"
807 "movq (%0),%%mm0\n"
808 "movq 8(%0),%%mm1\n"
809 "addl %2,%0\n"
810 "subl $2, %%ecx\n"
811 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
812 "1:\n"
813
814 SUM(%%mm4, %%mm5, %%mm0, %%mm1)
815
816 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
817
818 "subl $2, %%ecx\n"
819 "jnz 1b\n"
820
821 "movq %%mm6,%%mm0\n"
822 "psrlq $32, %%mm6\n"
823 "paddw %%mm6,%%mm0\n"
824 "movq %%mm0,%%mm6\n"
825 "psrlq $16, %%mm0\n"
826 "paddw %%mm6,%%mm0\n"
827 "movd %%mm0,%1\n"
828 : "+r" (pix), "=r"(tmp)
829 : "r" (line_size) , "m" (h)
830 : "%ecx");
831 return tmp & 0xFFFF;
832}
833#undef SUM
834
835static int vsad_intra16_mmx2(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) {
836 int tmp;
837
838 assert( (((int)pix) & 7) == 0);
839 assert((line_size &7) ==0);
840
841#define SUM(in0, in1, out0, out1) \
842 "movq (%0), " #out0 "\n"\
843 "movq 8(%0), " #out1 "\n"\
844 "addl %2,%0\n"\
845 "psadbw " #out0 ", " #in0 "\n"\
846 "psadbw " #out1 ", " #in1 "\n"\
847 "paddw " #in1 ", " #in0 "\n"\
848 "paddw " #in0 ", %%mm6\n"
849
850 asm volatile (
851 "movl %3,%%ecx\n"
852 "pxor %%mm6,%%mm6\n"
853 "pxor %%mm7,%%mm7\n"
854 "movq (%0),%%mm0\n"
855 "movq 8(%0),%%mm1\n"
856 "addl %2,%0\n"
857 "subl $2, %%ecx\n"
858 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
859 "1:\n"
860
861 SUM(%%mm4, %%mm5, %%mm0, %%mm1)
862
863 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
864
865 "subl $2, %%ecx\n"
866 "jnz 1b\n"
867
868 "movd %%mm6,%1\n"
869 : "+r" (pix), "=r"(tmp)
870 : "r" (line_size) , "m" (h)
871 : "%ecx");
872 return tmp;
873}
874#undef SUM
875
876static int vsad16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
877 int tmp;
878
879 assert( (((int)pix1) & 7) == 0);
880 assert( (((int)pix2) & 7) == 0);
881 assert((line_size &7) ==0);
882
883#define SUM(in0, in1, out0, out1) \
884 "movq (%0),%%mm2\n"\
885 "movq (%1)," #out0 "\n"\
886 "movq 8(%0),%%mm3\n"\
887 "movq 8(%1)," #out1 "\n"\
888 "addl %3,%0\n"\
889 "addl %3,%1\n"\
890 "psubb " #out0 ", %%mm2\n"\
891 "psubb " #out1 ", %%mm3\n"\
892 "pxor %%mm7, %%mm2\n"\
893 "pxor %%mm7, %%mm3\n"\
894 "movq %%mm2, " #out0 "\n"\
895 "movq %%mm3, " #out1 "\n"\
896 "psubusb " #in0 ", %%mm2\n"\
897 "psubusb " #in1 ", %%mm3\n"\
898 "psubusb " #out0 ", " #in0 "\n"\
899 "psubusb " #out1 ", " #in1 "\n"\
900 "por %%mm2, " #in0 "\n"\
901 "por %%mm3, " #in1 "\n"\
902 "movq " #in0 ", %%mm2\n"\
903 "movq " #in1 ", %%mm3\n"\
904 "punpcklbw %%mm7, " #in0 "\n"\
905 "punpcklbw %%mm7, " #in1 "\n"\
906 "punpckhbw %%mm7, %%mm2\n"\
907 "punpckhbw %%mm7, %%mm3\n"\
908 "paddw " #in1 ", " #in0 "\n"\
909 "paddw %%mm3, %%mm2\n"\
910 "paddw %%mm2, " #in0 "\n"\
911 "paddw " #in0 ", %%mm6\n"
912
913
914 asm volatile (
915 "movl %4,%%ecx\n"
916 "pxor %%mm6,%%mm6\n"
917 "pcmpeqw %%mm7,%%mm7\n"
918 "psllw $15, %%mm7\n"
919 "packsswb %%mm7, %%mm7\n"
920 "movq (%0),%%mm0\n"
921 "movq (%1),%%mm2\n"
922 "movq 8(%0),%%mm1\n"
923 "movq 8(%1),%%mm3\n"
924 "addl %3,%0\n"
925 "addl %3,%1\n"
926 "subl $2, %%ecx\n"
927 "psubb %%mm2, %%mm0\n"
928 "psubb %%mm3, %%mm1\n"
929 "pxor %%mm7, %%mm0\n"
930 "pxor %%mm7, %%mm1\n"
931 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
932 "1:\n"
933
934 SUM(%%mm4, %%mm5, %%mm0, %%mm1)
935
936 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
937
938 "subl $2, %%ecx\n"
939 "jnz 1b\n"
940
941 "movq %%mm6,%%mm0\n"
942 "psrlq $32, %%mm6\n"
943 "paddw %%mm6,%%mm0\n"
944 "movq %%mm0,%%mm6\n"
945 "psrlq $16, %%mm0\n"
946 "paddw %%mm6,%%mm0\n"
947 "movd %%mm0,%2\n"
948 : "+r" (pix1), "+r" (pix2), "=r"(tmp)
949 : "r" (line_size) , "m" (h)
950 : "%ecx");
951 return tmp & 0x7FFF;
952}
953#undef SUM
954
955static int vsad16_mmx2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
956 int tmp;
957
958 assert( (((int)pix1) & 7) == 0);
959 assert( (((int)pix2) & 7) == 0);
960 assert((line_size &7) ==0);
961
962#define SUM(in0, in1, out0, out1) \
963 "movq (%0)," #out0 "\n"\
964 "movq (%1),%%mm2\n"\
965 "movq 8(%0)," #out1 "\n"\
966 "movq 8(%1),%%mm3\n"\
967 "addl %3,%0\n"\
968 "addl %3,%1\n"\
969 "psubb %%mm2, " #out0 "\n"\
970 "psubb %%mm3, " #out1 "\n"\
971 "pxor %%mm7, " #out0 "\n"\
972 "pxor %%mm7, " #out1 "\n"\
973 "psadbw " #out0 ", " #in0 "\n"\
974 "psadbw " #out1 ", " #in1 "\n"\
975 "paddw " #in1 ", " #in0 "\n"\
976 "paddw " #in0 ", %%mm6\n"
977
978 asm volatile (
979 "movl %4,%%ecx\n"
980 "pxor %%mm6,%%mm6\n"
981 "pcmpeqw %%mm7,%%mm7\n"
982 "psllw $15, %%mm7\n"
983 "packsswb %%mm7, %%mm7\n"
984 "movq (%0),%%mm0\n"
985 "movq (%1),%%mm2\n"
986 "movq 8(%0),%%mm1\n"
987 "movq 8(%1),%%mm3\n"
988 "addl %3,%0\n"
989 "addl %3,%1\n"
990 "subl $2, %%ecx\n"
991 "psubb %%mm2, %%mm0\n"
992 "psubb %%mm3, %%mm1\n"
993 "pxor %%mm7, %%mm0\n"
994 "pxor %%mm7, %%mm1\n"
995 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
996 "1:\n"
997
998 SUM(%%mm4, %%mm5, %%mm0, %%mm1)
999
1000 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
1001
1002 "subl $2, %%ecx\n"
1003 "jnz 1b\n"
1004
1005 "movd %%mm6,%2\n"
1006 : "+r" (pix1), "+r" (pix2), "=r"(tmp)
1007 : "r" (line_size) , "m" (h)
1008 : "%ecx");
1009 return tmp;
1010}
1011#undef SUM
1012
11f18faf
MN
1013static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
1014 int i=0;
1015 asm volatile(
1016 "1: \n\t"
1017 "movq (%2, %0), %%mm0 \n\t"
1018 "movq (%1, %0), %%mm1 \n\t"
1019 "psubb %%mm0, %%mm1 \n\t"
1020 "movq %%mm1, (%3, %0) \n\t"
1021 "movq 8(%2, %0), %%mm0 \n\t"
1022 "movq 8(%1, %0), %%mm1 \n\t"
1023 "psubb %%mm0, %%mm1 \n\t"
1024 "movq %%mm1, 8(%3, %0) \n\t"
1025 "addl $16, %0 \n\t"
1026 "cmpl %4, %0 \n\t"
1027 " jb 1b \n\t"
1028 : "+r" (i)
1029 : "r"(src1), "r"(src2), "r"(dst), "r"(w-15)
1030 );
1031 for(; i<w; i++)
1032 dst[i+0] = src1[i+0]-src2[i+0];
1033}
84705403
MN
1034
1035static void sub_hfyu_median_prediction_mmx2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
1036 int i=0;
1037 uint8_t l, lt;
1038
1039 asm volatile(
1040 "1: \n\t"
1041 "movq -1(%1, %0), %%mm0 \n\t" // LT
1042 "movq (%1, %0), %%mm1 \n\t" // T
1043 "movq -1(%2, %0), %%mm2 \n\t" // L
1044 "movq (%2, %0), %%mm3 \n\t" // X
1045 "movq %%mm2, %%mm4 \n\t" // L
1046 "psubb %%mm0, %%mm2 \n\t"
1047 "paddb %%mm1, %%mm2 \n\t" // L + T - LT
1048 "movq %%mm4, %%mm5 \n\t" // L
1049 "pmaxub %%mm1, %%mm4 \n\t" // max(T, L)
1050 "pminub %%mm5, %%mm1 \n\t" // min(T, L)
1051 "pminub %%mm2, %%mm4 \n\t"
1052 "pmaxub %%mm1, %%mm4 \n\t"
1053 "psubb %%mm4, %%mm3 \n\t" // dst - pred
1054 "movq %%mm3, (%3, %0) \n\t"
1055 "addl $8, %0 \n\t"
1056 "cmpl %4, %0 \n\t"
1057 " jb 1b \n\t"
1058 : "+r" (i)
1059 : "r"(src1), "r"(src2), "r"(dst), "r"(w)
1060 );
1061
1062 l= *left;
1063 lt= *left_top;
1064
1065 dst[0]= src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt)&0xFF);
1066
1067 *left_top= src1[w-1];
1068 *left = src2[w-1];
1069}
1070
8e0a3db7
MN
1071#define LBUTTERFLY2(a1,b1,a2,b2)\
1072 "paddw " #b1 ", " #a1 " \n\t"\
1073 "paddw " #b2 ", " #a2 " \n\t"\
1074 "paddw " #b1 ", " #b1 " \n\t"\
1075 "paddw " #b2 ", " #b2 " \n\t"\
1076 "psubw " #a1 ", " #b1 " \n\t"\
7db52b63 1077 "psubw " #a2 ", " #b2 " \n\t"
1457ab52
MN
1078
1079#define HADAMARD48\
8e0a3db7
MN
1080 LBUTTERFLY2(%%mm0, %%mm1, %%mm2, %%mm3)\
1081 LBUTTERFLY2(%%mm4, %%mm5, %%mm6, %%mm7)\
1082 LBUTTERFLY2(%%mm0, %%mm2, %%mm1, %%mm3)\
1083 LBUTTERFLY2(%%mm4, %%mm6, %%mm5, %%mm7)\
1084 LBUTTERFLY2(%%mm0, %%mm4, %%mm1, %%mm5)\
1085 LBUTTERFLY2(%%mm2, %%mm6, %%mm3, %%mm7)\
1457ab52
MN
1086
1087#define MMABS(a,z)\
1088 "pxor " #z ", " #z " \n\t"\
1089 "pcmpgtw " #a ", " #z " \n\t"\
1090 "pxor " #z ", " #a " \n\t"\
1091 "psubw " #z ", " #a " \n\t"
1092
1093#define MMABS_SUM(a,z, sum)\
1094 "pxor " #z ", " #z " \n\t"\
1095 "pcmpgtw " #a ", " #z " \n\t"\
1096 "pxor " #z ", " #a " \n\t"\
1097 "psubw " #z ", " #a " \n\t"\
1098 "paddusw " #a ", " #sum " \n\t"
1099
8e0a3db7
MN
1100#define MMABS_MMX2(a,z)\
1101 "pxor " #z ", " #z " \n\t"\
1102 "psubw " #a ", " #z " \n\t"\
1103 "pmaxsw " #z ", " #a " \n\t"
1104
1105#define MMABS_SUM_MMX2(a,z, sum)\
1106 "pxor " #z ", " #z " \n\t"\
1107 "psubw " #a ", " #z " \n\t"\
1108 "pmaxsw " #z ", " #a " \n\t"\
1109 "paddusw " #a ", " #sum " \n\t"
1110
1457ab52
MN
1111#define SBUTTERFLY(a,b,t,n)\
1112 "movq " #a ", " #t " \n\t" /* abcd */\
1113 "punpckl" #n " " #b ", " #a " \n\t" /* aebf */\
1114 "punpckh" #n " " #b ", " #t " \n\t" /* cgdh */\
8e0a3db7 1115
1457ab52
MN
1116#define TRANSPOSE4(a,b,c,d,t)\
1117 SBUTTERFLY(a,b,t,wd) /* a=aebf t=cgdh */\
1118 SBUTTERFLY(c,d,b,wd) /* c=imjn b=kolp */\
1119 SBUTTERFLY(a,c,d,dq) /* a=aeim d=bfjn */\
1120 SBUTTERFLY(t,b,c,dq) /* t=cgko c=dhlp */
1121
1122#define LOAD4(o, a, b, c, d)\
1123 "movq "#o"(%1), " #a " \n\t"\
1124 "movq "#o"+16(%1), " #b " \n\t"\
1125 "movq "#o"+32(%1), " #c " \n\t"\
1126 "movq "#o"+48(%1), " #d " \n\t"
1127
1128#define STORE4(o, a, b, c, d)\
1129 "movq "#a", "#o"(%1) \n\t"\
1130 "movq "#b", "#o"+16(%1) \n\t"\
1131 "movq "#c", "#o"+32(%1) \n\t"\
1132 "movq "#d", "#o"+48(%1) \n\t"\
1133
bb198e19 1134static int hadamard8_diff_mmx(void *s, uint8_t *src1, uint8_t *src2, int stride, int h){
1457ab52
MN
1135 uint64_t temp[16] __align8;
1136 int sum=0;
bb198e19
MN
1137
1138 assert(h==8);
1457ab52
MN
1139
1140 diff_pixels_mmx((DCTELEM*)temp, src1, src2, stride);
11f18faf 1141
1457ab52
MN
1142 asm volatile(
1143 LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
1144 LOAD4(64, %%mm4, %%mm5, %%mm6, %%mm7)
1145
1146 HADAMARD48
1147
1148 "movq %%mm7, 112(%1) \n\t"
1149
1150 TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
1151 STORE4(0 , %%mm0, %%mm3, %%mm7, %%mm2)
1152
1153 "movq 112(%1), %%mm7 \n\t"
1154 TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
1155 STORE4(64, %%mm4, %%mm7, %%mm0, %%mm6)
1156
1157 LOAD4(8 , %%mm0, %%mm1, %%mm2, %%mm3)
1158 LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
1159
1160 HADAMARD48
1161
1162 "movq %%mm7, 120(%1) \n\t"
1163
1164 TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
1165 STORE4(8 , %%mm0, %%mm3, %%mm7, %%mm2)
1166
1167 "movq 120(%1), %%mm7 \n\t"
1168 TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
1169 "movq %%mm7, %%mm5 \n\t"//FIXME remove
1170 "movq %%mm6, %%mm7 \n\t"
1171 "movq %%mm0, %%mm6 \n\t"
1172// STORE4(72, %%mm4, %%mm7, %%mm0, %%mm6) //FIXME remove
1173
1174 LOAD4(64, %%mm0, %%mm1, %%mm2, %%mm3)
1175// LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
1176
1177 HADAMARD48
1178 "movq %%mm7, 64(%1) \n\t"
1179 MMABS(%%mm0, %%mm7)
1180 MMABS_SUM(%%mm1, %%mm7, %%mm0)
1181 MMABS_SUM(%%mm2, %%mm7, %%mm0)
1182 MMABS_SUM(%%mm3, %%mm7, %%mm0)
1183 MMABS_SUM(%%mm4, %%mm7, %%mm0)
1184 MMABS_SUM(%%mm5, %%mm7, %%mm0)
1185 MMABS_SUM(%%mm6, %%mm7, %%mm0)
1186 "movq 64(%1), %%mm1 \n\t"
1187 MMABS_SUM(%%mm1, %%mm7, %%mm0)
1188 "movq %%mm0, 64(%1) \n\t"
1189
1190 LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
1191 LOAD4(8 , %%mm4, %%mm5, %%mm6, %%mm7)
1192
1193 HADAMARD48
1194 "movq %%mm7, (%1) \n\t"
1195 MMABS(%%mm0, %%mm7)
1196 MMABS_SUM(%%mm1, %%mm7, %%mm0)
1197 MMABS_SUM(%%mm2, %%mm7, %%mm0)
1198 MMABS_SUM(%%mm3, %%mm7, %%mm0)
1199 MMABS_SUM(%%mm4, %%mm7, %%mm0)
1200 MMABS_SUM(%%mm5, %%mm7, %%mm0)
1201 MMABS_SUM(%%mm6, %%mm7, %%mm0)
1202 "movq (%1), %%mm1 \n\t"
1203 MMABS_SUM(%%mm1, %%mm7, %%mm0)
1204 "movq 64(%1), %%mm1 \n\t"
1205 MMABS_SUM(%%mm1, %%mm7, %%mm0)
1206
1207 "movq %%mm0, %%mm1 \n\t"
1208 "psrlq $32, %%mm0 \n\t"
1209 "paddusw %%mm1, %%mm0 \n\t"
1210 "movq %%mm0, %%mm1 \n\t"
1211 "psrlq $16, %%mm0 \n\t"
1212 "paddusw %%mm1, %%mm0 \n\t"
1213 "movd %%mm0, %0 \n\t"
1214
1215 : "=r" (sum)
1216 : "r"(temp)
1217 );
1218 return sum&0xFFFF;
1219}
1220
bb198e19 1221static int hadamard8_diff_mmx2(void *s, uint8_t *src1, uint8_t *src2, int stride, int h){
8e0a3db7
MN
1222 uint64_t temp[16] __align8;
1223 int sum=0;
bb198e19
MN
1224
1225 assert(h==8);
8e0a3db7
MN
1226
1227 diff_pixels_mmx((DCTELEM*)temp, src1, src2, stride);
1228
1229 asm volatile(
1230 LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
1231 LOAD4(64, %%mm4, %%mm5, %%mm6, %%mm7)
1232
1233 HADAMARD48
1234
1235 "movq %%mm7, 112(%1) \n\t"
1236
1237 TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
1238 STORE4(0 , %%mm0, %%mm3, %%mm7, %%mm2)
1239
1240 "movq 112(%1), %%mm7 \n\t"
1241 TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
1242 STORE4(64, %%mm4, %%mm7, %%mm0, %%mm6)
1243
1244 LOAD4(8 , %%mm0, %%mm1, %%mm2, %%mm3)
1245 LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
1246
1247 HADAMARD48
1248
1249 "movq %%mm7, 120(%1) \n\t"
1250
1251 TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
1252 STORE4(8 , %%mm0, %%mm3, %%mm7, %%mm2)
1253
1254 "movq 120(%1), %%mm7 \n\t"
1255 TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
1256 "movq %%mm7, %%mm5 \n\t"//FIXME remove
1257 "movq %%mm6, %%mm7 \n\t"
1258 "movq %%mm0, %%mm6 \n\t"
1259// STORE4(72, %%mm4, %%mm7, %%mm0, %%mm6) //FIXME remove
1260
1261 LOAD4(64, %%mm0, %%mm1, %%mm2, %%mm3)
1262// LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
1263
1264 HADAMARD48
1265 "movq %%mm7, 64(%1) \n\t"
1266 MMABS_MMX2(%%mm0, %%mm7)
1267 MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
1268 MMABS_SUM_MMX2(%%mm2, %%mm7, %%mm0)
1269 MMABS_SUM_MMX2(%%mm3, %%mm7, %%mm0)
1270 MMABS_SUM_MMX2(%%mm4, %%mm7, %%mm0)
1271 MMABS_SUM_MMX2(%%mm5, %%mm7, %%mm0)
1272 MMABS_SUM_MMX2(%%mm6, %%mm7, %%mm0)
1273 "movq 64(%1), %%mm1 \n\t"
1274 MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
1275 "movq %%mm0, 64(%1) \n\t"
1276
1277 LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
1278 LOAD4(8 , %%mm4, %%mm5, %%mm6, %%mm7)
1279
1280 HADAMARD48
1281 "movq %%mm7, (%1) \n\t"
1282 MMABS_MMX2(%%mm0, %%mm7)
1283 MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
1284 MMABS_SUM_MMX2(%%mm2, %%mm7, %%mm0)
1285 MMABS_SUM_MMX2(%%mm3, %%mm7, %%mm0)
1286 MMABS_SUM_MMX2(%%mm4, %%mm7, %%mm0)
1287 MMABS_SUM_MMX2(%%mm5, %%mm7, %%mm0)
1288 MMABS_SUM_MMX2(%%mm6, %%mm7, %%mm0)
1289 "movq (%1), %%mm1 \n\t"
1290 MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
1291 "movq 64(%1), %%mm1 \n\t"
1292 MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
1293
1294 "movq %%mm0, %%mm1 \n\t"
1295 "psrlq $32, %%mm0 \n\t"
1296 "paddusw %%mm1, %%mm0 \n\t"
1297 "movq %%mm0, %%mm1 \n\t"
1298 "psrlq $16, %%mm0 \n\t"
1299 "paddusw %%mm1, %%mm0 \n\t"
1300 "movd %%mm0, %0 \n\t"
1301
1302 : "=r" (sum)
1303 : "r"(temp)
1304 );
1305 return sum&0xFFFF;
1306}
1307
1308
bb198e19
MN
1309WARPER8_16_SQ(hadamard8_diff_mmx, hadamard8_diff16_mmx)
1310WARPER8_16_SQ(hadamard8_diff_mmx2, hadamard8_diff16_mmx2)
764ef400 1311#endif //CONFIG_ENCODERS
11f18faf 1312
3178ee4c
MN
1313#define put_no_rnd_pixels8_mmx(a,b,c,d) put_pixels8_mmx(a,b,c,d)
1314#define put_no_rnd_pixels16_mmx(a,b,c,d) put_pixels16_mmx(a,b,c,d)
1315
826f429a
MN
1316#define QPEL_V_LOW(m3,m4,m5,m6, pw_20, pw_3, rnd, in0, in1, in2, in7, out, OP)\
1317 "paddw " #m4 ", " #m3 " \n\t" /* x1 */\
c296f66b 1318 "movq "MANGLE(ff_pw_20)", %%mm4 \n\t" /* 20 */\
826f429a
MN
1319 "pmullw " #m3 ", %%mm4 \n\t" /* 20x1 */\
1320 "movq "#in7", " #m3 " \n\t" /* d */\
1321 "movq "#in0", %%mm5 \n\t" /* D */\
1322 "paddw " #m3 ", %%mm5 \n\t" /* x4 */\
1323 "psubw %%mm5, %%mm4 \n\t" /* 20x1 - x4 */\
1324 "movq "#in1", %%mm5 \n\t" /* C */\
1325 "movq "#in2", %%mm6 \n\t" /* B */\
1326 "paddw " #m6 ", %%mm5 \n\t" /* x3 */\
1327 "paddw " #m5 ", %%mm6 \n\t" /* x2 */\
1328 "paddw %%mm6, %%mm6 \n\t" /* 2x2 */\
1329 "psubw %%mm6, %%mm5 \n\t" /* -2x2 + x3 */\
c296f66b 1330 "pmullw "MANGLE(ff_pw_3)", %%mm5 \n\t" /* -6x2 + 3x3 */\
826f429a
MN
1331 "paddw " #rnd ", %%mm4 \n\t" /* x2 */\
1332 "paddw %%mm4, %%mm5 \n\t" /* 20x1 - 6x2 + 3x3 - x4 */\
1333 "psraw $5, %%mm5 \n\t"\
1334 "packuswb %%mm5, %%mm5 \n\t"\
1335 OP(%%mm5, out, %%mm7, d)
1336
3178ee4c 1337#define QPEL_BASE(OPNAME, ROUNDER, RND, OP_MMX2, OP_3DNOW)\
5c91a675 1338static void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
826f429a
MN
1339 uint64_t temp;\
1340\
1341 asm volatile(\
1342 "pxor %%mm7, %%mm7 \n\t"\
1343 "1: \n\t"\
1344 "movq (%0), %%mm0 \n\t" /* ABCDEFGH */\
1345 "movq %%mm0, %%mm1 \n\t" /* ABCDEFGH */\
1346 "movq %%mm0, %%mm2 \n\t" /* ABCDEFGH */\
1347 "punpcklbw %%mm7, %%mm0 \n\t" /* 0A0B0C0D */\
1348 "punpckhbw %%mm7, %%mm1 \n\t" /* 0E0F0G0H */\
1349 "pshufw $0x90, %%mm0, %%mm5 \n\t" /* 0A0A0B0C */\
1350 "pshufw $0x41, %%mm0, %%mm6 \n\t" /* 0B0A0A0B */\
1351 "movq %%mm2, %%mm3 \n\t" /* ABCDEFGH */\
1352 "movq %%mm2, %%mm4 \n\t" /* ABCDEFGH */\
1353 "psllq $8, %%mm2 \n\t" /* 0ABCDEFG */\
1354 "psllq $16, %%mm3 \n\t" /* 00ABCDEF */\
1355 "psllq $24, %%mm4 \n\t" /* 000ABCDE */\
1356 "punpckhbw %%mm7, %%mm2 \n\t" /* 0D0E0F0G */\
1357 "punpckhbw %%mm7, %%mm3 \n\t" /* 0C0D0E0F */\
1358 "punpckhbw %%mm7, %%mm4 \n\t" /* 0B0C0D0E */\
1359 "paddw %%mm3, %%mm5 \n\t" /* b */\
1360 "paddw %%mm2, %%mm6 \n\t" /* c */\
1361 "paddw %%mm5, %%mm5 \n\t" /* 2b */\
1362 "psubw %%mm5, %%mm6 \n\t" /* c - 2b */\
1363 "pshufw $0x06, %%mm0, %%mm5 \n\t" /* 0C0B0A0A */\
c296f66b 1364 "pmullw "MANGLE(ff_pw_3)", %%mm6 \n\t" /* 3c - 6b */\
826f429a
MN
1365 "paddw %%mm4, %%mm0 \n\t" /* a */\
1366 "paddw %%mm1, %%mm5 \n\t" /* d */\
c296f66b 1367 "pmullw "MANGLE(ff_pw_20)", %%mm0 \n\t" /* 20a */\
826f429a 1368 "psubw %%mm5, %%mm0 \n\t" /* 20a - d */\
c296f66b 1369 "paddw %6, %%mm6 \n\t"\
826f429a
MN
1370 "paddw %%mm6, %%mm0 \n\t" /* 20a - 6b + 3c - d */\
1371 "psraw $5, %%mm0 \n\t"\
c296f66b 1372 "movq %%mm0, %5 \n\t"\
826f429a
MN
1373 /* mm1=EFGH, mm2=DEFG, mm3=CDEF, mm4=BCDE, mm7=0 */\
1374 \
1375 "movq 5(%0), %%mm0 \n\t" /* FGHIJKLM */\
1376 "movq %%mm0, %%mm5 \n\t" /* FGHIJKLM */\
1377 "movq %%mm0, %%mm6 \n\t" /* FGHIJKLM */\
1378 "psrlq $8, %%mm0 \n\t" /* GHIJKLM0 */\
1379 "psrlq $16, %%mm5 \n\t" /* HIJKLM00 */\
1380 "punpcklbw %%mm7, %%mm0 \n\t" /* 0G0H0I0J */\
1381 "punpcklbw %%mm7, %%mm5 \n\t" /* 0H0I0J0K */\
1382 "paddw %%mm0, %%mm2 \n\t" /* b */\
1383 "paddw %%mm5, %%mm3 \n\t" /* c */\
1384 "paddw %%mm2, %%mm2 \n\t" /* 2b */\
1385 "psubw %%mm2, %%mm3 \n\t" /* c - 2b */\
1386 "movq %%mm6, %%mm2 \n\t" /* FGHIJKLM */\
1387 "psrlq $24, %%mm6 \n\t" /* IJKLM000 */\
1388 "punpcklbw %%mm7, %%mm2 \n\t" /* 0F0G0H0I */\
1389 "punpcklbw %%mm7, %%mm6 \n\t" /* 0I0J0K0L */\
c296f66b 1390 "pmullw "MANGLE(ff_pw_3)", %%mm3 \n\t" /* 3c - 6b */\
826f429a
MN
1391 "paddw %%mm2, %%mm1 \n\t" /* a */\
1392 "paddw %%mm6, %%mm4 \n\t" /* d */\
c296f66b 1393 "pmullw "MANGLE(ff_pw_20)", %%mm1 \n\t" /* 20a */\
826f429a 1394 "psubw %%mm4, %%mm3 \n\t" /* - 6b +3c - d */\
c296f66b 1395 "paddw %6, %%mm1 \n\t"\
826f429a
MN
1396 "paddw %%mm1, %%mm3 \n\t" /* 20a - 6b +3c - d */\
1397 "psraw $5, %%mm3 \n\t"\
c296f66b 1398 "movq %5, %%mm1 \n\t"\
826f429a 1399 "packuswb %%mm3, %%mm1 \n\t"\
3178ee4c 1400 OP_MMX2(%%mm1, (%1),%%mm4, q)\
826f429a
MN
1401 /* mm0= GHIJ, mm2=FGHI, mm5=HIJK, mm6=IJKL, mm7=0 */\
1402 \
1403 "movq 9(%0), %%mm1 \n\t" /* JKLMNOPQ */\
1404 "movq %%mm1, %%mm4 \n\t" /* JKLMNOPQ */\
1405 "movq %%mm1, %%mm3 \n\t" /* JKLMNOPQ */\
1406 "psrlq $8, %%mm1 \n\t" /* KLMNOPQ0 */\
1407 "psrlq $16, %%mm4 \n\t" /* LMNOPQ00 */\
1408 "punpcklbw %%mm7, %%mm1 \n\t" /* 0K0L0M0N */\
1409 "punpcklbw %%mm7, %%mm4 \n\t" /* 0L0M0N0O */\
1410 "paddw %%mm1, %%mm5 \n\t" /* b */\
1411 "paddw %%mm4, %%mm0 \n\t" /* c */\
1412 "paddw %%mm5, %%mm5 \n\t" /* 2b */\
1413 "psubw %%mm5, %%mm0 \n\t" /* c - 2b */\
1414 "movq %%mm3, %%mm5 \n\t" /* JKLMNOPQ */\
1415 "psrlq $24, %%mm3 \n\t" /* MNOPQ000 */\
c296f66b 1416 "pmullw "MANGLE(ff_pw_3)", %%mm0 \n\t" /* 3c - 6b */\
826f429a
MN
1417 "punpcklbw %%mm7, %%mm3 \n\t" /* 0M0N0O0P */\
1418 "paddw %%mm3, %%mm2 \n\t" /* d */\
1419 "psubw %%mm2, %%mm0 \n\t" /* -6b + 3c - d */\
1420 "movq %%mm5, %%mm2 \n\t" /* JKLMNOPQ */\
1421 "punpcklbw %%mm7, %%mm2 \n\t" /* 0J0K0L0M */\
1422 "punpckhbw %%mm7, %%mm5 \n\t" /* 0N0O0P0Q */\
1423 "paddw %%mm2, %%mm6 \n\t" /* a */\
c296f66b
MN
1424 "pmullw "MANGLE(ff_pw_20)", %%mm6 \n\t" /* 20a */\
1425 "paddw %6, %%mm0 \n\t"\
826f429a
MN
1426 "paddw %%mm6, %%mm0 \n\t" /* 20a - 6b + 3c - d */\
1427 "psraw $5, %%mm0 \n\t"\
1428 /* mm1=KLMN, mm2=JKLM, mm3=MNOP, mm4=LMNO, mm5=NOPQ mm7=0 */\
1429 \
1430 "paddw %%mm5, %%mm3 \n\t" /* a */\
1431 "pshufw $0xF9, %%mm5, %%mm6 \n\t" /* 0O0P0Q0Q */\
1432 "paddw %%mm4, %%mm6 \n\t" /* b */\
1433 "pshufw $0xBE, %%mm5, %%mm4 \n\t" /* 0P0Q0Q0P */\
1434 "pshufw $0x6F, %%mm5, %%mm5 \n\t" /* 0Q0Q0P0O */\
1435 "paddw %%mm1, %%mm4 \n\t" /* c */\
1436 "paddw %%mm2, %%mm5 \n\t" /* d */\
1437 "paddw %%mm6, %%mm6 \n\t" /* 2b */\
1438 "psubw %%mm6, %%mm4 \n\t" /* c - 2b */\
c296f66b
MN
1439 "pmullw "MANGLE(ff_pw_20)", %%mm3 \n\t" /* 20a */\
1440 "pmullw "MANGLE(ff_pw_3)", %%mm4 \n\t" /* 3c - 6b */\
826f429a 1441 "psubw %%mm5, %%mm3 \n\t" /* -6b + 3c - d */\
c296f66b 1442 "paddw %6, %%mm4 \n\t"\
826f429a
MN
1443 "paddw %%mm3, %%mm4 \n\t" /* 20a - 6b + 3c - d */\
1444 "psraw $5, %%mm4 \n\t"\
1445 "packuswb %%mm4, %%mm0 \n\t"\
3178ee4c 1446 OP_MMX2(%%mm0, 8(%1), %%mm4, q)\
826f429a
MN
1447 \
1448 "addl %3, %0 \n\t"\
1449 "addl %4, %1 \n\t"\
1450 "decl %2 \n\t"\
1451 " jnz 1b \n\t"\
5a508a98 1452 : "+a"(src), "+c"(dst), "+m"(h)\
0b093b6f
MN
1453 : "d"(srcStride), "S"(dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(temp), "m"(ROUNDER)\
1454 : "memory"\
826f429a
MN
1455 );\
1456}\
1457\
1458static void OPNAME ## mpeg4_qpel16_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
1459 int i;\
1460 int16_t temp[16];\
1461 /* quick HACK, XXX FIXME MUST be optimized */\
1462 for(i=0; i<h; i++)\
1463 {\
1464 temp[ 0]= (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]);\
1465 temp[ 1]= (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]);\
1466 temp[ 2]= (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]);\
1467 temp[ 3]= (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]);\
1468 temp[ 4]= (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]);\
1469 temp[ 5]= (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]);\
1470 temp[ 6]= (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]);\
1471 temp[ 7]= (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]);\
1472 temp[ 8]= (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]);\
1473 temp[ 9]= (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]);\
1474 temp[10]= (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]);\
1475 temp[11]= (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]);\
1476 temp[12]= (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]);\
1477 temp[13]= (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]);\
1478 temp[14]= (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]);\
1479 temp[15]= (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]);\
1480 asm volatile(\
1481 "movq (%0), %%mm0 \n\t"\
1482 "movq 8(%0), %%mm1 \n\t"\
1483 "paddw %2, %%mm0 \n\t"\
1484 "paddw %2, %%mm1 \n\t"\
1485 "psraw $5, %%mm0 \n\t"\
1486 "psraw $5, %%mm1 \n\t"\
1487 "packuswb %%mm1, %%mm0 \n\t"\
3178ee4c 1488 OP_3DNOW(%%mm0, (%1), %%mm1, q)\
826f429a
MN
1489 "movq 16(%0), %%mm0 \n\t"\
1490 "movq 24(%0), %%mm1 \n\t"\
1491 "paddw %2, %%mm0 \n\t"\
1492 "paddw %2, %%mm1 \n\t"\
1493 "psraw $5, %%mm0 \n\t"\
1494 "psraw $5, %%mm1 \n\t"\
1495 "packuswb %%mm1, %%mm0 \n\t"\
3178ee4c 1496 OP_3DNOW(%%mm0, 8(%1), %%mm1, q)\
826f429a 1497 :: "r"(temp), "r"(dst), "m"(ROUNDER)\
0b093b6f 1498 : "memory"\
826f429a
MN
1499 );\
1500 dst+=dstStride;\
1501 src+=srcStride;\
1502 }\
1503}\
1504\
5c91a675 1505static void OPNAME ## mpeg4_qpel8_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
826f429a
MN
1506 uint64_t temp;\
1507\
1508 asm volatile(\
1509 "pxor %%mm7, %%mm7 \n\t"\
1510 "1: \n\t"\
1511 "movq (%0), %%mm0 \n\t" /* ABCDEFGH */\
1512 "movq %%mm0, %%mm1 \n\t" /* ABCDEFGH */\
1513 "movq %%mm0, %%mm2 \n\t" /* ABCDEFGH */\
1514 "punpcklbw %%mm7, %%mm0 \n\t" /* 0A0B0C0D */\
1515 "punpckhbw %%mm7, %%mm1 \n\t" /* 0E0F0G0H */\
1516 "pshufw $0x90, %%mm0, %%mm5 \n\t" /* 0A0A0B0C */\
1517 "pshufw $0x41, %%mm0, %%mm6 \n\t" /* 0B0A0A0B */\
1518 "movq %%mm2, %%mm3 \n\t" /* ABCDEFGH */\
1519 "movq %%mm2, %%mm4 \n\t" /* ABCDEFGH */\
1520 "psllq $8, %%mm2 \n\t" /* 0ABCDEFG */\
1521 "psllq $16, %%mm3 \n\t" /* 00ABCDEF */\
1522 "psllq $24, %%mm4 \n\t" /* 000ABCDE */\
1523 "punpckhbw %%mm7, %%mm2 \n\t" /* 0D0E0F0G */\
1524 "punpckhbw %%mm7, %%mm3 \n\t" /* 0C0D0E0F */\
1525 "punpckhbw %%mm7, %%mm4 \n\t" /* 0B0C0D0E */\
1526 "paddw %%mm3, %%mm5 \n\t" /* b */\
1527 "paddw %%mm2, %%mm6 \n\t" /* c */\
1528 "paddw %%mm5, %%mm5 \n\t" /* 2b */\
1529 "psubw %%mm5, %%mm6 \n\t" /* c - 2b */\
1530 "pshufw $0x06, %%mm0, %%mm5 \n\t" /* 0C0B0A0A */\
c296f66b 1531 "pmullw "MANGLE(ff_pw_3)", %%mm6 \n\t" /* 3c - 6b */\
826f429a
MN
1532 "paddw %%mm4, %%mm0 \n\t" /* a */\
1533 "paddw %%mm1, %%mm5 \n\t" /* d */\
c296f66b 1534 "pmullw "MANGLE(ff_pw_20)", %%mm0 \n\t" /* 20a */\
826f429a 1535 "psubw %%mm5, %%mm0 \n\t" /* 20a - d */\
c296f66b 1536 "paddw %6, %%mm6 \n\t"\
826f429a
MN
1537 "paddw %%mm6, %%mm0 \n\t" /* 20a - 6b + 3c - d */\
1538 "psraw $5, %%mm0 \n\t"\
1539 /* mm1=EFGH, mm2=DEFG, mm3=CDEF, mm4=BCDE, mm7=0 */\
1540 \
1541 "movd 5(%0), %%mm5 \n\t" /* FGHI */\
1542 "punpcklbw %%mm7, %%mm5 \n\t" /* 0F0G0H0I */\
1543 "pshufw $0xF9, %%mm5, %%mm6 \n\t" /* 0G0H0I0I */\
1544 "paddw %%mm5, %%mm1 \n\t" /* a */\
1545 "paddw %%mm6, %%mm2 \n\t" /* b */\
1546 "pshufw $0xBE, %%mm5, %%mm6 \n\t" /* 0H0I0I0H */\
1547 "pshufw $0x6F, %%mm5, %%mm5 \n\t" /* 0I0I0H0G */\
1548 "paddw %%mm6, %%mm3 \n\t" /* c */\
1549 "paddw %%mm5, %%mm4 \n\t" /* d */\
1550 "paddw %%mm2, %%mm2 \n\t" /* 2b */\
1551 "psubw %%mm2, %%mm3 \n\t" /* c - 2b */\
c296f66b
MN
1552 "pmullw "MANGLE(ff_pw_20)", %%mm1 \n\t" /* 20a */\
1553 "pmullw "MANGLE(ff_pw_3)", %%mm3 \n\t" /* 3c - 6b */\
826f429a 1554 "psubw %%mm4, %%mm3 \n\t" /* -6b + 3c - d */\
c296f66b 1555 "paddw %6, %%mm1 \n\t"\
826f429a
MN
1556 "paddw %%mm1, %%mm3 \n\t" /* 20a - 6b + 3c - d */\
1557 "psraw $5, %%mm3 \n\t"\
1558 "packuswb %%mm3, %%mm0 \n\t"\
3178ee4c 1559 OP_MMX2(%%mm0, (%1), %%mm4, q)\
826f429a
MN
1560 \
1561 "addl %3, %0 \n\t"\
1562 "addl %4, %1 \n\t"\
1563 "decl %2 \n\t"\
c296f66b 1564 " jnz 1b \n\t"\
5a508a98 1565 : "+a"(src), "+c"(dst), "+m"(h)\
0b093b6f
MN
1566 : "S"(srcStride), "D"(dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(temp), "m"(ROUNDER)\
1567 : "memory"\
826f429a
MN
1568 );\
1569}\
1570\
1571static void OPNAME ## mpeg4_qpel8_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
1572 int i;\
1573 int16_t temp[8];\
1574 /* quick HACK, XXX FIXME MUST be optimized */\
1575 for(i=0; i<h; i++)\
1576 {\
1577 temp[ 0]= (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]);\
1578 temp[ 1]= (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]);\
1579 temp[ 2]= (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]);\
1580 temp[ 3]= (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]);\
1581 temp[ 4]= (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]);\
1582 temp[ 5]= (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 8]);\
1583 temp[ 6]= (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 8])*3 - (src[ 3]+src[ 7]);\
1584 temp[ 7]= (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 8])*6 + (src[ 5]+src[ 7])*3 - (src[ 4]+src[ 6]);\
1585 asm volatile(\
1586 "movq (%0), %%mm0 \n\t"\
1587 "movq 8(%0), %%mm1 \n\t"\
1588 "paddw %2, %%mm0 \n\t"\
1589 "paddw %2, %%mm1 \n\t"\
1590 "psraw $5, %%mm0 \n\t"\
1591 "psraw $5, %%mm1 \n\t"\
1592 "packuswb %%mm1, %%mm0 \n\t"\
3178ee4c 1593 OP_3DNOW(%%mm0, (%1), %%mm1, q)\
826f429a 1594 :: "r"(temp), "r"(dst), "m"(ROUNDER)\
0b093b6f 1595 :"memory"\
826f429a
MN
1596 );\
1597 dst+=dstStride;\
1598 src+=srcStride;\
1599 }\
3178ee4c
MN
1600}
1601
1602#define QPEL_OP(OPNAME, ROUNDER, RND, OP, MMX)\
1603\
1604static void OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1605 uint64_t temp[17*4];\
1606 uint64_t *temp_ptr= temp;\
1607 int count= 17;\
1608\
1609 /*FIXME unroll */\
1610 asm volatile(\
1611 "pxor %%mm7, %%mm7 \n\t"\
1612 "1: \n\t"\
1613 "movq (%0), %%mm0 \n\t"\
1614 "movq (%0), %%mm1 \n\t"\
1615 "movq 8(%0), %%mm2 \n\t"\
1616 "movq 8(%0), %%mm3 \n\t"\
1617 "punpcklbw %%mm7, %%mm0 \n\t"\
1618 "punpckhbw %%mm7, %%mm1 \n\t"\
1619 "punpcklbw %%mm7, %%mm2 \n\t"\
1620 "punpckhbw %%mm7, %%mm3 \n\t"\
1621 "movq %%mm0, (%1) \n\t"\
1622 "movq %%mm1, 17*8(%1) \n\t"\
5a508a98
MN
1623 "movq %%mm2, 2*17*8(%1) \n\t"\
1624 "movq %%mm3, 3*17*8(%1) \n\t"\
3178ee4c
MN
1625 "addl $8, %1 \n\t"\
1626 "addl %3, %0 \n\t"\
1627 "decl %2 \n\t"\
1628 " jnz 1b \n\t"\
1629 : "+r" (src), "+r" (temp_ptr), "+r"(count)\
5a508a98 1630 : "r" (srcStride)\
0b093b6f 1631 : "memory"\
3178ee4c
MN
1632 );\
1633 \
1634 temp_ptr= temp;\
1635 count=4;\
1636 \
1637/*FIXME reorder for speed */\
3178ee4c
MN
1638 asm volatile(\
1639 /*"pxor %%mm7, %%mm7 \n\t"*/\
3178ee4c
MN
1640 "1: \n\t"\
1641 "movq (%0), %%mm0 \n\t"\
1642 "movq 8(%0), %%mm1 \n\t"\
1643 "movq 16(%0), %%mm2 \n\t"\
1644 "movq 24(%0), %%mm3 \n\t"\
c296f66b
MN
1645 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 16(%0), 8(%0), (%0), 32(%0), (%1), OP)\
1646 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 8(%0), (%0), (%0), 40(%0), (%1, %3), OP)\
3178ee4c 1647 "addl %4, %1 \n\t"\
c296f66b 1648 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, (%0), (%0), 8(%0), 48(%0), (%1), OP)\
3178ee4c 1649 \
c296f66b 1650 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, (%0), 8(%0), 16(%0), 56(%0), (%1, %3), OP)\
3178ee4c 1651 "addl %4, %1 \n\t"\
c296f66b
MN
1652 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 8(%0), 16(%0), 24(%0), 64(%0), (%1), OP)\
1653 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 16(%0), 24(%0), 32(%0), 72(%0), (%1, %3), OP)\
3178ee4c 1654 "addl %4, %1 \n\t"\
c296f66b
MN
1655 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 24(%0), 32(%0), 40(%0), 80(%0), (%1), OP)\
1656 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 32(%0), 40(%0), 48(%0), 88(%0), (%1, %3), OP)\
3178ee4c 1657 "addl %4, %1 \n\t"\
c296f66b
MN
1658 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 40(%0), 48(%0), 56(%0), 96(%0), (%1), OP)\
1659 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 48(%0), 56(%0), 64(%0),104(%0), (%1, %3), OP)\
3178ee4c 1660 "addl %4, %1 \n\t"\
c296f66b
MN
1661 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 56(%0), 64(%0), 72(%0),112(%0), (%1), OP)\
1662 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 64(%0), 72(%0), 80(%0),120(%0), (%1, %3), OP)\
3178ee4c 1663 "addl %4, %1 \n\t"\
c296f66b 1664 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 72(%0), 80(%0), 88(%0),128(%0), (%1), OP)\
3178ee4c 1665 \
c296f66b 1666 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 80(%0), 88(%0), 96(%0),128(%0), (%1, %3), OP)\
3178ee4c 1667 "addl %4, %1 \n\t" \
c296f66b
MN
1668 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 88(%0), 96(%0),104(%0),120(%0), (%1), OP)\
1669 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 96(%0),104(%0),112(%0),112(%0), (%1, %3), OP)\
3178ee4c
MN
1670 \
1671 "addl $136, %0 \n\t"\
c296f66b 1672 "addl %6, %1 \n\t"\
3178ee4c
MN
1673 "decl %2 \n\t"\
1674 " jnz 1b \n\t"\
3178ee4c 1675 \
5a508a98 1676 : "+r"(temp_ptr), "+r"(dst), "+g"(count)\
c296f66b 1677 : "r"(dstStride), "r"(2*dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(ROUNDER), "g"(4-14*dstStride)\
0b093b6f 1678 :"memory"\
3178ee4c 1679 );\
826f429a
MN
1680}\
1681\
5c91a675 1682static void OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
826f429a
MN
1683 uint64_t temp[9*4];\
1684 uint64_t *temp_ptr= temp;\
1685 int count= 9;\
1686\
1687 /*FIXME unroll */\
1688 asm volatile(\
1689 "pxor %%mm7, %%mm7 \n\t"\
1690 "1: \n\t"\
1691 "movq (%0), %%mm0 \n\t"\
1692 "movq (%0), %%mm1 \n\t"\
1693 "punpcklbw %%mm7, %%mm0 \n\t"\
1694 "punpckhbw %%mm7, %%mm1 \n\t"\
1695 "movq %%mm0, (%1) \n\t"\
1696 "movq %%mm1, 9*8(%1) \n\t"\
1697 "addl $8, %1 \n\t"\
1698 "addl %3, %0 \n\t"\
1699 "decl %2 \n\t"\
1700 " jnz 1b \n\t"\
1701 : "+r" (src), "+r" (temp_ptr), "+r"(count)\
1702 : "r" (srcStride)\
0b093b6f 1703 : "memory"\
826f429a
MN
1704 );\
1705 \
1706 temp_ptr= temp;\
1707 count=2;\
1708 \
1709/*FIXME reorder for speed */\
1710 asm volatile(\
1711 /*"pxor %%mm7, %%mm7 \n\t"*/\
1712 "1: \n\t"\
1713 "movq (%0), %%mm0 \n\t"\
1714 "movq 8(%0), %%mm1 \n\t"\
1715 "movq 16(%0), %%mm2 \n\t"\
1716 "movq 24(%0), %%mm3 \n\t"\
c296f66b
MN
1717 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 16(%0), 8(%0), (%0), 32(%0), (%1), OP)\
1718 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 8(%0), (%0), (%0), 40(%0), (%1, %3), OP)\
826f429a 1719 "addl %4, %1 \n\t"\
c296f66b 1720 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, (%0), (%0), 8(%0), 48(%0), (%1), OP)\
826f429a 1721 \
c296f66b 1722 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, (%0), 8(%0), 16(%0), 56(%0), (%1, %3), OP)\
826f429a 1723 "addl %4, %1 \n\t"\
c296f66b 1724 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 8(%0), 16(%0), 24(%0), 64(%0), (%1), OP)\
826f429a 1725 \
c296f66b 1726 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 16(%0), 24(%0), 32(%0), 64(%0), (%1, %3), OP)\
826f429a 1727 "addl %4, %1 \n\t"\
c296f66b
MN
1728 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 24(%0), 32(%0), 40(%0), 56(%0), (%1), OP)\
1729 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 32(%0), 40(%0), 48(%0), 48(%0), (%1, %3), OP)\
826f429a
MN
1730 \
1731 "addl $72, %0 \n\t"\
c296f66b 1732 "addl %6, %1 \n\t"\
826f429a
MN
1733 "decl %2 \n\t"\
1734 " jnz 1b \n\t"\
1735 \
c296f66b
MN
1736 : "+r"(temp_ptr), "+r"(dst), "+g"(count)\
1737 : "r"(dstStride), "r"(2*dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(ROUNDER), "g"(4-6*dstStride)\
0b093b6f
MN
1738 : "memory"\
1739 );\
3178ee4c 1740}\
826f429a 1741\
0c1a9eda 1742static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
3178ee4c 1743 OPNAME ## pixels8_mmx(dst, src, stride, 8);\
826f429a
MN
1744}\
1745\
0c1a9eda 1746static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953 1747 uint64_t temp[8];\
826f429a
MN
1748 uint8_t * const half= (uint8_t*)temp;\
1749 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\
1750 OPNAME ## pixels8_l2_mmx(dst, src, half, stride, stride, 8);\
1751}\
1752\
0c1a9eda 1753static void OPNAME ## qpel8_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1754 OPNAME ## mpeg4_qpel8_h_lowpass_ ## MMX(dst, src, stride, stride, 8);\
1755}\
1756\
0c1a9eda 1757static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953 1758 uint64_t temp[8];\
826f429a
MN
1759 uint8_t * const half= (uint8_t*)temp;\
1760 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\
1761 OPNAME ## pixels8_l2_mmx(dst, src+1, half, stride, stride, 8);\
1762}\
1763\
0c1a9eda 1764static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953 1765 uint64_t temp[8];\
826f429a 1766 uint8_t * const half= (uint8_t*)temp;\
3178ee4c 1767 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\
826f429a
MN
1768 OPNAME ## pixels8_l2_mmx(dst, src, half, stride, stride, 8);\
1769}\
1770\
0c1a9eda 1771static void OPNAME ## qpel8_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
3178ee4c 1772 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, src, stride, stride);\
826f429a
MN
1773}\
1774\
0c1a9eda 1775static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953 1776 uint64_t temp[8];\
826f429a 1777 uint8_t * const half= (uint8_t*)temp;\
3178ee4c 1778 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\
826f429a
MN
1779 OPNAME ## pixels8_l2_mmx(dst, src+stride, half, stride, stride, 8);\
1780}\
0c1a9eda 1781static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1782 uint64_t half[8 + 9];\
1783 uint8_t * const halfH= ((uint8_t*)half) + 64;\
1784 uint8_t * const halfHV= ((uint8_t*)half);\
826f429a 1785 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
db794953 1786 put ## RND ## pixels8_l2_mmx(halfH, src, halfH, 8, stride, 9);\
3178ee4c 1787 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
db794953 1788 OPNAME ## pixels8_l2_mmx(dst, halfH, halfHV, stride, 8, 8);\
826f429a 1789}\
0c1a9eda 1790static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1791 uint64_t half[8 + 9];\
1792 uint8_t * const halfH= ((uint8_t*)half) + 64;\
1793 uint8_t * const halfHV= ((uint8_t*)half);\
826f429a 1794 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
db794953 1795 put ## RND ## pixels8_l2_mmx(halfH, src+1, halfH, 8, stride, 9);\
3178ee4c 1796 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
db794953 1797 OPNAME ## pixels8_l2_mmx(dst, halfH, halfHV, stride, 8, 8);\
826f429a 1798}\
0c1a9eda 1799static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1800 uint64_t half[8 + 9];\
1801 uint8_t * const halfH= ((uint8_t*)half) + 64;\
1802 uint8_t * const halfHV= ((uint8_t*)half);\
826f429a 1803 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
db794953 1804 put ## RND ## pixels8_l2_mmx(halfH, src, halfH, 8, stride, 9);\
3178ee4c 1805 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
db794953 1806 OPNAME ## pixels8_l2_mmx(dst, halfH+8, halfHV, stride, 8, 8);\
826f429a 1807}\
0c1a9eda 1808static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1809 uint64_t half[8 + 9];\
1810 uint8_t * const halfH= ((uint8_t*)half) + 64;\
1811 uint8_t * const halfHV= ((uint8_t*)half);\
1812 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
1813 put ## RND ## pixels8_l2_mmx(halfH, src+1, halfH, 8, stride, 9);\
3178ee4c 1814 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
db794953 1815 OPNAME ## pixels8_l2_mmx(dst, halfH+8, halfHV, stride, 8, 8);\
826f429a 1816}\
0c1a9eda 1817static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953 1818 uint64_t half[8 + 9];\
826f429a
MN
1819 uint8_t * const halfH= ((uint8_t*)half) + 64;\
1820 uint8_t * const halfHV= ((uint8_t*)half);\
1821 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
3178ee4c 1822 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
826f429a
MN
1823 OPNAME ## pixels8_l2_mmx(dst, halfH, halfHV, stride, 8, 8);\
1824}\
0c1a9eda 1825static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953 1826 uint64_t half[8 + 9];\
826f429a
MN
1827 uint8_t * const halfH= ((uint8_t*)half) + 64;\
1828 uint8_t * const halfHV= ((uint8_t*)half);\
1829 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
3178ee4c 1830 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
826f429a
MN
1831 OPNAME ## pixels8_l2_mmx(dst, halfH+8, halfHV, stride, 8, 8);\
1832}\
0c1a9eda 1833static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1834 uint64_t half[8 + 9];\
1835 uint8_t * const halfH= ((uint8_t*)half);\
826f429a 1836 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
db794953
MN
1837 put ## RND ## pixels8_l2_mmx(halfH, src, halfH, 8, stride, 9);\
1838 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
826f429a 1839}\
0c1a9eda 1840static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1841 uint64_t half[8 + 9];\
1842 uint8_t * const halfH= ((uint8_t*)half);\
826f429a 1843 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
db794953
MN
1844 put ## RND ## pixels8_l2_mmx(halfH, src+1, halfH, 8, stride, 9);\
1845 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
826f429a 1846}\
0c1a9eda 1847static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953 1848 uint64_t half[9];\
826f429a
MN
1849 uint8_t * const halfH= ((uint8_t*)half);\
1850 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
3178ee4c 1851 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
826f429a 1852}\
0c1a9eda 1853static void OPNAME ## qpel16_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
3178ee4c 1854 OPNAME ## pixels16_mmx(dst, src, stride, 16);\
826f429a
MN
1855}\
1856\
0c1a9eda 1857static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1858 uint64_t temp[32];\
1859 uint8_t * const half= (uint8_t*)temp;\
1860 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\
1861 OPNAME ## pixels16_l2_mmx(dst, src, half, stride, stride, 16);\
1862}\
1863\
0c1a9eda 1864static void OPNAME ## qpel16_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1865 OPNAME ## mpeg4_qpel16_h_lowpass_ ## MMX(dst, src, stride, stride, 16);\
1866}\
1867\
0c1a9eda 1868static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1869 uint64_t temp[32];\
1870 uint8_t * const half= (uint8_t*)temp;\
1871 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\
1872 OPNAME ## pixels16_l2_mmx(dst, src+1, half, stride, stride, 16);\
1873}\
1874\
0c1a9eda 1875static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1876 uint64_t temp[32];\
1877 uint8_t * const half= (uint8_t*)temp;\
3178ee4c 1878 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\
826f429a
MN
1879 OPNAME ## pixels16_l2_mmx(dst, src, half, stride, stride, 16);\
1880}\
1881\
0c1a9eda 1882static void OPNAME ## qpel16_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
3178ee4c 1883 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, src, stride, stride);\
826f429a
MN
1884}\
1885\
0c1a9eda 1886static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1887 uint64_t temp[32];\
1888 uint8_t * const half= (uint8_t*)temp;\
3178ee4c 1889 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\
826f429a
MN
1890 OPNAME ## pixels16_l2_mmx(dst, src+stride, half, stride, stride, 16);\
1891}\
0c1a9eda 1892static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1893 uint64_t half[16*2 + 17*2];\
1894 uint8_t * const halfH= ((uint8_t*)half) + 256;\
1895 uint8_t * const halfHV= ((uint8_t*)half);\
826f429a 1896 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
db794953 1897 put ## RND ## pixels16_l2_mmx(halfH, src, halfH, 16, stride, 17);\
3178ee4c 1898 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
db794953 1899 OPNAME ## pixels16_l2_mmx(dst, halfH, halfHV, stride, 16, 16);\
826f429a 1900}\
0c1a9eda 1901static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1902 uint64_t half[16*2 + 17*2];\
1903 uint8_t * const halfH= ((uint8_t*)half) + 256;\
1904 uint8_t * const halfHV= ((uint8_t*)half);\
826f429a 1905 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
db794953 1906 put ## RND ## pixels16_l2_mmx(halfH, src+1, halfH, 16, stride, 17);\
3178ee4c 1907 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
db794953 1908 OPNAME ## pixels16_l2_mmx(dst, halfH, halfHV, stride, 16, 16);\
826f429a 1909}\
0c1a9eda 1910static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1911 uint64_t half[16*2 + 17*2];\
1912 uint8_t * const halfH= ((uint8_t*)half) + 256;\
1913 uint8_t * const halfHV= ((uint8_t*)half);\
826f429a 1914 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
db794953 1915 put ## RND ## pixels16_l2_mmx(halfH, src, halfH, 16, stride, 17);\
3178ee4c 1916 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
db794953 1917 OPNAME ## pixels16_l2_mmx(dst, halfH+16, halfHV, stride, 16, 16);\
826f429a 1918}\
0c1a9eda 1919static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1920 uint64_t half[16*2 + 17*2];\
1921 uint8_t * const halfH= ((uint8_t*)half) + 256;\
1922 uint8_t * const halfHV= ((uint8_t*)half);\
1923 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
1924 put ## RND ## pixels16_l2_mmx(halfH, src+1, halfH, 16, stride, 17);\
3178ee4c 1925 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
db794953 1926 OPNAME ## pixels16_l2_mmx(dst, halfH+16, halfHV, stride, 16, 16);\
826f429a 1927}\
0c1a9eda 1928static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1929 uint64_t half[16*2 + 17*2];\
1930 uint8_t * const halfH= ((uint8_t*)half) + 256;\
1931 uint8_t * const halfHV= ((uint8_t*)half);\
1932 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
3178ee4c 1933 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
826f429a
MN
1934 OPNAME ## pixels16_l2_mmx(dst, halfH, halfHV, stride, 16, 16);\
1935}\
0c1a9eda 1936static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1937 uint64_t half[16*2 + 17*2];\
1938 uint8_t * const halfH= ((uint8_t*)half) + 256;\
1939 uint8_t * const halfHV= ((uint8_t*)half);\
1940 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
3178ee4c 1941 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
826f429a
MN
1942 OPNAME ## pixels16_l2_mmx(dst, halfH+16, halfHV, stride, 16, 16);\
1943}\
0c1a9eda 1944static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1945 uint64_t half[17*2];\
1946 uint8_t * const halfH= ((uint8_t*)half);\
826f429a 1947 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
db794953
MN
1948 put ## RND ## pixels16_l2_mmx(halfH, src, halfH, 16, stride, 17);\
1949 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
826f429a 1950}\
0c1a9eda 1951static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
db794953
MN
1952 uint64_t half[17*2];\
1953 uint8_t * const halfH= ((uint8_t*)half);\
826f429a 1954 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
db794953
MN
1955 put ## RND ## pixels16_l2_mmx(halfH, src+1, halfH, 16, stride, 17);\
1956 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
826f429a 1957}\
0c1a9eda 1958static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
826f429a
MN
1959 uint64_t half[17*2];\
1960 uint8_t * const halfH= ((uint8_t*)half);\
1961 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
3178ee4c 1962 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
826f429a
MN
1963}
1964
1965
1966#define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t"
3178ee4c 1967#define AVG_3DNOW_OP(a,b,temp, size) \
826f429a
MN
1968"mov" #size " " #b ", " #temp " \n\t"\
1969"pavgusb " #temp ", " #a " \n\t"\
1970"mov" #size " " #a ", " #b " \n\t"
3178ee4c 1971#define AVG_MMX2_OP(a,b,temp, size) \
826f429a
MN
1972"mov" #size " " #b ", " #temp " \n\t"\
1973"pavgb " #temp ", " #a " \n\t"\
1974"mov" #size " " #a ", " #b " \n\t"
3178ee4c
MN
1975
1976QPEL_BASE(put_ , ff_pw_16, _ , PUT_OP, PUT_OP)
1977QPEL_BASE(avg_ , ff_pw_16, _ , AVG_MMX2_OP, AVG_3DNOW_OP)
1978QPEL_BASE(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, PUT_OP)
1979QPEL_OP(put_ , ff_pw_16, _ , PUT_OP, 3dnow)
1980QPEL_OP(avg_ , ff_pw_16, _ , AVG_3DNOW_OP, 3dnow)
1981QPEL_OP(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, 3dnow)
826f429a 1982QPEL_OP(put_ , ff_pw_16, _ , PUT_OP, mmx2)
3178ee4c 1983QPEL_OP(avg_ , ff_pw_16, _ , AVG_MMX2_OP, mmx2)
826f429a
MN
1984QPEL_OP(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, mmx2)
1985
61a4e8ae 1986#if 0
d6a4c0b1 1987static void just_return() { return; }
61a4e8ae 1988#endif
d6a4c0b1 1989
826f429a
MN
1990#define SET_QPEL_FUNC(postfix1, postfix2) \
1991 c->put_ ## postfix1 = put_ ## postfix2;\
1992 c->put_no_rnd_ ## postfix1 = put_no_rnd_ ## postfix2;\
1993 c->avg_ ## postfix1 = avg_ ## postfix2;
b0368839 1994
364a1797
MN
1995static int try_8x8basis_mmx(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
1996 int i=0;
1997
1998 assert(ABS(scale) < 256);
1999 scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT;
2000
2001 asm volatile(
2002 "pcmpeqw %%mm6, %%mm6 \n\t" // -1w
2003 "psrlw $15, %%mm6 \n\t" // 1w
2004 "pxor %%mm7, %%mm7 \n\t"
2005 "movd %4, %%mm5 \n\t"
2006 "punpcklwd %%mm5, %%mm5 \n\t"
2007 "punpcklwd %%mm5, %%mm5 \n\t"
2008 "1: \n\t"
2009 "movq (%1, %0), %%mm0 \n\t"
2010 "movq 8(%1, %0), %%mm1 \n\t"
2011 "pmulhw %%mm5, %%mm0 \n\t"
2012 "pmulhw %%mm5, %%mm1 \n\t"
2013 "paddw %%mm6, %%mm0 \n\t"
2014 "paddw %%mm6, %%mm1 \n\t"
2015 "psraw $1, %%mm0 \n\t"
2016 "psraw $1, %%mm1 \n\t"
2017 "paddw (%2, %0), %%mm0 \n\t"
2018 "paddw 8(%2, %0), %%mm1 \n\t"
2019 "psraw $6, %%mm0 \n\t"
2020 "psraw $6, %%mm1 \n\t"
2021 "pmullw (%3, %0), %%mm0 \n\t"
2022 "pmullw 8(%3, %0), %%mm1 \n\t"
2023 "pmaddwd %%mm0, %%mm0 \n\t"
2024 "pmaddwd %%mm1, %%mm1 \n\t"
2025 "paddd %%mm1, %%mm0 \n\t"
2026 "psrld $4, %%mm0 \n\t"
2027 "paddd %%mm0, %%mm7 \n\t"
2028 "addl $16, %0 \n\t"
2029 "cmpl $128, %0 \n\t" //FIXME optimize & bench
2030 " jb 1b \n\t"
2031 "movq %%mm7, %%mm6 \n\t"
2032 "psrlq $32, %%mm7 \n\t"
2033 "paddd %%mm6, %%mm7 \n\t"
2034 "psrld $2, %%mm7 \n\t"
2035 "movd %%mm7, %0 \n\t"
2036
2037 : "+r" (i)
2038 : "r"(basis), "r"(rem), "r"(weight), "g"(scale)
2039 );
2040 return i;
2041}
2042
2043static void add_8x8basis_mmx(int16_t rem[64], int16_t basis[64], int scale){
2044 int i=0;
2045
2046 if(ABS(scale) < 256){
2047 scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT;
2048 asm volatile(
2049 "pcmpeqw %%mm6, %%mm6 \n\t" // -1w
2050 "psrlw $15, %%mm6 \n\t" // 1w
2051 "movd %3, %%mm5 \n\t"
2052 "punpcklwd %%mm5, %%mm5 \n\t"
2053 "punpcklwd %%mm5, %%mm5 \n\t"
2054 "1: \n\t"
2055 "movq (%1, %0), %%mm0 \n\t"
2056 "movq 8(%1, %0), %%mm1 \n\t"
2057 "pmulhw %%mm5, %%mm0 \n\t"
2058 "pmulhw %%mm5, %%mm1 \n\t"
2059 "paddw %%mm6, %%mm0 \n\t"
2060 "paddw %%mm6, %%mm1 \n\t"
2061 "psraw $1, %%mm0 \n\t"
2062 "psraw $1, %%mm1 \n\t"
2063 "paddw (%2, %0), %%mm0 \n\t"
2064 "paddw 8(%2, %0), %%mm1 \n\t"
2065 "movq %%mm0, (%2, %0) \n\t"
2066 "movq %%mm1, 8(%2, %0) \n\t"
2067 "addl $16, %0 \n\t"
2068 "cmpl $128, %0 \n\t" //FIXME optimize & bench
2069 " jb 1b \n\t"
2070
2071 : "+r" (i)
2072 : "r"(basis), "r"(rem), "g"(scale)
2073 );
2074 }else{
2075 for(i=0; i<8*8; i++){
2076 rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
2077 }
2078 }
2079}
2080
b0368839
MN
2081/* external functions, from idct_mmx.c */
2082void ff_mmx_idct(DCTELEM *block);
2083void ff_mmxext_idct(DCTELEM *block);
2084
2085/* XXX: those functions should be suppressed ASAP when all IDCTs are
2086 converted */
2087static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
2088{
2089 ff_mmx_idct (block);
2090 put_pixels_clamped_mmx(block, dest, line_size);
2091}
2092static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
2093{
2094 ff_mmx_idct (block);
2095 add_pixels_clamped_mmx(block, dest, line_size);
2096}
2097static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
2098{
2099 ff_mmxext_idct (block);
2100 put_pixels_clamped_mmx(block, dest, line_size);
2101}
2102static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
2103{
2104 ff_mmxext_idct (block);
2105 add_pixels_clamped_mmx(block, dest, line_size);
2106}
826f429a 2107
b0368839 2108void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
de6d9b64
FB
2109{
2110 mm_flags = mm_support();
63f60826 2111
e5247b5f
ZK
2112 if (avctx->dsp_mask) {
2113 if (avctx->dsp_mask & FF_MM_FORCE)
2114 mm_flags |= (avctx->dsp_mask & 0xffff);
2115 else
2116 mm_flags &= ~(avctx->dsp_mask & 0xffff);
2117 }
63f60826 2118
1565dabc 2119#if 0
01456e8e 2120 av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:");
de6d9b64 2121 if (mm_flags & MM_MMX)
01456e8e 2122 av_log(avctx, AV_LOG_INFO, " mmx");
de6d9b64 2123 if (mm_flags & MM_MMXEXT)
01456e8e 2124 av_log(avctx, AV_LOG_INFO, " mmxext");
de6d9b64 2125 if (mm_flags & MM_3DNOW)
01456e8e 2126 av_log(avctx, AV_LOG_INFO, " 3dnow");
de6d9b64 2127 if (mm_flags & MM_SSE)
01456e8e 2128 av_log(avctx, AV_LOG_INFO, " sse");
de6d9b64 2129 if (mm_flags & MM_SSE2)
01456e8e
MM
2130 av_log(avctx, AV_LOG_INFO, " sse2");
2131 av_log(avctx, AV_LOG_INFO, "\n");
de6d9b64
FB
2132#endif
2133
2134 if (mm_flags & MM_MMX) {
b0368839
MN
2135 const int idct_algo= avctx->idct_algo;
2136
5fd74135 2137#ifdef CONFIG_ENCODERS
e96682e6 2138 const int dct_algo = avctx->dct_algo;
cf3bf5bb 2139 if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
8fd19ab2
MN
2140 if(mm_flags & MM_SSE2){
2141 c->fdct = ff_fdct_sse2;
2142 }else if(mm_flags & MM_MMXEXT){
cf3bf5bb
MN
2143 c->fdct = ff_fdct_mmx2;
2144 }else{
2145 c->fdct = ff_fdct_mmx;
2146 }
2147 }
5fd74135 2148#endif //CONFIG_ENCODERS
b0368839
MN
2149
2150 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
2151 c->idct_put= ff_simple_idct_put_mmx;
2152 c->idct_add= ff_simple_idct_add_mmx;
4fb518c3 2153 c->idct = ff_simple_idct_mmx;
b0368839
MN
2154 c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
2155 }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
2156 if(mm_flags & MM_MMXEXT){
2157 c->idct_put= ff_libmpeg2mmx2_idct_put;
2158 c->idct_add= ff_libmpeg2mmx2_idct_add;
4fb518c3 2159 c->idct = ff_mmxext_idct;
b0368839
MN
2160 }else{
2161 c->idct_put= ff_libmpeg2mmx_idct_put;
2162 c->idct_add= ff_libmpeg2mmx_idct_add;
4fb518c3 2163 c->idct = ff_mmx_idct;
b0368839
MN
2164 }
2165 c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
2166 }
01456e8e
MM
2167
2168 /* VP3 optimized DSP functions */
38acbc3c
MM
2169 if (mm_flags & MM_SSE2) {
2170 c->vp3_dsp_init = vp3_dsp_init_sse2;
116824d0 2171 c->vp3_idct = vp3_idct_sse2;
38acbc3c
MM
2172 } else {
2173 c->vp3_dsp_init = vp3_dsp_init_mmx;
116824d0 2174 c->vp3_idct = vp3_idct_mmx;
38acbc3c 2175 }
116824d0 2176
764ef400 2177#ifdef CONFIG_ENCODERS
eb4b3dd3
ZK
2178 c->get_pixels = get_pixels_mmx;
2179 c->diff_pixels = diff_pixels_mmx;
764ef400 2180#endif //CONFIG_ENCODERS
eb4b3dd3 2181 c->put_pixels_clamped = put_pixels_clamped_mmx;
f9ed9d85 2182 c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;
eb4b3dd3
ZK
2183 c->add_pixels_clamped = add_pixels_clamped_mmx;
2184 c->clear_blocks = clear_blocks_mmx;
764ef400 2185#ifdef CONFIG_ENCODERS
eb4b3dd3 2186 c->pix_sum = pix_sum16_mmx;
764ef400 2187#endif //CONFIG_ENCODERS
eb4b3dd3 2188
eb4b3dd3
ZK
2189 c->put_pixels_tab[0][0] = put_pixels16_mmx;
2190 c->put_pixels_tab[0][1] = put_pixels16_x2_mmx;
2191 c->put_pixels_tab[0][2] = put_pixels16_y2_mmx;
2192 c->put_pixels_tab[0][3] = put_pixels16_xy2_mmx;
2193
2194 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmx;
2195 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx;
2196 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx;
2197 c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_mmx;
2198
2199 c->avg_pixels_tab[0][0] = avg_pixels16_mmx;
2200 c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx;
2201 c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx;
2202 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx;
2203
2204 c->avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_mmx;
2205 c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_mmx;
2206 c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_mmx;
2207 c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_mmx;
2208
2209 c->put_pixels_tab[1][0] = put_pixels8_mmx;
2210 c->put_pixels_tab[1][1] = put_pixels8_x2_mmx;
2211 c->put_pixels_tab[1][2] = put_pixels8_y2_mmx;
2212 c->put_pixels_tab[1][3] = put_pixels8_xy2_mmx;
2213
2214 c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmx;
2215 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx;
2216 c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx;
2217 c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_mmx;
2218
2219 c->avg_pixels_tab[1][0] = avg_pixels8_mmx;
2220 c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx;
2221 c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx;
2222 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx;
2223
2224 c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_mmx;
2225 c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_mmx;
2226 c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_mmx;
2227 c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_mmx;
826f429a 2228
11f18faf 2229 c->add_bytes= add_bytes_mmx;
764ef400 2230#ifdef CONFIG_ENCODERS
11f18faf 2231 c->diff_bytes= diff_bytes_mmx;
1457ab52
MN
2232
2233 c->hadamard8_diff[0]= hadamard8_diff16_mmx;
2234 c->hadamard8_diff[1]= hadamard8_diff_mmx;
2235
2a006cd3
FL
2236 c->pix_norm1 = pix_norm1_mmx;
2237 c->sse[0] = sse16_mmx;
622348f9
MN
2238 c->vsad[4]= vsad_intra16_mmx;
2239
2240 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
2241 c->vsad[0] = vsad16_mmx;
2242 }
364a1797
MN
2243
2244 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
2245 c->try_8x8basis= try_8x8basis_mmx;
2246 }
2247 c->add_8x8basis= add_8x8basis_mmx;
2248
764ef400 2249#endif //CONFIG_ENCODERS
359f98de
MN
2250
2251 c->h263_v_loop_filter= h263_v_loop_filter_mmx;
364a1797 2252 c->h263_h_loop_filter= h263_h_loop_filter_mmx;
1457ab52 2253
de6d9b64 2254 if (mm_flags & MM_MMXEXT) {
eb4b3dd3
ZK
2255 c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
2256 c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
eb4b3dd3
ZK
2257
2258 c->avg_pixels_tab[0][0] = avg_pixels16_mmx2;
2259 c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
2260 c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
eb4b3dd3
ZK
2261
2262 c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
2263 c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
eb4b3dd3
ZK
2264
2265 c->avg_pixels_tab[1][0] = avg_pixels8_mmx2;
2266 c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
2267 c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
b0368839 2268
764ef400 2269#ifdef CONFIG_ENCODERS
8e0a3db7
MN
2270 c->hadamard8_diff[0]= hadamard8_diff16_mmx2;
2271 c->hadamard8_diff[1]= hadamard8_diff_mmx2;
622348f9 2272 c->vsad[4]= vsad_intra16_mmx2;
764ef400 2273#endif //CONFIG_ENCODERS
8e0a3db7 2274
b0368839
MN
2275 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
2276 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
2277 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
2278 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
2279 c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
2280 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
2281 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
fb85b027 2282#ifdef CONFIG_ENCODERS
622348f9 2283 c->vsad[0] = vsad16_mmx2;
fb85b027 2284#endif //CONFIG_ENCODERS
b0368839 2285 }
3178ee4c 2286
c296f66b 2287#if 1
826f429a
MN
2288 SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_mmx2)
2289 SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_mmx2)
2290 SET_QPEL_FUNC(qpel_pixels_tab[0][ 2], qpel16_mc20_mmx2)
2291 SET_QPEL_FUNC(qpel_pixels_tab[0][ 3], qpel16_mc30_mmx2)
2292 SET_QPEL_FUNC(qpel_pixels_tab[0][ 4], qpel16_mc01_mmx2)
2293 SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_mmx2)
2294 SET_QPEL_FUNC(qpel_pixels_tab[0][ 6], qpel16_mc21_mmx2)
2295 SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_mmx2)
2296 SET_QPEL_FUNC(qpel_pixels_tab[0][ 8], qpel16_mc02_mmx2)
2297 SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_mmx2)
2298 SET_QPEL_FUNC(qpel_pixels_tab[0][10], qpel16_mc22_mmx2)
2299 SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_mmx2)
2300 SET_QPEL_FUNC(qpel_pixels_tab[0][12], qpel16_mc03_mmx2)
2301 SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_mmx2)
2302 SET_QPEL_FUNC(qpel_pixels_tab[0][14], qpel16_mc23_mmx2)
2303 SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_mmx2)
2304 SET_QPEL_FUNC(qpel_pixels_tab[1][ 0], qpel8_mc00_mmx2)
2305 SET_QPEL_FUNC(qpel_pixels_tab[1][ 1], qpel8_mc10_mmx2)
2306 SET_QPEL_FUNC(qpel_pixels_tab[1][ 2], qpel8_mc20_mmx2)
2307 SET_QPEL_FUNC(qpel_pixels_tab[1][ 3], qpel8_mc30_mmx2)
2308 SET_QPEL_FUNC(qpel_pixels_tab[1][ 4], qpel8_mc01_mmx2)
2309 SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_mmx2)
2310 SET_QPEL_FUNC(qpel_pixels_tab[1][ 6], qpel8_mc21_mmx2)
2311 SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_mmx2)
2312 SET_QPEL_FUNC(qpel_pixels_tab[1][ 8], qpel8_mc02_mmx2)
2313 SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_mmx2)
2314 SET_QPEL_FUNC(qpel_pixels_tab[1][10], qpel8_mc22_mmx2)
2315 SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_mmx2)
2316 SET_QPEL_FUNC(qpel_pixels_tab[1][12], qpel8_mc03_mmx2)
2317 SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_mmx2)
2318 SET_QPEL_FUNC(qpel_pixels_tab[1][14], qpel8_mc23_mmx2)
2319 SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_mmx2)
c296f66b 2320#endif
84705403 2321
0c11692a 2322#ifdef CONFIG_ENCODERS
84705403 2323 c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2;
0c11692a 2324#endif //CONFIG_ENCODERS
de6d9b64 2325 } else if (mm_flags & MM_3DNOW) {
eb4b3dd3
ZK
2326 c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
2327 c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
eb4b3dd3
ZK
2328
2329 c->avg_pixels_tab[0][0] = avg_pixels16_3dnow;
2330 c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
2331 c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
eb4b3dd3
ZK
2332
2333 c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
2334 c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
eb4b3dd3
ZK
2335
2336 c->avg_pixels_tab[1][0] = avg_pixels8_3dnow;
2337 c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
2338 c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
b0368839
MN
2339
2340 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
2341 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
2342 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
2343 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
2344 c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
2345 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
2346 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
2347 }
db794953 2348
826f429a
MN
2349 SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_3dnow)
2350 SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_3dnow)
2351 SET_QPEL_FUNC(qpel_pixels_tab[0][ 2], qpel16_mc20_3dnow)
2352 SET_QPEL_FUNC(qpel_pixels_tab[0][ 3], qpel16_mc30_3dnow)
2353 SET_QPEL_FUNC(qpel_pixels_tab[0][ 4], qpel16_mc01_3dnow)
2354 SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_3dnow)
2355 SET_QPEL_FUNC(qpel_pixels_tab[0][ 6], qpel16_mc21_3dnow)
2356 SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_3dnow)
2357 SET_QPEL_FUNC(qpel_pixels_tab[0][ 8], qpel16_mc02_3dnow)
2358 SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_3dnow)
2359 SET_QPEL_FUNC(qpel_pixels_tab[0][10], qpel16_mc22_3dnow)
2360 SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_3dnow)
2361 SET_QPEL_FUNC(qpel_pixels_tab[0][12], qpel16_mc03_3dnow)
2362 SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_3dnow)
2363 SET_QPEL_FUNC(qpel_pixels_tab[0][14], qpel16_mc23_3dnow)
2364 SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_3dnow)
2365 SET_QPEL_FUNC(qpel_pixels_tab[1][ 0], qpel8_mc00_3dnow)
2366 SET_QPEL_FUNC(qpel_pixels_tab[1][ 1], qpel8_mc10_3dnow)
2367 SET_QPEL_FUNC(qpel_pixels_tab[1][ 2], qpel8_mc20_3dnow)
2368 SET_QPEL_FUNC(qpel_pixels_tab[1][ 3], qpel8_mc30_3dnow)
2369 SET_QPEL_FUNC(qpel_pixels_tab[1][ 4], qpel8_mc01_3dnow)
2370 SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_3dnow)
2371 SET_QPEL_FUNC(qpel_pixels_tab[1][ 6], qpel8_mc21_3dnow)
2372 SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_3dnow)
2373 SET_QPEL_FUNC(qpel_pixels_tab[1][ 8], qpel8_mc02_3dnow)
2374 SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_3dnow)
2375 SET_QPEL_FUNC(qpel_pixels_tab[1][10], qpel8_mc22_3dnow)
2376 SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_3dnow)
2377 SET_QPEL_FUNC(qpel_pixels_tab[1][12], qpel8_mc03_3dnow)
2378 SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_3dnow)
2379 SET_QPEL_FUNC(qpel_pixels_tab[1][14], qpel8_mc23_3dnow)
2380 SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_3dnow)
de6d9b64
FB
2381 }
2382 }
b0368839 2383
764ef400 2384#ifdef CONFIG_ENCODERS
b0368839 2385 dsputil_init_pix_mmx(c, avctx);
764ef400 2386#endif //CONFIG_ENCODERS
d6a4c0b1
ZK
2387#if 0
2388 // for speed testing
2389 get_pixels = just_return;
2390 put_pixels_clamped = just_return;
2391 add_pixels_clamped = just_return;
2392
2393 pix_abs16x16 = just_return;
2394 pix_abs16x16_x2 = just_return;
2395 pix_abs16x16_y2 = just_return;
2396 pix_abs16x16_xy2 = just_return;
2397
2398 put_pixels_tab[0] = just_return;
2399 put_pixels_tab[1] = just_return;
2400 put_pixels_tab[2] = just_return;
2401 put_pixels_tab[3] = just_return;
2402
2403 put_no_rnd_pixels_tab[0] = just_return;
2404 put_no_rnd_pixels_tab[1] = just_return;
2405 put_no_rnd_pixels_tab[2] = just_return;
2406 put_no_rnd_pixels_tab[3] = just_return;
2407
2408 avg_pixels_tab[0] = just_return;
2409 avg_pixels_tab[1] = just_return;
2410 avg_pixels_tab[2] = just_return;
2411 avg_pixels_tab[3] = just_return;
2412
2413 avg_no_rnd_pixels_tab[0] = just_return;
2414 avg_no_rnd_pixels_tab[1] = just_return;
2415 avg_no_rnd_pixels_tab[2] = just_return;
2416 avg_no_rnd_pixels_tab[3] = just_return;
2417
d6a4c0b1
ZK
2418 //av_fdct = just_return;
2419 //ff_idct = just_return;
2420#endif
de6d9b64 2421}