comparison postproc/swscale.c @ 9455:aab93879d8f8

cleanup
author michael
date Tue, 18 Feb 2003 19:36:20 +0000
parents 83fe90af3e16
children eff727517e6b
comparison
equal deleted inserted replaced
9454:50ef22bcc0c3 9455:aab93879d8f8
157 #ifdef ARCH_X86 157 #ifdef ARCH_X86
158 #define CAN_COMPILE_X86_ASM 158 #define CAN_COMPILE_X86_ASM
159 #endif 159 #endif
160 160
161 #ifdef CAN_COMPILE_X86_ASM 161 #ifdef CAN_COMPILE_X86_ASM
162 static uint64_t __attribute__((aligned(8))) yCoeff= 0x2568256825682568LL;
163 static uint64_t __attribute__((aligned(8))) vrCoeff= 0x3343334333433343LL;
164 static uint64_t __attribute__((aligned(8))) ubCoeff= 0x40cf40cf40cf40cfLL;
165 static uint64_t __attribute__((aligned(8))) vgCoeff= 0xE5E2E5E2E5E2E5E2LL;
166 static uint64_t __attribute__((aligned(8))) ugCoeff= 0xF36EF36EF36EF36ELL;
167 static uint64_t __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL; 162 static uint64_t __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL;
168 static uint64_t __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL; 163 static uint64_t __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL;
169 static uint64_t __attribute__((aligned(8))) w400= 0x0400040004000400LL;
170 static uint64_t __attribute__((aligned(8))) w80= 0x0080008000800080LL;
171 static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL; 164 static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL;
172 static uint64_t __attribute__((aligned(8))) w02= 0x0002000200020002LL; 165 static uint64_t __attribute__((aligned(8))) w02= 0x0002000200020002LL;
173 static uint64_t __attribute__((aligned(8))) bm00001111=0x00000000FFFFFFFFLL; 166 static uint64_t __attribute__((aligned(8))) bm00001111=0x00000000FFFFFFFFLL;
174 static uint64_t __attribute__((aligned(8))) bm00000111=0x0000000000FFFFFFLL; 167 static uint64_t __attribute__((aligned(8))) bm00000111=0x0000000000FFFFFFLL;
175 static uint64_t __attribute__((aligned(8))) bm11111000=0xFFFFFFFFFF000000LL; 168 static uint64_t __attribute__((aligned(8))) bm11111000=0xFFFFFFFFFF000000LL;
247 extern const uint8_t dither_8x8_220[8][8]; 240 extern const uint8_t dither_8x8_220[8][8];
248 241
249 #ifdef CAN_COMPILE_X86_ASM 242 #ifdef CAN_COMPILE_X86_ASM
250 void in_asm_used_var_warning_killer() 243 void in_asm_used_var_warning_killer()
251 { 244 {
252 volatile int i= yCoeff+vrCoeff+ubCoeff+vgCoeff+ugCoeff+bF8+bFC+w400+w80+w10+ 245 volatile int i= bF8+bFC+w10+
253 bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+ 246 bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+
254 M24A+M24B+M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0]+bm01010101; 247 M24A+M24B+M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0]+bm01010101;
255 if(i) i=0; 248 if(i) i=0;
256 } 249 }
257 #endif 250 #endif
1673 const int srcId= (srcFormat&0xFF)>>2; // 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 1666 const int srcId= (srcFormat&0xFF)>>2; // 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8
1674 const int dstId= (dstFormat&0xFF)>>2; 1667 const int dstId= (dstFormat&0xFF)>>2;
1675 void (*conv)(const uint8_t *src, uint8_t *dst, unsigned src_size)=NULL; 1668 void (*conv)(const uint8_t *src, uint8_t *dst, unsigned src_size)=NULL;
1676 1669
1677 /* BGR -> BGR */ 1670 /* BGR -> BGR */
1678 if(isBGR(srcFormat) && isBGR(dstFormat)){ 1671 if( (isBGR(srcFormat) && isBGR(dstFormat))
1672 || (isRGB(srcFormat) && isRGB(dstFormat))){
1679 switch(srcId | (dstId<<4)){ 1673 switch(srcId | (dstId<<4)){
1680 case 0x34: conv= rgb16to15; break; 1674 case 0x34: conv= rgb16to15; break;
1681 case 0x36: conv= rgb24to15; break; 1675 case 0x36: conv= rgb24to15; break;
1682 case 0x38: conv= rgb32to15; break; 1676 case 0x38: conv= rgb32to15; break;
1683 case 0x43: conv= rgb15to16; break; 1677 case 0x43: conv= rgb15to16; break;
1690 case 0x84: conv= rgb16to32; break; 1684 case 0x84: conv= rgb16to32; break;
1691 case 0x86: conv= rgb24to32; break; 1685 case 0x86: conv= rgb24to32; break;
1692 default: MSG_ERR("swScaler: internal error %s -> %s converter\n", 1686 default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
1693 vo_format_name(srcFormat), vo_format_name(dstFormat)); break; 1687 vo_format_name(srcFormat), vo_format_name(dstFormat)); break;
1694 } 1688 }
1695 }else if(isBGR(srcFormat) && isRGB(dstFormat)){ 1689 }else if( (isBGR(srcFormat) && isRGB(dstFormat))
1690 || (isRGB(srcFormat) && isBGR(dstFormat))){
1696 switch(srcId | (dstId<<4)){ 1691 switch(srcId | (dstId<<4)){
1697 case 0x33: conv= rgb15tobgr15; break; 1692 case 0x33: conv= rgb15tobgr15; break;
1698 case 0x34: conv= rgb16tobgr15; break; 1693 case 0x34: conv= rgb16tobgr15; break;
1699 case 0x36: conv= rgb24tobgr15; break; 1694 case 0x36: conv= rgb24tobgr15; break;
1700 case 0x38: conv= rgb32tobgr15; break; 1695 case 0x38: conv= rgb32tobgr15; break;
1711 case 0x86: conv= rgb24tobgr32; break; 1706 case 0x86: conv= rgb24tobgr32; break;
1712 case 0x88: conv= rgb32tobgr32; break; 1707 case 0x88: conv= rgb32tobgr32; break;
1713 default: MSG_ERR("swScaler: internal error %s -> %s converter\n", 1708 default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
1714 vo_format_name(srcFormat), vo_format_name(dstFormat)); break; 1709 vo_format_name(srcFormat), vo_format_name(dstFormat)); break;
1715 } 1710 }
1716 }else if(isRGB(srcFormat) && isRGB(dstFormat)){ 1711 }else{
1717 switch(srcId | (dstId<<4)){ 1712 MSG_ERR("swScaler: internal error %s -> %s converter\n",
1718 case 0x34: conv= rgb16to15; break; 1713 vo_format_name(srcFormat), vo_format_name(dstFormat));
1719 case 0x36: conv= rgb24to15; break; 1714 }
1720 case 0x38: conv= rgb32to15; break; 1715
1721 case 0x43: conv= rgb15to16; break;
1722 case 0x46: conv= rgb24to16; break;
1723 case 0x48: conv= rgb32to16; break;
1724 case 0x63: conv= rgb15to24; break;
1725 case 0x64: conv= rgb16to24; break;
1726 case 0x68: conv= rgb32to24; break;
1727 case 0x83: conv= rgb15to32; break;
1728 case 0x84: conv= rgb16to32; break;
1729 case 0x86: conv= rgb24to32; break;
1730 default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
1731 vo_format_name(srcFormat), vo_format_name(dstFormat)); break;
1732 }
1733 }else if(isRGB(srcFormat) && isBGR(dstFormat)){
1734 switch(srcId | (dstId<<4)){
1735 case 0x33: conv= rgb15tobgr15; break;
1736 case 0x34: conv= rgb16tobgr15; break;
1737 case 0x36: conv= rgb24tobgr15; break;
1738 case 0x38: conv= rgb32tobgr15; break;
1739 case 0x43: conv= rgb15tobgr16; break;
1740 case 0x44: conv= rgb16tobgr16; break;
1741 case 0x46: conv= rgb24tobgr16; break;
1742 case 0x48: conv= rgb32tobgr16; break;
1743 case 0x63: conv= rgb15tobgr24; break;
1744 case 0x64: conv= rgb16tobgr24; break;
1745 case 0x66: conv= rgb24tobgr24; break;
1746 case 0x68: conv= rgb32tobgr24; break;
1747 case 0x83: conv= rgb15tobgr32; break;
1748 case 0x84: conv= rgb16tobgr32; break;
1749 case 0x86: conv= rgb24tobgr32; break;
1750 case 0x88: conv= rgb32tobgr32; break;
1751 default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
1752 vo_format_name(srcFormat), vo_format_name(dstFormat)); break;
1753 }
1754 }
1755 if(dstStride[0]*srcBpp == srcStride[0]*dstBpp) 1716 if(dstStride[0]*srcBpp == srcStride[0]*dstBpp)
1756 conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]); 1717 conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
1757 else 1718 else
1758 { 1719 {
1759 int i; 1720 int i;
2110 { 2071 {
2111 /* yv12_to_nv12 */ 2072 /* yv12_to_nv12 */
2112 if((srcFormat == IMGFMT_YV12||srcFormat==IMGFMT_I420)&&dstFormat == IMGFMT_NV12) 2073 if((srcFormat == IMGFMT_YV12||srcFormat==IMGFMT_I420)&&dstFormat == IMGFMT_NV12)
2113 { 2074 {
2114 c->swScale= PlanarToNV12Wrapper; 2075 c->swScale= PlanarToNV12Wrapper;
2115
2116 if(flags&SWS_PRINT_INFO)
2117 MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",
2118 vo_format_name(srcFormat), vo_format_name(dstFormat));
2119 return c;
2120 } 2076 }
2121 /* yuv2bgr */ 2077 /* yuv2bgr */
2122 if((srcFormat==IMGFMT_YV12 || srcFormat==IMGFMT_I420) && isBGR(dstFormat)) 2078 if((srcFormat==IMGFMT_YV12 || srcFormat==IMGFMT_I420) && isBGR(dstFormat))
2123 { 2079 {
2124 // FIXME multiple yuv2rgb converters wont work that way cuz that thing is full of globals&statics 2080 // FIXME multiple yuv2rgb converters wont work that way cuz that thing is full of globals&statics
2130 yuv2rgb_init( dstFormat&0xFF /* =bpp */, MODE_RGB); 2086 yuv2rgb_init( dstFormat&0xFF /* =bpp */, MODE_RGB);
2131 #else 2087 #else
2132 yuv2rgb_init( dstFormat&0xFF /* =bpp */, MODE_RGB); 2088 yuv2rgb_init( dstFormat&0xFF /* =bpp */, MODE_RGB);
2133 #endif 2089 #endif
2134 c->swScale= planarYuvToBgr; 2090 c->swScale= planarYuvToBgr;
2135
2136 if(flags&SWS_PRINT_INFO)
2137 MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",
2138 vo_format_name(srcFormat), vo_format_name(dstFormat));
2139 return c;
2140 }
2141
2142 /* simple copy */
2143 if( srcFormat == dstFormat
2144 || (srcFormat==IMGFMT_YV12 && dstFormat==IMGFMT_I420)
2145 || (srcFormat==IMGFMT_I420 && dstFormat==IMGFMT_YV12)
2146 || (isPlanarYUV(srcFormat) && isGray(dstFormat))
2147 || (isPlanarYUV(dstFormat) && isGray(srcFormat))
2148 )
2149 {
2150 c->swScale= simpleCopy;
2151
2152 if(flags&SWS_PRINT_INFO)
2153 MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",
2154 vo_format_name(srcFormat), vo_format_name(dstFormat));
2155 return c;
2156 } 2091 }
2157 2092
2158 if( srcFormat==IMGFMT_YVU9 && (dstFormat==IMGFMT_YV12 || dstFormat==IMGFMT_I420) ) 2093 if( srcFormat==IMGFMT_YVU9 && (dstFormat==IMGFMT_YV12 || dstFormat==IMGFMT_I420) )
2159 { 2094 {
2160 c->swScale= yvu9toyv12Wrapper; 2095 c->swScale= yvu9toyv12Wrapper;
2161
2162 if(flags&SWS_PRINT_INFO)
2163 MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",
2164 vo_format_name(srcFormat), vo_format_name(dstFormat));
2165 return c;
2166 } 2096 }
2167 2097
2168 /* bgr24toYV12 */ 2098 /* bgr24toYV12 */
2169 if(srcFormat==IMGFMT_BGR24 && dstFormat==IMGFMT_YV12) 2099 if(srcFormat==IMGFMT_BGR24 && dstFormat==IMGFMT_YV12)
2170 c->swScale= bgr24toyv12Wrapper; 2100 c->swScale= bgr24toyv12Wrapper;
2185 2115
2186 /* yv12_to_yuy2 */ 2116 /* yv12_to_yuy2 */
2187 if((srcFormat == IMGFMT_YV12||srcFormat==IMGFMT_I420)&&dstFormat == IMGFMT_YUY2) 2117 if((srcFormat == IMGFMT_YV12||srcFormat==IMGFMT_I420)&&dstFormat == IMGFMT_YUY2)
2188 { 2118 {
2189 c->swScale= PlanarToYuy2Wrapper; 2119 c->swScale= PlanarToYuy2Wrapper;
2190
2191 if(flags&SWS_PRINT_INFO)
2192 MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",
2193 vo_format_name(srcFormat), vo_format_name(dstFormat));
2194 return c;
2195 } 2120 }
2121 }
2122
2123 /* simple copy */
2124 if( srcFormat == dstFormat
2125 || (srcFormat==IMGFMT_YV12 && dstFormat==IMGFMT_I420)
2126 || (srcFormat==IMGFMT_I420 && dstFormat==IMGFMT_YV12)
2127 || (isPlanarYUV(srcFormat) && isGray(dstFormat))
2128 || (isPlanarYUV(dstFormat) && isGray(srcFormat))
2129 )
2130 {
2131 c->swScale= simpleCopy;
2196 } 2132 }
2197 2133
2198 if(c->swScale){ 2134 if(c->swScale){
2199 if(flags&SWS_PRINT_INFO) 2135 if(flags&SWS_PRINT_INFO)
2200 MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n", 2136 MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",