clib/libmpeg2/motion_comp_mmx.c

filter: Statementstmt 0.0% 0 / 542 Branchbran 0.0% 0 / 122 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 664 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/libmpeg2/motion_comp.c ↑ Summary clib/libmpeg2/slice.c »
1 /*
2 * motion_comp_mmx.c
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5 *
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * See http://libmpeg2.sourceforge.net/ for updates.
8 *
9 * mpeg2dec is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * mpeg2dec is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23  
24 #include "config.h"
25  
26 #if defined(ARCH_X86) || defined(ARCH_X86_64)
27  
28 #include <inttypes.h>
29  
30 #include "mpeg2.h"
31 #include "attributes.h"
32 #include "mpeg2_internal.h"
33 #include "mmx.h"
34  
35 #define CPU_MMXEXT 0
36 #define CPU_3DNOW 1
37  
38  
39 /* MMX code - needs a rewrite */
40  
41 /*
42 * Motion Compensation frequently needs to average values using the
43 * formula (x+y+1)>>1. Both MMXEXT and 3Dnow include one instruction
44 * to compute this, but it's been left out of classic MMX.
45 *
46 * We need to be careful of overflows when doing this computation.
47 * Rather than unpacking data to 16-bits, which reduces parallelism,
48 * we use the following formulas:
49 *
50 * (x+y)>>1 == (x&y)+((x^y)>>1)
51 * (x+y+1)>>1 == (x|y)-((x^y)>>1)
52 */
53  
54 /* some rounding constants */
55 static mmx_t mask1 = {0xfefefefefefefefeLL};
56 static mmx_t round4 = {0x0002000200020002LL};
57  
58 /*
59 * This code should probably be compiled with loop unrolling
60 * (ie, -funroll-loops in gcc)becuase some of the loops
61 * use a small static number of iterations. This was written
62 * with the assumption the compiler knows best about when
63 * unrolling will help
64 */
65  
66 0 static inline void mmx_zero_reg (void)
67 {
68 /* load 0 into mm0 */
69 0 pxor_r2r (mm0, mm0);
70 0 }
71  
72 0 static inline void mmx_average_2_U8 (uint8_t * dest, const uint8_t * src1,
73 const uint8_t * src2)
74 {
75 /* *dest = (*src1 + *src2 + 1)/ 2; */
76  
77 0 movq_m2r (*src1, mm1); /* load 8 src1 bytes */
78 0 movq_r2r (mm1, mm2); /* copy 8 src1 bytes */
79  
80 0 movq_m2r (*src2, mm3); /* load 8 src2 bytes */
81 0 movq_r2r (mm3, mm4); /* copy 8 src2 bytes */
82  
83 0 pxor_r2r (mm1, mm3); /* xor src1 and src2 */
84 0 pand_m2r (mask1, mm3); /* mask lower bits */
85 0 psrlq_i2r (1, mm3); /* /2 */
86 0 por_r2r (mm2, mm4); /* or src1 and src2 */
87 0 psubb_r2r (mm3, mm4); /* subtract subresults */
88 0 movq_r2m (mm4, *dest); /* store result in dest */
89 0 }
90  
91 0 static inline void mmx_interp_average_2_U8 (uint8_t * dest,
92 const uint8_t * src1,
93 const uint8_t * src2)
94 {
95 /* *dest = (*dest + (*src1 + *src2 + 1)/ 2 + 1)/ 2; */
96  
97 0 movq_m2r (*dest, mm1); /* load 8 dest bytes */
98 0 movq_r2r (mm1, mm2); /* copy 8 dest bytes */
99  
100 0 movq_m2r (*src1, mm3); /* load 8 src1 bytes */
101 0 movq_r2r (mm3, mm4); /* copy 8 src1 bytes */
102  
103 0 movq_m2r (*src2, mm5); /* load 8 src2 bytes */
104 0 movq_r2r (mm5, mm6); /* copy 8 src2 bytes */
105  
106 0 pxor_r2r (mm3, mm5); /* xor src1 and src2 */
107 0 pand_m2r (mask1, mm5); /* mask lower bits */
108 0 psrlq_i2r (1, mm5); /* /2 */
109 0 por_r2r (mm4, mm6); /* or src1 and src2 */
110 0 psubb_r2r (mm5, mm6); /* subtract subresults */
111 0 movq_r2r (mm6, mm5); /* copy subresult */
112  
113 0 pxor_r2r (mm1, mm5); /* xor srcavg and dest */
114 0 pand_m2r (mask1, mm5); /* mask lower bits */
115 0 psrlq_i2r (1, mm5); /* /2 */
116 0 por_r2r (mm2, mm6); /* or srcavg and dest */
117 0 psubb_r2r (mm5, mm6); /* subtract subresults */
118 0 movq_r2m (mm6, *dest); /* store result in dest */
119 0 }
120  
121 0 static inline void mmx_average_4_U8 (uint8_t * dest, const uint8_t * src1,
122 const uint8_t * src2,
123 const uint8_t * src3,
124 const uint8_t * src4)
125 {
126 /* *dest = (*src1 + *src2 + *src3 + *src4 + 2)/ 4; */
127  
128 0 movq_m2r (*src1, mm1); /* load 8 src1 bytes */
129 0 movq_r2r (mm1, mm2); /* copy 8 src1 bytes */
130  
131 0 punpcklbw_r2r (mm0, mm1); /* unpack low src1 bytes */
132 0 punpckhbw_r2r (mm0, mm2); /* unpack high src1 bytes */
133  
134 0 movq_m2r (*src2, mm3); /* load 8 src2 bytes */
135 0 movq_r2r (mm3, mm4); /* copy 8 src2 bytes */
136  
137 0 punpcklbw_r2r (mm0, mm3); /* unpack low src2 bytes */
138 0 punpckhbw_r2r (mm0, mm4); /* unpack high src2 bytes */
139  
140 0 paddw_r2r (mm3, mm1); /* add lows */
141 0 paddw_r2r (mm4, mm2); /* add highs */
142  
143 /* now have partials in mm1 and mm2 */
144  
145 0 movq_m2r (*src3, mm3); /* load 8 src3 bytes */
146 0 movq_r2r (mm3, mm4); /* copy 8 src3 bytes */
147  
148 0 punpcklbw_r2r (mm0, mm3); /* unpack low src3 bytes */
149 0 punpckhbw_r2r (mm0, mm4); /* unpack high src3 bytes */
150  
151 0 paddw_r2r (mm3, mm1); /* add lows */
152 0 paddw_r2r (mm4, mm2); /* add highs */
153  
154 0 movq_m2r (*src4, mm5); /* load 8 src4 bytes */
155 0 movq_r2r (mm5, mm6); /* copy 8 src4 bytes */
156  
157 0 punpcklbw_r2r (mm0, mm5); /* unpack low src4 bytes */
158 0 punpckhbw_r2r (mm0, mm6); /* unpack high src4 bytes */
159  
160 0 paddw_r2r (mm5, mm1); /* add lows */
161 0 paddw_r2r (mm6, mm2); /* add highs */
162  
163 /* now have subtotal in mm1 and mm2 */
164  
165 0 paddw_m2r (round4, mm1);
166 0 psraw_i2r (2, mm1); /* /4 */
167 0 paddw_m2r (round4, mm2);
168 0 psraw_i2r (2, mm2); /* /4 */
169  
170 0 packuswb_r2r (mm2, mm1); /* pack (w/ saturation) */
171 0 movq_r2m (mm1, *dest); /* store result in dest */
172 0 }
173  
174 0 static inline void mmx_interp_average_4_U8 (uint8_t * dest,
175 const uint8_t * src1,
176 const uint8_t * src2,
177 const uint8_t * src3,
178 const uint8_t * src4)
179 {
180 /* *dest = (*dest + (*src1 + *src2 + *src3 + *src4 + 2)/ 4 + 1)/ 2; */
181  
182 0 movq_m2r (*src1, mm1); /* load 8 src1 bytes */
183 0 movq_r2r (mm1, mm2); /* copy 8 src1 bytes */
184  
185 0 punpcklbw_r2r (mm0, mm1); /* unpack low src1 bytes */
186 0 punpckhbw_r2r (mm0, mm2); /* unpack high src1 bytes */
187  
188 0 movq_m2r (*src2, mm3); /* load 8 src2 bytes */
189 0 movq_r2r (mm3, mm4); /* copy 8 src2 bytes */
190  
191 0 punpcklbw_r2r (mm0, mm3); /* unpack low src2 bytes */
192 0 punpckhbw_r2r (mm0, mm4); /* unpack high src2 bytes */
193  
194 0 paddw_r2r (mm3, mm1); /* add lows */
195 0 paddw_r2r (mm4, mm2); /* add highs */
196  
197 /* now have partials in mm1 and mm2 */
198  
199 0 movq_m2r (*src3, mm3); /* load 8 src3 bytes */
200 0 movq_r2r (mm3, mm4); /* copy 8 src3 bytes */
201  
202 0 punpcklbw_r2r (mm0, mm3); /* unpack low src3 bytes */
203 0 punpckhbw_r2r (mm0, mm4); /* unpack high src3 bytes */
204  
205 0 paddw_r2r (mm3, mm1); /* add lows */
206 0 paddw_r2r (mm4, mm2); /* add highs */
207  
208 0 movq_m2r (*src4, mm5); /* load 8 src4 bytes */
209 0 movq_r2r (mm5, mm6); /* copy 8 src4 bytes */
210  
211 0 punpcklbw_r2r (mm0, mm5); /* unpack low src4 bytes */
212 0 punpckhbw_r2r (mm0, mm6); /* unpack high src4 bytes */
213  
214 0 paddw_r2r (mm5, mm1); /* add lows */
215 0 paddw_r2r (mm6, mm2); /* add highs */
216  
217 0 paddw_m2r (round4, mm1);
218 0 psraw_i2r (2, mm1); /* /4 */
219 0 paddw_m2r (round4, mm2);
220 0 psraw_i2r (2, mm2); /* /4 */
221  
222 /* now have subtotal/4 in mm1 and mm2 */
223  
224 0 movq_m2r (*dest, mm3); /* load 8 dest bytes */
225 0 movq_r2r (mm3, mm4); /* copy 8 dest bytes */
226  
227 0 packuswb_r2r (mm2, mm1); /* pack (w/ saturation) */
228 0 movq_r2r (mm1,mm2); /* copy subresult */
229  
230 0 pxor_r2r (mm1, mm3); /* xor srcavg and dest */
231 0 pand_m2r (mask1, mm3); /* mask lower bits */
232 0 psrlq_i2r (1, mm3); /* /2 */
233 0 por_r2r (mm2, mm4); /* or srcavg and dest */
234 0 psubb_r2r (mm3, mm4); /* subtract subresults */
235 0 movq_r2m (mm4, *dest); /* store result in dest */
236 0 }
237  
238 /*-----------------------------------------------------------------------*/
239  
240 0 static inline void MC_avg_mmx (const int width, int height, uint8_t * dest,
241 const uint8_t * ref, const int stride)
242 {
243 0 mmx_zero_reg ();
244  
245 do {
246 0 mmx_average_2_U8 (dest, dest, ref);
247  
248 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
249 0 mmx_average_2_U8 (dest+8, dest+8, ref+8);
250  
251 0 dest += stride;
252 0 ref += stride;
253 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
254 0 }
255  
256 0 static void MC_avg_o_16_mmx (uint8_t * dest, const uint8_t * ref,
257 int stride, int height)
258 {
259 0 MC_avg_mmx (16, height, dest, ref, stride);
260 0 }
261  
262 0 static void MC_avg_o_8_mmx (uint8_t * dest, const uint8_t * ref,
263 int stride, int height)
264 {
265 0 MC_avg_mmx (8, height, dest, ref, stride);
266 0 }
267  
268 /*-----------------------------------------------------------------------*/
269  
270 0 static inline void MC_put_mmx (const int width, int height, uint8_t * dest,
271 const uint8_t * ref, const int stride)
272 {
273 0 mmx_zero_reg ();
274  
275 do {
276 0 movq_m2r (* ref, mm1); /* load 8 ref bytes */
277 0 movq_r2m (mm1,* dest); /* store 8 bytes at curr */
278  
279 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
280 {
281 0 movq_m2r (* (ref+8), mm1); /* load 8 ref bytes */
282 0 movq_r2m (mm1,* (dest+8)); /* store 8 bytes at curr */
283 }
284  
285 0 dest += stride;
286 0 ref += stride;
287 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
288 0 }
289  
290 0 static void MC_put_o_16_mmx (uint8_t * dest, const uint8_t * ref,
291 int stride, int height)
292 {
293 0 MC_put_mmx (16, height, dest, ref, stride);
294 0 }
295  
296 0 static void MC_put_o_8_mmx (uint8_t * dest, const uint8_t * ref,
297 int stride, int height)
298 {
299 0 MC_put_mmx (8, height, dest, ref, stride);
300 0 }
301  
302 /*-----------------------------------------------------------------------*/
303  
304 /* Half pixel interpolation in the x direction */
305 0 static inline void MC_avg_x_mmx (const int width, int height, uint8_t * dest,
306 const uint8_t * ref, const int stride)
307 {
308 0 mmx_zero_reg ();
309  
310 do {
311 0 mmx_interp_average_2_U8 (dest, ref, ref+1);
312  
313 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
314 0 mmx_interp_average_2_U8 (dest+8, ref+8, ref+9);
315  
316 0 dest += stride;
317 0 ref += stride;
318 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
319 0 }
320  
321 0 static void MC_avg_x_16_mmx (uint8_t * dest, const uint8_t * ref,
322 int stride, int height)
323 {
324 0 MC_avg_x_mmx (16, height, dest, ref, stride);
325 0 }
326  
327 0 static void MC_avg_x_8_mmx (uint8_t * dest, const uint8_t * ref,
328 int stride, int height)
329 {
330 0 MC_avg_x_mmx (8, height, dest, ref, stride);
331 0 }
332  
333 /*-----------------------------------------------------------------------*/
334  
335 0 static inline void MC_put_x_mmx (const int width, int height, uint8_t * dest,
336 const uint8_t * ref, const int stride)
337 {
338 0 mmx_zero_reg ();
339  
340 do {
341 0 mmx_average_2_U8 (dest, ref, ref+1);
342  
343 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
344 0 mmx_average_2_U8 (dest+8, ref+8, ref+9);
345  
346 0 dest += stride;
347 0 ref += stride;
348 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
349 0 }
350  
351 0 static void MC_put_x_16_mmx (uint8_t * dest, const uint8_t * ref,
352 int stride, int height)
353 {
354 0 MC_put_x_mmx (16, height, dest, ref, stride);
355 0 }
356  
357 0 static void MC_put_x_8_mmx (uint8_t * dest, const uint8_t * ref,
358 int stride, int height)
359 {
360 0 MC_put_x_mmx (8, height, dest, ref, stride);
361 0 }
362  
363 /*-----------------------------------------------------------------------*/
364  
365 0 static inline void MC_avg_xy_mmx (const int width, int height, uint8_t * dest,
366 const uint8_t * ref, const int stride)
367 {
368 0 const uint8_t * ref_next = ref + stride;
369  
370 0 mmx_zero_reg ();
371  
372 do {
373 0 mmx_interp_average_4_U8 (dest, ref, ref+1, ref_next, ref_next+1);
374  
375 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
376 0 mmx_interp_average_4_U8 (dest+8, ref+8, ref+9,
377 ref_next+8, ref_next+9);
378  
379 0 dest += stride;
380 0 ref += stride;
381 0 ref_next += stride;
382 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
383 0 }
384  
385 0 static void MC_avg_xy_16_mmx (uint8_t * dest, const uint8_t * ref,
386 int stride, int height)
387 {
388 0 MC_avg_xy_mmx (16, height, dest, ref, stride);
389 0 }
390  
391 0 static void MC_avg_xy_8_mmx (uint8_t * dest, const uint8_t * ref,
392 int stride, int height)
393 {
394 0 MC_avg_xy_mmx (8, height, dest, ref, stride);
395 0 }
396  
397 /*-----------------------------------------------------------------------*/
398  
399 0 static inline void MC_put_xy_mmx (const int width, int height, uint8_t * dest,
400 const uint8_t * ref, const int stride)
401 {
402 0 const uint8_t * ref_next = ref + stride;
403  
404 0 mmx_zero_reg ();
405  
406 do {
407 0 mmx_average_4_U8 (dest, ref, ref+1, ref_next, ref_next+1);
408  
409 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
410 0 mmx_average_4_U8 (dest+8, ref+8, ref+9, ref_next+8, ref_next+9);
411  
412 0 dest += stride;
413 0 ref += stride;
414 0 ref_next += stride;
415 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
416 0 }
417  
418 0 static void MC_put_xy_16_mmx (uint8_t * dest, const uint8_t * ref,
419 int stride, int height)
420 {
421 0 MC_put_xy_mmx (16, height, dest, ref, stride);
422 0 }
423  
424 0 static void MC_put_xy_8_mmx (uint8_t * dest, const uint8_t * ref,
425 int stride, int height)
426 {
427 0 MC_put_xy_mmx (8, height, dest, ref, stride);
428 0 }
429  
430 /*-----------------------------------------------------------------------*/
431  
432 0 static inline void MC_avg_y_mmx (const int width, int height, uint8_t * dest,
433 const uint8_t * ref, const int stride)
434 {
435 0 const uint8_t * ref_next = ref + stride;
436  
437 0 mmx_zero_reg ();
438  
439 do {
440 0 mmx_interp_average_2_U8 (dest, ref, ref_next);
441  
442 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
443 0 mmx_interp_average_2_U8 (dest+8, ref+8, ref_next+8);
444  
445 0 dest += stride;
446 0 ref += stride;
447 0 ref_next += stride;
448 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
449 0 }
450  
451 0 static void MC_avg_y_16_mmx (uint8_t * dest, const uint8_t * ref,
452 int stride, int height)
453 {
454 0 MC_avg_y_mmx (16, height, dest, ref, stride);
455 0 }
456  
457 0 static void MC_avg_y_8_mmx (uint8_t * dest, const uint8_t * ref,
458 int stride, int height)
459 {
460 0 MC_avg_y_mmx (8, height, dest, ref, stride);
461 0 }
462  
463 /*-----------------------------------------------------------------------*/
464  
465 0 static inline void MC_put_y_mmx (const int width, int height, uint8_t * dest,
466 const uint8_t * ref, const int stride)
467 {
468 0 const uint8_t * ref_next = ref + stride;
469  
470 0 mmx_zero_reg ();
471  
472 do {
473 0 mmx_average_2_U8 (dest, ref, ref_next);
474  
475 0 ▶ if (width == 16)
Branch: 1 branch
BranchTrueFalseTotal
if (width == 16) 0 0 0
476 0 mmx_average_2_U8 (dest+8, ref+8, ref_next+8);
477  
478 0 dest += stride;
479 0 ref += stride;
480 0 ref_next += stride;
481 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
482 0 }
483  
484 0 static void MC_put_y_16_mmx (uint8_t * dest, const uint8_t * ref,
485 int stride, int height)
486 {
487 0 MC_put_y_mmx (16, height, dest, ref, stride);
488 0 }
489  
490 0 static void MC_put_y_8_mmx (uint8_t * dest, const uint8_t * ref,
491 int stride, int height)
492 {
493 0 MC_put_y_mmx (8, height, dest, ref, stride);
494 0 }
495  
496  
497 MPEG2_MC_EXTERN (mmx)
498  
499  
500  
501  
502  
503  
504  
505 /* CPU_MMXEXT/CPU_3DNOW adaptation layer */
506  
507 #define pavg_r2r(src,dest) \
508 do { \
509 if (cpu == CPU_MMXEXT) \
510 pavgb_r2r (src, dest); \
511 else \
512 pavgusb_r2r (src, dest); \
513 } while (0)
514  
515 #define pavg_m2r(src,dest) \
516 do { \
517 if (cpu == CPU_MMXEXT) \
518 pavgb_m2r (src, dest); \
519 else \
520 pavgusb_m2r (src, dest); \
521 } while (0)
522  
523  
524 /* CPU_MMXEXT code */
525  
526  
527 0 static inline void MC_put1_8 (int height, uint8_t * dest, const uint8_t * ref,
528 const int stride)
529 {
530 do {
531 0 movq_m2r (*ref, mm0);
532 0 movq_r2m (mm0, *dest);
533 0 ref += stride;
534 0 dest += stride;
535 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
536 0 }
537  
538 0 static inline void MC_put1_16 (int height, uint8_t * dest, const uint8_t * ref,
539 const int stride)
540 {
541 do {
542 0 movq_m2r (*ref, mm0);
543 0 movq_m2r (*(ref+8), mm1);
544 0 ref += stride;
545 0 movq_r2m (mm0, *dest);
546 0 movq_r2m (mm1, *(dest+8));
547 0 dest += stride;
548 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
549 0 }
550  
551 0 static inline void MC_avg1_8 (int height, uint8_t * dest, const uint8_t * ref,
552 const int stride, const int cpu)
553 {
554 do {
555 0 movq_m2r (*ref, mm0);
556 0 ▶ pavg_m2r (*dest, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*dest, mm0); 0 0 0
557 0 ref += stride;
558 0 movq_r2m (mm0, *dest);
559 0 dest += stride;
560 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
561 0 }
562  
563 0 static inline void MC_avg1_16 (int height, uint8_t * dest, const uint8_t * ref,
564 const int stride, const int cpu)
565 {
566 do {
567 0 movq_m2r (*ref, mm0);
568 0 movq_m2r (*(ref+8), mm1);
569 0 ▶ pavg_m2r (*dest, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*dest, mm0); 0 0 0
570 0 ▶ pavg_m2r (*(dest+8), mm1);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(dest+8), mm1); 0 0 0
571 0 movq_r2m (mm0, *dest);
572 0 ref += stride;
573 0 movq_r2m (mm1, *(dest+8));
574 0 dest += stride;
575 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
576 0 }
577  
578 0 static inline void MC_put2_8 (int height, uint8_t * dest, const uint8_t * ref,
579 const int stride, const int offset,
580 const int cpu)
581 {
582 do {
583 0 movq_m2r (*ref, mm0);
584 0 ▶ pavg_m2r (*(ref+offset), mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(ref+offset), mm0); 0 0 0
585 0 ref += stride;
586 0 movq_r2m (mm0, *dest);
587 0 dest += stride;
588 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
589 0 }
590  
591 0 static inline void MC_put2_16 (int height, uint8_t * dest, const uint8_t * ref,
592 const int stride, const int offset,
593 const int cpu)
594 {
595 do {
596 0 movq_m2r (*ref, mm0);
597 0 movq_m2r (*(ref+8), mm1);
598 0 ▶ pavg_m2r (*(ref+offset), mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(ref+offset), mm0); 0 0 0
599 0 ▶ pavg_m2r (*(ref+offset+8), mm1);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(ref+offset+8), mm1); 0 0 0
600 0 movq_r2m (mm0, *dest);
601 0 ref += stride;
602 0 movq_r2m (mm1, *(dest+8));
603 0 dest += stride;
604 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
605 0 }
606  
607 0 static inline void MC_avg2_8 (int height, uint8_t * dest, const uint8_t * ref,
608 const int stride, const int offset,
609 const int cpu)
610 {
611 do {
612 0 movq_m2r (*ref, mm0);
613 0 ▶ pavg_m2r (*(ref+offset), mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(ref+offset), mm0); 0 0 0
614 0 ▶ pavg_m2r (*dest, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*dest, mm0); 0 0 0
615 0 ref += stride;
616 0 movq_r2m (mm0, *dest);
617 0 dest += stride;
618 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
619 0 }
620  
621 0 static inline void MC_avg2_16 (int height, uint8_t * dest, const uint8_t * ref,
622 const int stride, const int offset,
623 const int cpu)
624 {
625 do {
626 0 movq_m2r (*ref, mm0);
627 0 movq_m2r (*(ref+8), mm1);
628 0 ▶ pavg_m2r (*(ref+offset), mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(ref+offset), mm0); 0 0 0
629 0 ▶ pavg_m2r (*(ref+offset+8), mm1);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(ref+offset+8), mm1); 0 0 0
630 0 ▶ pavg_m2r (*dest, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*dest, mm0); 0 0 0
631 0 ▶ pavg_m2r (*(dest+8), mm1);
Branch: 1 branch
BranchTrueFalseTotal
pavg_m2r (*(dest+8), mm1); 0 0 0
632 0 ref += stride;
633 0 movq_r2m (mm0, *dest);
634 0 movq_r2m (mm1, *(dest+8));
635 0 dest += stride;
636 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
637 0 }
638  
639 static mmx_t mask_one = {0x0101010101010101LL};
640  
641 0 static inline void MC_put4_8 (int height, uint8_t * dest, const uint8_t * ref,
642 const int stride, const int cpu)
643 {
644 0 movq_m2r (*ref, mm0);
645 0 movq_m2r (*(ref+1), mm1);
646 0 movq_r2r (mm0, mm7);
647 0 pxor_r2r (mm1, mm7);
648 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
649 0 ref += stride;
650  
651 do {
652 0 movq_m2r (*ref, mm2);
653 0 movq_r2r (mm0, mm5);
654  
655 0 movq_m2r (*(ref+1), mm3);
656 0 movq_r2r (mm2, mm6);
657  
658 0 pxor_r2r (mm3, mm6);
659 0 ▶ pavg_r2r (mm3, mm2);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm3, mm2); 0 0 0
660  
661 0 por_r2r (mm6, mm7);
662 0 pxor_r2r (mm2, mm5);
663  
664 0 pand_r2r (mm5, mm7);
665 0 ▶ pavg_r2r (mm2, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm2, mm0); 0 0 0
666  
667 0 pand_m2r (mask_one, mm7);
668  
669 0 psubusb_r2r (mm7, mm0);
670  
671 0 ref += stride;
672 0 movq_r2m (mm0, *dest);
673 0 dest += stride;
674  
675 0 movq_r2r (mm6, mm7); /* unroll ! */
676 0 movq_r2r (mm2, mm0); /* unroll ! */
677 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
678 0 }
679  
680 0 static inline void MC_put4_16 (int height, uint8_t * dest, const uint8_t * ref,
681 const int stride, const int cpu)
682 {
683 do {
684 0 movq_m2r (*ref, mm0);
685 0 movq_m2r (*(ref+stride+1), mm1);
686 0 movq_r2r (mm0, mm7);
687 0 movq_m2r (*(ref+1), mm2);
688 0 pxor_r2r (mm1, mm7);
689 0 movq_m2r (*(ref+stride), mm3);
690 0 movq_r2r (mm2, mm6);
691 0 pxor_r2r (mm3, mm6);
692 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
693 0 ▶ pavg_r2r (mm3, mm2);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm3, mm2); 0 0 0
694 0 por_r2r (mm6, mm7);
695 0 movq_r2r (mm0, mm6);
696 0 pxor_r2r (mm2, mm6);
697 0 pand_r2r (mm6, mm7);
698 0 pand_m2r (mask_one, mm7);
699 0 ▶ pavg_r2r (mm2, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm2, mm0); 0 0 0
700 0 psubusb_r2r (mm7, mm0);
701 0 movq_r2m (mm0, *dest);
702  
703 0 movq_m2r (*(ref+8), mm0);
704 0 movq_m2r (*(ref+stride+9), mm1);
705 0 movq_r2r (mm0, mm7);
706 0 movq_m2r (*(ref+9), mm2);
707 0 pxor_r2r (mm1, mm7);
708 0 movq_m2r (*(ref+stride+8), mm3);
709 0 movq_r2r (mm2, mm6);
710 0 pxor_r2r (mm3, mm6);
711 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
712 0 ▶ pavg_r2r (mm3, mm2);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm3, mm2); 0 0 0
713 0 por_r2r (mm6, mm7);
714 0 movq_r2r (mm0, mm6);
715 0 pxor_r2r (mm2, mm6);
716 0 pand_r2r (mm6, mm7);
717 0 pand_m2r (mask_one, mm7);
718 0 ▶ pavg_r2r (mm2, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm2, mm0); 0 0 0
719 0 psubusb_r2r (mm7, mm0);
720 0 ref += stride;
721 0 movq_r2m (mm0, *(dest+8));
722 0 dest += stride;
723 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
724 0 }
725  
726 0 static inline void MC_avg4_8 (int height, uint8_t * dest, const uint8_t * ref,
727 const int stride, const int cpu)
728 {
729 do {
730 0 movq_m2r (*ref, mm0);
731 0 movq_m2r (*(ref+stride+1), mm1);
732 0 movq_r2r (mm0, mm7);
733 0 movq_m2r (*(ref+1), mm2);
734 0 pxor_r2r (mm1, mm7);
735 0 movq_m2r (*(ref+stride), mm3);
736 0 movq_r2r (mm2, mm6);
737 0 pxor_r2r (mm3, mm6);
738 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
739 0 ▶ pavg_r2r (mm3, mm2);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm3, mm2); 0 0 0
740 0 por_r2r (mm6, mm7);
741 0 movq_r2r (mm0, mm6);
742 0 pxor_r2r (mm2, mm6);
743 0 pand_r2r (mm6, mm7);
744 0 pand_m2r (mask_one, mm7);
745 0 ▶ pavg_r2r (mm2, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm2, mm0); 0 0 0
746 0 psubusb_r2r (mm7, mm0);
747 0 movq_m2r (*dest, mm1);
748 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
749 0 ref += stride;
750 0 movq_r2m (mm0, *dest);
751 0 dest += stride;
752 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
753 0 }
754  
755 0 static inline void MC_avg4_16 (int height, uint8_t * dest, const uint8_t * ref,
756 const int stride, const int cpu)
757 {
758 do {
759 0 movq_m2r (*ref, mm0);
760 0 movq_m2r (*(ref+stride+1), mm1);
761 0 movq_r2r (mm0, mm7);
762 0 movq_m2r (*(ref+1), mm2);
763 0 pxor_r2r (mm1, mm7);
764 0 movq_m2r (*(ref+stride), mm3);
765 0 movq_r2r (mm2, mm6);
766 0 pxor_r2r (mm3, mm6);
767 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
768 0 ▶ pavg_r2r (mm3, mm2);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm3, mm2); 0 0 0
769 0 por_r2r (mm6, mm7);
770 0 movq_r2r (mm0, mm6);
771 0 pxor_r2r (mm2, mm6);
772 0 pand_r2r (mm6, mm7);
773 0 pand_m2r (mask_one, mm7);
774 0 ▶ pavg_r2r (mm2, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm2, mm0); 0 0 0
775 0 psubusb_r2r (mm7, mm0);
776 0 movq_m2r (*dest, mm1);
777 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
778 0 movq_r2m (mm0, *dest);
779  
780 0 movq_m2r (*(ref+8), mm0);
781 0 movq_m2r (*(ref+stride+9), mm1);
782 0 movq_r2r (mm0, mm7);
783 0 movq_m2r (*(ref+9), mm2);
784 0 pxor_r2r (mm1, mm7);
785 0 movq_m2r (*(ref+stride+8), mm3);
786 0 movq_r2r (mm2, mm6);
787 0 pxor_r2r (mm3, mm6);
788 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
789 0 ▶ pavg_r2r (mm3, mm2);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm3, mm2); 0 0 0
790 0 por_r2r (mm6, mm7);
791 0 movq_r2r (mm0, mm6);
792 0 pxor_r2r (mm2, mm6);
793 0 pand_r2r (mm6, mm7);
794 0 pand_m2r (mask_one, mm7);
795 0 ▶ pavg_r2r (mm2, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm2, mm0); 0 0 0
796 0 psubusb_r2r (mm7, mm0);
797 0 movq_m2r (*(dest+8), mm1);
798 0 ▶ pavg_r2r (mm1, mm0);
Branch: 1 branch
BranchTrueFalseTotal
pavg_r2r (mm1, mm0); 0 0 0
799 0 ref += stride;
800 0 movq_r2m (mm0, *(dest+8));
801 0 dest += stride;
802 0 ▶ } while (--height);
Branch: 1 branch
BranchTrueFalseTotal
} while (--height); 0 0 0
803 0 }
804  
805 0 static void MC_avg_o_16_mmxext (uint8_t * dest, const uint8_t * ref,
806 int stride, int height)
807 {
808 0 MC_avg1_16 (height, dest, ref, stride, CPU_MMXEXT);
809 0 }
810  
811 0 static void MC_avg_o_8_mmxext (uint8_t * dest, const uint8_t * ref,
812 int stride, int height)
813 {
814 0 MC_avg1_8 (height, dest, ref, stride, CPU_MMXEXT);
815 0 }
816  
817 0 static void MC_put_o_16_mmxext (uint8_t * dest, const uint8_t * ref,
818 int stride, int height)
819 {
820 0 MC_put1_16 (height, dest, ref, stride);
821 0 }
822  
823 0 static void MC_put_o_8_mmxext (uint8_t * dest, const uint8_t * ref,
824 int stride, int height)
825 {
826 0 MC_put1_8 (height, dest, ref, stride);
827 0 }
828  
829 0 static void MC_avg_x_16_mmxext (uint8_t * dest, const uint8_t * ref,
830 int stride, int height)
831 {
832 0 MC_avg2_16 (height, dest, ref, stride, 1, CPU_MMXEXT);
833 0 }
834  
835 0 static void MC_avg_x_8_mmxext (uint8_t * dest, const uint8_t * ref,
836 int stride, int height)
837 {
838 0 MC_avg2_8 (height, dest, ref, stride, 1, CPU_MMXEXT);
839 0 }
840  
841 0 static void MC_put_x_16_mmxext (uint8_t * dest, const uint8_t * ref,
842 int stride, int height)
843 {
844 0 MC_put2_16 (height, dest, ref, stride, 1, CPU_MMXEXT);
845 0 }
846  
847 0 static void MC_put_x_8_mmxext (uint8_t * dest, const uint8_t * ref,
848 int stride, int height)
849 {
850 0 MC_put2_8 (height, dest, ref, stride, 1, CPU_MMXEXT);
851 0 }
852  
853 0 static void MC_avg_y_16_mmxext (uint8_t * dest, const uint8_t * ref,
854 int stride, int height)
855 {
856 0 MC_avg2_16 (height, dest, ref, stride, stride, CPU_MMXEXT);
857 0 }
858  
859 0 static void MC_avg_y_8_mmxext (uint8_t * dest, const uint8_t * ref,
860 int stride, int height)
861 {
862 0 MC_avg2_8 (height, dest, ref, stride, stride, CPU_MMXEXT);
863 0 }
864  
865 0 static void MC_put_y_16_mmxext (uint8_t * dest, const uint8_t * ref,
866 int stride, int height)
867 {
868 0 MC_put2_16 (height, dest, ref, stride, stride, CPU_MMXEXT);
869 0 }
870  
871 0 static void MC_put_y_8_mmxext (uint8_t * dest, const uint8_t * ref,
872 int stride, int height)
873 {
874 0 MC_put2_8 (height, dest, ref, stride, stride, CPU_MMXEXT);
875 0 }
876  
877 0 static void MC_avg_xy_16_mmxext (uint8_t * dest, const uint8_t * ref,
878 int stride, int height)
879 {
880 0 MC_avg4_16 (height, dest, ref, stride, CPU_MMXEXT);
881 0 }
882  
883 0 static void MC_avg_xy_8_mmxext (uint8_t * dest, const uint8_t * ref,
884 int stride, int height)
885 {
886 0 MC_avg4_8 (height, dest, ref, stride, CPU_MMXEXT);
887 0 }
888  
889 0 static void MC_put_xy_16_mmxext (uint8_t * dest, const uint8_t * ref,
890 int stride, int height)
891 {
892 0 MC_put4_16 (height, dest, ref, stride, CPU_MMXEXT);
893 0 }
894  
895 0 static void MC_put_xy_8_mmxext (uint8_t * dest, const uint8_t * ref,
896 int stride, int height)
897 {
898 0 MC_put4_8 (height, dest, ref, stride, CPU_MMXEXT);
899 0 }
900  
901  
902 MPEG2_MC_EXTERN (mmxext)
903  
904  
905  
906 0 static void MC_avg_o_16_3dnow (uint8_t * dest, const uint8_t * ref,
907 int stride, int height)
908 {
909 0 MC_avg1_16 (height, dest, ref, stride, CPU_3DNOW);
910 0 }
911  
912 0 static void MC_avg_o_8_3dnow (uint8_t * dest, const uint8_t * ref,
913 int stride, int height)
914 {
915 0 MC_avg1_8 (height, dest, ref, stride, CPU_3DNOW);
916 0 }
917  
918 0 static void MC_put_o_16_3dnow (uint8_t * dest, const uint8_t * ref,
919 int stride, int height)
920 {
921 0 MC_put1_16 (height, dest, ref, stride);
922 0 }
923  
924 0 static void MC_put_o_8_3dnow (uint8_t * dest, const uint8_t * ref,
925 int stride, int height)
926 {
927 0 MC_put1_8 (height, dest, ref, stride);
928 0 }
929  
930 0 static void MC_avg_x_16_3dnow (uint8_t * dest, const uint8_t * ref,
931 int stride, int height)
932 {
933 0 MC_avg2_16 (height, dest, ref, stride, 1, CPU_3DNOW);
934 0 }
935  
936 0 static void MC_avg_x_8_3dnow (uint8_t * dest, const uint8_t * ref,
937 int stride, int height)
938 {
939 0 MC_avg2_8 (height, dest, ref, stride, 1, CPU_3DNOW);
940 0 }
941  
942 0 static void MC_put_x_16_3dnow (uint8_t * dest, const uint8_t * ref,
943 int stride, int height)
944 {
945 0 MC_put2_16 (height, dest, ref, stride, 1, CPU_3DNOW);
946 0 }
947  
948 0 static void MC_put_x_8_3dnow (uint8_t * dest, const uint8_t * ref,
949 int stride, int height)
950 {
951 0 MC_put2_8 (height, dest, ref, stride, 1, CPU_3DNOW);
952 0 }
953  
954 0 static void MC_avg_y_16_3dnow (uint8_t * dest, const uint8_t * ref,
955 int stride, int height)
956 {
957 0 MC_avg2_16 (height, dest, ref, stride, stride, CPU_3DNOW);
958 0 }
959  
960 0 static void MC_avg_y_8_3dnow (uint8_t * dest, const uint8_t * ref,
961 int stride, int height)
962 {
963 0 MC_avg2_8 (height, dest, ref, stride, stride, CPU_3DNOW);
964 0 }
965  
966 0 static void MC_put_y_16_3dnow (uint8_t * dest, const uint8_t * ref,
967 int stride, int height)
968 {
969 0 MC_put2_16 (height, dest, ref, stride, stride, CPU_3DNOW);
970 0 }
971  
972 0 static void MC_put_y_8_3dnow (uint8_t * dest, const uint8_t * ref,
973 int stride, int height)
974 {
975 0 MC_put2_8 (height, dest, ref, stride, stride, CPU_3DNOW);
976 0 }
977  
978 0 static void MC_avg_xy_16_3dnow (uint8_t * dest, const uint8_t * ref,
979 int stride, int height)
980 {
981 0 MC_avg4_16 (height, dest, ref, stride, CPU_3DNOW);
982 0 }
983  
984 0 static void MC_avg_xy_8_3dnow (uint8_t * dest, const uint8_t * ref,
985 int stride, int height)
986 {
987 0 MC_avg4_8 (height, dest, ref, stride, CPU_3DNOW);
988 0 }
989  
990 0 static void MC_put_xy_16_3dnow (uint8_t * dest, const uint8_t * ref,
991 int stride, int height)
992 {
993 0 MC_put4_16 (height, dest, ref, stride, CPU_3DNOW);
994 0 }
995  
996 0 static void MC_put_xy_8_3dnow (uint8_t * dest, const uint8_t * ref,
997 int stride, int height)
998 {
999 0 MC_put4_8 (height, dest, ref, stride, CPU_3DNOW);
1000 0 }
1001  
1002  
1003 MPEG2_MC_EXTERN (3dnow)
1004  
1005 #endif
« clib/libmpeg2/motion_comp.c ↑ Summary clib/libmpeg2/slice.c »