Mercurial > mplayer.hg
comparison postproc/rgb2rgb_template.c @ 11072:3254b413ef1c
yv12->uyvy MMX
author | michael |
---|---|
date | Fri, 10 Oct 2003 00:19:16 +0000 |
parents | f33f908ae085 |
children | b5c106b694e4 |
comparison
equal
deleted
inserted
replaced
11071:9db8700a5a16 | 11072:3254b413ef1c |
---|---|
1574 { | 1574 { |
1575 unsigned y; | 1575 unsigned y; |
1576 const unsigned chromWidth= width>>1; | 1576 const unsigned chromWidth= width>>1; |
1577 for(y=0; y<height; y++) | 1577 for(y=0; y<height; y++) |
1578 { | 1578 { |
1579 #ifdef HAVE_MMX | |
1580 //FIXME handle 2 lines a once (fewer prefetch, reuse some chrom, but very likely limited by mem anyway) | |
1581 asm volatile( | |
1582 "xorl %%eax, %%eax \n\t" | |
1583 ".balign 16 \n\t" | |
1584 "1: \n\t" | |
1585 PREFETCH" 32(%1, %%eax, 2) \n\t" | |
1586 PREFETCH" 32(%2, %%eax) \n\t" | |
1587 PREFETCH" 32(%3, %%eax) \n\t" | |
1588 "movq (%2, %%eax), %%mm0 \n\t" // U(0) | |
1589 "movq %%mm0, %%mm2 \n\t" // U(0) | |
1590 "movq (%3, %%eax), %%mm1 \n\t" // V(0) | |
1591 "punpcklbw %%mm1, %%mm0 \n\t" // UVUV UVUV(0) | |
1592 "punpckhbw %%mm1, %%mm2 \n\t" // UVUV UVUV(8) | |
1593 | |
1594 "movq (%1, %%eax,2), %%mm3 \n\t" // Y(0) | |
1595 "movq 8(%1, %%eax,2), %%mm5 \n\t" // Y(8) | |
1596 "movq %%mm0, %%mm4 \n\t" // Y(0) | |
1597 "movq %%mm2, %%mm6 \n\t" // Y(8) | |
1598 "punpcklbw %%mm3, %%mm0 \n\t" // YUYV YUYV(0) | |
1599 "punpckhbw %%mm3, %%mm4 \n\t" // YUYV YUYV(4) | |
1600 "punpcklbw %%mm5, %%mm2 \n\t" // YUYV YUYV(8) | |
1601 "punpckhbw %%mm5, %%mm6 \n\t" // YUYV YUYV(12) | |
1602 | |
1603 MOVNTQ" %%mm0, (%0, %%eax, 4) \n\t" | |
1604 MOVNTQ" %%mm4, 8(%0, %%eax, 4) \n\t" | |
1605 MOVNTQ" %%mm2, 16(%0, %%eax, 4) \n\t" | |
1606 MOVNTQ" %%mm6, 24(%0, %%eax, 4) \n\t" | |
1607 | |
1608 "addl $8, %%eax \n\t" | |
1609 "cmpl %4, %%eax \n\t" | |
1610 " jb 1b \n\t" | |
1611 ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth) | |
1612 : "%eax" | |
1613 ); | |
1614 #else | |
1615 //FIXME adapt the alpha asm code from yv12->yuy2 | |
1616 | |
1579 #if __WORDSIZE >= 64 | 1617 #if __WORDSIZE >= 64 |
1580 int i; | 1618 int i; |
1581 uint64_t *ldst = (uint64_t *) dst; | 1619 uint64_t *ldst = (uint64_t *) dst; |
1582 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; | 1620 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; |
1583 for(i = 0; i < chromWidth; i += 2){ | 1621 for(i = 0; i < chromWidth; i += 2){ |
1601 yc += 2; | 1639 yc += 2; |
1602 uc++; | 1640 uc++; |
1603 vc++; | 1641 vc++; |
1604 } | 1642 } |
1605 #endif | 1643 #endif |
1644 #endif | |
1606 if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) | 1645 if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) |
1607 { | 1646 { |
1608 usrc += chromStride; | 1647 usrc += chromStride; |
1609 vsrc += chromStride; | 1648 vsrc += chromStride; |
1610 } | 1649 } |
1611 ysrc += lumStride; | 1650 ysrc += lumStride; |
1612 dst += dstStride; | 1651 dst += dstStride; |
1613 } | 1652 } |
1653 #ifdef HAVE_MMX | |
1654 asm( EMMS" \n\t" | |
1655 SFENCE" \n\t" | |
1656 :::"memory"); | |
1657 #endif | |
1614 } | 1658 } |
1615 | 1659 |
1616 /** | 1660 /** |
1617 * | 1661 * |
1618 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a | 1662 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a |