Go to the documentation of this file.
39 #define PREFETCH "prefetchnta"
41 #define MOVNTQ "movntq"
42 #define SFENCE "sfence"
46 #if !COMPILE_TEMPLATE_SSE2
51 const uint8_t *
s =
src;
53 const uint8_t *mm_end;
57 __asm__ volatile(
"movq %0, %%mm7"::
"m"(mask32a):
"memory");
61 "movd (%1), %%mm0 \n\t"
62 "punpckldq 3(%1), %%mm0 \n\t"
63 "movd 6(%1), %%mm1 \n\t"
64 "punpckldq 9(%1), %%mm1 \n\t"
65 "movd 12(%1), %%mm2 \n\t"
66 "punpckldq 15(%1), %%mm2 \n\t"
67 "movd 18(%1), %%mm3 \n\t"
68 "punpckldq 21(%1), %%mm3 \n\t"
69 "por %%mm7, %%mm0 \n\t"
70 "por %%mm7, %%mm1 \n\t"
71 "por %%mm7, %%mm2 \n\t"
72 "por %%mm7, %%mm3 \n\t"
75 MOVNTQ" %%mm2, 16(%0) \n\t"
92 #define STORE_BGR24_MMX \
93 "psrlq $8, %%mm2 \n\t" \
94 "psrlq $8, %%mm3 \n\t" \
95 "psrlq $8, %%mm6 \n\t" \
96 "psrlq $8, %%mm7 \n\t" \
97 "pand "MANGLE(mask24l)", %%mm0\n\t" \
98 "pand "MANGLE(mask24l)", %%mm1\n\t" \
99 "pand "MANGLE(mask24l)", %%mm4\n\t" \
100 "pand "MANGLE(mask24l)", %%mm5\n\t" \
101 "pand "MANGLE(mask24h)", %%mm2\n\t" \
102 "pand "MANGLE(mask24h)", %%mm3\n\t" \
103 "pand "MANGLE(mask24h)", %%mm6\n\t" \
104 "pand "MANGLE(mask24h)", %%mm7\n\t" \
105 "por %%mm2, %%mm0 \n\t" \
106 "por %%mm3, %%mm1 \n\t" \
107 "por %%mm6, %%mm4 \n\t" \
108 "por %%mm7, %%mm5 \n\t" \
110 "movq %%mm1, %%mm2 \n\t" \
111 "movq %%mm4, %%mm3 \n\t" \
112 "psllq $48, %%mm2 \n\t" \
113 "psllq $32, %%mm3 \n\t" \
114 "por %%mm2, %%mm0 \n\t" \
115 "psrlq $16, %%mm1 \n\t" \
116 "psrlq $32, %%mm4 \n\t" \
117 "psllq $16, %%mm5 \n\t" \
118 "por %%mm3, %%mm1 \n\t" \
119 "por %%mm5, %%mm4 \n\t" \
121 MOVNTQ" %%mm0, (%0) \n\t" \
122 MOVNTQ" %%mm1, 8(%0) \n\t" \
123 MOVNTQ" %%mm4, 16(%0)"
129 const uint8_t *
s =
src;
131 const uint8_t *mm_end;
138 "movq (%1), %%mm0 \n\t"
139 "movq 8(%1), %%mm1 \n\t"
140 "movq 16(%1), %%mm4 \n\t"
141 "movq 24(%1), %%mm5 \n\t"
142 "movq %%mm0, %%mm2 \n\t"
143 "movq %%mm1, %%mm3 \n\t"
144 "movq %%mm4, %%mm6 \n\t"
145 "movq %%mm5, %%mm7 \n\t"
171 register const uint8_t*
s=
src;
172 register uint8_t*
d=dst;
173 register const uint8_t *end;
174 const uint8_t *mm_end;
177 __asm__ volatile(
"movq %0, %%mm4"::
"m"(mask15s));
182 "movq (%1), %%mm0 \n\t"
183 "movq 8(%1), %%mm2 \n\t"
184 "movq %%mm0, %%mm1 \n\t"
185 "movq %%mm2, %%mm3 \n\t"
186 "pand %%mm4, %%mm0 \n\t"
187 "pand %%mm4, %%mm2 \n\t"
188 "paddw %%mm1, %%mm0 \n\t"
189 "paddw %%mm3, %%mm2 \n\t"
201 register unsigned x= *((
const uint32_t *)
s);
202 *((uint32_t *)
d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
207 register unsigned short x= *((
const uint16_t *)
s);
208 *((uint16_t *)
d) = (x&0x7FFF) + (x&0x7FE0);
214 register const uint8_t*
s=
src;
215 register uint8_t*
d=dst;
216 register const uint8_t *end;
217 const uint8_t *mm_end;
220 __asm__ volatile(
"movq %0, %%mm7"::
"m"(mask15rg));
221 __asm__ volatile(
"movq %0, %%mm6"::
"m"(mask15b));
226 "movq (%1), %%mm0 \n\t"
227 "movq 8(%1), %%mm2 \n\t"
228 "movq %%mm0, %%mm1 \n\t"
229 "movq %%mm2, %%mm3 \n\t"
230 "psrlq $1, %%mm0 \n\t"
231 "psrlq $1, %%mm2 \n\t"
232 "pand %%mm7, %%mm0 \n\t"
233 "pand %%mm7, %%mm2 \n\t"
234 "pand %%mm6, %%mm1 \n\t"
235 "pand %%mm6, %%mm3 \n\t"
236 "por %%mm1, %%mm0 \n\t"
237 "por %%mm3, %%mm2 \n\t"
249 register uint32_t x= *((
const uint32_t*)
s);
250 *((uint32_t *)
d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F);
255 register uint16_t x= *((
const uint16_t*)
s);
256 *((uint16_t *)
d) = ((x>>1)&0x7FE0) | (x&0x001F);
262 const uint8_t *
s =
src;
264 const uint8_t *mm_end;
265 uint16_t *
d = (uint16_t *)dst;
269 "movq %3, %%mm5 \n\t"
270 "movq %4, %%mm6 \n\t"
271 "movq %5, %%mm7 \n\t"
276 "movd (%1), %%mm0 \n\t"
277 "movd 4(%1), %%mm3 \n\t"
278 "punpckldq 8(%1), %%mm0 \n\t"
279 "punpckldq 12(%1), %%mm3 \n\t"
280 "movq %%mm0, %%mm1 \n\t"
281 "movq %%mm3, %%mm4 \n\t"
282 "pand %%mm6, %%mm0 \n\t"
283 "pand %%mm6, %%mm3 \n\t"
284 "pmaddwd %%mm7, %%mm0 \n\t"
285 "pmaddwd %%mm7, %%mm3 \n\t"
286 "pand %%mm5, %%mm1 \n\t"
287 "pand %%mm5, %%mm4 \n\t"
288 "por %%mm1, %%mm0 \n\t"
289 "por %%mm4, %%mm3 \n\t"
290 "psrld $5, %%mm0 \n\t"
291 "pslld $11, %%mm3 \n\t"
292 "por %%mm3, %%mm0 \n\t"
300 :
"r" (mm_end),
"m" (mask3216g),
"m" (mask3216br),
"m" (mul3216)
305 register int rgb = *(
const uint32_t*)
s;
s += 4;
306 *
d++ = ((
rgb&0xFF)>>3) + ((
rgb&0xFC00)>>5) + ((
rgb&0xF80000)>>8);
312 const uint8_t *
s =
src;
314 const uint8_t *mm_end;
315 uint16_t *
d = (uint16_t *)dst;
319 "movq %0, %%mm7 \n\t"
320 "movq %1, %%mm6 \n\t"
321 ::
"m"(red_16mask),
"m"(green_16mask));
326 "movd (%1), %%mm0 \n\t"
327 "movd 4(%1), %%mm3 \n\t"
328 "punpckldq 8(%1), %%mm0 \n\t"
329 "punpckldq 12(%1), %%mm3 \n\t"
330 "movq %%mm0, %%mm1 \n\t"
331 "movq %%mm0, %%mm2 \n\t"
332 "movq %%mm3, %%mm4 \n\t"
333 "movq %%mm3, %%mm5 \n\t"
334 "psllq $8, %%mm0 \n\t"
335 "psllq $8, %%mm3 \n\t"
336 "pand %%mm7, %%mm0 \n\t"
337 "pand %%mm7, %%mm3 \n\t"
338 "psrlq $5, %%mm1 \n\t"
339 "psrlq $5, %%mm4 \n\t"
340 "pand %%mm6, %%mm1 \n\t"
341 "pand %%mm6, %%mm4 \n\t"
342 "psrlq $19, %%mm2 \n\t"
343 "psrlq $19, %%mm5 \n\t"
344 "pand %2, %%mm2 \n\t"
345 "pand %2, %%mm5 \n\t"
346 "por %%mm1, %%mm0 \n\t"
347 "por %%mm4, %%mm3 \n\t"
348 "por %%mm2, %%mm0 \n\t"
349 "por %%mm5, %%mm3 \n\t"
350 "psllq $16, %%mm3 \n\t"
351 "por %%mm3, %%mm0 \n\t"
353 ::
"r"(
d),
"r"(
s),
"m"(blue_16mask):
"memory");
360 register int rgb = *(
const uint32_t*)
s;
s += 4;
361 *
d++ = ((
rgb&0xF8)<<8) + ((
rgb&0xFC00)>>5) + ((
rgb&0xF80000)>>19);
367 const uint8_t *
s =
src;
369 const uint8_t *mm_end;
370 uint16_t *
d = (uint16_t *)dst;
374 "movq %3, %%mm5 \n\t"
375 "movq %4, %%mm6 \n\t"
376 "movq %5, %%mm7 \n\t"
381 "movd (%1), %%mm0 \n\t"
382 "movd 4(%1), %%mm3 \n\t"
383 "punpckldq 8(%1), %%mm0 \n\t"
384 "punpckldq 12(%1), %%mm3 \n\t"
385 "movq %%mm0, %%mm1 \n\t"
386 "movq %%mm3, %%mm4 \n\t"
387 "pand %%mm6, %%mm0 \n\t"
388 "pand %%mm6, %%mm3 \n\t"
389 "pmaddwd %%mm7, %%mm0 \n\t"
390 "pmaddwd %%mm7, %%mm3 \n\t"
391 "pand %%mm5, %%mm1 \n\t"
392 "pand %%mm5, %%mm4 \n\t"
393 "por %%mm1, %%mm0 \n\t"
394 "por %%mm4, %%mm3 \n\t"
395 "psrld $6, %%mm0 \n\t"
396 "pslld $10, %%mm3 \n\t"
397 "por %%mm3, %%mm0 \n\t"
405 :
"r" (mm_end),
"m" (mask3215g),
"m" (mask3216br),
"m" (mul3215)
410 register int rgb = *(
const uint32_t*)
s;
s += 4;
411 *
d++ = ((
rgb&0xFF)>>3) + ((
rgb&0xF800)>>6) + ((
rgb&0xF80000)>>9);
417 const uint8_t *
s =
src;
419 const uint8_t *mm_end;
420 uint16_t *
d = (uint16_t *)dst;
424 "movq %0, %%mm7 \n\t"
425 "movq %1, %%mm6 \n\t"
426 ::
"m"(red_15mask),
"m"(green_15mask));
431 "movd (%1), %%mm0 \n\t"
432 "movd 4(%1), %%mm3 \n\t"
433 "punpckldq 8(%1), %%mm0 \n\t"
434 "punpckldq 12(%1), %%mm3 \n\t"
435 "movq %%mm0, %%mm1 \n\t"
436 "movq %%mm0, %%mm2 \n\t"
437 "movq %%mm3, %%mm4 \n\t"
438 "movq %%mm3, %%mm5 \n\t"
439 "psllq $7, %%mm0 \n\t"
440 "psllq $7, %%mm3 \n\t"
441 "pand %%mm7, %%mm0 \n\t"
442 "pand %%mm7, %%mm3 \n\t"
443 "psrlq $6, %%mm1 \n\t"
444 "psrlq $6, %%mm4 \n\t"
445 "pand %%mm6, %%mm1 \n\t"
446 "pand %%mm6, %%mm4 \n\t"
447 "psrlq $19, %%mm2 \n\t"
448 "psrlq $19, %%mm5 \n\t"
449 "pand %2, %%mm2 \n\t"
450 "pand %2, %%mm5 \n\t"
451 "por %%mm1, %%mm0 \n\t"
452 "por %%mm4, %%mm3 \n\t"
453 "por %%mm2, %%mm0 \n\t"
454 "por %%mm5, %%mm3 \n\t"
455 "psllq $16, %%mm3 \n\t"
456 "por %%mm3, %%mm0 \n\t"
458 ::
"r"(
d),
"r"(
s),
"m"(blue_15mask):
"memory");
465 register int rgb = *(
const uint32_t*)
s;
s += 4;
466 *
d++ = ((
rgb&0xF8)<<7) + ((
rgb&0xF800)>>6) + ((
rgb&0xF80000)>>19);
472 const uint8_t *
s =
src;
474 const uint8_t *mm_end;
475 uint16_t *
d = (uint16_t *)dst;
479 "movq %0, %%mm7 \n\t"
480 "movq %1, %%mm6 \n\t"
481 ::
"m"(red_16mask),
"m"(green_16mask));
486 "movd (%1), %%mm0 \n\t"
487 "movd 3(%1), %%mm3 \n\t"
488 "punpckldq 6(%1), %%mm0 \n\t"
489 "punpckldq 9(%1), %%mm3 \n\t"
490 "movq %%mm0, %%mm1 \n\t"
491 "movq %%mm0, %%mm2 \n\t"
492 "movq %%mm3, %%mm4 \n\t"
493 "movq %%mm3, %%mm5 \n\t"
494 "psrlq $3, %%mm0 \n\t"
495 "psrlq $3, %%mm3 \n\t"
496 "pand %2, %%mm0 \n\t"
497 "pand %2, %%mm3 \n\t"
498 "psrlq $5, %%mm1 \n\t"
499 "psrlq $5, %%mm4 \n\t"
500 "pand %%mm6, %%mm1 \n\t"
501 "pand %%mm6, %%mm4 \n\t"
502 "psrlq $8, %%mm2 \n\t"
503 "psrlq $8, %%mm5 \n\t"
504 "pand %%mm7, %%mm2 \n\t"
505 "pand %%mm7, %%mm5 \n\t"
506 "por %%mm1, %%mm0 \n\t"
507 "por %%mm4, %%mm3 \n\t"
508 "por %%mm2, %%mm0 \n\t"
509 "por %%mm5, %%mm3 \n\t"
510 "psllq $16, %%mm3 \n\t"
511 "por %%mm3, %%mm0 \n\t"
513 ::
"r"(
d),
"r"(
s),
"m"(blue_16mask):
"memory");
523 *
d++ = (
b>>3) | ((
g&0xFC)<<3) | ((
r&0xF8)<<8);
529 const uint8_t *
s =
src;
531 const uint8_t *mm_end;
532 uint16_t *
d = (uint16_t *)dst;
536 "movq %0, %%mm7 \n\t"
537 "movq %1, %%mm6 \n\t"
538 ::
"m"(red_16mask),
"m"(green_16mask));
543 "movd (%1), %%mm0 \n\t"
544 "movd 3(%1), %%mm3 \n\t"
545 "punpckldq 6(%1), %%mm0 \n\t"
546 "punpckldq 9(%1), %%mm3 \n\t"
547 "movq %%mm0, %%mm1 \n\t"
548 "movq %%mm0, %%mm2 \n\t"
549 "movq %%mm3, %%mm4 \n\t"
550 "movq %%mm3, %%mm5 \n\t"
551 "psllq $8, %%mm0 \n\t"
552 "psllq $8, %%mm3 \n\t"
553 "pand %%mm7, %%mm0 \n\t"
554 "pand %%mm7, %%mm3 \n\t"
555 "psrlq $5, %%mm1 \n\t"
556 "psrlq $5, %%mm4 \n\t"
557 "pand %%mm6, %%mm1 \n\t"
558 "pand %%mm6, %%mm4 \n\t"
559 "psrlq $19, %%mm2 \n\t"
560 "psrlq $19, %%mm5 \n\t"
561 "pand %2, %%mm2 \n\t"
562 "pand %2, %%mm5 \n\t"
563 "por %%mm1, %%mm0 \n\t"
564 "por %%mm4, %%mm3 \n\t"
565 "por %%mm2, %%mm0 \n\t"
566 "por %%mm5, %%mm3 \n\t"
567 "psllq $16, %%mm3 \n\t"
568 "por %%mm3, %%mm0 \n\t"
570 ::
"r"(
d),
"r"(
s),
"m"(blue_16mask):
"memory");
580 *
d++ = (
b>>3) | ((
g&0xFC)<<3) | ((
r&0xF8)<<8);
586 const uint8_t *
s =
src;
588 const uint8_t *mm_end;
589 uint16_t *
d = (uint16_t *)dst;
593 "movq %0, %%mm7 \n\t"
594 "movq %1, %%mm6 \n\t"
595 ::
"m"(red_15mask),
"m"(green_15mask));
600 "movd (%1), %%mm0 \n\t"
601 "movd 3(%1), %%mm3 \n\t"
602 "punpckldq 6(%1), %%mm0 \n\t"
603 "punpckldq 9(%1), %%mm3 \n\t"
604 "movq %%mm0, %%mm1 \n\t"
605 "movq %%mm0, %%mm2 \n\t"
606 "movq %%mm3, %%mm4 \n\t"
607 "movq %%mm3, %%mm5 \n\t"
608 "psrlq $3, %%mm0 \n\t"
609 "psrlq $3, %%mm3 \n\t"
610 "pand %2, %%mm0 \n\t"
611 "pand %2, %%mm3 \n\t"
612 "psrlq $6, %%mm1 \n\t"
613 "psrlq $6, %%mm4 \n\t"
614 "pand %%mm6, %%mm1 \n\t"
615 "pand %%mm6, %%mm4 \n\t"
616 "psrlq $9, %%mm2 \n\t"
617 "psrlq $9, %%mm5 \n\t"
618 "pand %%mm7, %%mm2 \n\t"
619 "pand %%mm7, %%mm5 \n\t"
620 "por %%mm1, %%mm0 \n\t"
621 "por %%mm4, %%mm3 \n\t"
622 "por %%mm2, %%mm0 \n\t"
623 "por %%mm5, %%mm3 \n\t"
624 "psllq $16, %%mm3 \n\t"
625 "por %%mm3, %%mm0 \n\t"
627 ::
"r"(
d),
"r"(
s),
"m"(blue_15mask):
"memory");
637 *
d++ = (
b>>3) | ((
g&0xF8)<<2) | ((
r&0xF8)<<7);
643 const uint8_t *
s =
src;
645 const uint8_t *mm_end;
646 uint16_t *
d = (uint16_t *)dst;
650 "movq %0, %%mm7 \n\t"
651 "movq %1, %%mm6 \n\t"
652 ::
"m"(red_15mask),
"m"(green_15mask));
657 "movd (%1), %%mm0 \n\t"
658 "movd 3(%1), %%mm3 \n\t"
659 "punpckldq 6(%1), %%mm0 \n\t"
660 "punpckldq 9(%1), %%mm3 \n\t"
661 "movq %%mm0, %%mm1 \n\t"
662 "movq %%mm0, %%mm2 \n\t"
663 "movq %%mm3, %%mm4 \n\t"
664 "movq %%mm3, %%mm5 \n\t"
665 "psllq $7, %%mm0 \n\t"
666 "psllq $7, %%mm3 \n\t"
667 "pand %%mm7, %%mm0 \n\t"
668 "pand %%mm7, %%mm3 \n\t"
669 "psrlq $6, %%mm1 \n\t"
670 "psrlq $6, %%mm4 \n\t"
671 "pand %%mm6, %%mm1 \n\t"
672 "pand %%mm6, %%mm4 \n\t"
673 "psrlq $19, %%mm2 \n\t"
674 "psrlq $19, %%mm5 \n\t"
675 "pand %2, %%mm2 \n\t"
676 "pand %2, %%mm5 \n\t"
677 "por %%mm1, %%mm0 \n\t"
678 "por %%mm4, %%mm3 \n\t"
679 "por %%mm2, %%mm0 \n\t"
680 "por %%mm5, %%mm3 \n\t"
681 "psllq $16, %%mm3 \n\t"
682 "por %%mm3, %%mm0 \n\t"
684 ::
"r"(
d),
"r"(
s),
"m"(blue_15mask):
"memory");
694 *
d++ = (
b>>3) | ((
g&0xF8)<<2) | ((
r&0xF8)<<7);
701 const uint16_t *mm_end;
703 const uint16_t *
s = (
const uint16_t*)
src;
704 end =
s + src_size/2;
710 "movq (%1), %%mm0 \n\t"
711 "movq (%1), %%mm1 \n\t"
712 "movq (%1), %%mm2 \n\t"
713 "pand %2, %%mm0 \n\t"
714 "pand %3, %%mm1 \n\t"
715 "pand %4, %%mm2 \n\t"
716 "psllq $5, %%mm0 \n\t"
717 "pmulhw "MANGLE(mul15_mid)
", %%mm0 \n\t"
718 "pmulhw "MANGLE(mul15_mid)
", %%mm1 \n\t"
719 "pmulhw "MANGLE(mul15_hi)
", %%mm2 \n\t"
720 "movq %%mm0, %%mm3 \n\t"
721 "movq %%mm1, %%mm4 \n\t"
722 "movq %%mm2, %%mm5 \n\t"
723 "punpcklwd %5, %%mm0 \n\t"
724 "punpcklwd %5, %%mm1 \n\t"
725 "punpcklwd %5, %%mm2 \n\t"
726 "punpckhwd %5, %%mm3 \n\t"
727 "punpckhwd %5, %%mm4 \n\t"
728 "punpckhwd %5, %%mm5 \n\t"
729 "psllq $8, %%mm1 \n\t"
730 "psllq $16, %%mm2 \n\t"
731 "por %%mm1, %%mm0 \n\t"
732 "por %%mm2, %%mm0 \n\t"
733 "psllq $8, %%mm4 \n\t"
734 "psllq $16, %%mm5 \n\t"
735 "por %%mm4, %%mm3 \n\t"
736 "por %%mm5, %%mm3 \n\t"
738 "movq %%mm0, %%mm6 \n\t"
739 "movq %%mm3, %%mm7 \n\t"
741 "movq 8(%1), %%mm0 \n\t"
742 "movq 8(%1), %%mm1 \n\t"
743 "movq 8(%1), %%mm2 \n\t"
744 "pand %2, %%mm0 \n\t"
745 "pand %3, %%mm1 \n\t"
746 "pand %4, %%mm2 \n\t"
747 "psllq $5, %%mm0 \n\t"
748 "pmulhw "MANGLE(mul15_mid)
", %%mm0 \n\t"
749 "pmulhw "MANGLE(mul15_mid)
", %%mm1 \n\t"
750 "pmulhw "MANGLE(mul15_hi)
", %%mm2 \n\t"
751 "movq %%mm0, %%mm3 \n\t"
752 "movq %%mm1, %%mm4 \n\t"
753 "movq %%mm2, %%mm5 \n\t"
754 "punpcklwd %5, %%mm0 \n\t"
755 "punpcklwd %5, %%mm1 \n\t"
756 "punpcklwd %5, %%mm2 \n\t"
757 "punpckhwd %5, %%mm3 \n\t"
758 "punpckhwd %5, %%mm4 \n\t"
759 "punpckhwd %5, %%mm5 \n\t"
760 "psllq $8, %%mm1 \n\t"
761 "psllq $16, %%mm2 \n\t"
762 "por %%mm1, %%mm0 \n\t"
763 "por %%mm2, %%mm0 \n\t"
764 "psllq $8, %%mm4 \n\t"
765 "psllq $16, %%mm5 \n\t"
766 "por %%mm4, %%mm3 \n\t"
767 "por %%mm5, %%mm3 \n\t"
770 :
"r"(
s),
"m"(mask15b),
"m"(mask15g),
"m"(mask15r),
"m"(mmx_null)
775 "movq %%mm0, %%mm4 \n\t"
776 "movq %%mm3, %%mm5 \n\t"
777 "movq %%mm6, %%mm0 \n\t"
778 "movq %%mm7, %%mm1 \n\t"
780 "movq %%mm4, %%mm6 \n\t"
781 "movq %%mm5, %%mm7 \n\t"
782 "movq %%mm0, %%mm2 \n\t"
783 "movq %%mm1, %%mm3 \n\t"
796 register uint16_t bgr;
798 *
d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
799 *
d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
800 *
d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
807 const uint16_t *mm_end;
808 uint8_t *
d = (uint8_t *)dst;
809 const uint16_t *
s = (
const uint16_t *)
src;
810 end =
s + src_size/2;
816 "movq (%1), %%mm0 \n\t"
817 "movq (%1), %%mm1 \n\t"
818 "movq (%1), %%mm2 \n\t"
819 "pand %2, %%mm0 \n\t"
820 "pand %3, %%mm1 \n\t"
821 "pand %4, %%mm2 \n\t"
822 "psllq $5, %%mm0 \n\t"
823 "psrlq $1, %%mm2 \n\t"
824 "pmulhw "MANGLE(mul15_mid)
", %%mm0 \n\t"
825 "pmulhw "MANGLE(mul16_mid)
", %%mm1 \n\t"
826 "pmulhw "MANGLE(mul15_hi)
", %%mm2 \n\t"
827 "movq %%mm0, %%mm3 \n\t"
828 "movq %%mm1, %%mm4 \n\t"
829 "movq %%mm2, %%mm5 \n\t"
830 "punpcklwd %5, %%mm0 \n\t"
831 "punpcklwd %5, %%mm1 \n\t"
832 "punpcklwd %5, %%mm2 \n\t"
833 "punpckhwd %5, %%mm3 \n\t"
834 "punpckhwd %5, %%mm4 \n\t"
835 "punpckhwd %5, %%mm5 \n\t"
836 "psllq $8, %%mm1 \n\t"
837 "psllq $16, %%mm2 \n\t"
838 "por %%mm1, %%mm0 \n\t"
839 "por %%mm2, %%mm0 \n\t"
840 "psllq $8, %%mm4 \n\t"
841 "psllq $16, %%mm5 \n\t"
842 "por %%mm4, %%mm3 \n\t"
843 "por %%mm5, %%mm3 \n\t"
845 "movq %%mm0, %%mm6 \n\t"
846 "movq %%mm3, %%mm7 \n\t"
848 "movq 8(%1), %%mm0 \n\t"
849 "movq 8(%1), %%mm1 \n\t"
850 "movq 8(%1), %%mm2 \n\t"
851 "pand %2, %%mm0 \n\t"
852 "pand %3, %%mm1 \n\t"
853 "pand %4, %%mm2 \n\t"
854 "psllq $5, %%mm0 \n\t"
855 "psrlq $1, %%mm2 \n\t"
856 "pmulhw "MANGLE(mul15_mid)
", %%mm0 \n\t"
857 "pmulhw "MANGLE(mul16_mid)
", %%mm1 \n\t"
858 "pmulhw "MANGLE(mul15_hi)
", %%mm2 \n\t"
859 "movq %%mm0, %%mm3 \n\t"
860 "movq %%mm1, %%mm4 \n\t"
861 "movq %%mm2, %%mm5 \n\t"
862 "punpcklwd %5, %%mm0 \n\t"
863 "punpcklwd %5, %%mm1 \n\t"
864 "punpcklwd %5, %%mm2 \n\t"
865 "punpckhwd %5, %%mm3 \n\t"
866 "punpckhwd %5, %%mm4 \n\t"
867 "punpckhwd %5, %%mm5 \n\t"
868 "psllq $8, %%mm1 \n\t"
869 "psllq $16, %%mm2 \n\t"
870 "por %%mm1, %%mm0 \n\t"
871 "por %%mm2, %%mm0 \n\t"
872 "psllq $8, %%mm4 \n\t"
873 "psllq $16, %%mm5 \n\t"
874 "por %%mm4, %%mm3 \n\t"
875 "por %%mm5, %%mm3 \n\t"
877 :
"r"(
s),
"m"(mask16b),
"m"(mask16g),
"m"(mask16r),
"m"(mmx_null)
882 "movq %%mm0, %%mm4 \n\t"
883 "movq %%mm3, %%mm5 \n\t"
884 "movq %%mm6, %%mm0 \n\t"
885 "movq %%mm7, %%mm1 \n\t"
887 "movq %%mm4, %%mm6 \n\t"
888 "movq %%mm5, %%mm7 \n\t"
889 "movq %%mm0, %%mm2 \n\t"
890 "movq %%mm1, %%mm3 \n\t"
903 register uint16_t bgr;
905 *
d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
906 *
d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
907 *
d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
919 "packuswb %%mm7, %%mm0 \n\t" \
920 "packuswb %%mm7, %%mm1 \n\t" \
921 "packuswb %%mm7, %%mm2 \n\t" \
922 "punpcklbw %%mm1, %%mm0 \n\t" \
923 "punpcklbw %%mm6, %%mm2 \n\t" \
924 "movq %%mm0, %%mm3 \n\t" \
925 "punpcklwd %%mm2, %%mm0 \n\t" \
926 "punpckhwd %%mm2, %%mm3 \n\t" \
927 MOVNTQ" %%mm0, (%0) \n\t" \
928 MOVNTQ" %%mm3, 8(%0) \n\t" \
933 const uint16_t *mm_end;
935 const uint16_t *
s = (
const uint16_t *)
src;
936 end =
s + src_size/2;
938 __asm__ volatile(
"pxor %%mm7,%%mm7 \n\t":::
"memory");
939 __asm__ volatile(
"pcmpeqd %%mm6,%%mm6 \n\t":::
"memory");
944 "movq (%1), %%mm0 \n\t"
945 "movq (%1), %%mm1 \n\t"
946 "movq (%1), %%mm2 \n\t"
947 "pand %2, %%mm0 \n\t"
948 "pand %3, %%mm1 \n\t"
949 "pand %4, %%mm2 \n\t"
950 "psllq $5, %%mm0 \n\t"
951 "pmulhw %5, %%mm0 \n\t"
952 "pmulhw %5, %%mm1 \n\t"
953 "pmulhw "MANGLE(mul15_hi)
", %%mm2 \n\t"
955 ::
"r"(
d),
"r"(
s),
"m"(mask15b),
"m"(mask15g),
"m"(mask15r) ,
"m"(mul15_mid)
964 register uint16_t bgr;
966 *
d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
967 *
d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
968 *
d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
976 const uint16_t *mm_end;
978 const uint16_t *
s = (
const uint16_t*)
src;
979 end =
s + src_size/2;
981 __asm__ volatile(
"pxor %%mm7,%%mm7 \n\t":::
"memory");
982 __asm__ volatile(
"pcmpeqd %%mm6,%%mm6 \n\t":::
"memory");
987 "movq (%1), %%mm0 \n\t"
988 "movq (%1), %%mm1 \n\t"
989 "movq (%1), %%mm2 \n\t"
990 "pand %2, %%mm0 \n\t"
991 "pand %3, %%mm1 \n\t"
992 "pand %4, %%mm2 \n\t"
993 "psllq $5, %%mm0 \n\t"
994 "psrlq $1, %%mm2 \n\t"
995 "pmulhw %5, %%mm0 \n\t"
996 "pmulhw "MANGLE(mul16_mid)
", %%mm1 \n\t"
997 "pmulhw "MANGLE(mul15_hi)
", %%mm2 \n\t"
999 ::
"r"(
d),
"r"(
s),
"m"(mask16b),
"m"(mask16g),
"m"(mask16r),
"m"(mul15_mid)
1008 register uint16_t bgr;
1010 *
d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
1011 *
d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
1012 *
d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
1020 x86_reg mmx_size= 23 - src_size;
1022 "test %%"FF_REG_a
", %%"FF_REG_a
" \n\t"
1024 "movq "MANGLE(mask24r)
", %%mm5 \n\t"
1025 "movq "MANGLE(mask24g)
", %%mm6 \n\t"
1026 "movq "MANGLE(mask24b)
", %%mm7 \n\t"
1029 PREFETCH" 32(%1, %%"FF_REG_a
") \n\t"
1030 "movq (%1, %%"FF_REG_a
"), %%mm0 \n\t"
1031 "movq (%1, %%"FF_REG_a
"), %%mm1 \n\t"
1032 "movq 2(%1, %%"FF_REG_a
"), %%mm2 \n\t"
1033 "psllq $16, %%mm0 \n\t"
1034 "pand %%mm5, %%mm0 \n\t"
1035 "pand %%mm6, %%mm1 \n\t"
1036 "pand %%mm7, %%mm2 \n\t"
1037 "por %%mm0, %%mm1 \n\t"
1038 "por %%mm2, %%mm1 \n\t"
1039 "movq 6(%1, %%"FF_REG_a
"), %%mm0 \n\t"
1040 MOVNTQ" %%mm1,(%2, %%"FF_REG_a
") \n\t"
1041 "movq 8(%1, %%"FF_REG_a
"), %%mm1 \n\t"
1042 "movq 10(%1, %%"FF_REG_a
"), %%mm2 \n\t"
1043 "pand %%mm7, %%mm0 \n\t"
1044 "pand %%mm5, %%mm1 \n\t"
1045 "pand %%mm6, %%mm2 \n\t"
1046 "por %%mm0, %%mm1 \n\t"
1047 "por %%mm2, %%mm1 \n\t"
1048 "movq 14(%1, %%"FF_REG_a
"), %%mm0 \n\t"
1049 MOVNTQ" %%mm1, 8(%2, %%"FF_REG_a
")\n\t"
1050 "movq 16(%1, %%"FF_REG_a
"), %%mm1 \n\t"
1051 "movq 18(%1, %%"FF_REG_a
"), %%mm2 \n\t"
1052 "pand %%mm6, %%mm0 \n\t"
1053 "pand %%mm7, %%mm1 \n\t"
1054 "pand %%mm5, %%mm2 \n\t"
1055 "por %%mm0, %%mm1 \n\t"
1056 "por %%mm2, %%mm1 \n\t"
1057 MOVNTQ" %%mm1, 16(%2, %%"FF_REG_a
") \n\t"
1058 "add $24, %%"FF_REG_a
" \n\t"
1062 :
"r" (
src-mmx_size),
"r"(dst-mmx_size)
1069 if (mmx_size==23)
return;
1073 src_size= 23-mmx_size;
1076 for (
i=0;
i<src_size;
i+=3) {
1079 dst[
i + 1] =
src[
i + 1];
1080 dst[
i + 2] =
src[
i + 0];
1085 static inline void RENAME(yuvPlanartoyuy2)(
const uint8_t *ysrc,
const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
1087 int lumStride,
int chromStride,
int dstStride,
int vertLumPerChroma)
1091 for (y=0; y<
height; y++) {
1094 "xor %%"FF_REG_a
", %%"FF_REG_a
" \n\t"
1097 PREFETCH" 32(%1, %%"FF_REG_a
", 2) \n\t"
1098 PREFETCH" 32(%2, %%"FF_REG_a
") \n\t"
1099 PREFETCH" 32(%3, %%"FF_REG_a
") \n\t"
1100 "movq (%2, %%"FF_REG_a
"), %%mm0 \n\t"
1101 "movq %%mm0, %%mm2 \n\t"
1102 "movq (%3, %%"FF_REG_a
"), %%mm1 \n\t"
1103 "punpcklbw %%mm1, %%mm0 \n\t"
1104 "punpckhbw %%mm1, %%mm2 \n\t"
1106 "movq (%1, %%"FF_REG_a
",2), %%mm3 \n\t"
1107 "movq 8(%1, %%"FF_REG_a
",2), %%mm5 \n\t"
1108 "movq %%mm3, %%mm4 \n\t"
1109 "movq %%mm5, %%mm6 \n\t"
1110 "punpcklbw %%mm0, %%mm3 \n\t"
1111 "punpckhbw %%mm0, %%mm4 \n\t"
1112 "punpcklbw %%mm2, %%mm5 \n\t"
1113 "punpckhbw %%mm2, %%mm6 \n\t"
1115 MOVNTQ" %%mm3, (%0, %%"FF_REG_a
", 4) \n\t"
1116 MOVNTQ" %%mm4, 8(%0, %%"FF_REG_a
", 4) \n\t"
1117 MOVNTQ" %%mm5, 16(%0, %%"FF_REG_a
", 4) \n\t"
1118 MOVNTQ" %%mm6, 24(%0, %%"FF_REG_a
", 4) \n\t"
1120 "add $8, %%"FF_REG_a
" \n\t"
1121 "cmp %4, %%"FF_REG_a
" \n\t"
1123 ::
"r"(dst),
"r"(ysrc),
"r"(usrc),
"r"(vsrc),
"g" (chromWidth)
1126 if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
1127 usrc += chromStride;
1128 vsrc += chromStride;
1142 static inline void RENAME(
yv12toyuy2)(
const uint8_t *ysrc,
const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
1144 int lumStride,
int chromStride,
int dstStride)
1147 RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst,
width,
height, lumStride, chromStride, dstStride, 2);
1150 static inline void RENAME(yuvPlanartouyvy)(
const uint8_t *ysrc,
const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
1152 int lumStride,
int chromStride,
int dstStride,
int vertLumPerChroma)
1156 for (y=0; y<
height; y++) {
1159 "xor %%"FF_REG_a
", %%"FF_REG_a
" \n\t"
1162 PREFETCH" 32(%1, %%"FF_REG_a
", 2) \n\t"
1163 PREFETCH" 32(%2, %%"FF_REG_a
") \n\t"
1164 PREFETCH" 32(%3, %%"FF_REG_a
") \n\t"
1165 "movq (%2, %%"FF_REG_a
"), %%mm0 \n\t"
1166 "movq %%mm0, %%mm2 \n\t"
1167 "movq (%3, %%"FF_REG_a
"), %%mm1 \n\t"
1168 "punpcklbw %%mm1, %%mm0 \n\t"
1169 "punpckhbw %%mm1, %%mm2 \n\t"
1171 "movq (%1, %%"FF_REG_a
",2), %%mm3 \n\t"
1172 "movq 8(%1, %%"FF_REG_a
",2), %%mm5 \n\t"
1173 "movq %%mm0, %%mm4 \n\t"
1174 "movq %%mm2, %%mm6 \n\t"
1175 "punpcklbw %%mm3, %%mm0 \n\t"
1176 "punpckhbw %%mm3, %%mm4 \n\t"
1177 "punpcklbw %%mm5, %%mm2 \n\t"
1178 "punpckhbw %%mm5, %%mm6 \n\t"
1180 MOVNTQ" %%mm0, (%0, %%"FF_REG_a
", 4) \n\t"
1181 MOVNTQ" %%mm4, 8(%0, %%"FF_REG_a
", 4) \n\t"
1182 MOVNTQ" %%mm2, 16(%0, %%"FF_REG_a
", 4) \n\t"
1183 MOVNTQ" %%mm6, 24(%0, %%"FF_REG_a
", 4) \n\t"
1185 "add $8, %%"FF_REG_a
" \n\t"
1186 "cmp %4, %%"FF_REG_a
" \n\t"
1188 ::
"r"(dst),
"r"(ysrc),
"r"(usrc),
"r"(vsrc),
"g" (chromWidth)
1191 if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
1192 usrc += chromStride;
1193 vsrc += chromStride;
1207 static inline void RENAME(
yv12touyvy)(
const uint8_t *ysrc,
const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
1209 int lumStride,
int chromStride,
int dstStride)
1212 RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst,
width,
height, lumStride, chromStride, dstStride, 2);
1218 static inline void RENAME(
yuv422ptouyvy)(
const uint8_t *ysrc,
const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
1220 int lumStride,
int chromStride,
int dstStride)
1222 RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst,
width,
height, lumStride, chromStride, dstStride, 1);
1228 static inline void RENAME(
yuv422ptoyuy2)(
const uint8_t *ysrc,
const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
1230 int lumStride,
int chromStride,
int dstStride)
1232 RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst,
width,
height, lumStride, chromStride, dstStride, 1);
1241 int lumStride,
int chromStride,
int srcStride)
1245 for (y=0; y<
height; y+=2) {
1247 "xor %%"FF_REG_a
", %%"FF_REG_a
"\n\t"
1248 "pcmpeqw %%mm7, %%mm7 \n\t"
1249 "psrlw $8, %%mm7 \n\t"
1252 PREFETCH" 64(%0, %%"FF_REG_a
", 4) \n\t"
1253 "movq (%0, %%"FF_REG_a
", 4), %%mm0 \n\t"
1254 "movq 8(%0, %%"FF_REG_a
", 4), %%mm1 \n\t"
1255 "movq %%mm0, %%mm2 \n\t"
1256 "movq %%mm1, %%mm3 \n\t"
1257 "psrlw $8, %%mm0 \n\t"
1258 "psrlw $8, %%mm1 \n\t"
1259 "pand %%mm7, %%mm2 \n\t"
1260 "pand %%mm7, %%mm3 \n\t"
1261 "packuswb %%mm1, %%mm0 \n\t"
1262 "packuswb %%mm3, %%mm2 \n\t"
1264 MOVNTQ" %%mm2, (%1, %%"FF_REG_a
", 2) \n\t"
1266 "movq 16(%0, %%"FF_REG_a
", 4), %%mm1 \n\t"
1267 "movq 24(%0, %%"FF_REG_a
", 4), %%mm2 \n\t"
1268 "movq %%mm1, %%mm3 \n\t"
1269 "movq %%mm2, %%mm4 \n\t"
1270 "psrlw $8, %%mm1 \n\t"
1271 "psrlw $8, %%mm2 \n\t"
1272 "pand %%mm7, %%mm3 \n\t"
1273 "pand %%mm7, %%mm4 \n\t"
1274 "packuswb %%mm2, %%mm1 \n\t"
1275 "packuswb %%mm4, %%mm3 \n\t"
1277 MOVNTQ" %%mm3, 8(%1, %%"FF_REG_a
", 2) \n\t"
1279 "movq %%mm0, %%mm2 \n\t"
1280 "movq %%mm1, %%mm3 \n\t"
1281 "psrlw $8, %%mm0 \n\t"
1282 "psrlw $8, %%mm1 \n\t"
1283 "pand %%mm7, %%mm2 \n\t"
1284 "pand %%mm7, %%mm3 \n\t"
1285 "packuswb %%mm1, %%mm0 \n\t"
1286 "packuswb %%mm3, %%mm2 \n\t"
1288 MOVNTQ" %%mm0, (%3, %%"FF_REG_a
") \n\t"
1289 MOVNTQ" %%mm2, (%2, %%"FF_REG_a
") \n\t"
1291 "add $8, %%"FF_REG_a
" \n\t"
1292 "cmp %4, %%"FF_REG_a
" \n\t"
1294 ::
"r"(
src),
"r"(ydst),
"r"(udst),
"r"(vdst),
"g" (chromWidth)
1295 :
"memory",
"%"FF_REG_a
1302 "xor %%"FF_REG_a
", %%"FF_REG_a
"\n\t"
1305 PREFETCH" 64(%0, %%"FF_REG_a
", 4) \n\t"
1306 "movq (%0, %%"FF_REG_a
", 4), %%mm0 \n\t"
1307 "movq 8(%0, %%"FF_REG_a
", 4), %%mm1 \n\t"
1308 "movq 16(%0, %%"FF_REG_a
", 4), %%mm2 \n\t"
1309 "movq 24(%0, %%"FF_REG_a
", 4), %%mm3 \n\t"
1310 "pand %%mm7, %%mm0 \n\t"
1311 "pand %%mm7, %%mm1 \n\t"
1312 "pand %%mm7, %%mm2 \n\t"
1313 "pand %%mm7, %%mm3 \n\t"
1314 "packuswb %%mm1, %%mm0 \n\t"
1315 "packuswb %%mm3, %%mm2 \n\t"
1317 MOVNTQ" %%mm0, (%1, %%"FF_REG_a
", 2) \n\t"
1318 MOVNTQ" %%mm2, 8(%1, %%"FF_REG_a
", 2) \n\t"
1320 "add $8, %%"FF_REG_a
"\n\t"
1321 "cmp %4, %%"FF_REG_a
"\n\t"
1324 ::
"r"(
src),
"r"(ydst),
"r"(udst),
"r"(vdst),
"g" (chromWidth)
1325 :
"memory",
"%"FF_REG_a
1327 udst += chromStride;
1328 vdst += chromStride;
1337 static inline void RENAME(
planar2x)(
const uint8_t *
src, uint8_t *dst,
int srcWidth,
int srcHeight,
int srcStride,
int dstStride)
1344 for (x=0; x<srcWidth-1; x++) {
1345 dst[2*x+1]= (3*
src[x] +
src[x+1])>>2;
1346 dst[2*x+2]= (
src[x] + 3*
src[x+1])>>2;
1348 dst[2*srcWidth-1]=
src[srcWidth-1];
1352 for (y=1; y<srcHeight; y++) {
1353 x86_reg mmxSize= srcWidth&~15;
1357 "mov %4, %%"FF_REG_a
" \n\t"
1358 "movq "MANGLE(mmx_ff)
", %%mm0 \n\t"
1359 "movq (%0, %%"FF_REG_a
"), %%mm4 \n\t"
1360 "movq %%mm4, %%mm2 \n\t"
1361 "psllq $8, %%mm4 \n\t"
1362 "pand %%mm0, %%mm2 \n\t"
1363 "por %%mm2, %%mm4 \n\t"
1364 "movq (%1, %%"FF_REG_a
"), %%mm5 \n\t"
1365 "movq %%mm5, %%mm3 \n\t"
1366 "psllq $8, %%mm5 \n\t"
1367 "pand %%mm0, %%mm3 \n\t"
1368 "por %%mm3, %%mm5 \n\t"
1370 "movq (%0, %%"FF_REG_a
"), %%mm0 \n\t"
1371 "movq (%1, %%"FF_REG_a
"), %%mm1 \n\t"
1372 "movq 1(%0, %%"FF_REG_a
"), %%mm2 \n\t"
1373 "movq 1(%1, %%"FF_REG_a
"), %%mm3 \n\t"
1374 PAVGB" %%mm0, %%mm5 \n\t"
1375 PAVGB" %%mm0, %%mm3 \n\t"
1376 PAVGB" %%mm0, %%mm5 \n\t"
1377 PAVGB" %%mm0, %%mm3 \n\t"
1378 PAVGB" %%mm1, %%mm4 \n\t"
1379 PAVGB" %%mm1, %%mm2 \n\t"
1380 PAVGB" %%mm1, %%mm4 \n\t"
1381 PAVGB" %%mm1, %%mm2 \n\t"
1382 "movq %%mm5, %%mm7 \n\t"
1383 "movq %%mm4, %%mm6 \n\t"
1384 "punpcklbw %%mm3, %%mm5 \n\t"
1385 "punpckhbw %%mm3, %%mm7 \n\t"
1386 "punpcklbw %%mm2, %%mm4 \n\t"
1387 "punpckhbw %%mm2, %%mm6 \n\t"
1388 MOVNTQ" %%mm5, (%2, %%"FF_REG_a
", 2) \n\t"
1389 MOVNTQ" %%mm7, 8(%2, %%"FF_REG_a
", 2) \n\t"
1390 MOVNTQ" %%mm4, (%3, %%"FF_REG_a
", 2) \n\t"
1391 MOVNTQ" %%mm6, 8(%3, %%"FF_REG_a
", 2) \n\t"
1392 "add $8, %%"FF_REG_a
" \n\t"
1393 "movq -1(%0, %%"FF_REG_a
"), %%mm4 \n\t"
1394 "movq -1(%1, %%"FF_REG_a
"), %%mm5 \n\t"
1396 ::
"r" (
src + mmxSize ),
"r" (
src + srcStride + mmxSize ),
1397 "r" (dst + mmxSize*2),
"r" (dst + dstStride + mmxSize*2),
1404 dst[0] = (
src[0] * 3 +
src[srcStride]) >> 2;
1405 dst[dstStride] = (
src[0] + 3 *
src[srcStride]) >> 2;
1408 for (x=mmxSize-1; x<srcWidth-1; x++) {
1409 dst[2*x +1]= (3*
src[x+0] +
src[x+srcStride+1])>>2;
1410 dst[2*x+dstStride+2]= (
src[x+0] + 3*
src[x+srcStride+1])>>2;
1411 dst[2*x+dstStride+1]= (
src[x+1] + 3*
src[x+srcStride ])>>2;
1412 dst[2*x +2]= (3*
src[x+1] +
src[x+srcStride ])>>2;
1414 dst[srcWidth*2 -1 ]= (3*
src[srcWidth-1] +
src[srcWidth-1 + srcStride])>>2;
1415 dst[srcWidth*2 -1 + dstStride]= (
src[srcWidth-1] + 3*
src[srcWidth-1 + srcStride])>>2;
1424 for (x=0; x<srcWidth-1; x++) {
1425 dst[2*x+1]= (3*
src[x] +
src[x+1])>>2;
1426 dst[2*x+2]= (
src[x] + 3*
src[x+1])>>2;
1428 dst[2*srcWidth-1]=
src[srcWidth-1];
1441 static inline void RENAME(uyvytoyv12)(
const uint8_t *
src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
1443 int lumStride,
int chromStride,
int srcStride)
1447 for (y=0; y<
height; y+=2) {
1449 "xor %%"FF_REG_a
", %%"FF_REG_a
" \n\t"
1450 "pcmpeqw %%mm7, %%mm7 \n\t"
1451 "psrlw $8, %%mm7 \n\t"
1454 PREFETCH" 64(%0, %%"FF_REG_a
", 4) \n\t"
1455 "movq (%0, %%"FF_REG_a
", 4), %%mm0 \n\t"
1456 "movq 8(%0, %%"FF_REG_a
", 4), %%mm1 \n\t"
1457 "movq %%mm0, %%mm2 \n\t"
1458 "movq %%mm1, %%mm3 \n\t"
1459 "pand %%mm7, %%mm0 \n\t"
1460 "pand %%mm7, %%mm1 \n\t"
1461 "psrlw $8, %%mm2 \n\t"
1462 "psrlw $8, %%mm3 \n\t"
1463 "packuswb %%mm1, %%mm0 \n\t"
1464 "packuswb %%mm3, %%mm2 \n\t"
1466 MOVNTQ" %%mm2, (%1, %%"FF_REG_a
", 2) \n\t"
1468 "movq 16(%0, %%"FF_REG_a
", 4), %%mm1 \n\t"
1469 "movq 24(%0, %%"FF_REG_a
", 4), %%mm2 \n\t"
1470 "movq %%mm1, %%mm3 \n\t"
1471 "movq %%mm2, %%mm4 \n\t"
1472 "pand %%mm7, %%mm1 \n\t"
1473 "pand %%mm7, %%mm2 \n\t"
1474 "psrlw $8, %%mm3 \n\t"
1475 "psrlw $8, %%mm4 \n\t"
1476 "packuswb %%mm2, %%mm1 \n\t"
1477 "packuswb %%mm4, %%mm3 \n\t"
1479 MOVNTQ" %%mm3, 8(%1, %%"FF_REG_a
", 2) \n\t"
1481 "movq %%mm0, %%mm2 \n\t"
1482 "movq %%mm1, %%mm3 \n\t"
1483 "psrlw $8, %%mm0 \n\t"
1484 "psrlw $8, %%mm1 \n\t"
1485 "pand %%mm7, %%mm2 \n\t"
1486 "pand %%mm7, %%mm3 \n\t"
1487 "packuswb %%mm1, %%mm0 \n\t"
1488 "packuswb %%mm3, %%mm2 \n\t"
1490 MOVNTQ" %%mm0, (%3, %%"FF_REG_a
") \n\t"
1491 MOVNTQ" %%mm2, (%2, %%"FF_REG_a
") \n\t"
1493 "add $8, %%"FF_REG_a
" \n\t"
1494 "cmp %4, %%"FF_REG_a
" \n\t"
1496 ::
"r"(
src),
"r"(ydst),
"r"(udst),
"r"(vdst),
"g" (chromWidth)
1497 :
"memory",
"%"FF_REG_a
1504 "xor %%"FF_REG_a
", %%"FF_REG_a
" \n\t"
1507 PREFETCH" 64(%0, %%"FF_REG_a
", 4) \n\t"
1508 "movq (%0, %%"FF_REG_a
", 4), %%mm0 \n\t"
1509 "movq 8(%0, %%"FF_REG_a
", 4), %%mm1 \n\t"
1510 "movq 16(%0, %%"FF_REG_a
", 4), %%mm2 \n\t"
1511 "movq 24(%0, %%"FF_REG_a
", 4), %%mm3 \n\t"
1512 "psrlw $8, %%mm0 \n\t"
1513 "psrlw $8, %%mm1 \n\t"
1514 "psrlw $8, %%mm2 \n\t"
1515 "psrlw $8, %%mm3 \n\t"
1516 "packuswb %%mm1, %%mm0 \n\t"
1517 "packuswb %%mm3, %%mm2 \n\t"
1519 MOVNTQ" %%mm0, (%1, %%"FF_REG_a
", 2) \n\t"
1520 MOVNTQ" %%mm2, 8(%1, %%"FF_REG_a
", 2) \n\t"
1522 "add $8, %%"FF_REG_a
" \n\t"
1523 "cmp %4, %%"FF_REG_a
" \n\t"
1526 ::
"r"(
src),
"r"(ydst),
"r"(udst),
"r"(vdst),
"g" (chromWidth)
1527 :
"memory",
"%"FF_REG_a
1529 udst += chromStride;
1530 vdst += chromStride;
1547 static inline void RENAME(rgb24toyv12)(
const uint8_t *
src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
1549 int lumStride,
int chromStride,
int srcStride,
1552 #define BGR2Y_IDX "16*4+16*32"
1553 #define BGR2U_IDX "16*4+16*33"
1554 #define BGR2V_IDX "16*4+16*34"
1561 ydst += 2*lumStride;
1562 udst += chromStride;
1563 vdst += chromStride;
1567 for (y=0; y<
height-2; y+=2) {
1569 for (
i=0;
i<2;
i++) {
1571 "mov %2, %%"FF_REG_a
"\n\t"
1572 "movq "BGR2Y_IDX
"(%3), %%mm6 \n\t"
1573 "movq "MANGLE(ff_w1111)
", %%mm5 \n\t"
1574 "pxor %%mm7, %%mm7 \n\t"
1575 "lea (%%"FF_REG_a
", %%"FF_REG_a
", 2), %%"FF_REG_d
" \n\t"
1578 PREFETCH" 64(%0, %%"FF_REG_d
") \n\t"
1579 "movd (%0, %%"FF_REG_d
"), %%mm0 \n\t"
1580 "movd 3(%0, %%"FF_REG_d
"), %%mm1 \n\t"
1581 "punpcklbw %%mm7, %%mm0 \n\t"
1582 "punpcklbw %%mm7, %%mm1 \n\t"
1583 "movd 6(%0, %%"FF_REG_d
"), %%mm2 \n\t"
1584 "movd 9(%0, %%"FF_REG_d
"), %%mm3 \n\t"
1585 "punpcklbw %%mm7, %%mm2 \n\t"
1586 "punpcklbw %%mm7, %%mm3 \n\t"
1587 "pmaddwd %%mm6, %%mm0 \n\t"
1588 "pmaddwd %%mm6, %%mm1 \n\t"
1589 "pmaddwd %%mm6, %%mm2 \n\t"
1590 "pmaddwd %%mm6, %%mm3 \n\t"
1591 "psrad $8, %%mm0 \n\t"
1592 "psrad $8, %%mm1 \n\t"
1593 "psrad $8, %%mm2 \n\t"
1594 "psrad $8, %%mm3 \n\t"
1595 "packssdw %%mm1, %%mm0 \n\t"
1596 "packssdw %%mm3, %%mm2 \n\t"
1597 "pmaddwd %%mm5, %%mm0 \n\t"
1598 "pmaddwd %%mm5, %%mm2 \n\t"
1599 "packssdw %%mm2, %%mm0 \n\t"
1600 "psraw $7, %%mm0 \n\t"
1602 "movd 12(%0, %%"FF_REG_d
"), %%mm4 \n\t"
1603 "movd 15(%0, %%"FF_REG_d
"), %%mm1 \n\t"
1604 "punpcklbw %%mm7, %%mm4 \n\t"
1605 "punpcklbw %%mm7, %%mm1 \n\t"
1606 "movd 18(%0, %%"FF_REG_d
"), %%mm2 \n\t"
1607 "movd 21(%0, %%"FF_REG_d
"), %%mm3 \n\t"
1608 "punpcklbw %%mm7, %%mm2 \n\t"
1609 "punpcklbw %%mm7, %%mm3 \n\t"
1610 "pmaddwd %%mm6, %%mm4 \n\t"
1611 "pmaddwd %%mm6, %%mm1 \n\t"
1612 "pmaddwd %%mm6, %%mm2 \n\t"
1613 "pmaddwd %%mm6, %%mm3 \n\t"
1614 "psrad $8, %%mm4 \n\t"
1615 "psrad $8, %%mm1 \n\t"
1616 "psrad $8, %%mm2 \n\t"
1617 "psrad $8, %%mm3 \n\t"
1618 "packssdw %%mm1, %%mm4 \n\t"
1619 "packssdw %%mm3, %%mm2 \n\t"
1620 "pmaddwd %%mm5, %%mm4 \n\t"
1621 "pmaddwd %%mm5, %%mm2 \n\t"
1622 "add $24, %%"FF_REG_d
"\n\t"
1623 "packssdw %%mm2, %%mm4 \n\t"
1624 "psraw $7, %%mm4 \n\t"
1626 "packuswb %%mm4, %%mm0 \n\t"
1627 "paddusb "MANGLE(ff_bgr2YOffset)
", %%mm0 \n\t"
1629 MOVNTQ" %%mm0, (%1, %%"FF_REG_a
") \n\t"
1630 "add $8, %%"FF_REG_a
" \n\t"
1634 :
"%"FF_REG_a,
"%"FF_REG_d
1641 "mov %4, %%"FF_REG_a
"\n\t"
1642 "movq "MANGLE(ff_w1111)
", %%mm5 \n\t"
1643 "movq "BGR2U_IDX
"(%5), %%mm6 \n\t"
1644 "pxor %%mm7, %%mm7 \n\t"
1645 "lea (%%"FF_REG_a
", %%"FF_REG_a
", 2), %%"FF_REG_d
" \n\t"
1646 "add %%"FF_REG_d
", %%"FF_REG_d
"\n\t"
1649 PREFETCH" 64(%0, %%"FF_REG_d
") \n\t"
1650 PREFETCH" 64(%1, %%"FF_REG_d
") \n\t"
1651 "movq (%0, %%"FF_REG_d
"), %%mm0 \n\t"
1652 "movq (%1, %%"FF_REG_d
"), %%mm1 \n\t"
1653 "movq 6(%0, %%"FF_REG_d
"), %%mm2 \n\t"
1654 "movq 6(%1, %%"FF_REG_d
"), %%mm3 \n\t"
1655 PAVGB" %%mm1, %%mm0 \n\t"
1656 PAVGB" %%mm3, %%mm2 \n\t"
1657 "movq %%mm0, %%mm1 \n\t"
1658 "movq %%mm2, %%mm3 \n\t"
1659 "psrlq $24, %%mm0 \n\t"
1660 "psrlq $24, %%mm2 \n\t"
1661 PAVGB" %%mm1, %%mm0 \n\t"
1662 PAVGB" %%mm3, %%mm2 \n\t"
1663 "punpcklbw %%mm7, %%mm0 \n\t"
1664 "punpcklbw %%mm7, %%mm2 \n\t"
1665 "movq "BGR2V_IDX
"(%5), %%mm1 \n\t"
1666 "movq "BGR2V_IDX
"(%5), %%mm3 \n\t"
1668 "pmaddwd %%mm0, %%mm1 \n\t"
1669 "pmaddwd %%mm2, %%mm3 \n\t"
1670 "pmaddwd %%mm6, %%mm0 \n\t"
1671 "pmaddwd %%mm6, %%mm2 \n\t"
1672 "psrad $8, %%mm0 \n\t"
1673 "psrad $8, %%mm1 \n\t"
1674 "psrad $8, %%mm2 \n\t"
1675 "psrad $8, %%mm3 \n\t"
1676 "packssdw %%mm2, %%mm0 \n\t"
1677 "packssdw %%mm3, %%mm1 \n\t"
1678 "pmaddwd %%mm5, %%mm0 \n\t"
1679 "pmaddwd %%mm5, %%mm1 \n\t"
1680 "packssdw %%mm1, %%mm0 \n\t"
1681 "psraw $7, %%mm0 \n\t"
1683 "movq 12(%0, %%"FF_REG_d
"), %%mm4 \n\t"
1684 "movq 12(%1, %%"FF_REG_d
"), %%mm1 \n\t"
1685 "movq 18(%0, %%"FF_REG_d
"), %%mm2 \n\t"
1686 "movq 18(%1, %%"FF_REG_d
"), %%mm3 \n\t"
1687 PAVGB" %%mm1, %%mm4 \n\t"
1688 PAVGB" %%mm3, %%mm2 \n\t"
1689 "movq %%mm4, %%mm1 \n\t"
1690 "movq %%mm2, %%mm3 \n\t"
1691 "psrlq $24, %%mm4 \n\t"
1692 "psrlq $24, %%mm2 \n\t"
1693 PAVGB" %%mm1, %%mm4 \n\t"
1694 PAVGB" %%mm3, %%mm2 \n\t"
1695 "punpcklbw %%mm7, %%mm4 \n\t"
1696 "punpcklbw %%mm7, %%mm2 \n\t"
1697 "movq "BGR2V_IDX
"(%5), %%mm1 \n\t"
1698 "movq "BGR2V_IDX
"(%5), %%mm3 \n\t"
1700 "pmaddwd %%mm4, %%mm1 \n\t"
1701 "pmaddwd %%mm2, %%mm3 \n\t"
1702 "pmaddwd %%mm6, %%mm4 \n\t"
1703 "pmaddwd %%mm6, %%mm2 \n\t"
1704 "psrad $8, %%mm4 \n\t"
1705 "psrad $8, %%mm1 \n\t"
1706 "psrad $8, %%mm2 \n\t"
1707 "psrad $8, %%mm3 \n\t"
1708 "packssdw %%mm2, %%mm4 \n\t"
1709 "packssdw %%mm3, %%mm1 \n\t"
1710 "pmaddwd %%mm5, %%mm4 \n\t"
1711 "pmaddwd %%mm5, %%mm1 \n\t"
1712 "add $24, %%"FF_REG_d
"\n\t"
1713 "packssdw %%mm1, %%mm4 \n\t"
1714 "psraw $7, %%mm4 \n\t"
1716 "movq %%mm0, %%mm1 \n\t"
1717 "punpckldq %%mm4, %%mm0 \n\t"
1718 "punpckhdq %%mm4, %%mm1 \n\t"
1719 "packsswb %%mm1, %%mm0 \n\t"
1720 "paddb "MANGLE(ff_bgr2UVOffset)
", %%mm0 \n\t"
1721 "movd %%mm0, (%2, %%"FF_REG_a
") \n\t"
1722 "punpckhdq %%mm0, %%mm0 \n\t"
1723 "movd %%mm0, (%3, %%"FF_REG_a
") \n\t"
1724 "add $4, %%"FF_REG_a
" \n\t"
1726 : :
"r" (
src+chromWidth*6),
"r" (
src+srcStride+chromWidth*6),
"r" (udst+chromWidth),
"r" (vdst+chromWidth),
"g" (-chromWidth),
"r"(
rgb2yuv)
1728 :
"%"FF_REG_a,
"%"FF_REG_d
1731 udst += chromStride;
1732 vdst += chromStride;
1745 #if !COMPILE_TEMPLATE_AVX && COMPILE_TEMPLATE_SSE2
1748 int src2Stride,
int dstStride)
1756 if (!((((intptr_t)
src1) | ((intptr_t)
src2) | ((intptr_t)dest))&15)) {
1758 "xor %%"FF_REG_a
", %%"FF_REG_a
" \n\t"
1760 PREFETCH" 64(%1, %%"FF_REG_a
") \n\t"
1761 PREFETCH" 64(%2, %%"FF_REG_a
") \n\t"
1762 "movdqa (%1, %%"FF_REG_a
"), %%xmm0 \n\t"
1763 "movdqa (%1, %%"FF_REG_a
"), %%xmm1 \n\t"
1764 "movdqa (%2, %%"FF_REG_a
"), %%xmm2 \n\t"
1765 "punpcklbw %%xmm2, %%xmm0 \n\t"
1766 "punpckhbw %%xmm2, %%xmm1 \n\t"
1767 "movntdq %%xmm0, (%0, %%"FF_REG_a
", 2) \n\t"
1768 "movntdq %%xmm1, 16(%0, %%"FF_REG_a
", 2) \n\t"
1769 "add $16, %%"FF_REG_a
" \n\t"
1770 "cmp %3, %%"FF_REG_a
" \n\t"
1773 :
"memory",
XMM_CLOBBERS(
"xmm0",
"xmm1",
"xmm2",)
"%"FF_REG_a
1777 "xor %%"FF_REG_a
", %%"FF_REG_a
" \n\t"
1779 PREFETCH" 64(%1, %%"FF_REG_a
") \n\t"
1780 PREFETCH" 64(%2, %%"FF_REG_a
") \n\t"
1781 "movq (%1, %%"FF_REG_a
"), %%mm0 \n\t"
1782 "movq 8(%1, %%"FF_REG_a
"), %%mm2 \n\t"
1783 "movq %%mm0, %%mm1 \n\t"
1784 "movq %%mm2, %%mm3 \n\t"
1785 "movq (%2, %%"FF_REG_a
"), %%mm4 \n\t"
1786 "movq 8(%2, %%"FF_REG_a
"), %%mm5 \n\t"
1787 "punpcklbw %%mm4, %%mm0 \n\t"
1788 "punpckhbw %%mm4, %%mm1 \n\t"
1789 "punpcklbw %%mm5, %%mm2 \n\t"
1790 "punpckhbw %%mm5, %%mm3 \n\t"
1791 MOVNTQ" %%mm0, (%0, %%"FF_REG_a
", 2) \n\t"
1792 MOVNTQ" %%mm1, 8(%0, %%"FF_REG_a
", 2) \n\t"
1793 MOVNTQ" %%mm2, 16(%0, %%"FF_REG_a
", 2) \n\t"
1794 MOVNTQ" %%mm3, 24(%0, %%"FF_REG_a
", 2) \n\t"
1795 "add $16, %%"FF_REG_a
" \n\t"
1796 "cmp %3, %%"FF_REG_a
" \n\t"
1799 :
"memory",
"%"FF_REG_a
1819 #if !COMPILE_TEMPLATE_AVX || HAVE_AVX_EXTERNAL
1820 #if COMPILE_TEMPLATE_SSE2 && HAVE_X86ASM
1821 void RENAME(ff_nv12ToUV)(uint8_t *dstU, uint8_t *dstV,
1822 const uint8_t *unused,
1823 const uint8_t *
src1,
1824 const uint8_t *
src2,
1829 int dst1Stride,
int dst2Stride)
1847 #if !COMPILE_TEMPLATE_SSE2
1849 uint8_t *dst1, uint8_t *dst2,
1851 int srcStride1,
int srcStride2,
1852 int dstStride1,
int dstStride2)
1860 ::
"m"(*(
src1+srcStride1)),
"m"(*(
src2+srcStride2)):
"memory");
1862 const uint8_t*
s1=
src1+srcStride1*(y>>1);
1863 uint8_t*
d=dst1+dstStride1*y;
1865 for (;x<
w-31;x+=32) {
1868 "movq (%1,%2), %%mm0 \n\t"
1869 "movq 8(%1,%2), %%mm2 \n\t"
1870 "movq 16(%1,%2), %%mm4 \n\t"
1871 "movq 24(%1,%2), %%mm6 \n\t"
1872 "movq %%mm0, %%mm1 \n\t"
1873 "movq %%mm2, %%mm3 \n\t"
1874 "movq %%mm4, %%mm5 \n\t"
1875 "movq %%mm6, %%mm7 \n\t"
1876 "punpcklbw %%mm0, %%mm0 \n\t"
1877 "punpckhbw %%mm1, %%mm1 \n\t"
1878 "punpcklbw %%mm2, %%mm2 \n\t"
1879 "punpckhbw %%mm3, %%mm3 \n\t"
1880 "punpcklbw %%mm4, %%mm4 \n\t"
1881 "punpckhbw %%mm5, %%mm5 \n\t"
1882 "punpcklbw %%mm6, %%mm6 \n\t"
1883 "punpckhbw %%mm7, %%mm7 \n\t"
1884 MOVNTQ" %%mm0, (%0,%2,2) \n\t"
1885 MOVNTQ" %%mm1, 8(%0,%2,2) \n\t"
1886 MOVNTQ" %%mm2, 16(%0,%2,2) \n\t"
1887 MOVNTQ" %%mm3, 24(%0,%2,2) \n\t"
1888 MOVNTQ" %%mm4, 32(%0,%2,2) \n\t"
1889 MOVNTQ" %%mm5, 40(%0,%2,2) \n\t"
1890 MOVNTQ" %%mm6, 48(%0,%2,2) \n\t"
1891 MOVNTQ" %%mm7, 56(%0,%2,2)"
1892 ::
"r"(
d),
"r"(
s1),
"r"(x)
1895 for (;x<
w;x++)
d[2*x]=
d[2*x+1]=
s1[x];
1898 const uint8_t*
s2=
src2+srcStride2*(y>>1);
1899 uint8_t*
d=dst2+dstStride2*y;
1901 for (;x<
w-31;x+=32) {
1904 "movq (%1,%2), %%mm0 \n\t"
1905 "movq 8(%1,%2), %%mm2 \n\t"
1906 "movq 16(%1,%2), %%mm4 \n\t"
1907 "movq 24(%1,%2), %%mm6 \n\t"
1908 "movq %%mm0, %%mm1 \n\t"
1909 "movq %%mm2, %%mm3 \n\t"
1910 "movq %%mm4, %%mm5 \n\t"
1911 "movq %%mm6, %%mm7 \n\t"
1912 "punpcklbw %%mm0, %%mm0 \n\t"
1913 "punpckhbw %%mm1, %%mm1 \n\t"
1914 "punpcklbw %%mm2, %%mm2 \n\t"
1915 "punpckhbw %%mm3, %%mm3 \n\t"
1916 "punpcklbw %%mm4, %%mm4 \n\t"
1917 "punpckhbw %%mm5, %%mm5 \n\t"
1918 "punpcklbw %%mm6, %%mm6 \n\t"
1919 "punpckhbw %%mm7, %%mm7 \n\t"
1920 MOVNTQ" %%mm0, (%0,%2,2) \n\t"
1921 MOVNTQ" %%mm1, 8(%0,%2,2) \n\t"
1922 MOVNTQ" %%mm2, 16(%0,%2,2) \n\t"
1923 MOVNTQ" %%mm3, 24(%0,%2,2) \n\t"
1924 MOVNTQ" %%mm4, 32(%0,%2,2) \n\t"
1925 MOVNTQ" %%mm5, 40(%0,%2,2) \n\t"
1926 MOVNTQ" %%mm6, 48(%0,%2,2) \n\t"
1927 MOVNTQ" %%mm7, 56(%0,%2,2)"
1928 ::
"r"(
d),
"r"(
s2),
"r"(x)
1931 for (;x<
w;x++)
d[2*x]=
d[2*x+1]=
s2[x];
1943 int srcStride1,
int srcStride2,
1944 int srcStride3,
int dstStride)
1950 const uint8_t* yp=
src1+srcStride1*y;
1951 const uint8_t* up=
src2+srcStride2*(y>>2);
1952 const uint8_t* vp=src3+srcStride3*(y>>2);
1953 uint8_t*
d=dst+dstStride*y;
1960 "movq (%1, %0, 4), %%mm0 \n\t"
1961 "movq (%2, %0), %%mm1 \n\t"
1962 "movq (%3, %0), %%mm2 \n\t"
1963 "movq %%mm0, %%mm3 \n\t"
1964 "movq %%mm1, %%mm4 \n\t"
1965 "movq %%mm2, %%mm5 \n\t"
1966 "punpcklbw %%mm1, %%mm1 \n\t"
1967 "punpcklbw %%mm2, %%mm2 \n\t"
1968 "punpckhbw %%mm4, %%mm4 \n\t"
1969 "punpckhbw %%mm5, %%mm5 \n\t"
1971 "movq %%mm1, %%mm6 \n\t"
1972 "punpcklbw %%mm2, %%mm1 \n\t"
1973 "punpcklbw %%mm1, %%mm0 \n\t"
1974 "punpckhbw %%mm1, %%mm3 \n\t"
1975 MOVNTQ" %%mm0, (%4, %0, 8) \n\t"
1976 MOVNTQ" %%mm3, 8(%4, %0, 8) \n\t"
1978 "punpckhbw %%mm2, %%mm6 \n\t"
1979 "movq 8(%1, %0, 4), %%mm0 \n\t"
1980 "movq %%mm0, %%mm3 \n\t"
1981 "punpcklbw %%mm6, %%mm0 \n\t"
1982 "punpckhbw %%mm6, %%mm3 \n\t"
1983 MOVNTQ" %%mm0, 16(%4, %0, 8) \n\t"
1984 MOVNTQ" %%mm3, 24(%4, %0, 8) \n\t"
1986 "movq %%mm4, %%mm6 \n\t"
1987 "movq 16(%1, %0, 4), %%mm0 \n\t"
1988 "movq %%mm0, %%mm3 \n\t"
1989 "punpcklbw %%mm5, %%mm4 \n\t"
1990 "punpcklbw %%mm4, %%mm0 \n\t"
1991 "punpckhbw %%mm4, %%mm3 \n\t"
1992 MOVNTQ" %%mm0, 32(%4, %0, 8) \n\t"
1993 MOVNTQ" %%mm3, 40(%4, %0, 8) \n\t"
1995 "punpckhbw %%mm5, %%mm6 \n\t"
1996 "movq 24(%1, %0, 4), %%mm0 \n\t"
1997 "movq %%mm0, %%mm3 \n\t"
1998 "punpcklbw %%mm6, %%mm0 \n\t"
1999 "punpckhbw %%mm6, %%mm3 \n\t"
2000 MOVNTQ" %%mm0, 48(%4, %0, 8) \n\t"
2001 MOVNTQ" %%mm3, 56(%4, %0, 8) \n\t"
2004 :
"r"(yp),
"r" (up),
"r"(vp),
"r"(
d)
2008 const int x2 = x<<2;
2011 d[8*x+2] = yp[x2+1];
2013 d[8*x+4] = yp[x2+2];
2015 d[8*x+6] = yp[x2+3];
2035 "pcmpeqw %%mm7, %%mm7 \n\t"
2036 "psrlw $8, %%mm7 \n\t"
2038 "movq -30(%1, %0, 2), %%mm0 \n\t"
2039 "movq -22(%1, %0, 2), %%mm1 \n\t"
2040 "movq -14(%1, %0, 2), %%mm2 \n\t"
2041 "movq -6(%1, %0, 2), %%mm3 \n\t"
2042 "pand %%mm7, %%mm0 \n\t"
2043 "pand %%mm7, %%mm1 \n\t"
2044 "pand %%mm7, %%mm2 \n\t"
2045 "pand %%mm7, %%mm3 \n\t"
2046 "packuswb %%mm1, %%mm0 \n\t"
2047 "packuswb %%mm3, %%mm2 \n\t"
2048 MOVNTQ" %%mm0,-15(%2, %0) \n\t"
2049 MOVNTQ" %%mm2,- 7(%2, %0) \n\t"
2053 :
"r"(
src),
"r"(dst)
2058 dst[count]=
src[2*count];
2073 "pcmpeqw %%mm7, %%mm7 \n\t"
2074 "psrlw $8, %%mm7 \n\t"
2076 "movq -32(%1, %0, 2), %%mm0 \n\t"
2077 "movq -24(%1, %0, 2), %%mm1 \n\t"
2078 "movq -16(%1, %0, 2), %%mm2 \n\t"
2079 "movq -8(%1, %0, 2), %%mm3 \n\t"
2080 "pand %%mm7, %%mm0 \n\t"
2081 "pand %%mm7, %%mm1 \n\t"
2082 "pand %%mm7, %%mm2 \n\t"
2083 "pand %%mm7, %%mm3 \n\t"
2084 "packuswb %%mm1, %%mm0 \n\t"
2085 "packuswb %%mm3, %%mm2 \n\t"
2086 MOVNTQ" %%mm0,-16(%2, %0) \n\t"
2087 MOVNTQ" %%mm2,- 8(%2, %0) \n\t"
2091 :
"r"(
src),
"r"(dst)
2096 dst[count]=
src[2*count];
2102 static void RENAME(extract_even2)(
const uint8_t *
src, uint8_t *dst0, uint8_t *dst1,
x86_reg count)
2111 "pcmpeqw %%mm7, %%mm7 \n\t"
2112 "psrlw $8, %%mm7 \n\t"
2114 "movq -28(%1, %0, 4), %%mm0 \n\t"
2115 "movq -20(%1, %0, 4), %%mm1 \n\t"
2116 "movq -12(%1, %0, 4), %%mm2 \n\t"
2117 "movq -4(%1, %0, 4), %%mm3 \n\t"
2118 "pand %%mm7, %%mm0 \n\t"
2119 "pand %%mm7, %%mm1 \n\t"
2120 "pand %%mm7, %%mm2 \n\t"
2121 "pand %%mm7, %%mm3 \n\t"
2122 "packuswb %%mm1, %%mm0 \n\t"
2123 "packuswb %%mm3, %%mm2 \n\t"
2124 "movq %%mm0, %%mm1 \n\t"
2125 "movq %%mm2, %%mm3 \n\t"
2126 "psrlw $8, %%mm0 \n\t"
2127 "psrlw $8, %%mm2 \n\t"
2128 "pand %%mm7, %%mm1 \n\t"
2129 "pand %%mm7, %%mm3 \n\t"
2130 "packuswb %%mm2, %%mm0 \n\t"
2131 "packuswb %%mm3, %%mm1 \n\t"
2132 MOVNTQ" %%mm0,- 7(%3, %0) \n\t"
2133 MOVNTQ" %%mm1,- 7(%2, %0) \n\t"
2137 :
"r"(
src),
"r"(dst0),
"r"(dst1)
2142 dst0[count]=
src[4*count+0];
2143 dst1[count]=
src[4*count+2];
2149 static void RENAME(extract_even2avg)(
const uint8_t *
src0,
const uint8_t *
src1, uint8_t *dst0, uint8_t *dst1,
x86_reg count)
2160 "pcmpeqw %%mm7, %%mm7 \n\t"
2161 "psrlw $8, %%mm7 \n\t"
2163 "movq -28(%1, %0, 4), %%mm0 \n\t"
2164 "movq -20(%1, %0, 4), %%mm1 \n\t"
2165 "movq -12(%1, %0, 4), %%mm2 \n\t"
2166 "movq -4(%1, %0, 4), %%mm3 \n\t"
2167 PAVGB" -28(%2, %0, 4), %%mm0 \n\t"
2168 PAVGB" -20(%2, %0, 4), %%mm1 \n\t"
2169 PAVGB" -12(%2, %0, 4), %%mm2 \n\t"
2170 PAVGB" - 4(%2, %0, 4), %%mm3 \n\t"
2171 "pand %%mm7, %%mm0 \n\t"
2172 "pand %%mm7, %%mm1 \n\t"
2173 "pand %%mm7, %%mm2 \n\t"
2174 "pand %%mm7, %%mm3 \n\t"
2175 "packuswb %%mm1, %%mm0 \n\t"
2176 "packuswb %%mm3, %%mm2 \n\t"
2177 "movq %%mm0, %%mm1 \n\t"
2178 "movq %%mm2, %%mm3 \n\t"
2179 "psrlw $8, %%mm0 \n\t"
2180 "psrlw $8, %%mm2 \n\t"
2181 "pand %%mm7, %%mm1 \n\t"
2182 "pand %%mm7, %%mm3 \n\t"
2183 "packuswb %%mm2, %%mm0 \n\t"
2184 "packuswb %%mm3, %%mm1 \n\t"
2185 MOVNTQ" %%mm0,- 7(%4, %0) \n\t"
2186 MOVNTQ" %%mm1,- 7(%3, %0) \n\t"
2190 :
"r"(
src0),
"r"(
src1),
"r"(dst0),
"r"(dst1)
2196 dst0[count]= (
src0[4*count+0]+
src1[4*count+0])>>1;
2197 dst1[count]= (
src0[4*count+2]+
src1[4*count+2])>>1;
2202 static void RENAME(extract_odd2)(
const uint8_t *
src, uint8_t *dst0, uint8_t *dst1,
x86_reg count)
2211 "pcmpeqw %%mm7, %%mm7 \n\t"
2212 "psrlw $8, %%mm7 \n\t"
2214 "movq -28(%1, %0, 4), %%mm0 \n\t"
2215 "movq -20(%1, %0, 4), %%mm1 \n\t"
2216 "movq -12(%1, %0, 4), %%mm2 \n\t"
2217 "movq -4(%1, %0, 4), %%mm3 \n\t"
2218 "psrlw $8, %%mm0 \n\t"
2219 "psrlw $8, %%mm1 \n\t"
2220 "psrlw $8, %%mm2 \n\t"
2221 "psrlw $8, %%mm3 \n\t"
2222 "packuswb %%mm1, %%mm0 \n\t"
2223 "packuswb %%mm3, %%mm2 \n\t"
2224 "movq %%mm0, %%mm1 \n\t"
2225 "movq %%mm2, %%mm3 \n\t"
2226 "psrlw $8, %%mm0 \n\t"
2227 "psrlw $8, %%mm2 \n\t"
2228 "pand %%mm7, %%mm1 \n\t"
2229 "pand %%mm7, %%mm3 \n\t"
2230 "packuswb %%mm2, %%mm0 \n\t"
2231 "packuswb %%mm3, %%mm1 \n\t"
2232 MOVNTQ" %%mm0,- 7(%3, %0) \n\t"
2233 MOVNTQ" %%mm1,- 7(%2, %0) \n\t"
2237 :
"r"(
src),
"r"(dst0),
"r"(dst1)
2243 dst0[count]=
src[4*count+0];
2244 dst1[count]=
src[4*count+2];
2249 static void RENAME(extract_odd2avg)(
const uint8_t *
src0,
const uint8_t *
src1, uint8_t *dst0, uint8_t *dst1,
x86_reg count)
2260 "pcmpeqw %%mm7, %%mm7 \n\t"
2261 "psrlw $8, %%mm7 \n\t"
2263 "movq -28(%1, %0, 4), %%mm0 \n\t"
2264 "movq -20(%1, %0, 4), %%mm1 \n\t"
2265 "movq -12(%1, %0, 4), %%mm2 \n\t"
2266 "movq -4(%1, %0, 4), %%mm3 \n\t"
2267 PAVGB" -28(%2, %0, 4), %%mm0 \n\t"
2268 PAVGB" -20(%2, %0, 4), %%mm1 \n\t"
2269 PAVGB" -12(%2, %0, 4), %%mm2 \n\t"
2270 PAVGB" - 4(%2, %0, 4), %%mm3 \n\t"
2271 "psrlw $8, %%mm0 \n\t"
2272 "psrlw $8, %%mm1 \n\t"
2273 "psrlw $8, %%mm2 \n\t"
2274 "psrlw $8, %%mm3 \n\t"
2275 "packuswb %%mm1, %%mm0 \n\t"
2276 "packuswb %%mm3, %%mm2 \n\t"
2277 "movq %%mm0, %%mm1 \n\t"
2278 "movq %%mm2, %%mm3 \n\t"
2279 "psrlw $8, %%mm0 \n\t"
2280 "psrlw $8, %%mm2 \n\t"
2281 "pand %%mm7, %%mm1 \n\t"
2282 "pand %%mm7, %%mm3 \n\t"
2283 "packuswb %%mm2, %%mm0 \n\t"
2284 "packuswb %%mm3, %%mm1 \n\t"
2285 MOVNTQ" %%mm0,- 7(%4, %0) \n\t"
2286 MOVNTQ" %%mm1,- 7(%3, %0) \n\t"
2290 :
"r"(
src0),
"r"(
src1),
"r"(dst0),
"r"(dst1)
2298 dst0[count]= (
src0[4*count+0]+
src1[4*count+0])>>1;
2299 dst1[count]= (
src0[4*count+2]+
src1[4*count+2])>>1;
2306 int lumStride,
int chromStride,
int srcStride)
2311 for (y=0; y<
height; y++) {
2314 RENAME(extract_odd2avg)(
src-srcStride,
src, udst, vdst, chromWidth);
2331 int lumStride,
int chromStride,
int srcStride)
2336 for (y=0; y<
height; y++) {
2338 RENAME(extract_odd2)(
src, udst, vdst, chromWidth);
2354 int lumStride,
int chromStride,
int srcStride)
2359 for (y=0; y<
height; y++) {
2362 RENAME(extract_even2avg)(
src-srcStride,
src, udst, vdst, chromWidth);
2380 int lumStride,
int chromStride,
int srcStride)
2385 for (y=0; y<
height; y++) {
2387 RENAME(extract_even2)(
src, udst, vdst, chromWidth);
2405 #if !COMPILE_TEMPLATE_SSE2
2444 #if !COMPILE_TEMPLATE_AVX && COMPILE_TEMPLATE_SSE2
2447 #if !COMPILE_TEMPLATE_AVX || HAVE_AVX_EXTERNAL
2448 #if COMPILE_TEMPLATE_SSE2 && HAVE_X86ASM
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
void(* yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
void(* yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, int width, int height, int lumStride, int chromStride, int srcStride)
Height should be a multiple of 2 and width should be a multiple of 16.
#define NAMED_CONSTRAINTS_ADD(...)
static const char rgb2yuv[]
void(* rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
void(* yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
void(* yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
void(* rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size)
void(* ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, int width, int height, int lumStride, int chromStride, int srcStride, int32_t *rgb2yuv)
Height should be a multiple of 2 and width should be a multiple of 2.
void(* rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_CEIL_RSHIFT(a, b)
void(* rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
void(* yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
void(* rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
#define XMM_CLOBBERS(...)
void(* interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int src1Stride, int src2Stride, int dstStride)
void(* yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, uint8_t *dst, int width, int height, int srcStride1, int srcStride2, int srcStride3, int dstStride)
void(* rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size)
void(* yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, int width, int height, int lumStride, int chromStride, int srcStride, int32_t *rgb2yuv)
Height should be a multiple of 2 and width should be a multiple of 2.
void(* rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size)
void(* uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
#define i(width, name, range_min, range_max)
void(* rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size)
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")
void(* deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, int width, int height, int srcStride, int dst1Stride, int dst2Stride)
void(* uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
void(* yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
void(* vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst1, uint8_t *dst2, int width, int height, int srcStride1, int srcStride2, int dstStride1, int dstStride2)
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
void(* planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride)