comparison h264.c @ 5638:4a26dc4ca11d libavcodec

Move H.264 intra prediction functions into their own context
author kostya
date Wed, 05 Sep 2007 05:30:08 +0000
parents 550e37ec2204
children d2598034f2a9
comparison
equal deleted inserted replaced
5637:473cada682a1 5638:4a26dc4ca11d
1679 } 1679 }
1680 1680
1681 return last_non_zero; 1681 return last_non_zero;
1682 } 1682 }
1683 1683
1684 static void pred4x4_vertical_c(uint8_t *src, uint8_t *topright, int stride){
1685 const uint32_t a= ((uint32_t*)(src-stride))[0];
1686 ((uint32_t*)(src+0*stride))[0]= a;
1687 ((uint32_t*)(src+1*stride))[0]= a;
1688 ((uint32_t*)(src+2*stride))[0]= a;
1689 ((uint32_t*)(src+3*stride))[0]= a;
1690 }
1691
1692 static void pred4x4_horizontal_c(uint8_t *src, uint8_t *topright, int stride){
1693 ((uint32_t*)(src+0*stride))[0]= src[-1+0*stride]*0x01010101;
1694 ((uint32_t*)(src+1*stride))[0]= src[-1+1*stride]*0x01010101;
1695 ((uint32_t*)(src+2*stride))[0]= src[-1+2*stride]*0x01010101;
1696 ((uint32_t*)(src+3*stride))[0]= src[-1+3*stride]*0x01010101;
1697 }
1698
1699 static void pred4x4_dc_c(uint8_t *src, uint8_t *topright, int stride){
1700 const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride]
1701 + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3;
1702
1703 ((uint32_t*)(src+0*stride))[0]=
1704 ((uint32_t*)(src+1*stride))[0]=
1705 ((uint32_t*)(src+2*stride))[0]=
1706 ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101;
1707 }
1708
1709 static void pred4x4_left_dc_c(uint8_t *src, uint8_t *topright, int stride){
1710 const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
1711
1712 ((uint32_t*)(src+0*stride))[0]=
1713 ((uint32_t*)(src+1*stride))[0]=
1714 ((uint32_t*)(src+2*stride))[0]=
1715 ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101;
1716 }
1717
1718 static void pred4x4_top_dc_c(uint8_t *src, uint8_t *topright, int stride){
1719 const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;
1720
1721 ((uint32_t*)(src+0*stride))[0]=
1722 ((uint32_t*)(src+1*stride))[0]=
1723 ((uint32_t*)(src+2*stride))[0]=
1724 ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101;
1725 }
1726
1727 static void pred4x4_128_dc_c(uint8_t *src, uint8_t *topright, int stride){
1728 ((uint32_t*)(src+0*stride))[0]=
1729 ((uint32_t*)(src+1*stride))[0]=
1730 ((uint32_t*)(src+2*stride))[0]=
1731 ((uint32_t*)(src+3*stride))[0]= 128U*0x01010101U;
1732 }
1733
1734
1735 #define LOAD_TOP_RIGHT_EDGE\
1736 const int av_unused t4= topright[0];\
1737 const int av_unused t5= topright[1];\
1738 const int av_unused t6= topright[2];\
1739 const int av_unused t7= topright[3];\
1740
1741 #define LOAD_LEFT_EDGE\
1742 const int av_unused l0= src[-1+0*stride];\
1743 const int av_unused l1= src[-1+1*stride];\
1744 const int av_unused l2= src[-1+2*stride];\
1745 const int av_unused l3= src[-1+3*stride];\
1746
1747 #define LOAD_TOP_EDGE\
1748 const int av_unused t0= src[ 0-1*stride];\
1749 const int av_unused t1= src[ 1-1*stride];\
1750 const int av_unused t2= src[ 2-1*stride];\
1751 const int av_unused t3= src[ 3-1*stride];\
1752
1753 static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){
1754 const int lt= src[-1-1*stride];
1755 LOAD_TOP_EDGE
1756 LOAD_LEFT_EDGE
1757
1758 src[0+3*stride]=(l3 + 2*l2 + l1 + 2)>>2;
1759 src[0+2*stride]=
1760 src[1+3*stride]=(l2 + 2*l1 + l0 + 2)>>2;
1761 src[0+1*stride]=
1762 src[1+2*stride]=
1763 src[2+3*stride]=(l1 + 2*l0 + lt + 2)>>2;
1764 src[0+0*stride]=
1765 src[1+1*stride]=
1766 src[2+2*stride]=
1767 src[3+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
1768 src[1+0*stride]=
1769 src[2+1*stride]=
1770 src[3+2*stride]=(lt + 2*t0 + t1 + 2)>>2;
1771 src[2+0*stride]=
1772 src[3+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
1773 src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2;
1774 }
1775
1776 static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){
1777 LOAD_TOP_EDGE
1778 LOAD_TOP_RIGHT_EDGE
1779 // LOAD_LEFT_EDGE
1780
1781 src[0+0*stride]=(t0 + t2 + 2*t1 + 2)>>2;
1782 src[1+0*stride]=
1783 src[0+1*stride]=(t1 + t3 + 2*t2 + 2)>>2;
1784 src[2+0*stride]=
1785 src[1+1*stride]=
1786 src[0+2*stride]=(t2 + t4 + 2*t3 + 2)>>2;
1787 src[3+0*stride]=
1788 src[2+1*stride]=
1789 src[1+2*stride]=
1790 src[0+3*stride]=(t3 + t5 + 2*t4 + 2)>>2;
1791 src[3+1*stride]=
1792 src[2+2*stride]=
1793 src[1+3*stride]=(t4 + t6 + 2*t5 + 2)>>2;
1794 src[3+2*stride]=
1795 src[2+3*stride]=(t5 + t7 + 2*t6 + 2)>>2;
1796 src[3+3*stride]=(t6 + 3*t7 + 2)>>2;
1797 }
1798
1799 static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride){
1800 const int lt= src[-1-1*stride];
1801 LOAD_TOP_EDGE
1802 LOAD_LEFT_EDGE
1803
1804 src[0+0*stride]=
1805 src[1+2*stride]=(lt + t0 + 1)>>1;
1806 src[1+0*stride]=
1807 src[2+2*stride]=(t0 + t1 + 1)>>1;
1808 src[2+0*stride]=
1809 src[3+2*stride]=(t1 + t2 + 1)>>1;
1810 src[3+0*stride]=(t2 + t3 + 1)>>1;
1811 src[0+1*stride]=
1812 src[1+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
1813 src[1+1*stride]=
1814 src[2+3*stride]=(lt + 2*t0 + t1 + 2)>>2;
1815 src[2+1*stride]=
1816 src[3+3*stride]=(t0 + 2*t1 + t2 + 2)>>2;
1817 src[3+1*stride]=(t1 + 2*t2 + t3 + 2)>>2;
1818 src[0+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
1819 src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
1820 }
1821
1822 static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride){
1823 LOAD_TOP_EDGE
1824 LOAD_TOP_RIGHT_EDGE
1825
1826 src[0+0*stride]=(t0 + t1 + 1)>>1;
1827 src[1+0*stride]=
1828 src[0+2*stride]=(t1 + t2 + 1)>>1;
1829 src[2+0*stride]=
1830 src[1+2*stride]=(t2 + t3 + 1)>>1;
1831 src[3+0*stride]=
1832 src[2+2*stride]=(t3 + t4+ 1)>>1;
1833 src[3+2*stride]=(t4 + t5+ 1)>>1;
1834 src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
1835 src[1+1*stride]=
1836 src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
1837 src[2+1*stride]=
1838 src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
1839 src[3+1*stride]=
1840 src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
1841 src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
1842 }
1843
1844 static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride){
1845 LOAD_LEFT_EDGE
1846
1847 src[0+0*stride]=(l0 + l1 + 1)>>1;
1848 src[1+0*stride]=(l0 + 2*l1 + l2 + 2)>>2;
1849 src[2+0*stride]=
1850 src[0+1*stride]=(l1 + l2 + 1)>>1;
1851 src[3+0*stride]=
1852 src[1+1*stride]=(l1 + 2*l2 + l3 + 2)>>2;
1853 src[2+1*stride]=
1854 src[0+2*stride]=(l2 + l3 + 1)>>1;
1855 src[3+1*stride]=
1856 src[1+2*stride]=(l2 + 2*l3 + l3 + 2)>>2;
1857 src[3+2*stride]=
1858 src[1+3*stride]=
1859 src[0+3*stride]=
1860 src[2+2*stride]=
1861 src[2+3*stride]=
1862 src[3+3*stride]=l3;
1863 }
1864
1865 static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int stride){
1866 const int lt= src[-1-1*stride];
1867 LOAD_TOP_EDGE
1868 LOAD_LEFT_EDGE
1869
1870 src[0+0*stride]=
1871 src[2+1*stride]=(lt + l0 + 1)>>1;
1872 src[1+0*stride]=
1873 src[3+1*stride]=(l0 + 2*lt + t0 + 2)>>2;
1874 src[2+0*stride]=(lt + 2*t0 + t1 + 2)>>2;
1875 src[3+0*stride]=(t0 + 2*t1 + t2 + 2)>>2;
1876 src[0+1*stride]=
1877 src[2+2*stride]=(l0 + l1 + 1)>>1;
1878 src[1+1*stride]=
1879 src[3+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
1880 src[0+2*stride]=
1881 src[2+3*stride]=(l1 + l2+ 1)>>1;
1882 src[1+2*stride]=
1883 src[3+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
1884 src[0+3*stride]=(l2 + l3 + 1)>>1;
1885 src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
1886 }
1887
1888 void ff_pred16x16_vertical_c(uint8_t *src, int stride){
1889 int i;
1890 const uint32_t a= ((uint32_t*)(src-stride))[0];
1891 const uint32_t b= ((uint32_t*)(src-stride))[1];
1892 const uint32_t c= ((uint32_t*)(src-stride))[2];
1893 const uint32_t d= ((uint32_t*)(src-stride))[3];
1894
1895 for(i=0; i<16; i++){
1896 ((uint32_t*)(src+i*stride))[0]= a;
1897 ((uint32_t*)(src+i*stride))[1]= b;
1898 ((uint32_t*)(src+i*stride))[2]= c;
1899 ((uint32_t*)(src+i*stride))[3]= d;
1900 }
1901 }
1902
1903 void ff_pred16x16_horizontal_c(uint8_t *src, int stride){
1904 int i;
1905
1906 for(i=0; i<16; i++){
1907 ((uint32_t*)(src+i*stride))[0]=
1908 ((uint32_t*)(src+i*stride))[1]=
1909 ((uint32_t*)(src+i*stride))[2]=
1910 ((uint32_t*)(src+i*stride))[3]= src[-1+i*stride]*0x01010101;
1911 }
1912 }
1913
1914 void ff_pred16x16_dc_c(uint8_t *src, int stride){
1915 int i, dc=0;
1916
1917 for(i=0;i<16; i++){
1918 dc+= src[-1+i*stride];
1919 }
1920
1921 for(i=0;i<16; i++){
1922 dc+= src[i-stride];
1923 }
1924
1925 dc= 0x01010101*((dc + 16)>>5);
1926
1927 for(i=0; i<16; i++){
1928 ((uint32_t*)(src+i*stride))[0]=
1929 ((uint32_t*)(src+i*stride))[1]=
1930 ((uint32_t*)(src+i*stride))[2]=
1931 ((uint32_t*)(src+i*stride))[3]= dc;
1932 }
1933 }
1934
1935 void ff_pred16x16_left_dc_c(uint8_t *src, int stride){
1936 int i, dc=0;
1937
1938 for(i=0;i<16; i++){
1939 dc+= src[-1+i*stride];
1940 }
1941
1942 dc= 0x01010101*((dc + 8)>>4);
1943
1944 for(i=0; i<16; i++){
1945 ((uint32_t*)(src+i*stride))[0]=
1946 ((uint32_t*)(src+i*stride))[1]=
1947 ((uint32_t*)(src+i*stride))[2]=
1948 ((uint32_t*)(src+i*stride))[3]= dc;
1949 }
1950 }
1951
1952 void ff_pred16x16_top_dc_c(uint8_t *src, int stride){
1953 int i, dc=0;
1954
1955 for(i=0;i<16; i++){
1956 dc+= src[i-stride];
1957 }
1958 dc= 0x01010101*((dc + 8)>>4);
1959
1960 for(i=0; i<16; i++){
1961 ((uint32_t*)(src+i*stride))[0]=
1962 ((uint32_t*)(src+i*stride))[1]=
1963 ((uint32_t*)(src+i*stride))[2]=
1964 ((uint32_t*)(src+i*stride))[3]= dc;
1965 }
1966 }
1967
1968 void ff_pred16x16_128_dc_c(uint8_t *src, int stride){
1969 int i;
1970
1971 for(i=0; i<16; i++){
1972 ((uint32_t*)(src+i*stride))[0]=
1973 ((uint32_t*)(src+i*stride))[1]=
1974 ((uint32_t*)(src+i*stride))[2]=
1975 ((uint32_t*)(src+i*stride))[3]= 0x01010101U*128U;
1976 }
1977 }
1978
1979 static inline void pred16x16_plane_compat_c(uint8_t *src, int stride, const int svq3){
1980 int i, j, k;
1981 int a;
1982 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
1983 const uint8_t * const src0 = src+7-stride;
1984 const uint8_t *src1 = src+8*stride-1;
1985 const uint8_t *src2 = src1-2*stride; // == src+6*stride-1;
1986 int H = src0[1] - src0[-1];
1987 int V = src1[0] - src2[ 0];
1988 for(k=2; k<=8; ++k) {
1989 src1 += stride; src2 -= stride;
1990 H += k*(src0[k] - src0[-k]);
1991 V += k*(src1[0] - src2[ 0]);
1992 }
1993 if(svq3){
1994 H = ( 5*(H/4) ) / 16;
1995 V = ( 5*(V/4) ) / 16;
1996
1997 /* required for 100% accuracy */
1998 i = H; H = V; V = i;
1999 }else{
2000 H = ( 5*H+32 ) >> 6;
2001 V = ( 5*V+32 ) >> 6;
2002 }
2003
2004 a = 16*(src1[0] + src2[16] + 1) - 7*(V+H);
2005 for(j=16; j>0; --j) {
2006 int b = a;
2007 a += V;
2008 for(i=-16; i<0; i+=4) {
2009 src[16+i] = cm[ (b ) >> 5 ];
2010 src[17+i] = cm[ (b+ H) >> 5 ];
2011 src[18+i] = cm[ (b+2*H) >> 5 ];
2012 src[19+i] = cm[ (b+3*H) >> 5 ];
2013 b += 4*H;
2014 }
2015 src += stride;
2016 }
2017 }
2018
2019 void ff_pred16x16_plane_c(uint8_t *src, int stride){
2020 pred16x16_plane_compat_c(src, stride, 0);
2021 }
2022
2023 void ff_pred8x8_vertical_c(uint8_t *src, int stride){
2024 int i;
2025 const uint32_t a= ((uint32_t*)(src-stride))[0];
2026 const uint32_t b= ((uint32_t*)(src-stride))[1];
2027
2028 for(i=0; i<8; i++){
2029 ((uint32_t*)(src+i*stride))[0]= a;
2030 ((uint32_t*)(src+i*stride))[1]= b;
2031 }
2032 }
2033
2034 void ff_pred8x8_horizontal_c(uint8_t *src, int stride){
2035 int i;
2036
2037 for(i=0; i<8; i++){
2038 ((uint32_t*)(src+i*stride))[0]=
2039 ((uint32_t*)(src+i*stride))[1]= src[-1+i*stride]*0x01010101;
2040 }
2041 }
2042
2043 void ff_pred8x8_128_dc_c(uint8_t *src, int stride){
2044 int i;
2045
2046 for(i=0; i<8; i++){
2047 ((uint32_t*)(src+i*stride))[0]=
2048 ((uint32_t*)(src+i*stride))[1]= 0x01010101U*128U;
2049 }
2050 }
2051
2052 void ff_pred8x8_left_dc_c(uint8_t *src, int stride){
2053 int i;
2054 int dc0, dc2;
2055
2056 dc0=dc2=0;
2057 for(i=0;i<4; i++){
2058 dc0+= src[-1+i*stride];
2059 dc2+= src[-1+(i+4)*stride];
2060 }
2061 dc0= 0x01010101*((dc0 + 2)>>2);
2062 dc2= 0x01010101*((dc2 + 2)>>2);
2063
2064 for(i=0; i<4; i++){
2065 ((uint32_t*)(src+i*stride))[0]=
2066 ((uint32_t*)(src+i*stride))[1]= dc0;
2067 }
2068 for(i=4; i<8; i++){
2069 ((uint32_t*)(src+i*stride))[0]=
2070 ((uint32_t*)(src+i*stride))[1]= dc2;
2071 }
2072 }
2073
2074 void ff_pred8x8_top_dc_c(uint8_t *src, int stride){
2075 int i;
2076 int dc0, dc1;
2077
2078 dc0=dc1=0;
2079 for(i=0;i<4; i++){
2080 dc0+= src[i-stride];
2081 dc1+= src[4+i-stride];
2082 }
2083 dc0= 0x01010101*((dc0 + 2)>>2);
2084 dc1= 0x01010101*((dc1 + 2)>>2);
2085
2086 for(i=0; i<4; i++){
2087 ((uint32_t*)(src+i*stride))[0]= dc0;
2088 ((uint32_t*)(src+i*stride))[1]= dc1;
2089 }
2090 for(i=4; i<8; i++){
2091 ((uint32_t*)(src+i*stride))[0]= dc0;
2092 ((uint32_t*)(src+i*stride))[1]= dc1;
2093 }
2094 }
2095
2096
2097 void ff_pred8x8_dc_c(uint8_t *src, int stride){
2098 int i;
2099 int dc0, dc1, dc2, dc3;
2100
2101 dc0=dc1=dc2=0;
2102 for(i=0;i<4; i++){
2103 dc0+= src[-1+i*stride] + src[i-stride];
2104 dc1+= src[4+i-stride];
2105 dc2+= src[-1+(i+4)*stride];
2106 }
2107 dc3= 0x01010101*((dc1 + dc2 + 4)>>3);
2108 dc0= 0x01010101*((dc0 + 4)>>3);
2109 dc1= 0x01010101*((dc1 + 2)>>2);
2110 dc2= 0x01010101*((dc2 + 2)>>2);
2111
2112 for(i=0; i<4; i++){
2113 ((uint32_t*)(src+i*stride))[0]= dc0;
2114 ((uint32_t*)(src+i*stride))[1]= dc1;
2115 }
2116 for(i=4; i<8; i++){
2117 ((uint32_t*)(src+i*stride))[0]= dc2;
2118 ((uint32_t*)(src+i*stride))[1]= dc3;
2119 }
2120 }
2121
2122 void ff_pred8x8_plane_c(uint8_t *src, int stride){
2123 int j, k;
2124 int a;
2125 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
2126 const uint8_t * const src0 = src+3-stride;
2127 const uint8_t *src1 = src+4*stride-1;
2128 const uint8_t *src2 = src1-2*stride; // == src+2*stride-1;
2129 int H = src0[1] - src0[-1];
2130 int V = src1[0] - src2[ 0];
2131 for(k=2; k<=4; ++k) {
2132 src1 += stride; src2 -= stride;
2133 H += k*(src0[k] - src0[-k]);
2134 V += k*(src1[0] - src2[ 0]);
2135 }
2136 H = ( 17*H+16 ) >> 5;
2137 V = ( 17*V+16 ) >> 5;
2138
2139 a = 16*(src1[0] + src2[8]+1) - 3*(V+H);
2140 for(j=8; j>0; --j) {
2141 int b = a;
2142 a += V;
2143 src[0] = cm[ (b ) >> 5 ];
2144 src[1] = cm[ (b+ H) >> 5 ];
2145 src[2] = cm[ (b+2*H) >> 5 ];
2146 src[3] = cm[ (b+3*H) >> 5 ];
2147 src[4] = cm[ (b+4*H) >> 5 ];
2148 src[5] = cm[ (b+5*H) >> 5 ];
2149 src[6] = cm[ (b+6*H) >> 5 ];
2150 src[7] = cm[ (b+7*H) >> 5 ];
2151 src += stride;
2152 }
2153 }
2154
2155 #define SRC(x,y) src[(x)+(y)*stride]
2156 #define PL(y) \
2157 const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
2158 #define PREDICT_8x8_LOAD_LEFT \
2159 const int l0 = ((has_topleft ? SRC(-1,-1) : SRC(-1,0)) \
2160 + 2*SRC(-1,0) + SRC(-1,1) + 2) >> 2; \
2161 PL(1) PL(2) PL(3) PL(4) PL(5) PL(6) \
2162 const int l7 av_unused = (SRC(-1,6) + 3*SRC(-1,7) + 2) >> 2
2163
2164 #define PT(x) \
2165 const int t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
2166 #define PREDICT_8x8_LOAD_TOP \
2167 const int t0 = ((has_topleft ? SRC(-1,-1) : SRC(0,-1)) \
2168 + 2*SRC(0,-1) + SRC(1,-1) + 2) >> 2; \
2169 PT(1) PT(2) PT(3) PT(4) PT(5) PT(6) \
2170 const int t7 av_unused = ((has_topright ? SRC(8,-1) : SRC(7,-1)) \
2171 + 2*SRC(7,-1) + SRC(6,-1) + 2) >> 2
2172
2173 #define PTR(x) \
2174 t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
2175 #define PREDICT_8x8_LOAD_TOPRIGHT \
2176 int t8, t9, t10, t11, t12, t13, t14, t15; \
2177 if(has_topright) { \
2178 PTR(8) PTR(9) PTR(10) PTR(11) PTR(12) PTR(13) PTR(14) \
2179 t15 = (SRC(14,-1) + 3*SRC(15,-1) + 2) >> 2; \
2180 } else t8=t9=t10=t11=t12=t13=t14=t15= SRC(7,-1);
2181
2182 #define PREDICT_8x8_LOAD_TOPLEFT \
2183 const int lt = (SRC(-1,0) + 2*SRC(-1,-1) + SRC(0,-1) + 2) >> 2
2184
2185 #define PREDICT_8x8_DC(v) \
2186 int y; \
2187 for( y = 0; y < 8; y++ ) { \
2188 ((uint32_t*)src)[0] = \
2189 ((uint32_t*)src)[1] = v; \
2190 src += stride; \
2191 }
2192
2193 static void pred8x8l_128_dc_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2194 {
2195 PREDICT_8x8_DC(0x80808080);
2196 }
2197 static void pred8x8l_left_dc_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2198 {
2199 PREDICT_8x8_LOAD_LEFT;
2200 const uint32_t dc = ((l0+l1+l2+l3+l4+l5+l6+l7+4) >> 3) * 0x01010101;
2201 PREDICT_8x8_DC(dc);
2202 }
2203 static void pred8x8l_top_dc_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2204 {
2205 PREDICT_8x8_LOAD_TOP;
2206 const uint32_t dc = ((t0+t1+t2+t3+t4+t5+t6+t7+4) >> 3) * 0x01010101;
2207 PREDICT_8x8_DC(dc);
2208 }
2209 static void pred8x8l_dc_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2210 {
2211 PREDICT_8x8_LOAD_LEFT;
2212 PREDICT_8x8_LOAD_TOP;
2213 const uint32_t dc = ((l0+l1+l2+l3+l4+l5+l6+l7
2214 +t0+t1+t2+t3+t4+t5+t6+t7+8) >> 4) * 0x01010101;
2215 PREDICT_8x8_DC(dc);
2216 }
2217 static void pred8x8l_horizontal_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2218 {
2219 PREDICT_8x8_LOAD_LEFT;
2220 #define ROW(y) ((uint32_t*)(src+y*stride))[0] =\
2221 ((uint32_t*)(src+y*stride))[1] = 0x01010101 * l##y
2222 ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
2223 #undef ROW
2224 }
2225 static void pred8x8l_vertical_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2226 {
2227 int y;
2228 PREDICT_8x8_LOAD_TOP;
2229 src[0] = t0;
2230 src[1] = t1;
2231 src[2] = t2;
2232 src[3] = t3;
2233 src[4] = t4;
2234 src[5] = t5;
2235 src[6] = t6;
2236 src[7] = t7;
2237 for( y = 1; y < 8; y++ )
2238 *(uint64_t*)(src+y*stride) = *(uint64_t*)src;
2239 }
2240 static void pred8x8l_down_left_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2241 {
2242 PREDICT_8x8_LOAD_TOP;
2243 PREDICT_8x8_LOAD_TOPRIGHT;
2244 SRC(0,0)= (t0 + 2*t1 + t2 + 2) >> 2;
2245 SRC(0,1)=SRC(1,0)= (t1 + 2*t2 + t3 + 2) >> 2;
2246 SRC(0,2)=SRC(1,1)=SRC(2,0)= (t2 + 2*t3 + t4 + 2) >> 2;
2247 SRC(0,3)=SRC(1,2)=SRC(2,1)=SRC(3,0)= (t3 + 2*t4 + t5 + 2) >> 2;
2248 SRC(0,4)=SRC(1,3)=SRC(2,2)=SRC(3,1)=SRC(4,0)= (t4 + 2*t5 + t6 + 2) >> 2;
2249 SRC(0,5)=SRC(1,4)=SRC(2,3)=SRC(3,2)=SRC(4,1)=SRC(5,0)= (t5 + 2*t6 + t7 + 2) >> 2;
2250 SRC(0,6)=SRC(1,5)=SRC(2,4)=SRC(3,3)=SRC(4,2)=SRC(5,1)=SRC(6,0)= (t6 + 2*t7 + t8 + 2) >> 2;
2251 SRC(0,7)=SRC(1,6)=SRC(2,5)=SRC(3,4)=SRC(4,3)=SRC(5,2)=SRC(6,1)=SRC(7,0)= (t7 + 2*t8 + t9 + 2) >> 2;
2252 SRC(1,7)=SRC(2,6)=SRC(3,5)=SRC(4,4)=SRC(5,3)=SRC(6,2)=SRC(7,1)= (t8 + 2*t9 + t10 + 2) >> 2;
2253 SRC(2,7)=SRC(3,6)=SRC(4,5)=SRC(5,4)=SRC(6,3)=SRC(7,2)= (t9 + 2*t10 + t11 + 2) >> 2;
2254 SRC(3,7)=SRC(4,6)=SRC(5,5)=SRC(6,4)=SRC(7,3)= (t10 + 2*t11 + t12 + 2) >> 2;
2255 SRC(4,7)=SRC(5,6)=SRC(6,5)=SRC(7,4)= (t11 + 2*t12 + t13 + 2) >> 2;
2256 SRC(5,7)=SRC(6,6)=SRC(7,5)= (t12 + 2*t13 + t14 + 2) >> 2;
2257 SRC(6,7)=SRC(7,6)= (t13 + 2*t14 + t15 + 2) >> 2;
2258 SRC(7,7)= (t14 + 3*t15 + 2) >> 2;
2259 }
2260 static void pred8x8l_down_right_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2261 {
2262 PREDICT_8x8_LOAD_TOP;
2263 PREDICT_8x8_LOAD_LEFT;
2264 PREDICT_8x8_LOAD_TOPLEFT;
2265 SRC(0,7)= (l7 + 2*l6 + l5 + 2) >> 2;
2266 SRC(0,6)=SRC(1,7)= (l6 + 2*l5 + l4 + 2) >> 2;
2267 SRC(0,5)=SRC(1,6)=SRC(2,7)= (l5 + 2*l4 + l3 + 2) >> 2;
2268 SRC(0,4)=SRC(1,5)=SRC(2,6)=SRC(3,7)= (l4 + 2*l3 + l2 + 2) >> 2;
2269 SRC(0,3)=SRC(1,4)=SRC(2,5)=SRC(3,6)=SRC(4,7)= (l3 + 2*l2 + l1 + 2) >> 2;
2270 SRC(0,2)=SRC(1,3)=SRC(2,4)=SRC(3,5)=SRC(4,6)=SRC(5,7)= (l2 + 2*l1 + l0 + 2) >> 2;
2271 SRC(0,1)=SRC(1,2)=SRC(2,3)=SRC(3,4)=SRC(4,5)=SRC(5,6)=SRC(6,7)= (l1 + 2*l0 + lt + 2) >> 2;
2272 SRC(0,0)=SRC(1,1)=SRC(2,2)=SRC(3,3)=SRC(4,4)=SRC(5,5)=SRC(6,6)=SRC(7,7)= (l0 + 2*lt + t0 + 2) >> 2;
2273 SRC(1,0)=SRC(2,1)=SRC(3,2)=SRC(4,3)=SRC(5,4)=SRC(6,5)=SRC(7,6)= (lt + 2*t0 + t1 + 2) >> 2;
2274 SRC(2,0)=SRC(3,1)=SRC(4,2)=SRC(5,3)=SRC(6,4)=SRC(7,5)= (t0 + 2*t1 + t2 + 2) >> 2;
2275 SRC(3,0)=SRC(4,1)=SRC(5,2)=SRC(6,3)=SRC(7,4)= (t1 + 2*t2 + t3 + 2) >> 2;
2276 SRC(4,0)=SRC(5,1)=SRC(6,2)=SRC(7,3)= (t2 + 2*t3 + t4 + 2) >> 2;
2277 SRC(5,0)=SRC(6,1)=SRC(7,2)= (t3 + 2*t4 + t5 + 2) >> 2;
2278 SRC(6,0)=SRC(7,1)= (t4 + 2*t5 + t6 + 2) >> 2;
2279 SRC(7,0)= (t5 + 2*t6 + t7 + 2) >> 2;
2280
2281 }
2282 static void pred8x8l_vertical_right_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2283 {
2284 PREDICT_8x8_LOAD_TOP;
2285 PREDICT_8x8_LOAD_LEFT;
2286 PREDICT_8x8_LOAD_TOPLEFT;
2287 SRC(0,6)= (l5 + 2*l4 + l3 + 2) >> 2;
2288 SRC(0,7)= (l6 + 2*l5 + l4 + 2) >> 2;
2289 SRC(0,4)=SRC(1,6)= (l3 + 2*l2 + l1 + 2) >> 2;
2290 SRC(0,5)=SRC(1,7)= (l4 + 2*l3 + l2 + 2) >> 2;
2291 SRC(0,2)=SRC(1,4)=SRC(2,6)= (l1 + 2*l0 + lt + 2) >> 2;
2292 SRC(0,3)=SRC(1,5)=SRC(2,7)= (l2 + 2*l1 + l0 + 2) >> 2;
2293 SRC(0,1)=SRC(1,3)=SRC(2,5)=SRC(3,7)= (l0 + 2*lt + t0 + 2) >> 2;
2294 SRC(0,0)=SRC(1,2)=SRC(2,4)=SRC(3,6)= (lt + t0 + 1) >> 1;
2295 SRC(1,1)=SRC(2,3)=SRC(3,5)=SRC(4,7)= (lt + 2*t0 + t1 + 2) >> 2;
2296 SRC(1,0)=SRC(2,2)=SRC(3,4)=SRC(4,6)= (t0 + t1 + 1) >> 1;
2297 SRC(2,1)=SRC(3,3)=SRC(4,5)=SRC(5,7)= (t0 + 2*t1 + t2 + 2) >> 2;
2298 SRC(2,0)=SRC(3,2)=SRC(4,4)=SRC(5,6)= (t1 + t2 + 1) >> 1;
2299 SRC(3,1)=SRC(4,3)=SRC(5,5)=SRC(6,7)= (t1 + 2*t2 + t3 + 2) >> 2;
2300 SRC(3,0)=SRC(4,2)=SRC(5,4)=SRC(6,6)= (t2 + t3 + 1) >> 1;
2301 SRC(4,1)=SRC(5,3)=SRC(6,5)=SRC(7,7)= (t2 + 2*t3 + t4 + 2) >> 2;
2302 SRC(4,0)=SRC(5,2)=SRC(6,4)=SRC(7,6)= (t3 + t4 + 1) >> 1;
2303 SRC(5,1)=SRC(6,3)=SRC(7,5)= (t3 + 2*t4 + t5 + 2) >> 2;
2304 SRC(5,0)=SRC(6,2)=SRC(7,4)= (t4 + t5 + 1) >> 1;
2305 SRC(6,1)=SRC(7,3)= (t4 + 2*t5 + t6 + 2) >> 2;
2306 SRC(6,0)=SRC(7,2)= (t5 + t6 + 1) >> 1;
2307 SRC(7,1)= (t5 + 2*t6 + t7 + 2) >> 2;
2308 SRC(7,0)= (t6 + t7 + 1) >> 1;
2309 }
2310 static void pred8x8l_horizontal_down_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2311 {
2312 PREDICT_8x8_LOAD_TOP;
2313 PREDICT_8x8_LOAD_LEFT;
2314 PREDICT_8x8_LOAD_TOPLEFT;
2315 SRC(0,7)= (l6 + l7 + 1) >> 1;
2316 SRC(1,7)= (l5 + 2*l6 + l7 + 2) >> 2;
2317 SRC(0,6)=SRC(2,7)= (l5 + l6 + 1) >> 1;
2318 SRC(1,6)=SRC(3,7)= (l4 + 2*l5 + l6 + 2) >> 2;
2319 SRC(0,5)=SRC(2,6)=SRC(4,7)= (l4 + l5 + 1) >> 1;
2320 SRC(1,5)=SRC(3,6)=SRC(5,7)= (l3 + 2*l4 + l5 + 2) >> 2;
2321 SRC(0,4)=SRC(2,5)=SRC(4,6)=SRC(6,7)= (l3 + l4 + 1) >> 1;
2322 SRC(1,4)=SRC(3,5)=SRC(5,6)=SRC(7,7)= (l2 + 2*l3 + l4 + 2) >> 2;
2323 SRC(0,3)=SRC(2,4)=SRC(4,5)=SRC(6,6)= (l2 + l3 + 1) >> 1;
2324 SRC(1,3)=SRC(3,4)=SRC(5,5)=SRC(7,6)= (l1 + 2*l2 + l3 + 2) >> 2;
2325 SRC(0,2)=SRC(2,3)=SRC(4,4)=SRC(6,5)= (l1 + l2 + 1) >> 1;
2326 SRC(1,2)=SRC(3,3)=SRC(5,4)=SRC(7,5)= (l0 + 2*l1 + l2 + 2) >> 2;
2327 SRC(0,1)=SRC(2,2)=SRC(4,3)=SRC(6,4)= (l0 + l1 + 1) >> 1;
2328 SRC(1,1)=SRC(3,2)=SRC(5,3)=SRC(7,4)= (lt + 2*l0 + l1 + 2) >> 2;
2329 SRC(0,0)=SRC(2,1)=SRC(4,2)=SRC(6,3)= (lt + l0 + 1) >> 1;
2330 SRC(1,0)=SRC(3,1)=SRC(5,2)=SRC(7,3)= (l0 + 2*lt + t0 + 2) >> 2;
2331 SRC(2,0)=SRC(4,1)=SRC(6,2)= (t1 + 2*t0 + lt + 2) >> 2;
2332 SRC(3,0)=SRC(5,1)=SRC(7,2)= (t2 + 2*t1 + t0 + 2) >> 2;
2333 SRC(4,0)=SRC(6,1)= (t3 + 2*t2 + t1 + 2) >> 2;
2334 SRC(5,0)=SRC(7,1)= (t4 + 2*t3 + t2 + 2) >> 2;
2335 SRC(6,0)= (t5 + 2*t4 + t3 + 2) >> 2;
2336 SRC(7,0)= (t6 + 2*t5 + t4 + 2) >> 2;
2337 }
2338 static void pred8x8l_vertical_left_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2339 {
2340 PREDICT_8x8_LOAD_TOP;
2341 PREDICT_8x8_LOAD_TOPRIGHT;
2342 SRC(0,0)= (t0 + t1 + 1) >> 1;
2343 SRC(0,1)= (t0 + 2*t1 + t2 + 2) >> 2;
2344 SRC(0,2)=SRC(1,0)= (t1 + t2 + 1) >> 1;
2345 SRC(0,3)=SRC(1,1)= (t1 + 2*t2 + t3 + 2) >> 2;
2346 SRC(0,4)=SRC(1,2)=SRC(2,0)= (t2 + t3 + 1) >> 1;
2347 SRC(0,5)=SRC(1,3)=SRC(2,1)= (t2 + 2*t3 + t4 + 2) >> 2;
2348 SRC(0,6)=SRC(1,4)=SRC(2,2)=SRC(3,0)= (t3 + t4 + 1) >> 1;
2349 SRC(0,7)=SRC(1,5)=SRC(2,3)=SRC(3,1)= (t3 + 2*t4 + t5 + 2) >> 2;
2350 SRC(1,6)=SRC(2,4)=SRC(3,2)=SRC(4,0)= (t4 + t5 + 1) >> 1;
2351 SRC(1,7)=SRC(2,5)=SRC(3,3)=SRC(4,1)= (t4 + 2*t5 + t6 + 2) >> 2;
2352 SRC(2,6)=SRC(3,4)=SRC(4,2)=SRC(5,0)= (t5 + t6 + 1) >> 1;
2353 SRC(2,7)=SRC(3,5)=SRC(4,3)=SRC(5,1)= (t5 + 2*t6 + t7 + 2) >> 2;
2354 SRC(3,6)=SRC(4,4)=SRC(5,2)=SRC(6,0)= (t6 + t7 + 1) >> 1;
2355 SRC(3,7)=SRC(4,5)=SRC(5,3)=SRC(6,1)= (t6 + 2*t7 + t8 + 2) >> 2;
2356 SRC(4,6)=SRC(5,4)=SRC(6,2)=SRC(7,0)= (t7 + t8 + 1) >> 1;
2357 SRC(4,7)=SRC(5,5)=SRC(6,3)=SRC(7,1)= (t7 + 2*t8 + t9 + 2) >> 2;
2358 SRC(5,6)=SRC(6,4)=SRC(7,2)= (t8 + t9 + 1) >> 1;
2359 SRC(5,7)=SRC(6,5)=SRC(7,3)= (t8 + 2*t9 + t10 + 2) >> 2;
2360 SRC(6,6)=SRC(7,4)= (t9 + t10 + 1) >> 1;
2361 SRC(6,7)=SRC(7,5)= (t9 + 2*t10 + t11 + 2) >> 2;
2362 SRC(7,6)= (t10 + t11 + 1) >> 1;
2363 SRC(7,7)= (t10 + 2*t11 + t12 + 2) >> 2;
2364 }
2365 static void pred8x8l_horizontal_up_c(uint8_t *src, int has_topleft, int has_topright, int stride)
2366 {
2367 PREDICT_8x8_LOAD_LEFT;
2368 SRC(0,0)= (l0 + l1 + 1) >> 1;
2369 SRC(1,0)= (l0 + 2*l1 + l2 + 2) >> 2;
2370 SRC(0,1)=SRC(2,0)= (l1 + l2 + 1) >> 1;
2371 SRC(1,1)=SRC(3,0)= (l1 + 2*l2 + l3 + 2) >> 2;
2372 SRC(0,2)=SRC(2,1)=SRC(4,0)= (l2 + l3 + 1) >> 1;
2373 SRC(1,2)=SRC(3,1)=SRC(5,0)= (l2 + 2*l3 + l4 + 2) >> 2;
2374 SRC(0,3)=SRC(2,2)=SRC(4,1)=SRC(6,0)= (l3 + l4 + 1) >> 1;
2375 SRC(1,3)=SRC(3,2)=SRC(5,1)=SRC(7,0)= (l3 + 2*l4 + l5 + 2) >> 2;
2376 SRC(0,4)=SRC(2,3)=SRC(4,2)=SRC(6,1)= (l4 + l5 + 1) >> 1;
2377 SRC(1,4)=SRC(3,3)=SRC(5,2)=SRC(7,1)= (l4 + 2*l5 + l6 + 2) >> 2;
2378 SRC(0,5)=SRC(2,4)=SRC(4,3)=SRC(6,2)= (l5 + l6 + 1) >> 1;
2379 SRC(1,5)=SRC(3,4)=SRC(5,3)=SRC(7,2)= (l5 + 2*l6 + l7 + 2) >> 2;
2380 SRC(0,6)=SRC(2,5)=SRC(4,4)=SRC(6,3)= (l6 + l7 + 1) >> 1;
2381 SRC(1,6)=SRC(3,5)=SRC(5,4)=SRC(7,3)= (l6 + 3*l7 + 2) >> 2;
2382 SRC(0,7)=SRC(1,7)=SRC(2,6)=SRC(2,7)=SRC(3,6)=
2383 SRC(3,7)=SRC(4,5)=SRC(4,6)=SRC(4,7)=SRC(5,5)=
2384 SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
2385 SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
2386 }
2387 #undef PREDICT_8x8_LOAD_LEFT
2388 #undef PREDICT_8x8_LOAD_TOP
2389 #undef PREDICT_8x8_LOAD_TOPLEFT
2390 #undef PREDICT_8x8_LOAD_TOPRIGHT
2391 #undef PREDICT_8x8_DC
2392 #undef PTR
2393 #undef PT
2394 #undef PL
2395 #undef SRC
2396
2397 static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list, 1684 static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list,
2398 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, 1685 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
2399 int src_x_offset, int src_y_offset, 1686 int src_x_offset, int src_y_offset,
2400 qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op){ 1687 qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op){
2401 MpegEncContext * const s = &h->s; 1688 MpegEncContext * const s = &h->s;
2714 &run_len [6][0], 1, 1, 2001 &run_len [6][0], 1, 1,
2715 &run_bits[6][0], 1, 1, 1); 2002 &run_bits[6][0], 1, 1, 1);
2716 } 2003 }
2717 } 2004 }
2718 2005
2719 /**
2720 * Sets the intra prediction function pointers.
2721 */
2722 static void init_pred_ptrs(H264Context *h){
2723 // MpegEncContext * const s = &h->s;
2724
2725 h->pred4x4[VERT_PRED ]= pred4x4_vertical_c;
2726 h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c;
2727 h->pred4x4[DC_PRED ]= pred4x4_dc_c;
2728 h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_c;
2729 h->pred4x4[DIAG_DOWN_RIGHT_PRED]= pred4x4_down_right_c;
2730 h->pred4x4[VERT_RIGHT_PRED ]= pred4x4_vertical_right_c;
2731 h->pred4x4[HOR_DOWN_PRED ]= pred4x4_horizontal_down_c;
2732 h->pred4x4[VERT_LEFT_PRED ]= pred4x4_vertical_left_c;
2733 h->pred4x4[HOR_UP_PRED ]= pred4x4_horizontal_up_c;
2734 h->pred4x4[LEFT_DC_PRED ]= pred4x4_left_dc_c;
2735 h->pred4x4[TOP_DC_PRED ]= pred4x4_top_dc_c;
2736 h->pred4x4[DC_128_PRED ]= pred4x4_128_dc_c;
2737
2738 h->pred8x8l[VERT_PRED ]= pred8x8l_vertical_c;
2739 h->pred8x8l[HOR_PRED ]= pred8x8l_horizontal_c;
2740 h->pred8x8l[DC_PRED ]= pred8x8l_dc_c;
2741 h->pred8x8l[DIAG_DOWN_LEFT_PRED ]= pred8x8l_down_left_c;
2742 h->pred8x8l[DIAG_DOWN_RIGHT_PRED]= pred8x8l_down_right_c;
2743 h->pred8x8l[VERT_RIGHT_PRED ]= pred8x8l_vertical_right_c;
2744 h->pred8x8l[HOR_DOWN_PRED ]= pred8x8l_horizontal_down_c;
2745 h->pred8x8l[VERT_LEFT_PRED ]= pred8x8l_vertical_left_c;
2746 h->pred8x8l[HOR_UP_PRED ]= pred8x8l_horizontal_up_c;
2747 h->pred8x8l[LEFT_DC_PRED ]= pred8x8l_left_dc_c;
2748 h->pred8x8l[TOP_DC_PRED ]= pred8x8l_top_dc_c;
2749 h->pred8x8l[DC_128_PRED ]= pred8x8l_128_dc_c;
2750
2751 h->pred8x8[DC_PRED8x8 ]= ff_pred8x8_dc_c;
2752 h->pred8x8[VERT_PRED8x8 ]= ff_pred8x8_vertical_c;
2753 h->pred8x8[HOR_PRED8x8 ]= ff_pred8x8_horizontal_c;
2754 h->pred8x8[PLANE_PRED8x8 ]= ff_pred8x8_plane_c;
2755 h->pred8x8[LEFT_DC_PRED8x8]= ff_pred8x8_left_dc_c;
2756 h->pred8x8[TOP_DC_PRED8x8 ]= ff_pred8x8_top_dc_c;
2757 h->pred8x8[DC_128_PRED8x8 ]= ff_pred8x8_128_dc_c;
2758
2759 h->pred16x16[DC_PRED8x8 ]= ff_pred16x16_dc_c;
2760 h->pred16x16[VERT_PRED8x8 ]= ff_pred16x16_vertical_c;
2761 h->pred16x16[HOR_PRED8x8 ]= ff_pred16x16_horizontal_c;
2762 h->pred16x16[PLANE_PRED8x8 ]= ff_pred16x16_plane_c;
2763 h->pred16x16[LEFT_DC_PRED8x8]= ff_pred16x16_left_dc_c;
2764 h->pred16x16[TOP_DC_PRED8x8 ]= ff_pred16x16_top_dc_c;
2765 h->pred16x16[DC_128_PRED8x8 ]= ff_pred16x16_128_dc_c;
2766 }
2767
2768 static void free_tables(H264Context *h){ 2006 static void free_tables(H264Context *h){
2769 int i; 2007 int i;
2770 av_freep(&h->intra4x4_pred_mode); 2008 av_freep(&h->intra4x4_pred_mode);
2771 av_freep(&h->chroma_pred_mode_table); 2009 av_freep(&h->chroma_pred_mode_table);
2772 av_freep(&h->cbp_table); 2010 av_freep(&h->cbp_table);
2912 2150
2913 s->width = s->avctx->width; 2151 s->width = s->avctx->width;
2914 s->height = s->avctx->height; 2152 s->height = s->avctx->height;
2915 s->codec_id= s->avctx->codec->id; 2153 s->codec_id= s->avctx->codec->id;
2916 2154
2917 init_pred_ptrs(h); 2155 ff_h264_pred_init(&h->hpc, s->codec_id);
2918 2156
2919 h->dequant_coeff_pps= -1; 2157 h->dequant_coeff_pps= -1;
2920 s->unrestricted_mv=1; 2158 s->unrestricted_mv=1;
2921 s->decode=1; //FIXME 2159 s->decode=1; //FIXME
2922 2160
3268 if(IS_INTRA(mb_type)){ 2506 if(IS_INTRA(mb_type)){
3269 if(h->deblocking_filter && (simple || !FRAME_MBAFF)) 2507 if(h->deblocking_filter && (simple || !FRAME_MBAFF))
3270 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple); 2508 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple);
3271 2509
3272 if(simple || !ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ 2510 if(simple || !ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
3273 h->pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize); 2511 h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize);
3274 h->pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize); 2512 h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize);
3275 } 2513 }
3276 2514
3277 if(IS_INTRA4x4(mb_type)){ 2515 if(IS_INTRA4x4(mb_type)){
3278 if(simple || !s->encoding){ 2516 if(simple || !s->encoding){
3279 if(IS_8x8DCT(mb_type)){ 2517 if(IS_8x8DCT(mb_type)){
3280 for(i=0; i<16; i+=4){ 2518 for(i=0; i<16; i+=4){
3281 uint8_t * const ptr= dest_y + block_offset[i]; 2519 uint8_t * const ptr= dest_y + block_offset[i];
3282 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ]; 2520 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
3283 const int nnz = h->non_zero_count_cache[ scan8[i] ]; 2521 const int nnz = h->non_zero_count_cache[ scan8[i] ];
3284 h->pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000, 2522 h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,
3285 (h->topright_samples_available<<i)&0x4000, linesize); 2523 (h->topright_samples_available<<i)&0x4000, linesize);
3286 if(nnz){ 2524 if(nnz){
3287 if(nnz == 1 && h->mb[i*16]) 2525 if(nnz == 1 && h->mb[i*16])
3288 idct_dc_add(ptr, h->mb + i*16, linesize); 2526 idct_dc_add(ptr, h->mb + i*16, linesize);
3289 else 2527 else
3306 }else 2544 }else
3307 topright= ptr + 4 - linesize; 2545 topright= ptr + 4 - linesize;
3308 }else 2546 }else
3309 topright= NULL; 2547 topright= NULL;
3310 2548
3311 h->pred4x4[ dir ](ptr, topright, linesize); 2549 h->hpc.pred4x4[ dir ](ptr, topright, linesize);
3312 nnz = h->non_zero_count_cache[ scan8[i] ]; 2550 nnz = h->non_zero_count_cache[ scan8[i] ];
3313 if(nnz){ 2551 if(nnz){
3314 if(is_h264){ 2552 if(is_h264){
3315 if(nnz == 1 && h->mb[i*16]) 2553 if(nnz == 1 && h->mb[i*16])
3316 idct_dc_add(ptr, h->mb + i*16, linesize); 2554 idct_dc_add(ptr, h->mb + i*16, linesize);
3320 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); 2558 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0);
3321 } 2559 }
3322 } 2560 }
3323 } 2561 }
3324 }else{ 2562 }else{
3325 h->pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); 2563 h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);
3326 if(is_h264){ 2564 if(is_h264){
3327 if(!transform_bypass) 2565 if(!transform_bypass)
3328 h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[IS_INTRA(mb_type) ? 0:3][s->qscale][0]); 2566 h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[IS_INTRA(mb_type) ? 0:3][s->qscale][0]);
3329 }else 2567 }else
3330 svq3_luma_dc_dequant_idct_c(h->mb, s->qscale); 2568 svq3_luma_dc_dequant_idct_c(h->mb, s->qscale);