Mercurial > mplayer.hg
comparison libswscale/swscale_template.c @ 20945:92150c16e737
fixing the lamest bug in swscale, all the rgb/bgr->* code did 2x2 downsampling for chroma, it should just be 2x1 (the rest of the code also belived its 2x1 ...)
author | michael |
---|---|
date | Thu, 16 Nov 2006 14:44:00 +0000 |
parents | b8fe18a742ce |
children | bb4c952bc52c |
comparison
equal
deleted
inserted
replaced
20944:20910582789d | 20945:92150c16e737 |
---|---|
1728 #endif | 1728 #endif |
1729 } | 1729 } |
1730 | 1730 |
1731 static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width) | 1731 static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width) |
1732 { | 1732 { |
1733 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | 1733 assert(src1 == src2); |
1734 #ifdef HAVE_MMX | |
1734 asm volatile( | 1735 asm volatile( |
1735 "movq "MANGLE(bm01010101)", %%mm4\n\t" | 1736 "movq "MANGLE(bm01010101)", %%mm4\n\t" |
1736 "mov %0, %%"REG_a" \n\t" | 1737 "mov %0, %%"REG_a" \n\t" |
1737 "1: \n\t" | 1738 "1: \n\t" |
1738 "movq (%1, %%"REG_a",4), %%mm0 \n\t" | 1739 "movq (%1, %%"REG_a",4), %%mm0 \n\t" |
1739 "movq 8(%1, %%"REG_a",4), %%mm1 \n\t" | 1740 "movq 8(%1, %%"REG_a",4), %%mm1 \n\t" |
1740 "movq (%2, %%"REG_a",4), %%mm2 \n\t" | |
1741 "movq 8(%2, %%"REG_a",4), %%mm3 \n\t" | |
1742 PAVGB(%%mm2, %%mm0) | |
1743 PAVGB(%%mm3, %%mm1) | |
1744 "psrlw $8, %%mm0 \n\t" | 1741 "psrlw $8, %%mm0 \n\t" |
1745 "psrlw $8, %%mm1 \n\t" | 1742 "psrlw $8, %%mm1 \n\t" |
1746 "packuswb %%mm1, %%mm0 \n\t" | 1743 "packuswb %%mm1, %%mm0 \n\t" |
1747 "movq %%mm0, %%mm1 \n\t" | 1744 "movq %%mm0, %%mm1 \n\t" |
1748 "psrlw $8, %%mm0 \n\t" | 1745 "psrlw $8, %%mm0 \n\t" |
1749 "pand %%mm4, %%mm1 \n\t" | 1746 "pand %%mm4, %%mm1 \n\t" |
1750 "packuswb %%mm0, %%mm0 \n\t" | 1747 "packuswb %%mm0, %%mm0 \n\t" |
1751 "packuswb %%mm1, %%mm1 \n\t" | 1748 "packuswb %%mm1, %%mm1 \n\t" |
1752 "movd %%mm0, (%4, %%"REG_a") \n\t" | 1749 "movd %%mm0, (%3, %%"REG_a") \n\t" |
1753 "movd %%mm1, (%3, %%"REG_a") \n\t" | 1750 "movd %%mm1, (%2, %%"REG_a") \n\t" |
1754 "add $4, %%"REG_a" \n\t" | 1751 "add $4, %%"REG_a" \n\t" |
1755 " js 1b \n\t" | 1752 " js 1b \n\t" |
1756 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | 1753 : : "g" (-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width) |
1757 : "%"REG_a | 1754 : "%"REG_a |
1758 ); | 1755 ); |
1759 #else | 1756 #else |
1760 int i; | 1757 int i; |
1761 for(i=0; i<width; i++) | 1758 for(i=0; i<width; i++) |
1762 { | 1759 { |
1763 dstU[i]= (src1[4*i + 1] + src2[4*i + 1])>>1; | 1760 dstU[i]= src1[4*i + 1]; |
1764 dstV[i]= (src1[4*i + 3] + src2[4*i + 3])>>1; | 1761 dstV[i]= src1[4*i + 3]; |
1765 } | 1762 } |
1766 #endif | 1763 #endif |
1767 } | 1764 } |
1768 | 1765 |
1769 //this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses | 1766 //this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses |
1791 #endif | 1788 #endif |
1792 } | 1789 } |
1793 | 1790 |
1794 static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width) | 1791 static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width) |
1795 { | 1792 { |
1796 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | 1793 assert(src1 == src2); |
1794 #ifdef HAVE_MMX | |
1797 asm volatile( | 1795 asm volatile( |
1798 "movq "MANGLE(bm01010101)", %%mm4\n\t" | 1796 "movq "MANGLE(bm01010101)", %%mm4\n\t" |
1799 "mov %0, %%"REG_a" \n\t" | 1797 "mov %0, %%"REG_a" \n\t" |
1800 "1: \n\t" | 1798 "1: \n\t" |
1801 "movq (%1, %%"REG_a",4), %%mm0 \n\t" | 1799 "movq (%1, %%"REG_a",4), %%mm0 \n\t" |
1802 "movq 8(%1, %%"REG_a",4), %%mm1 \n\t" | 1800 "movq 8(%1, %%"REG_a",4), %%mm1 \n\t" |
1803 "movq (%2, %%"REG_a",4), %%mm2 \n\t" | |
1804 "movq 8(%2, %%"REG_a",4), %%mm3 \n\t" | |
1805 PAVGB(%%mm2, %%mm0) | |
1806 PAVGB(%%mm3, %%mm1) | |
1807 "pand %%mm4, %%mm0 \n\t" | 1801 "pand %%mm4, %%mm0 \n\t" |
1808 "pand %%mm4, %%mm1 \n\t" | 1802 "pand %%mm4, %%mm1 \n\t" |
1809 "packuswb %%mm1, %%mm0 \n\t" | 1803 "packuswb %%mm1, %%mm0 \n\t" |
1810 "movq %%mm0, %%mm1 \n\t" | 1804 "movq %%mm0, %%mm1 \n\t" |
1811 "psrlw $8, %%mm0 \n\t" | 1805 "psrlw $8, %%mm0 \n\t" |
1812 "pand %%mm4, %%mm1 \n\t" | 1806 "pand %%mm4, %%mm1 \n\t" |
1813 "packuswb %%mm0, %%mm0 \n\t" | 1807 "packuswb %%mm0, %%mm0 \n\t" |
1814 "packuswb %%mm1, %%mm1 \n\t" | 1808 "packuswb %%mm1, %%mm1 \n\t" |
1815 "movd %%mm0, (%4, %%"REG_a") \n\t" | 1809 "movd %%mm0, (%3, %%"REG_a") \n\t" |
1816 "movd %%mm1, (%3, %%"REG_a") \n\t" | 1810 "movd %%mm1, (%2, %%"REG_a") \n\t" |
1817 "add $4, %%"REG_a" \n\t" | 1811 "add $4, %%"REG_a" \n\t" |
1818 " js 1b \n\t" | 1812 " js 1b \n\t" |
1819 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | 1813 : : "g" (-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width) |
1820 : "%"REG_a | 1814 : "%"REG_a |
1821 ); | 1815 ); |
1822 #else | 1816 #else |
1823 int i; | 1817 int i; |
1824 for(i=0; i<width; i++) | 1818 for(i=0; i<width; i++) |
1825 { | 1819 { |
1826 dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1; | 1820 dstU[i]= src1[4*i + 0]; |
1827 dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1; | 1821 dstV[i]= src1[4*i + 2]; |
1828 } | 1822 } |
1829 #endif | 1823 #endif |
1830 } | 1824 } |
1831 | 1825 |
1832 static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width) | 1826 static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width) |
1843 } | 1837 } |
1844 | 1838 |
1845 static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | 1839 static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
1846 { | 1840 { |
1847 int i; | 1841 int i; |
1842 assert(src1 == src2); | |
1848 for(i=0; i<width; i++) | 1843 for(i=0; i<width; i++) |
1849 { | 1844 { |
1850 const int a= ((uint32_t*)src1)[2*i+0]; | 1845 const int a= ((uint32_t*)src1)[2*i+0]; |
1851 const int e= ((uint32_t*)src1)[2*i+1]; | 1846 const int e= ((uint32_t*)src1)[2*i+1]; |
1852 const int c= ((uint32_t*)src2)[2*i+0]; | 1847 const int l= (a&0xFF00FF) + (e&0xFF00FF); |
1853 const int d= ((uint32_t*)src2)[2*i+1]; | 1848 const int h= (a&0x00FF00) + (e&0x00FF00); |
1854 const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF); | |
1855 const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00); | |
1856 const int b= l&0x3FF; | 1849 const int b= l&0x3FF; |
1857 const int g= h>>8; | 1850 const int g= h>>8; |
1858 const int r= l>>16; | 1851 const int r= l>>16; |
1859 | 1852 |
1860 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | 1853 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128; |
1861 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | 1854 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128; |
1862 } | 1855 } |
1863 } | 1856 } |
1864 | 1857 |
1865 static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width) | 1858 static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width) |
1866 { | 1859 { |
1947 #endif | 1940 #endif |
1948 } | 1941 } |
1949 | 1942 |
1950 static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width) | 1943 static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width) |
1951 { | 1944 { |
1945 assert(src1 == src2); | |
1952 #ifdef HAVE_MMX | 1946 #ifdef HAVE_MMX |
1953 asm volatile( | 1947 asm volatile( |
1954 "mov %4, %%"REG_a" \n\t" | 1948 "mov %3, %%"REG_a" \n\t" |
1955 "movq "MANGLE(w1111)", %%mm5 \n\t" | 1949 "movq "MANGLE(w1111)", %%mm5 \n\t" |
1956 "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" | 1950 "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" |
1957 "pxor %%mm7, %%mm7 \n\t" | 1951 "pxor %%mm7, %%mm7 \n\t" |
1958 "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" | 1952 "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" |
1959 "add %%"REG_d", %%"REG_d" \n\t" | 1953 "add %%"REG_d", %%"REG_d" \n\t" |
1960 ASMALIGN(4) | 1954 ASMALIGN(4) |
1961 "1: \n\t" | 1955 "1: \n\t" |
1962 PREFETCH" 64(%0, %%"REG_d") \n\t" | 1956 PREFETCH" 64(%0, %%"REG_d") \n\t" |
1963 PREFETCH" 64(%1, %%"REG_d") \n\t" | |
1964 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | 1957 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
1965 "movq (%0, %%"REG_d"), %%mm0 \n\t" | 1958 "movq (%0, %%"REG_d"), %%mm0 \n\t" |
1966 "movq (%1, %%"REG_d"), %%mm1 \n\t" | |
1967 "movq 6(%0, %%"REG_d"), %%mm2 \n\t" | 1959 "movq 6(%0, %%"REG_d"), %%mm2 \n\t" |
1968 "movq 6(%1, %%"REG_d"), %%mm3 \n\t" | |
1969 PAVGB(%%mm1, %%mm0) | |
1970 PAVGB(%%mm3, %%mm2) | |
1971 "movq %%mm0, %%mm1 \n\t" | 1960 "movq %%mm0, %%mm1 \n\t" |
1972 "movq %%mm2, %%mm3 \n\t" | 1961 "movq %%mm2, %%mm3 \n\t" |
1973 "psrlq $24, %%mm0 \n\t" | 1962 "psrlq $24, %%mm0 \n\t" |
1974 "psrlq $24, %%mm2 \n\t" | 1963 "psrlq $24, %%mm2 \n\t" |
1975 PAVGB(%%mm1, %%mm0) | 1964 PAVGB(%%mm1, %%mm0) |
1976 PAVGB(%%mm3, %%mm2) | 1965 PAVGB(%%mm3, %%mm2) |
1977 "punpcklbw %%mm7, %%mm0 \n\t" | 1966 "punpcklbw %%mm7, %%mm0 \n\t" |
1978 "punpcklbw %%mm7, %%mm2 \n\t" | 1967 "punpcklbw %%mm7, %%mm2 \n\t" |
1979 #else | 1968 #else |
1980 "movd (%0, %%"REG_d"), %%mm0 \n\t" | 1969 "movd (%0, %%"REG_d"), %%mm0 \n\t" |
1981 "movd (%1, %%"REG_d"), %%mm1 \n\t" | |
1982 "movd 3(%0, %%"REG_d"), %%mm2 \n\t" | 1970 "movd 3(%0, %%"REG_d"), %%mm2 \n\t" |
1983 "movd 3(%1, %%"REG_d"), %%mm3 \n\t" | |
1984 "punpcklbw %%mm7, %%mm0 \n\t" | 1971 "punpcklbw %%mm7, %%mm0 \n\t" |
1985 "punpcklbw %%mm7, %%mm1 \n\t" | |
1986 "punpcklbw %%mm7, %%mm2 \n\t" | 1972 "punpcklbw %%mm7, %%mm2 \n\t" |
1987 "punpcklbw %%mm7, %%mm3 \n\t" | |
1988 "paddw %%mm1, %%mm0 \n\t" | |
1989 "paddw %%mm3, %%mm2 \n\t" | |
1990 "paddw %%mm2, %%mm0 \n\t" | 1973 "paddw %%mm2, %%mm0 \n\t" |
1991 "movd 6(%0, %%"REG_d"), %%mm4 \n\t" | 1974 "movd 6(%0, %%"REG_d"), %%mm4 \n\t" |
1992 "movd 6(%1, %%"REG_d"), %%mm1 \n\t" | |
1993 "movd 9(%0, %%"REG_d"), %%mm2 \n\t" | 1975 "movd 9(%0, %%"REG_d"), %%mm2 \n\t" |
1994 "movd 9(%1, %%"REG_d"), %%mm3 \n\t" | |
1995 "punpcklbw %%mm7, %%mm4 \n\t" | 1976 "punpcklbw %%mm7, %%mm4 \n\t" |
1996 "punpcklbw %%mm7, %%mm1 \n\t" | |
1997 "punpcklbw %%mm7, %%mm2 \n\t" | 1977 "punpcklbw %%mm7, %%mm2 \n\t" |
1998 "punpcklbw %%mm7, %%mm3 \n\t" | |
1999 "paddw %%mm1, %%mm4 \n\t" | |
2000 "paddw %%mm3, %%mm2 \n\t" | |
2001 "paddw %%mm4, %%mm2 \n\t" | 1978 "paddw %%mm4, %%mm2 \n\t" |
2002 "psrlw $2, %%mm0 \n\t" | 1979 "psrlw $1, %%mm0 \n\t" |
2003 "psrlw $2, %%mm2 \n\t" | 1980 "psrlw $1, %%mm2 \n\t" |
2004 #endif | 1981 #endif |
2005 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" | 1982 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
2006 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | 1983 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" |
2007 | 1984 |
2008 "pmaddwd %%mm0, %%mm1 \n\t" | 1985 "pmaddwd %%mm0, %%mm1 \n\t" |
2022 "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 | 1999 "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 |
2023 "psraw $7, %%mm0 \n\t" | 2000 "psraw $7, %%mm0 \n\t" |
2024 | 2001 |
2025 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | 2002 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2026 "movq 12(%0, %%"REG_d"), %%mm4 \n\t" | 2003 "movq 12(%0, %%"REG_d"), %%mm4 \n\t" |
2027 "movq 12(%1, %%"REG_d"), %%mm1 \n\t" | |
2028 "movq 18(%0, %%"REG_d"), %%mm2 \n\t" | 2004 "movq 18(%0, %%"REG_d"), %%mm2 \n\t" |
2029 "movq 18(%1, %%"REG_d"), %%mm3 \n\t" | |
2030 PAVGB(%%mm1, %%mm4) | |
2031 PAVGB(%%mm3, %%mm2) | |
2032 "movq %%mm4, %%mm1 \n\t" | 2005 "movq %%mm4, %%mm1 \n\t" |
2033 "movq %%mm2, %%mm3 \n\t" | 2006 "movq %%mm2, %%mm3 \n\t" |
2034 "psrlq $24, %%mm4 \n\t" | 2007 "psrlq $24, %%mm4 \n\t" |
2035 "psrlq $24, %%mm2 \n\t" | 2008 "psrlq $24, %%mm2 \n\t" |
2036 PAVGB(%%mm1, %%mm4) | 2009 PAVGB(%%mm1, %%mm4) |
2037 PAVGB(%%mm3, %%mm2) | 2010 PAVGB(%%mm3, %%mm2) |
2038 "punpcklbw %%mm7, %%mm4 \n\t" | 2011 "punpcklbw %%mm7, %%mm4 \n\t" |
2039 "punpcklbw %%mm7, %%mm2 \n\t" | 2012 "punpcklbw %%mm7, %%mm2 \n\t" |
2040 #else | 2013 #else |
2041 "movd 12(%0, %%"REG_d"), %%mm4 \n\t" | 2014 "movd 12(%0, %%"REG_d"), %%mm4 \n\t" |
2042 "movd 12(%1, %%"REG_d"), %%mm1 \n\t" | |
2043 "movd 15(%0, %%"REG_d"), %%mm2 \n\t" | 2015 "movd 15(%0, %%"REG_d"), %%mm2 \n\t" |
2044 "movd 15(%1, %%"REG_d"), %%mm3 \n\t" | |
2045 "punpcklbw %%mm7, %%mm4 \n\t" | 2016 "punpcklbw %%mm7, %%mm4 \n\t" |
2046 "punpcklbw %%mm7, %%mm1 \n\t" | |
2047 "punpcklbw %%mm7, %%mm2 \n\t" | 2017 "punpcklbw %%mm7, %%mm2 \n\t" |
2048 "punpcklbw %%mm7, %%mm3 \n\t" | |
2049 "paddw %%mm1, %%mm4 \n\t" | |
2050 "paddw %%mm3, %%mm2 \n\t" | |
2051 "paddw %%mm2, %%mm4 \n\t" | 2018 "paddw %%mm2, %%mm4 \n\t" |
2052 "movd 18(%0, %%"REG_d"), %%mm5 \n\t" | 2019 "movd 18(%0, %%"REG_d"), %%mm5 \n\t" |
2053 "movd 18(%1, %%"REG_d"), %%mm1 \n\t" | |
2054 "movd 21(%0, %%"REG_d"), %%mm2 \n\t" | 2020 "movd 21(%0, %%"REG_d"), %%mm2 \n\t" |
2055 "movd 21(%1, %%"REG_d"), %%mm3 \n\t" | |
2056 "punpcklbw %%mm7, %%mm5 \n\t" | 2021 "punpcklbw %%mm7, %%mm5 \n\t" |
2057 "punpcklbw %%mm7, %%mm1 \n\t" | |
2058 "punpcklbw %%mm7, %%mm2 \n\t" | 2022 "punpcklbw %%mm7, %%mm2 \n\t" |
2059 "punpcklbw %%mm7, %%mm3 \n\t" | |
2060 "paddw %%mm1, %%mm5 \n\t" | |
2061 "paddw %%mm3, %%mm2 \n\t" | |
2062 "paddw %%mm5, %%mm2 \n\t" | 2023 "paddw %%mm5, %%mm2 \n\t" |
2063 "movq "MANGLE(w1111)", %%mm5 \n\t" | 2024 "movq "MANGLE(w1111)", %%mm5 \n\t" |
2064 "psrlw $2, %%mm4 \n\t" | 2025 "psrlw $2, %%mm4 \n\t" |
2065 "psrlw $2, %%mm2 \n\t" | 2026 "psrlw $2, %%mm2 \n\t" |
2066 #endif | 2027 #endif |
2089 "punpckldq %%mm4, %%mm0 \n\t" | 2050 "punpckldq %%mm4, %%mm0 \n\t" |
2090 "punpckhdq %%mm4, %%mm1 \n\t" | 2051 "punpckhdq %%mm4, %%mm1 \n\t" |
2091 "packsswb %%mm1, %%mm0 \n\t" | 2052 "packsswb %%mm1, %%mm0 \n\t" |
2092 "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" | 2053 "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" |
2093 | 2054 |
2055 "movd %%mm0, (%1, %%"REG_a") \n\t" | |
2056 "punpckhdq %%mm0, %%mm0 \n\t" | |
2094 "movd %%mm0, (%2, %%"REG_a") \n\t" | 2057 "movd %%mm0, (%2, %%"REG_a") \n\t" |
2095 "punpckhdq %%mm0, %%mm0 \n\t" | |
2096 "movd %%mm0, (%3, %%"REG_a") \n\t" | |
2097 "add $4, %%"REG_a" \n\t" | 2058 "add $4, %%"REG_a" \n\t" |
2098 " js 1b \n\t" | 2059 " js 1b \n\t" |
2099 : : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width) | 2060 : : "r" (src1+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width) |
2100 : "%"REG_a, "%"REG_d | 2061 : "%"REG_a, "%"REG_d |
2101 ); | 2062 ); |
2102 #else | 2063 #else |
2103 int i; | 2064 int i; |
2104 for(i=0; i<width; i++) | 2065 for(i=0; i<width; i++) |
2105 { | 2066 { |
2106 int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | 2067 int b= src1[6*i + 0] + src1[6*i + 3]; |
2107 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | 2068 int g= src1[6*i + 1] + src1[6*i + 4]; |
2108 int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | 2069 int r= src1[6*i + 2] + src1[6*i + 5]; |
2109 | 2070 |
2110 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | 2071 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128; |
2111 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | 2072 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128; |
2112 } | 2073 } |
2113 #endif | 2074 #endif |
2114 } | 2075 } |
2115 | 2076 |
2116 static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width) | 2077 static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width) |
2127 } | 2088 } |
2128 } | 2089 } |
2129 | 2090 |
2130 static inline void RENAME(bgr16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | 2091 static inline void RENAME(bgr16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
2131 { | 2092 { |
2093 assert(src1==src2); | |
2132 int i; | 2094 int i; |
2133 for(i=0; i<width; i++) | 2095 for(i=0; i<width; i++) |
2134 { | 2096 { |
2135 int d0= ((uint32_t*)src1)[i]; | 2097 int d0= ((uint32_t*)src1)[i]; |
2136 int d1= ((uint32_t*)src2)[i]; | |
2137 | 2098 |
2138 int dl= (d0&0x07E0F81F) + (d1&0x07E0F81F); | 2099 int dl= (d0&0x07E0F81F); |
2139 int dh= ((d0>>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F); | 2100 int dh= ((d0>>5)&0x07C0F83F); |
2140 | 2101 |
2141 int dh2= (dh>>11) + (dh<<21); | 2102 int dh2= (dh>>11) + (dh<<21); |
2142 int d= dh2 + dl; | 2103 int d= dh2 + dl; |
2143 | 2104 |
2144 int b= d&0x7F; | 2105 int b= d&0x7F; |
2145 int r= (d>>11)&0x7F; | 2106 int r= (d>>11)&0x7F; |
2146 int g= d>>21; | 2107 int g= d>>21; |
2147 dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128; | 2108 dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+1-2)) + 128; |
2148 dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128; | 2109 dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+1-2)) + 128; |
2149 } | 2110 } |
2150 } | 2111 } |
2151 | 2112 |
2152 static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width) | 2113 static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width) |
2153 { | 2114 { |
2164 } | 2125 } |
2165 | 2126 |
2166 static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | 2127 static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
2167 { | 2128 { |
2168 int i; | 2129 int i; |
2130 assert(src1==src2); | |
2169 for(i=0; i<width; i++) | 2131 for(i=0; i<width; i++) |
2170 { | 2132 { |
2171 int d0= ((uint32_t*)src1)[i]; | 2133 int d0= ((uint32_t*)src1)[i]; |
2172 int d1= ((uint32_t*)src2)[i]; | |
2173 | 2134 |
2174 int dl= (d0&0x03E07C1F) + (d1&0x03E07C1F); | 2135 int dl= (d0&0x03E07C1F); |
2175 int dh= ((d0>>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F); | 2136 int dh= ((d0>>5)&0x03E0F81F); |
2176 | 2137 |
2177 int dh2= (dh>>11) + (dh<<21); | 2138 int dh2= (dh>>11) + (dh<<21); |
2178 int d= dh2 + dl; | 2139 int d= dh2 + dl; |
2179 | 2140 |
2180 int b= d&0x7F; | 2141 int b= d&0x7F; |
2181 int r= (d>>10)&0x7F; | 2142 int r= (d>>10)&0x7F; |
2182 int g= d>>21; | 2143 int g= d>>21; |
2183 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | 2144 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128; |
2184 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | 2145 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128; |
2185 } | 2146 } |
2186 } | 2147 } |
2187 | 2148 |
2188 | 2149 |
2189 static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, int width) | 2150 static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, int width) |
2200 } | 2161 } |
2201 | 2162 |
2202 static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | 2163 static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
2203 { | 2164 { |
2204 int i; | 2165 int i; |
2166 assert(src1==src2); | |
2205 for(i=0; i<width; i++) | 2167 for(i=0; i<width; i++) |
2206 { | 2168 { |
2207 const int a= ((uint32_t*)src1)[2*i+0]; | 2169 const int a= ((uint32_t*)src1)[2*i+0]; |
2208 const int e= ((uint32_t*)src1)[2*i+1]; | 2170 const int e= ((uint32_t*)src1)[2*i+1]; |
2209 const int c= ((uint32_t*)src2)[2*i+0]; | 2171 const int l= (a&0xFF00FF) + (e&0xFF00FF); |
2210 const int d= ((uint32_t*)src2)[2*i+1]; | 2172 const int h= (a&0x00FF00) + (e&0x00FF00); |
2211 const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF); | |
2212 const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00); | |
2213 const int r= l&0x3FF; | 2173 const int r= l&0x3FF; |
2214 const int g= h>>8; | 2174 const int g= h>>8; |
2215 const int b= l>>16; | 2175 const int b= l>>16; |
2216 | 2176 |
2217 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | 2177 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128; |
2218 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | 2178 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128; |
2219 } | 2179 } |
2220 } | 2180 } |
2221 | 2181 |
2222 static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) | 2182 static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) |
2223 { | 2183 { |
2233 } | 2193 } |
2234 | 2194 |
2235 static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | 2195 static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
2236 { | 2196 { |
2237 int i; | 2197 int i; |
2198 assert(src1==src2); | |
2238 for(i=0; i<width; i++) | 2199 for(i=0; i<width; i++) |
2239 { | 2200 { |
2240 int r= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | 2201 int r= src1[6*i + 0] + src1[6*i + 3]; |
2241 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | 2202 int g= src1[6*i + 1] + src1[6*i + 4]; |
2242 int b= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | 2203 int b= src1[6*i + 2] + src1[6*i + 5]; |
2243 | 2204 |
2244 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | 2205 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128; |
2245 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | 2206 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128; |
2246 } | 2207 } |
2247 } | 2208 } |
2248 | 2209 |
2249 static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width) | 2210 static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width) |
2250 { | 2211 { |