Changeset 828
- Timestamp:
- 03/12/08 23:55:59 (4 months ago)
- Files:
-
- trunk/ColorConversions.c (modified) (9 diffs)
- trunk/Perian.xcodeproj/project.pbxproj (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ColorConversions.c
r827 r828 24 24 #include <sys/sysctl.h> 25 25 26 #ifndef GOOD_COMPILER 27 #define noinline __attribute__((noinline)) 28 #else 29 #define noinline 30 #endif 31 32 #define unlikely(x) __builtin_expect(x, 0) 33 26 34 //----------------------------------------------------------------- 27 35 // FastY420 … … 58 66 // have a decent OS/QT version. 59 67 //----------------------------------------------------------------- 68 69 static void noinline Y420toY422_lastrow(UInt8 *o, const UInt8 *yc, const UInt8 *uc, const UInt8 *vc, unsigned halfWidth) 70 { 71 unsigned x; 72 for(x=0; x < halfWidth; x++) 73 { 74 unsigned x4 = x*4, x2 = x*2; 75 o[x4] = uc[x]; 76 o[x4+1] = yc[x2]; 77 o[x4+2] = vc[x]; 78 o[x4+3] = yc[x2+1]; 79 } 80 } 81 82 #define HandleLastRow(o, yc, uc, vc, halfWidth, height) if (unlikely(height & 1)) Y420toY422_lastrow(o, yc, uc, vc, halfWidth) 60 83 61 84 #ifdef __BIG_ENDIAN__ … … 104 127 baseAddr += outRB * 2; 105 128 } 106 if(height & 1) 107 { 108 int x; 109 for(x=0; x < halfWidth; x++) 110 { 111 unsigned x4 = x*4, x2 = x*2; 112 baseAddr[x4] = inU[x]; 113 baseAddr[x4+1] = inY[x2]; 114 baseAddr[x4+2] = inV[x]; 115 baseAddr[x4+3] = inY[x2+1]; 116 } 117 } 129 130 HandleLastRow(baseAddr, inY, inU, inV, halfWidth, height); 118 131 } 119 132 … … 166 179 vc += rV; 167 180 } 168 if(height & 1) 169 { 170 unsigned halfwidth = width / 2; 171 for(x=0; x < halfwidth; x++) 172 { 173 unsigned x4 = x*4, x2 = x*2; 174 o[x4] = uc[x]; 175 o[x4+1] = yc[x2]; 176 o[x4+2] = vc[x]; 177 o[x4+3] = yc[x2+1]; 178 } 179 } 181 182 HandleLastRow(o, yc, uc, vc, width / 2, height); 180 183 } 181 184 … … 213 216 asm volatile( 214 217 "\n0: \n\t" 218 "movdqa (%2), %%xmm0 \n\t" 219 "movdqa 16(%2), %%xmm2 \n\t" 220 "movdqa (%3), %%xmm1 \n\t" 221 "movdqa 16(%3), %%xmm3 \n\t" 215 222 "movdqu (%4), %%xmm4 \n\t" 216 223 "movdqu (%5), %%xmm5 \n\t" 224 "addl $32, %2 \n\t" 225 "addl $32, %3 \n\t" 217 226 "addl $16, %4 \n\t" 218 227 "addl $16, %5 \n\t" 219 "movdqa (%2), %%xmm0 \n\t"220 "movdqa 16(%2), %%xmm2 \n\t"221 "addl $32, %2 \n\t"222 "movdqa (%3), %%xmm1 \n\t"223 "movdqa 16(%3), %%xmm3 \n\t"224 "addl $32, %3 \n\t"225 228 "movdqa %%xmm4, %%xmm6 \n\t" 226 229 "punpcklbw %%xmm5, %%xmm4 \n\t" /*chroma_l*/ … … 252 255 "dec %6 \n\t" 253 256 "jnz 0b \n\t" 254 :255 257 : "r" (ov), "r" (ov2), 256 258 "r" (yv), "r" (yv2), "r" (uv), "r" (vv), 257 " c" (vWidth)259 "r" (vWidth) 258 260 ); 259 261 #else … … 294 296 vc += rV; 295 297 } 296 if(height & 1) 297 { 298 for(x=0; x < halfwidth; x++) 299 { 300 unsigned x4 = x*4, x2 = x*2; 301 o[x4] = uc[x]; 302 o[x4+1] = yc[x2]; 303 o[x4+2] = vc[x]; 304 o[x4+3] = yc[x2+1]; 305 } 306 } 307 } 308 309 310 static void __attribute__((noinline)) Y420toY422_x86_scalar(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 298 299 _mm_sfence(); 300 301 HandleLastRow(o, yc, uc, vc, halfwidth, height); 302 } 303 304 305 static void noinline Y420toY422_x86_scalar(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 311 306 { 312 307 UInt8 *yc = picture->data[0], *u = picture->data[1], *v = picture->data[2]; … … 332 327 v += rV; 333 328 } 334 if(height & 1) 335 { 336 for(x=0; x < halfwidth; x++) 337 { 338 unsigned x4 = x*4, x2 = x*2; 339 o[x4] = u[x]; 340 o[x4+1] = yc[x2]; 341 o[x4+2] = v[x]; 342 o[x4+3] = yc[x2+1]; 343 } 344 } 329 330 HandleLastRow(o, yc, u, v, halfwidth, height); 345 331 } 346 332 … … 350 336 351 337 //make sure the ffmpeg picture buffers are aligned enough, they're only guaranteed to be 8-byte for some reason... 352 if ((yc | picture->linesize[0]) % 16 == 0) { 353 Y420toY422_sse2(o, outRB, width, height, picture); 354 _mm_sfence(); 355 } else Y420toY422_x86_scalar(o, outRB, width, height, picture); 338 if (!unlikely((yc | picture->linesize[0]) % 16)) Y420toY422_sse2(o, outRB, width, height, picture); 339 else Y420toY422_x86_scalar(o, outRB, width, height, picture); 356 340 } 357 341 #endif trunk/Perian.xcodeproj/project.pbxproj
r814 r828 110 110 3D211A300B6B1AD80051299D /* SubParsing.m.rl in Sources */ = {isa = PBXBuildFile; fileRef = 3D211A2F0B6B1AD80051299D /* SubParsing.m.rl */; }; 111 111 3D41BEB40BCD3B510069E7C2 /* libuniversaldetector.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D41BE9A0BCD3B330069E7C2 /* libuniversaldetector.a */; }; 112 3D4A7A990B5533BC004C5D6A /* ColorConversions.c in Sources */ = {isa = PBXBuildFile; fileRef = 3D4A7A980B5533BC004C5D6A /* ColorConversions.c */; settings = {COMPILER_FLAGS = "-O3 -f no-reorder-blocks -fweb"; }; };112 3D4A7A990B5533BC004C5D6A /* ColorConversions.c in Sources */ = {isa = PBXBuildFile; fileRef = 3D4A7A980B5533BC004C5D6A /* ColorConversions.c */; settings = {COMPILER_FLAGS = "-O3 -fweb -fno-reorder-blocks -fomit-frame-pointer"; }; }; 113 113 3DAD32DA0B6DB26100DA0A72 /* StdIOCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 61CB114D0ACDF3C2007994BD /* StdIOCallback.cpp */; }; 114 114 3DB2BB290B6C92F000416863 /* SubATSUIRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DB2BB280B6C92F000416863 /* SubATSUIRenderer.m */; }; … … 1858 1858 DEAD_CODE_STRIPPING = YES; 1859 1859 EXPORTED_SYMBOLS_FILE = "$(SOURCE_ROOT)/exportedSymbols"; 1860 GCC_DYNAMIC_NO_PIC = NO;1861 1860 GCC_ENABLE_FIX_AND_CONTINUE = YES; 1862 1861 GCC_ENABLE_OBJC_GC = YES; … … 1901 1900 EXPORTED_SYMBOLS_FILE = "$(SOURCE_ROOT)/exportedSymbols"; 1902 1901 GCC_ALTIVEC_EXTENSIONS = YES; 1903 GCC_DYNAMIC_NO_PIC = NO;1904 1902 GCC_ENABLE_FIX_AND_CONTINUE = NO; 1905 1903 GCC_ENABLE_OBJC_GC = YES; … … 2027 2025 EXPORTED_SYMBOLS_FILE = "$(SOURCE_ROOT)/exportedSymbols"; 2028 2026 GCC_ALTIVEC_EXTENSIONS = YES; 2029 GCC_DYNAMIC_NO_PIC = NO;2030 2027 GCC_ENABLE_FIX_AND_CONTINUE = NO; 2031 2028 GCC_ENABLE_OBJC_GC = YES;
