2 * This file is part of Libav.
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "libavutil/attributes.h"
21 #include "libavutil/cpu.h"
22 #include "libavutil/x86/asm.h"
23 #include "libavutil/x86/cpu.h"
24 #include "libavcodec/dsputil.h"
25 #include "libavcodec/simple_idct.h"
26 #include "dsputil_x86.h"
27 #include "idct_xvid.h"
29 void ff_put_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
30 int dstStride, int src1Stride, int h);
31 void ff_put_no_rnd_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1,
32 uint8_t *src2, int dstStride,
33 int src1Stride, int h);
34 void ff_avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
35 int dstStride, int src1Stride, int h);
36 void ff_put_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
37 int dstStride, int src1Stride, int h);
38 void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
39 int dstStride, int src1Stride, int h);
40 void ff_put_no_rnd_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
41 int dstStride, int src1Stride, int h);
42 void ff_put_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
43 int dstStride, int srcStride, int h);
44 void ff_avg_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
45 int dstStride, int srcStride, int h);
46 void ff_put_no_rnd_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
47 int dstStride, int srcStride,
49 void ff_put_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
50 int dstStride, int srcStride, int h);
51 void ff_avg_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
52 int dstStride, int srcStride, int h);
53 void ff_put_no_rnd_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
54 int dstStride, int srcStride,
56 void ff_put_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
57 int dstStride, int srcStride);
58 void ff_avg_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
59 int dstStride, int srcStride);
60 void ff_put_no_rnd_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
61 int dstStride, int srcStride);
62 void ff_put_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
63 int dstStride, int srcStride);
64 void ff_avg_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
65 int dstStride, int srcStride);
66 void ff_put_no_rnd_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
67 int dstStride, int srcStride);
68 #define ff_put_no_rnd_pixels16_mmxext ff_put_pixels16_mmxext
69 #define ff_put_no_rnd_pixels8_mmxext ff_put_pixels8_mmxext
71 void ff_h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale);
72 void ff_h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale);
74 int32_t ff_scalarproduct_int16_mmxext(const int16_t *v1, const int16_t *v2,
76 int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2,
78 int32_t ff_scalarproduct_and_madd_int16_mmxext(int16_t *v1, const int16_t *v2,
81 int32_t ff_scalarproduct_and_madd_int16_sse2(int16_t *v1, const int16_t *v2,
84 int32_t ff_scalarproduct_and_madd_int16_ssse3(int16_t *v1, const int16_t *v2,
88 void ff_apply_window_int16_round_mmxext(int16_t *output, const int16_t *input,
89 const int16_t *window, unsigned int len);
90 void ff_apply_window_int16_round_sse2(int16_t *output, const int16_t *input,
91 const int16_t *window, unsigned int len);
92 void ff_apply_window_int16_mmxext(int16_t *output, const int16_t *input,
93 const int16_t *window, unsigned int len);
94 void ff_apply_window_int16_sse2(int16_t *output, const int16_t *input,
95 const int16_t *window, unsigned int len);
96 void ff_apply_window_int16_ssse3(int16_t *output, const int16_t *input,
97 const int16_t *window, unsigned int len);
98 void ff_apply_window_int16_ssse3_atom(int16_t *output, const int16_t *input,
99 const int16_t *window, unsigned int len);
101 void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w);
102 void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
104 void ff_add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top,
105 const uint8_t *diff, int w,
106 int *left, int *left_top);
107 int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src,
109 int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src,
112 void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src,
113 int32_t min, int32_t max, unsigned int len);
114 void ff_vector_clip_int32_sse2 (int32_t *dst, const int32_t *src,
115 int32_t min, int32_t max, unsigned int len);
116 void ff_vector_clip_int32_int_sse2(int32_t *dst, const int32_t *src,
117 int32_t min, int32_t max, unsigned int len);
118 void ff_vector_clip_int32_sse4 (int32_t *dst, const int32_t *src,
119 int32_t min, int32_t max, unsigned int len);
123 PIXELS16(static, ff_avg, , , _mmxext)
124 PIXELS16(static, ff_put, , , _mmxext)
126 #define QPEL_OP(OPNAME, RND, MMX) \
127 static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src, \
130 ff_ ## OPNAME ## pixels8_ ## MMX(dst, src, stride, 8); \
133 static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src, \
137 uint8_t * const half = (uint8_t*)temp; \
138 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, \
140 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half, \
141 stride, stride, 8); \
144 static void OPNAME ## qpel8_mc20_ ## MMX(uint8_t *dst, uint8_t *src, \
147 ff_ ## OPNAME ## mpeg4_qpel8_h_lowpass_ ## MMX(dst, src, stride, \
151 static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src, \
155 uint8_t * const half = (uint8_t*)temp; \
156 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, \
158 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + 1, half, stride, \
162 static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src, \
166 uint8_t * const half = (uint8_t*)temp; \
167 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, \
169 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half, \
170 stride, stride, 8); \
173 static void OPNAME ## qpel8_mc02_ ## MMX(uint8_t *dst, uint8_t *src, \
176 ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, src, \
180 static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src, \
184 uint8_t * const half = (uint8_t*)temp; \
185 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, \
187 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + stride, half, stride,\
191 static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src, \
194 uint64_t half[8 + 9]; \
195 uint8_t * const halfH = ((uint8_t*)half) + 64; \
196 uint8_t * const halfHV = ((uint8_t*)half); \
197 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
199 ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, \
201 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
202 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, \
206 static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src, \
209 uint64_t half[8 + 9]; \
210 uint8_t * const halfH = ((uint8_t*)half) + 64; \
211 uint8_t * const halfHV = ((uint8_t*)half); \
212 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
214 ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8, \
216 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
217 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, \
221 static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src, \
224 uint64_t half[8 + 9]; \
225 uint8_t * const halfH = ((uint8_t*)half) + 64; \
226 uint8_t * const halfHV = ((uint8_t*)half); \
227 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
229 ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, \
231 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
232 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV, \
236 static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src, \
239 uint64_t half[8 + 9]; \
240 uint8_t * const halfH = ((uint8_t*)half) + 64; \
241 uint8_t * const halfHV = ((uint8_t*)half); \
242 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
244 ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8, \
246 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
247 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV, \
251 static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src, \
254 uint64_t half[8 + 9]; \
255 uint8_t * const halfH = ((uint8_t*)half) + 64; \
256 uint8_t * const halfHV = ((uint8_t*)half); \
257 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
259 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
260 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, \
264 static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src, \
267 uint64_t half[8 + 9]; \
268 uint8_t * const halfH = ((uint8_t*)half) + 64; \
269 uint8_t * const halfHV = ((uint8_t*)half); \
270 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
272 ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
273 ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV, \
277 static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src, \
280 uint64_t half[8 + 9]; \
281 uint8_t * const halfH = ((uint8_t*)half); \
282 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
284 ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, \
286 ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \
290 static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src, \
293 uint64_t half[8 + 9]; \
294 uint8_t * const halfH = ((uint8_t*)half); \
295 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
297 ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8, \
299 ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \
303 static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src, \
307 uint8_t * const halfH = ((uint8_t*)half); \
308 ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
310 ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \
314 static void OPNAME ## qpel16_mc00_ ## MMX (uint8_t *dst, uint8_t *src, \
317 ff_ ## OPNAME ## pixels16_ ## MMX(dst, src, stride, 16); \
320 static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src, \
324 uint8_t * const half = (uint8_t*)temp; \
325 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, \
327 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, \
331 static void OPNAME ## qpel16_mc20_ ## MMX(uint8_t *dst, uint8_t *src, \
334 ff_ ## OPNAME ## mpeg4_qpel16_h_lowpass_ ## MMX(dst, src, \
335 stride, stride, 16);\
338 static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src, \
342 uint8_t * const half = (uint8_t*)temp; \
343 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, \
345 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src + 1, half, \
346 stride, stride, 16); \
349 static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src, \
353 uint8_t * const half = (uint8_t*)temp; \
354 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, \
356 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, \
360 static void OPNAME ## qpel16_mc02_ ## MMX(uint8_t *dst, uint8_t *src, \
363 ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, src, \
367 static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src, \
371 uint8_t * const half = (uint8_t*)temp; \
372 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, \
374 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src+stride, half, \
375 stride, stride, 16); \
378 static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src, \
381 uint64_t half[16 * 2 + 17 * 2]; \
382 uint8_t * const halfH = ((uint8_t*)half) + 256; \
383 uint8_t * const halfHV = ((uint8_t*)half); \
384 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
386 ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, \
388 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
390 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, \
394 static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src, \
397 uint64_t half[16 * 2 + 17 * 2]; \
398 uint8_t * const halfH = ((uint8_t*)half) + 256; \
399 uint8_t * const halfHV = ((uint8_t*)half); \
400 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
402 ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16, \
404 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
406 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, \
410 static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src, \
413 uint64_t half[16 * 2 + 17 * 2]; \
414 uint8_t * const halfH = ((uint8_t*)half) + 256; \
415 uint8_t * const halfHV = ((uint8_t*)half); \
416 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
418 ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, \
420 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
422 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV, \
426 static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src, \
429 uint64_t half[16 * 2 + 17 * 2]; \
430 uint8_t * const halfH = ((uint8_t*)half) + 256; \
431 uint8_t * const halfHV = ((uint8_t*)half); \
432 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
434 ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16, \
436 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
438 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV, \
442 static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src, \
445 uint64_t half[16 * 2 + 17 * 2]; \
446 uint8_t * const halfH = ((uint8_t*)half) + 256; \
447 uint8_t * const halfHV = ((uint8_t*)half); \
448 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
450 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
452 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, \
456 static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src, \
459 uint64_t half[16 * 2 + 17 * 2]; \
460 uint8_t * const halfH = ((uint8_t*)half) + 256; \
461 uint8_t * const halfHV = ((uint8_t*)half); \
462 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
464 ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
466 ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV, \
470 static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src, \
473 uint64_t half[17 * 2]; \
474 uint8_t * const halfH = ((uint8_t*)half); \
475 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
477 ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, \
479 ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, \
483 static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src, \
486 uint64_t half[17 * 2]; \
487 uint8_t * const halfH = ((uint8_t*)half); \
488 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
490 ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16, \
492 ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, \
496 static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, \
499 uint64_t half[17 * 2]; \
500 uint8_t * const halfH = ((uint8_t*)half); \
501 ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
503 ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, \
507 QPEL_OP(put_, _, mmxext)
508 QPEL_OP(avg_, _, mmxext)
509 QPEL_OP(put_no_rnd_, _no_rnd_, mmxext)
510 #endif /* HAVE_YASM */
512 #define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX) \
514 c->PFX ## _pixels_tab[IDX][ 0] = PREFIX ## PFX ## SIZE ## _mc00_ ## CPU; \
515 c->PFX ## _pixels_tab[IDX][ 1] = PREFIX ## PFX ## SIZE ## _mc10_ ## CPU; \
516 c->PFX ## _pixels_tab[IDX][ 2] = PREFIX ## PFX ## SIZE ## _mc20_ ## CPU; \
517 c->PFX ## _pixels_tab[IDX][ 3] = PREFIX ## PFX ## SIZE ## _mc30_ ## CPU; \
518 c->PFX ## _pixels_tab[IDX][ 4] = PREFIX ## PFX ## SIZE ## _mc01_ ## CPU; \
519 c->PFX ## _pixels_tab[IDX][ 5] = PREFIX ## PFX ## SIZE ## _mc11_ ## CPU; \
520 c->PFX ## _pixels_tab[IDX][ 6] = PREFIX ## PFX ## SIZE ## _mc21_ ## CPU; \
521 c->PFX ## _pixels_tab[IDX][ 7] = PREFIX ## PFX ## SIZE ## _mc31_ ## CPU; \
522 c->PFX ## _pixels_tab[IDX][ 8] = PREFIX ## PFX ## SIZE ## _mc02_ ## CPU; \
523 c->PFX ## _pixels_tab[IDX][ 9] = PREFIX ## PFX ## SIZE ## _mc12_ ## CPU; \
524 c->PFX ## _pixels_tab[IDX][10] = PREFIX ## PFX ## SIZE ## _mc22_ ## CPU; \
525 c->PFX ## _pixels_tab[IDX][11] = PREFIX ## PFX ## SIZE ## _mc32_ ## CPU; \
526 c->PFX ## _pixels_tab[IDX][12] = PREFIX ## PFX ## SIZE ## _mc03_ ## CPU; \
527 c->PFX ## _pixels_tab[IDX][13] = PREFIX ## PFX ## SIZE ## _mc13_ ## CPU; \
528 c->PFX ## _pixels_tab[IDX][14] = PREFIX ## PFX ## SIZE ## _mc23_ ## CPU; \
529 c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU; \
532 static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
536 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
538 c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
539 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
540 c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
542 if (!high_bit_depth) {
543 c->clear_block = ff_clear_block_mmx;
544 c->clear_blocks = ff_clear_blocks_mmx;
545 c->draw_edges = ff_draw_edges_mmx;
547 switch (avctx->idct_algo) {
549 case FF_IDCT_SIMPLEMMX:
550 c->idct_put = ff_simple_idct_put_mmx;
551 c->idct_add = ff_simple_idct_add_mmx;
552 c->idct = ff_simple_idct_mmx;
553 c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
555 case FF_IDCT_XVIDMMX:
556 c->idct_put = ff_idct_xvid_mmx_put;
557 c->idct_add = ff_idct_xvid_mmx_add;
558 c->idct = ff_idct_xvid_mmx;
565 c->add_bytes = ff_add_bytes_mmx;
566 #endif /* HAVE_MMX_INLINE */
568 #if HAVE_MMX_EXTERNAL
569 if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
570 c->h263_v_loop_filter = ff_h263_v_loop_filter_mmx;
571 c->h263_h_loop_filter = ff_h263_h_loop_filter_mmx;
574 c->vector_clip_int32 = ff_vector_clip_int32_mmx;
575 #endif /* HAVE_MMX_EXTERNAL */
578 static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
581 #if HAVE_MMXEXT_INLINE
582 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
584 if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
585 c->idct_put = ff_idct_xvid_mmxext_put;
586 c->idct_add = ff_idct_xvid_mmxext_add;
587 c->idct = ff_idct_xvid_mmxext;
589 #endif /* HAVE_MMXEXT_INLINE */
591 #if HAVE_MMXEXT_EXTERNAL
592 SET_QPEL_FUNCS(avg_qpel, 0, 16, mmxext, );
593 SET_QPEL_FUNCS(avg_qpel, 1, 8, mmxext, );
595 SET_QPEL_FUNCS(put_qpel, 0, 16, mmxext, );
596 SET_QPEL_FUNCS(put_qpel, 1, 8, mmxext, );
597 SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmxext, );
598 SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmxext, );
600 /* slower than cmov version on AMD */
601 if (!(cpu_flags & AV_CPU_FLAG_3DNOW))
602 c->add_hfyu_median_prediction = ff_add_hfyu_median_prediction_mmxext;
604 c->scalarproduct_int16 = ff_scalarproduct_int16_mmxext;
605 c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_mmxext;
607 if (avctx->flags & CODEC_FLAG_BITEXACT) {
608 c->apply_window_int16 = ff_apply_window_int16_mmxext;
610 c->apply_window_int16 = ff_apply_window_int16_round_mmxext;
612 #endif /* HAVE_MMXEXT_EXTERNAL */
615 static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx,
619 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
621 if (!high_bit_depth) {
622 if (!(CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)) {
623 /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
624 c->clear_block = ff_clear_block_sse;
625 c->clear_blocks = ff_clear_blocks_sse;
629 c->vector_clipf = ff_vector_clipf_sse;
630 #endif /* HAVE_SSE_INLINE */
633 static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
637 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
639 if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
640 c->idct_put = ff_idct_xvid_sse2_put;
641 c->idct_add = ff_idct_xvid_sse2_add;
642 c->idct = ff_idct_xvid_sse2;
643 c->idct_permutation_type = FF_SSE2_IDCT_PERM;
645 #endif /* HAVE_SSE2_INLINE */
647 #if HAVE_SSE2_EXTERNAL
648 c->scalarproduct_int16 = ff_scalarproduct_int16_sse2;
649 c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2;
650 if (cpu_flags & AV_CPU_FLAG_ATOM) {
651 c->vector_clip_int32 = ff_vector_clip_int32_int_sse2;
653 c->vector_clip_int32 = ff_vector_clip_int32_sse2;
655 if (avctx->flags & CODEC_FLAG_BITEXACT) {
656 c->apply_window_int16 = ff_apply_window_int16_sse2;
657 } else if (!(cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
658 c->apply_window_int16 = ff_apply_window_int16_round_sse2;
660 c->bswap_buf = ff_bswap32_buf_sse2;
661 #endif /* HAVE_SSE2_EXTERNAL */
664 static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
667 #if HAVE_SSSE3_EXTERNAL
668 c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_ssse3;
669 if (cpu_flags & AV_CPU_FLAG_SSE4) // not really SSE4, just slow on Conroe
670 c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_sse4;
672 if (cpu_flags & AV_CPU_FLAG_ATOM)
673 c->apply_window_int16 = ff_apply_window_int16_ssse3_atom;
675 c->apply_window_int16 = ff_apply_window_int16_ssse3;
676 if (!(cpu_flags & (AV_CPU_FLAG_SSE42 | AV_CPU_FLAG_3DNOW))) // cachesplit
677 c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_ssse3;
678 c->bswap_buf = ff_bswap32_buf_ssse3;
679 #endif /* HAVE_SSSE3_EXTERNAL */
682 static av_cold void dsputil_init_sse4(DSPContext *c, AVCodecContext *avctx,
685 #if HAVE_SSE4_EXTERNAL
686 c->vector_clip_int32 = ff_vector_clip_int32_sse4;
687 #endif /* HAVE_SSE4_EXTERNAL */
690 av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx)
692 int cpu_flags = av_get_cpu_flags();
694 #if HAVE_7REGS && HAVE_INLINE_ASM
695 if (cpu_flags & AV_CPU_FLAG_CMOV)
696 c->add_hfyu_median_prediction = ff_add_hfyu_median_prediction_cmov;
699 if (X86_MMX(cpu_flags))
700 dsputil_init_mmx(c, avctx, cpu_flags);
702 if (X86_MMXEXT(cpu_flags))
703 dsputil_init_mmxext(c, avctx, cpu_flags);
705 if (X86_SSE(cpu_flags))
706 dsputil_init_sse(c, avctx, cpu_flags);
708 if (X86_SSE2(cpu_flags))
709 dsputil_init_sse2(c, avctx, cpu_flags);
711 if (EXTERNAL_SSSE3(cpu_flags))
712 dsputil_init_ssse3(c, avctx, cpu_flags);
714 if (EXTERNAL_SSE4(cpu_flags))
715 dsputil_init_sse4(c, avctx, cpu_flags);
718 ff_dsputilenc_init_mmx(c, avctx);