Changeset 344
- Timestamp:
- 02/16/07 12:59:27 (2 years ago)
- Files:
-
- trunk/ColorConversions.c (modified) (12 diffs)
- trunk/ColorConversions.h (modified) (1 diff)
- trunk/SSATagParsing.m.rl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ColorConversions.c
r334 r344 63 63 //also, big-endian only 64 64 65 static void Y420toY422_ppc_scalar(UInt8* baseAddr, int outRB, int width, intheight, AVFrame * picture)66 { 67 int y = height >> 1;68 int halfWidth = width >> 1, halfHalfWidth = halfWidth >> 1;65 static void Y420toY422_ppc_scalar(UInt8* baseAddr, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 66 { 67 unsigned y = height / 2; 68 unsigned halfWidth = width / 2, halfHalfWidth = width / 4; 69 69 UInt8 *inY = picture->data[0], *inU = picture->data[1], *inV = picture->data[2]; 70 70 int rB = picture->linesize[0], rbU = picture->linesize[1], rbV = picture->linesize[2]; … … 106 106 } 107 107 108 static void Y420toY422_ppc_altivec(UInt8 * o, int outRB, int width, intheight, AVFrame * picture)109 { 110 UInt8 *yc = picture->data[0], *uc = picture->data[1], *vc = picture->data[2];111 intrY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2];112 int y,x,x2,x4, vWidth = width >> 5, halfheight = height >> 1;108 static void Y420toY422_ppc_altivec(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 109 { 110 UInt8 *yc = picture->data[0], *uc = picture->data[1], *vc = picture->data[2]; 111 unsigned rY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2]; 112 unsigned y,x,x2,x4, vWidth = width / 32, halfheight = height / 2; 113 113 114 114 for (y = 0; y < halfheight; y ++) { … … 139 139 UInt8 *o2 = o + outRB, *yc2 = yc + rY; 140 140 for (x = vWidth * 32, x2 = x*2; x < width; x += 2, x2 += 4) { 141 int hx = x >> 1;141 unsigned hx = x / 2; 142 142 o2[x2] = o[x2] = uc[hx]; 143 143 o[x2 + 1] = yc[x]; … … 156 156 } 157 157 158 void Y420toY422(UInt8 * o, int outRB, int width, intheight, AVFrame * picture)159 { 160 static void (*y420_function)(UInt8* baseAddr, int outRB, int width, intheight, AVFrame * picture) = NULL;158 void Y420toY422(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 159 { 160 static void (*y420_function)(UInt8* baseAddr, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) = NULL; 161 161 if (!y420_function) { 162 162 int sels[2] = { CTL_HW, HW_VECTORUNIT }; // from http://developer.apple.com/hardwaredrivers/ve/g3_compatibility.html … … 174 174 #include <emmintrin.h> 175 175 176 static void Y420toY422_sse2(UInt8 * o, int outRB, int width, int height, AVFrame * picture) 176 #define TRUNCATE(x, power) (x & ~(power-1)) 177 178 static void Y420toY422_sse2(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 177 179 { 178 180 UInt8 *yc = picture->data[0], *uc = picture->data[1], *vc = picture->data[2]; 179 intrY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2];180 int y,x, vWidth = width >> 4, halfheight = height >> 1, halfwidth = width >> 1;181 unsigned rY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2]; 182 unsigned y,x, vWidth = width / 16, halfheight = height / 2, halfwidth = width / 2; 181 183 182 184 for (y = 0; y < halfheight; y ++) { … … 189 191 * sse2 can do 64-bit loads, so we do that. (apple's h264 doesn't seem to, maybe we should copy them?) 190 192 * unrolling loops is very bad on x86 */ 191 intx2 = x*2;193 unsigned x2 = x*2; 192 194 __builtin_prefetch(&yv[x+1], 0, 0); __builtin_prefetch(&yv2[x+1], 0, 0); // prefetch next y vectors, throw it out of cache immediately after use 193 195 __builtin_prefetch(&uv[x+1], 0, 0); __builtin_prefetch(&vv[x+1], 0, 0); // and chroma too … … 206 208 } 207 209 208 if (__builtin_expect(width & 15, FALSE)) { //spill to scalar for the end if the row isn't a multiple of 16209 UInt8 *o2 = o + outRB, *yc2 = yc + rY;210 for (x = vWidth * 16; x < halfwidth; x++) {211 int hx = x>>1, x2 = x*2;212 o2[x 2] = o[x2] = uc[hx];213 o[x 2 + 1] = yc[x];214 o2[x 2 + 1] = yc2[x];215 o2[x 2 + 2] = o[x2 + 2] = vc[hx];216 o[x 2 + 3] = yc[x+ 1];217 o2[x 2 + 3] = yc2[x+ 1];210 if (__builtin_expect(width % 16 != 0, FALSE)) { //spill to scalar for the end if the row isn't a multiple of 16 211 UInt8 *o2 = (UInt8*)ov2, *yc2 = (UInt8*)yv2; 212 for (x = TRUNCATE(width, 16) / 2; x < halfwidth; x++) { 213 unsigned x4 = x*4, x2 = x*2; 214 o2[x4] = o[x4] = uc[x]; 215 o[x4 + 1] = yc[x2]; 216 o2[x4 + 1] = yc2[x2]; 217 o2[x4 + 2] = o[x4 + 2] = vc[x]; 218 o[x4 + 3] = yc[x2 + 1]; 219 o2[x4 + 3] = yc2[x2 + 1]; 218 220 } 219 221 } … … 228 230 229 231 230 static void Y420toY422_x86_scalar(UInt8 * o, int outRB, int width, intheight, AVFrame * picture)231 { 232 UInt8 *yc = picture->data[0], *u = picture->data[1], *v = picture->data[2];233 int rY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2], halfheight = height >> 1, halfwidth = width >> 1;234 inty, x;232 static void Y420toY422_x86_scalar(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 233 { 234 UInt8 *yc = picture->data[0], *u = picture->data[1], *v = picture->data[2]; 235 unsigned rY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2], halfheight = height / 2, halfwidth = width / 2; 236 unsigned y, x; 235 237 236 238 for (y = 0; y < halfheight; y ++) { 237 239 UInt8 *o2 = o + outRB, *yc2 = yc + rY; 238 240 239 for (x = 0; x < halfwidth; x ++) {240 int hx = x>>1, x2 = x*2;241 o2[x 2] = o[x2] = u[hx];242 o[x 2 + 1] = yc[x];243 o2[x 2 + 1] = yc2[x];244 o2[x 2 + 2] = o[x2 + 2] = v[hx];245 o[x 2 + 3] = yc[x+ 1];246 o2[x 2 + 3] = yc2[x+ 1];241 for (x = 0; x < halfwidth; x++) { 242 unsigned x4 = x*4, x2 = x*2; 243 o2[x4] = o[x4] = u[x]; 244 o[x4 + 1] = yc[x2]; 245 o2[x4 + 1] = yc2[x2]; 246 o2[x4 + 2] = o[x4 + 2] = v[x]; 247 o[x4 + 3] = yc[x2 + 1]; 248 o2[x4 + 3] = yc2[x2 + 1]; 247 249 } 248 250 … … 254 256 } 255 257 256 void Y420toY422(UInt8 * o, int outRB, int width, intheight, AVFrame * picture)258 void Y420toY422(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 257 259 { 258 260 uintptr_t yc = (uintptr_t)picture->data[0]; … … 266 268 #endif 267 269 268 void BGR24toRGB24(UInt8 *baseAddr, int rowBytes, int width, intheight, AVFrame *picture)269 { 270 inti, j;270 void BGR24toRGB24(UInt8 *baseAddr, unsigned rowBytes, unsigned width, unsigned height, AVFrame *picture) 271 { 272 unsigned i, j; 271 273 UInt8 *srcPtr = picture->data[0]; 272 274 … … 284 286 } 285 287 286 void RGB32toRGB32(UInt8 *baseAddr, int rowBytes, int width, intheight, AVFrame *picture)287 { 288 intx, y;288 void RGB32toRGB32(UInt8 *baseAddr, unsigned rowBytes, unsigned width, unsigned height, AVFrame *picture) 289 { 290 unsigned x, y; 289 291 UInt8 *srcPtr = picture->data[0]; 290 292 … … 302 304 } 303 305 304 void Y422toY422(UInt8* o, int outRB, int width, intheight, AVFrame * picture)306 void Y422toY422(UInt8* o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 305 307 { 306 308 UInt8 *yc = picture->data[0], *u = picture->data[1], *v = picture->data[2]; 307 int rY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2], y = 0, x, x2;308 309 for ( ; y < height; y++) {310 for (x = 0 , x2 = 0; x < width; x += 2, x2 += 4) {311 int hx = x >> 1;312 o[x 2] = u[hx];313 o[x 2 + 1] = yc[x];314 o[x 2 + 2] = v[hx];315 o[x 2 + 3] = yc[x+ 1];309 unsigned rY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2], y, x, x2, halfwidth = width / 2; 310 311 for (y = 0; y < height; y++) { 312 for (x = 0; x < halfwidth; x++) { 313 unsigned x2 = x * 2, x4 = x * 4; 314 o[x4] = u[x]; 315 o[x4 + 1] = yc[x2]; 316 o[x4 + 2] = v[x]; 317 o[x4 + 3] = yc[x2 + 1]; 316 318 } 317 319 trunk/ColorConversions.h
r282 r344 22 22 23 23 extern void FastY420(UInt8 *baseAddr, AVFrame *picture); 24 extern void Y420toY422(UInt8* baseAddr, int rowBytes, int width, intheight, AVFrame * picture);25 extern void RGB32toRGB32(UInt8 *baseAddr, int rowBytes, int width, intheight, AVFrame *picture);26 extern void BGR24toRGB24(UInt8 *baseAddr, int rowBytes, int width, intheight, AVFrame *picture);27 extern void Y422toY422(UInt8* o, int outRB, int width, intheight, AVFrame * picture);24 extern void Y420toY422(UInt8* baseAddr, unsigned rowBytes, unsigned width, unsigned height, AVFrame * picture); 25 extern void RGB32toRGB32(UInt8 *baseAddr, unsigned rowBytes, unsigned width, unsigned height, AVFrame *picture); 26 extern void BGR24toRGB24(UInt8 *baseAddr, unsigned rowBytes, unsigned width, unsigned height, AVFrame *picture); 27 extern void Y422toY422(UInt8* o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture); trunk/SSATagParsing.m.rl
r343 r344 541 541 542 542 flag = ([01] % {unichar fl = *(p-1); if (flag == '0' || flag == '1') flag = fl - '0';})? > {flag = 1;}; 543 num_ = "-"? digit *('.' digit*)?;543 num_ = "-"? digit+ ('.' digit*)?; 544 544 num = num_ > {numbegin = p;} % {num = [[NSString stringWithCharacters:numbegin length:p-numbegin] doubleValue];}; 545 545 546 intnum = "-"? (digit *) > {intbegin = p;} % {inum = [[NSString stringWithCharacters:intbegin length:p-intbegin] intValue];};547 548 color = ("H"|"&"){,2} (xdigit *) > {intbegin = p;} % color_end "&";546 intnum = "-"? (digit+) > {intbegin = p;} % {inum = [[NSString stringWithCharacters:intbegin length:p-intbegin] intValue];}; 547 548 color = ("H"|"&"){,2} (xdigit+) > {intbegin = p;} % color_end "&"; 549 549 550 550 cmd_specific = (("pos(" [^)]+ > pos_begin ")" % pos_end)
