2 * SIMD-optimized motion estimation
3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
8 * This file is part of FFmpeg.
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * FFmpeg is distributed in the hope that it will be useful,
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.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "libavutil/attributes.h"
26 #include "libavutil/cpu.h"
27 #include "libavutil/x86/asm.h"
28 #include "libavutil/x86/cpu.h"
29 #include "libavcodec/me_cmp.h"
30 #include "libavcodec/mpegvideo.h"
32 int ff_sum_abs_dctelem_mmx(int16_t *block);
33 int ff_sum_abs_dctelem_mmxext(int16_t *block);
34 int ff_sum_abs_dctelem_sse2(int16_t *block);
35 int ff_sum_abs_dctelem_ssse3(int16_t *block);
36 int ff_sse8_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
37 int line_size, int h);
38 int ff_sse16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
39 int line_size, int h);
40 int ff_sse16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
41 int line_size, int h);
42 int ff_hf_noise8_mmx(uint8_t *pix1, int lsize, int h);
43 int ff_hf_noise16_mmx(uint8_t *pix1, int lsize, int h);
44 int ff_sad8_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
46 int ff_sad16_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
48 int ff_sad16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
50 int ff_sad8_x2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
52 int ff_sad16_x2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
54 int ff_sad16_x2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
56 int ff_sad8_y2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
58 int ff_sad16_y2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
60 int ff_sad16_y2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
62 int ff_sad8_approx_xy2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
64 int ff_sad16_approx_xy2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
66 int ff_sad16_approx_xy2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
68 int ff_vsad_intra8_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
69 int line_size, int h);
70 int ff_vsad_intra16_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
71 int line_size, int h);
72 int ff_vsad_intra16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
73 int line_size, int h);
74 int ff_vsad8_approx_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
75 int line_size, int h);
76 int ff_vsad16_approx_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
77 int line_size, int h);
78 int ff_vsad16_approx_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
79 int line_size, int h);
81 #define hadamard_func(cpu) \
82 int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1, \
83 uint8_t *src2, int stride, int h); \
84 int ff_hadamard8_diff16_ ## cpu(MpegEncContext *s, uint8_t *src1, \
85 uint8_t *src2, int stride, int h);
93 static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2,
99 score1 = c->mecc.sse[0](c, pix1, pix2, line_size, h);
101 score1 = ff_sse16_mmx(c, pix1, pix2, line_size, h);
102 score2 = ff_hf_noise16_mmx(pix1, line_size, h) + ff_hf_noise8_mmx(pix1+8, line_size, h)
103 - ff_hf_noise16_mmx(pix2, line_size, h) - ff_hf_noise8_mmx(pix2+8, line_size, h);
106 return score1 + FFABS(score2) * c->avctx->nsse_weight;
108 return score1 + FFABS(score2) * 8;
111 static int nsse8_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2,
112 int line_size, int h)
114 int score1 = ff_sse8_mmx(c, pix1, pix2, line_size, h);
115 int score2 = ff_hf_noise8_mmx(pix1, line_size, h) -
116 ff_hf_noise8_mmx(pix2, line_size, h);
119 return score1 + FFABS(score2) * c->avctx->nsse_weight;
121 return score1 + FFABS(score2) * 8;
124 #endif /* HAVE_YASM */
128 static int vsad_intra16_mmx(MpegEncContext *v, uint8_t *pix, uint8_t *dummy,
129 int line_size, int h)
133 av_assert2((((int) pix) & 7) == 0);
134 av_assert2((line_size & 7) == 0);
136 #define SUM(in0, in1, out0, out1) \
137 "movq (%0), %%mm2\n" \
138 "movq 8(%0), %%mm3\n" \
140 "movq %%mm2, " #out0 "\n" \
141 "movq %%mm3, " #out1 "\n" \
142 "psubusb " #in0 ", %%mm2\n" \
143 "psubusb " #in1 ", %%mm3\n" \
144 "psubusb " #out0 ", " #in0 "\n" \
145 "psubusb " #out1 ", " #in1 "\n" \
146 "por %%mm2, " #in0 "\n" \
147 "por %%mm3, " #in1 "\n" \
148 "movq " #in0 ", %%mm2\n" \
149 "movq " #in1 ", %%mm3\n" \
150 "punpcklbw %%mm7, " #in0 "\n" \
151 "punpcklbw %%mm7, " #in1 "\n" \
152 "punpckhbw %%mm7, %%mm2\n" \
153 "punpckhbw %%mm7, %%mm3\n" \
154 "paddw " #in1 ", " #in0 "\n" \
155 "paddw %%mm3, %%mm2\n" \
156 "paddw %%mm2, " #in0 "\n" \
157 "paddw " #in0 ", %%mm6\n"
162 "pxor %%mm6, %%mm6\n"
163 "pxor %%mm7, %%mm7\n"
165 "movq 8(%0), %%mm1\n"
170 SUM(%%mm4, %%mm5, %%mm0, %%mm1)
172 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
177 "movq %%mm6, %%mm0\n"
179 "paddw %%mm6, %%mm0\n"
180 "movq %%mm0, %%mm6\n"
182 "paddw %%mm6, %%mm0\n"
184 : "+r" (pix), "=r" (tmp)
185 : "r" ((x86_reg) line_size), "m" (h)
192 static int vsad16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
193 int line_size, int h)
197 av_assert2((((int) pix1) & 7) == 0);
198 av_assert2((((int) pix2) & 7) == 0);
199 av_assert2((line_size & 7) == 0);
201 #define SUM(in0, in1, out0, out1) \
202 "movq (%0), %%mm2\n" \
203 "movq (%1), " #out0 "\n" \
204 "movq 8(%0), %%mm3\n" \
205 "movq 8(%1), " #out1 "\n" \
208 "psubb " #out0 ", %%mm2\n" \
209 "psubb " #out1 ", %%mm3\n" \
210 "pxor %%mm7, %%mm2\n" \
211 "pxor %%mm7, %%mm3\n" \
212 "movq %%mm2, " #out0 "\n" \
213 "movq %%mm3, " #out1 "\n" \
214 "psubusb " #in0 ", %%mm2\n" \
215 "psubusb " #in1 ", %%mm3\n" \
216 "psubusb " #out0 ", " #in0 "\n" \
217 "psubusb " #out1 ", " #in1 "\n" \
218 "por %%mm2, " #in0 "\n" \
219 "por %%mm3, " #in1 "\n" \
220 "movq " #in0 ", %%mm2\n" \
221 "movq " #in1 ", %%mm3\n" \
222 "punpcklbw %%mm7, " #in0 "\n" \
223 "punpcklbw %%mm7, " #in1 "\n" \
224 "punpckhbw %%mm7, %%mm2\n" \
225 "punpckhbw %%mm7, %%mm3\n" \
226 "paddw " #in1 ", " #in0 "\n" \
227 "paddw %%mm3, %%mm2\n" \
228 "paddw %%mm2, " #in0 "\n" \
229 "paddw " #in0 ", %%mm6\n"
234 "pxor %%mm6, %%mm6\n"
235 "pcmpeqw %%mm7, %%mm7\n"
237 "packsswb %%mm7, %%mm7\n"
240 "movq 8(%0), %%mm1\n"
241 "movq 8(%1), %%mm3\n"
244 "psubb %%mm2, %%mm0\n"
245 "psubb %%mm3, %%mm1\n"
246 "pxor %%mm7, %%mm0\n"
247 "pxor %%mm7, %%mm1\n"
251 SUM(%%mm4, %%mm5, %%mm0, %%mm1)
253 SUM(%%mm0, %%mm1, %%mm4, %%mm5)
258 "movq %%mm6, %%mm0\n"
260 "paddw %%mm6, %%mm0\n"
261 "movq %%mm0, %%mm6\n"
263 "paddw %%mm6, %%mm0\n"
265 : "+r" (pix1), "+r" (pix2), "=r" (tmp)
266 : "r" ((x86_reg) line_size), "m" (h)
273 DECLARE_ASM_CONST(8, uint64_t, round_tab)[3] = {
274 0x0000000000000000ULL,
275 0x0001000100010001ULL,
276 0x0002000200020002ULL,
279 static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
281 x86_reg len = -(x86_reg)stride * h;
285 "movq (%1, %%"REG_a"), %%mm0 \n\t"
286 "movq (%2, %%"REG_a"), %%mm2 \n\t"
287 "movq (%2, %%"REG_a"), %%mm4 \n\t"
288 "add %3, %%"REG_a" \n\t"
289 "psubusb %%mm0, %%mm2 \n\t"
290 "psubusb %%mm4, %%mm0 \n\t"
291 "movq (%1, %%"REG_a"), %%mm1 \n\t"
292 "movq (%2, %%"REG_a"), %%mm3 \n\t"
293 "movq (%2, %%"REG_a"), %%mm5 \n\t"
294 "psubusb %%mm1, %%mm3 \n\t"
295 "psubusb %%mm5, %%mm1 \n\t"
296 "por %%mm2, %%mm0 \n\t"
297 "por %%mm1, %%mm3 \n\t"
298 "movq %%mm0, %%mm1 \n\t"
299 "movq %%mm3, %%mm2 \n\t"
300 "punpcklbw %%mm7, %%mm0 \n\t"
301 "punpckhbw %%mm7, %%mm1 \n\t"
302 "punpcklbw %%mm7, %%mm3 \n\t"
303 "punpckhbw %%mm7, %%mm2 \n\t"
304 "paddw %%mm1, %%mm0 \n\t"
305 "paddw %%mm3, %%mm2 \n\t"
306 "paddw %%mm2, %%mm0 \n\t"
307 "paddw %%mm0, %%mm6 \n\t"
308 "add %3, %%"REG_a" \n\t"
311 : "r" (blk1 - len), "r" (blk2 - len), "r" ((x86_reg) stride));
314 static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2,
317 x86_reg len = -(x86_reg)stride * h;
321 "movq (%1, %%"REG_a"), %%mm0 \n\t"
322 "movq (%2, %%"REG_a"), %%mm1 \n\t"
323 "movq (%1, %%"REG_a"), %%mm2 \n\t"
324 "movq (%2, %%"REG_a"), %%mm3 \n\t"
325 "punpcklbw %%mm7, %%mm0 \n\t"
326 "punpcklbw %%mm7, %%mm1 \n\t"
327 "punpckhbw %%mm7, %%mm2 \n\t"
328 "punpckhbw %%mm7, %%mm3 \n\t"
329 "paddw %%mm0, %%mm1 \n\t"
330 "paddw %%mm2, %%mm3 \n\t"
331 "movq (%3, %%"REG_a"), %%mm4 \n\t"
332 "movq (%3, %%"REG_a"), %%mm2 \n\t"
333 "paddw %%mm5, %%mm1 \n\t"
334 "paddw %%mm5, %%mm3 \n\t"
335 "psrlw $1, %%mm1 \n\t"
336 "psrlw $1, %%mm3 \n\t"
337 "packuswb %%mm3, %%mm1 \n\t"
338 "psubusb %%mm1, %%mm4 \n\t"
339 "psubusb %%mm2, %%mm1 \n\t"
340 "por %%mm4, %%mm1 \n\t"
341 "movq %%mm1, %%mm0 \n\t"
342 "punpcklbw %%mm7, %%mm0 \n\t"
343 "punpckhbw %%mm7, %%mm1 \n\t"
344 "paddw %%mm1, %%mm0 \n\t"
345 "paddw %%mm0, %%mm6 \n\t"
346 "add %4, %%"REG_a" \n\t"
349 : "r" (blk1a - len), "r" (blk1b - len), "r" (blk2 - len),
350 "r" ((x86_reg) stride));
353 static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
355 x86_reg len = -(x86_reg)stride * h;
357 "movq (%1, %%"REG_a"), %%mm0 \n\t"
358 "movq 1(%1, %%"REG_a"), %%mm2 \n\t"
359 "movq %%mm0, %%mm1 \n\t"
360 "movq %%mm2, %%mm3 \n\t"
361 "punpcklbw %%mm7, %%mm0 \n\t"
362 "punpckhbw %%mm7, %%mm1 \n\t"
363 "punpcklbw %%mm7, %%mm2 \n\t"
364 "punpckhbw %%mm7, %%mm3 \n\t"
365 "paddw %%mm2, %%mm0 \n\t"
366 "paddw %%mm3, %%mm1 \n\t"
369 "movq (%2, %%"REG_a"), %%mm2 \n\t"
370 "movq 1(%2, %%"REG_a"), %%mm4 \n\t"
371 "movq %%mm2, %%mm3 \n\t"
372 "movq %%mm4, %%mm5 \n\t"
373 "punpcklbw %%mm7, %%mm2 \n\t"
374 "punpckhbw %%mm7, %%mm3 \n\t"
375 "punpcklbw %%mm7, %%mm4 \n\t"
376 "punpckhbw %%mm7, %%mm5 \n\t"
377 "paddw %%mm4, %%mm2 \n\t"
378 "paddw %%mm5, %%mm3 \n\t"
379 "movq %5, %%mm5 \n\t"
380 "paddw %%mm2, %%mm0 \n\t"
381 "paddw %%mm3, %%mm1 \n\t"
382 "paddw %%mm5, %%mm0 \n\t"
383 "paddw %%mm5, %%mm1 \n\t"
384 "movq (%3, %%"REG_a"), %%mm4 \n\t"
385 "movq (%3, %%"REG_a"), %%mm5 \n\t"
386 "psrlw $2, %%mm0 \n\t"
387 "psrlw $2, %%mm1 \n\t"
388 "packuswb %%mm1, %%mm0 \n\t"
389 "psubusb %%mm0, %%mm4 \n\t"
390 "psubusb %%mm5, %%mm0 \n\t"
391 "por %%mm4, %%mm0 \n\t"
392 "movq %%mm0, %%mm4 \n\t"
393 "punpcklbw %%mm7, %%mm0 \n\t"
394 "punpckhbw %%mm7, %%mm4 \n\t"
395 "paddw %%mm0, %%mm6 \n\t"
396 "paddw %%mm4, %%mm6 \n\t"
397 "movq %%mm2, %%mm0 \n\t"
398 "movq %%mm3, %%mm1 \n\t"
399 "add %4, %%"REG_a" \n\t"
402 : "r" (blk1 - len), "r" (blk1 - len + stride), "r" (blk2 - len),
403 "r" ((x86_reg) stride), "m" (round_tab[2]));
406 static inline int sum_mmx(void)
410 "movq %%mm6, %%mm0 \n\t"
411 "psrlq $32, %%mm6 \n\t"
412 "paddw %%mm0, %%mm6 \n\t"
413 "movq %%mm6, %%mm0 \n\t"
414 "psrlq $16, %%mm6 \n\t"
415 "paddw %%mm0, %%mm6 \n\t"
416 "movd %%mm6, %0 \n\t"
421 static inline void sad8_x2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
423 sad8_2_mmx(blk1, blk1 + 1, blk2, stride, h);
426 static inline void sad8_y2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
428 sad8_2_mmx(blk1, blk1 + stride, blk2, stride, h);
431 #define PIX_SAD(suf) \
432 static int sad8_ ## suf(MpegEncContext *v, uint8_t *blk2, \
433 uint8_t *blk1, int stride, int h) \
435 av_assert2(h == 8); \
437 "pxor %%mm7, %%mm7 \n\t" \
438 "pxor %%mm6, %%mm6 \n\t" \
441 sad8_1_ ## suf(blk1, blk2, stride, 8); \
443 return sum_ ## suf(); \
446 static int sad8_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
447 uint8_t *blk1, int stride, int h) \
449 av_assert2(h == 8); \
451 "pxor %%mm7, %%mm7 \n\t" \
452 "pxor %%mm6, %%mm6 \n\t" \
453 "movq %0, %%mm5 \n\t" \
454 :: "m" (round_tab[1])); \
456 sad8_x2a_ ## suf(blk1, blk2, stride, 8); \
458 return sum_ ## suf(); \
461 static int sad8_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
462 uint8_t *blk1, int stride, int h) \
464 av_assert2(h == 8); \
466 "pxor %%mm7, %%mm7 \n\t" \
467 "pxor %%mm6, %%mm6 \n\t" \
468 "movq %0, %%mm5 \n\t" \
469 :: "m" (round_tab[1])); \
471 sad8_y2a_ ## suf(blk1, blk2, stride, 8); \
473 return sum_ ## suf(); \
476 static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
477 uint8_t *blk1, int stride, int h) \
479 av_assert2(h == 8); \
481 "pxor %%mm7, %%mm7 \n\t" \
482 "pxor %%mm6, %%mm6 \n\t" \
485 sad8_4_ ## suf(blk1, blk2, stride, 8); \
487 return sum_ ## suf(); \
490 static int sad16_ ## suf(MpegEncContext *v, uint8_t *blk2, \
491 uint8_t *blk1, int stride, int h) \
494 "pxor %%mm7, %%mm7 \n\t" \
495 "pxor %%mm6, %%mm6 \n\t" \
498 sad8_1_ ## suf(blk1, blk2, stride, h); \
499 sad8_1_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
501 return sum_ ## suf(); \
504 static int sad16_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
505 uint8_t *blk1, int stride, int h) \
508 "pxor %%mm7, %%mm7 \n\t" \
509 "pxor %%mm6, %%mm6 \n\t" \
510 "movq %0, %%mm5 \n\t" \
511 :: "m" (round_tab[1])); \
513 sad8_x2a_ ## suf(blk1, blk2, stride, h); \
514 sad8_x2a_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
516 return sum_ ## suf(); \
519 static int sad16_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
520 uint8_t *blk1, int stride, int h) \
523 "pxor %%mm7, %%mm7 \n\t" \
524 "pxor %%mm6, %%mm6 \n\t" \
525 "movq %0, %%mm5 \n\t" \
526 :: "m" (round_tab[1])); \
528 sad8_y2a_ ## suf(blk1, blk2, stride, h); \
529 sad8_y2a_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
531 return sum_ ## suf(); \
534 static int sad16_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
535 uint8_t *blk1, int stride, int h) \
538 "pxor %%mm7, %%mm7 \n\t" \
539 "pxor %%mm6, %%mm6 \n\t" \
542 sad8_4_ ## suf(blk1, blk2, stride, h); \
543 sad8_4_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
545 return sum_ ## suf(); \
550 #endif /* HAVE_INLINE_ASM */
552 av_cold void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx)
554 int cpu_flags = av_get_cpu_flags();
557 if (INLINE_MMX(cpu_flags)) {
558 c->pix_abs[0][0] = sad16_mmx;
559 c->pix_abs[0][1] = sad16_x2_mmx;
560 c->pix_abs[0][2] = sad16_y2_mmx;
561 c->pix_abs[0][3] = sad16_xy2_mmx;
562 c->pix_abs[1][0] = sad8_mmx;
563 c->pix_abs[1][1] = sad8_x2_mmx;
564 c->pix_abs[1][2] = sad8_y2_mmx;
565 c->pix_abs[1][3] = sad8_xy2_mmx;
567 c->sad[0] = sad16_mmx;
568 c->sad[1] = sad8_mmx;
570 c->vsad[4] = vsad_intra16_mmx;
572 if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
573 c->vsad[0] = vsad16_mmx;
577 #endif /* HAVE_INLINE_ASM */
579 if (EXTERNAL_MMX(cpu_flags)) {
580 c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;
581 c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;
582 c->sum_abs_dctelem = ff_sum_abs_dctelem_mmx;
583 c->sse[0] = ff_sse16_mmx;
584 c->sse[1] = ff_sse8_mmx;
586 c->nsse[0] = nsse16_mmx;
587 c->nsse[1] = nsse8_mmx;
591 if (EXTERNAL_MMXEXT(cpu_flags)) {
592 c->hadamard8_diff[0] = ff_hadamard8_diff16_mmxext;
593 c->hadamard8_diff[1] = ff_hadamard8_diff_mmxext;
594 c->sum_abs_dctelem = ff_sum_abs_dctelem_mmxext;
596 c->sad[0] = ff_sad16_mmxext;
597 c->sad[1] = ff_sad8_mmxext;
599 c->pix_abs[0][0] = ff_sad16_mmxext;
600 c->pix_abs[0][1] = ff_sad16_x2_mmxext;
601 c->pix_abs[0][2] = ff_sad16_y2_mmxext;
602 c->pix_abs[1][0] = ff_sad8_mmxext;
603 c->pix_abs[1][1] = ff_sad8_x2_mmxext;
604 c->pix_abs[1][2] = ff_sad8_y2_mmxext;
606 c->vsad[4] = ff_vsad_intra16_mmxext;
607 c->vsad[5] = ff_vsad_intra8_mmxext;
609 if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
610 c->pix_abs[0][3] = ff_sad16_approx_xy2_mmxext;
611 c->pix_abs[1][3] = ff_sad8_approx_xy2_mmxext;
613 c->vsad[0] = ff_vsad16_approx_mmxext;
614 c->vsad[1] = ff_vsad8_approx_mmxext;
618 if (EXTERNAL_SSE2(cpu_flags)) {
619 c->sse[0] = ff_sse16_sse2;
620 c->sum_abs_dctelem = ff_sum_abs_dctelem_sse2;
622 #if HAVE_ALIGNED_STACK
623 c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;
624 c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;
626 if (!(cpu_flags & AV_CPU_FLAG_SSE2SLOW) && avctx->codec_id != AV_CODEC_ID_SNOW) {
627 c->sad[0] = ff_sad16_sse2;
628 c->pix_abs[0][0] = ff_sad16_sse2;
629 c->pix_abs[0][1] = ff_sad16_x2_sse2;
630 c->pix_abs[0][2] = ff_sad16_y2_sse2;
632 c->vsad[4] = ff_vsad_intra16_sse2;
633 if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
634 c->pix_abs[0][3] = ff_sad16_approx_xy2_sse2;
635 c->vsad[0] = ff_vsad16_approx_sse2;
640 if (EXTERNAL_SSSE3(cpu_flags)) {
641 c->sum_abs_dctelem = ff_sum_abs_dctelem_ssse3;
642 #if HAVE_ALIGNED_STACK
643 c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;
644 c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;