Mercurial > mplayer.hg
comparison libswscale/yuv2rgb_altivec.c @ 27312:f058ded683db
Remove AltiVec vector declaration compiler compatibility macros.
The original problem was that FSF and Apple gcc used a different syntax
for vector declarations, i.e. {} vs. (). Nowadays Apple gcc versions support
the standard {} syntax and versions that support {} are available on all
relevant Mac OS X versions. Thus the greater compatibility is no longer
worth cluttering the code with macros.
author | diego |
---|---|
date | Thu, 24 Jul 2008 16:49:14 +0000 |
parents | 66de7e5084dc |
children | ffbe8d9e13d6 |
comparison
equal
deleted
inserted
replaced
27311:f8711d691a46 | 27312:f058ded683db |
---|---|
141 a67b 89cA BdCD eEFf | 141 a67b 89cA BdCD eEFf |
142 | 142 |
143 */ | 143 */ |
144 static | 144 static |
145 const vector unsigned char | 145 const vector unsigned char |
146 perm_rgb_0 = AVV(0x00,0x01,0x10,0x02,0x03,0x11,0x04,0x05, | 146 perm_rgb_0 = {0x00,0x01,0x10,0x02,0x03,0x11,0x04,0x05, |
147 0x12,0x06,0x07,0x13,0x08,0x09,0x14,0x0a), | 147 0x12,0x06,0x07,0x13,0x08,0x09,0x14,0x0a}, |
148 perm_rgb_1 = AVV(0x0b,0x15,0x0c,0x0d,0x16,0x0e,0x0f,0x17, | 148 perm_rgb_1 = {0x0b,0x15,0x0c,0x0d,0x16,0x0e,0x0f,0x17, |
149 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f), | 149 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f}, |
150 perm_rgb_2 = AVV(0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, | 150 perm_rgb_2 = {0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, |
151 0x00,0x01,0x18,0x02,0x03,0x19,0x04,0x05), | 151 0x00,0x01,0x18,0x02,0x03,0x19,0x04,0x05}, |
152 perm_rgb_3 = AVV(0x1a,0x06,0x07,0x1b,0x08,0x09,0x1c,0x0a, | 152 perm_rgb_3 = {0x1a,0x06,0x07,0x1b,0x08,0x09,0x1c,0x0a, |
153 0x0b,0x1d,0x0c,0x0d,0x1e,0x0e,0x0f,0x1f); | 153 0x0b,0x1d,0x0c,0x0d,0x1e,0x0e,0x0f,0x1f}; |
154 | 154 |
155 #define vec_merge3(x2,x1,x0,y0,y1,y2) \ | 155 #define vec_merge3(x2,x1,x0,y0,y1,y2) \ |
156 do { \ | 156 do { \ |
157 typeof(x0) o0,o2,o3; \ | 157 typeof(x0) o0,o2,o3; \ |
158 o0 = vec_mergeh (x0,x1); \ | 158 o0 = vec_mergeh (x0,x1); \ |
220 | 220 |
221 | 221 |
222 | 222 |
223 #define vec_unh(x) \ | 223 #define vec_unh(x) \ |
224 (vector signed short) \ | 224 (vector signed short) \ |
225 vec_perm(x,(typeof(x))AVV(0),\ | 225 vec_perm(x,(typeof(x)){0}, \ |
226 (vector unsigned char)AVV(0x10,0x00,0x10,0x01,0x10,0x02,0x10,0x03,\ | 226 (vector unsigned char){0x10,0x00,0x10,0x01,0x10,0x02,0x10,0x03,\ |
227 0x10,0x04,0x10,0x05,0x10,0x06,0x10,0x07)) | 227 0x10,0x04,0x10,0x05,0x10,0x06,0x10,0x07}) |
228 #define vec_unl(x) \ | 228 #define vec_unl(x) \ |
229 (vector signed short) \ | 229 (vector signed short) \ |
230 vec_perm(x,(typeof(x))AVV(0),\ | 230 vec_perm(x,(typeof(x)){0}, \ |
231 (vector unsigned char)AVV(0x10,0x08,0x10,0x09,0x10,0x0A,0x10,0x0B,\ | 231 (vector unsigned char){0x10,0x08,0x10,0x09,0x10,0x0A,0x10,0x0B,\ |
232 0x10,0x0C,0x10,0x0D,0x10,0x0E,0x10,0x0F)) | 232 0x10,0x0C,0x10,0x0D,0x10,0x0E,0x10,0x0F}) |
233 | 233 |
234 #define vec_clip_s16(x) \ | 234 #define vec_clip_s16(x) \ |
235 vec_max (vec_min (x, (vector signed short)AVV(235,235,235,235,235,235,235,235)),\ | 235 vec_max (vec_min (x, (vector signed short){235,235,235,235,235,235,235,235}), \ |
236 (vector signed short)AVV( 16, 16, 16, 16, 16, 16, 16, 16)) | 236 (vector signed short){ 16, 16, 16, 16, 16, 16, 16, 16 }) |
237 | 237 |
238 #define vec_packclp(x,y) \ | 238 #define vec_packclp(x,y) \ |
239 (vector unsigned char)vec_packs \ | 239 (vector unsigned char)vec_packs \ |
240 ((vector unsigned short)vec_max (x,(vector signed short) AVV(0)), \ | 240 ((vector unsigned short)vec_max (x,(vector signed short) {0}), \ |
241 (vector unsigned short)vec_max (y,(vector signed short) AVV(0))) | 241 (vector unsigned short)vec_max (y,(vector signed short) {0})) |
242 | 242 |
243 //#define out_pixels(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a))AVV(0)),a,a,a,ptr) | 243 //#define out_pixels(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a)){0}),a,a,a,ptr) |
244 | 244 |
245 | 245 |
246 static inline void cvtyuvtoRGB (SwsContext *c, | 246 static inline void cvtyuvtoRGB (SwsContext *c, |
247 vector signed short Y, vector signed short U, vector signed short V, | 247 vector signed short Y, vector signed short U, vector signed short V, |
248 vector signed short *R, vector signed short *G, vector signed short *B) | 248 vector signed short *R, vector signed short *G, vector signed short *B) |
249 { | 249 { |
250 vector signed short vx,ux,uvx; | 250 vector signed short vx,ux,uvx; |
251 | 251 |
252 Y = vec_mradds (Y, c->CY, c->OY); | 252 Y = vec_mradds (Y, c->CY, c->OY); |
253 U = vec_sub (U,(vector signed short) | 253 U = vec_sub (U,(vector signed short) |
254 vec_splat((vector signed short)AVV(128),0)); | 254 vec_splat((vector signed short){128},0)); |
255 V = vec_sub (V,(vector signed short) | 255 V = vec_sub (V,(vector signed short) |
256 vec_splat((vector signed short)AVV(128),0)); | 256 vec_splat((vector signed short){128},0)); |
257 | 257 |
258 // ux = (CBU*(u<<c->CSHIFT)+0x4000)>>15; | 258 // ux = (CBU*(u<<c->CSHIFT)+0x4000)>>15; |
259 ux = vec_sl (U, c->CSHIFT); | 259 ux = vec_sl (U, c->CSHIFT); |
260 *B = vec_mradds (ux, c->CBU, Y); | 260 *B = vec_mradds (ux, c->CBU, Y); |
261 | 261 |
357 v = (vector signed char) \ | 357 v = (vector signed char) \ |
358 vec_perm (vivP[0], vivP[1], align_perm); \ | 358 vec_perm (vivP[0], vivP[1], align_perm); \ |
359 \ | 359 \ |
360 u = (vector signed char) \ | 360 u = (vector signed char) \ |
361 vec_sub (u,(vector signed char) \ | 361 vec_sub (u,(vector signed char) \ |
362 vec_splat((vector signed char)AVV(128),0)); \ | 362 vec_splat((vector signed char){128},0)); \ |
363 v = (vector signed char) \ | 363 v = (vector signed char) \ |
364 vec_sub (v,(vector signed char) \ | 364 vec_sub (v,(vector signed char) \ |
365 vec_splat((vector signed char)AVV(128),0)); \ | 365 vec_splat((vector signed char){128},0)); \ |
366 \ | 366 \ |
367 U = vec_unpackh (u); \ | 367 U = vec_unpackh (u); \ |
368 V = vec_unpackh (v); \ | 368 V = vec_unpackh (v); \ |
369 \ | 369 \ |
370 \ | 370 \ |
378 Y2 = vec_mradds (Y2, lCY, lOY); \ | 378 Y2 = vec_mradds (Y2, lCY, lOY); \ |
379 Y3 = vec_mradds (Y3, lCY, lOY); \ | 379 Y3 = vec_mradds (Y3, lCY, lOY); \ |
380 \ | 380 \ |
381 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */ \ | 381 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */ \ |
382 ux = vec_sl (U, lCSHIFT); \ | 382 ux = vec_sl (U, lCSHIFT); \ |
383 ux = vec_mradds (ux, lCBU, (vector signed short)AVV(0)); \ | 383 ux = vec_mradds (ux, lCBU, (vector signed short){0}); \ |
384 ux0 = vec_mergeh (ux,ux); \ | 384 ux0 = vec_mergeh (ux,ux); \ |
385 ux1 = vec_mergel (ux,ux); \ | 385 ux1 = vec_mergel (ux,ux); \ |
386 \ | 386 \ |
387 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */ \ | 387 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */ \ |
388 vx = vec_sl (V, lCSHIFT); \ | 388 vx = vec_sl (V, lCSHIFT); \ |
389 vx = vec_mradds (vx, lCRV, (vector signed short)AVV(0)); \ | 389 vx = vec_mradds (vx, lCRV, (vector signed short){0}); \ |
390 vx0 = vec_mergeh (vx,vx); \ | 390 vx0 = vec_mergeh (vx,vx); \ |
391 vx1 = vec_mergel (vx,vx); \ | 391 vx1 = vec_mergel (vx,vx); \ |
392 \ | 392 \ |
393 /* uvx = ((CGU*u) + (CGV*v))>>15 */ \ | 393 /* uvx = ((CGU*u) + (CGV*v))>>15 */ \ |
394 uvx = vec_mradds (U, lCGU, (vector signed short)AVV(0)); \ | 394 uvx = vec_mradds (U, lCGU, (vector signed short){0}); \ |
395 uvx = vec_mradds (V, lCGV, uvx); \ | 395 uvx = vec_mradds (V, lCGV, uvx); \ |
396 uvx0 = vec_mergeh (uvx,uvx); \ | 396 uvx0 = vec_mergeh (uvx,uvx); \ |
397 uvx1 = vec_mergel (uvx,uvx); \ | 397 uvx1 = vec_mergel (uvx,uvx); \ |
398 \ | 398 \ |
399 R0 = vec_add (Y0,vx0); \ | 399 R0 = vec_add (Y0,vx0); \ |
439 } \ | 439 } \ |
440 return srcSliceH; \ | 440 return srcSliceH; \ |
441 } | 441 } |
442 | 442 |
443 | 443 |
444 #define out_abgr(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a))AVV(0)),c,b,a,ptr) | 444 #define out_abgr(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a)){0}),c,b,a,ptr) |
445 #define out_bgra(a,b,c,ptr) vec_mstrgb32(typeof(a),c,b,a,((typeof (a))AVV(0)),ptr) | 445 #define out_bgra(a,b,c,ptr) vec_mstrgb32(typeof(a),c,b,a,((typeof (a)){0}),ptr) |
446 #define out_rgba(a,b,c,ptr) vec_mstrgb32(typeof(a),a,b,c,((typeof (a))AVV(0)),ptr) | 446 #define out_rgba(a,b,c,ptr) vec_mstrgb32(typeof(a),a,b,c,((typeof (a)){0}),ptr) |
447 #define out_argb(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a))AVV(0)),a,b,c,ptr) | 447 #define out_argb(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a)){0}),a,b,c,ptr) |
448 #define out_rgb24(a,b,c,ptr) vec_mstrgb24(a,b,c,ptr) | 448 #define out_rgb24(a,b,c,ptr) vec_mstrgb24(a,b,c,ptr) |
449 #define out_bgr24(a,b,c,ptr) vec_mstbgr24(a,b,c,ptr) | 449 #define out_bgr24(a,b,c,ptr) vec_mstbgr24(a,b,c,ptr) |
450 | 450 |
451 DEFCSP420_CVT (yuv2_abgr, out_abgr) | 451 DEFCSP420_CVT (yuv2_abgr, out_abgr) |
452 #if 1 | 452 #if 1 |
521 | 521 |
522 align_perm = vec_lvsl (0, vi); | 522 align_perm = vec_lvsl (0, vi); |
523 v = (vector signed char)vec_perm (vivP[0], vivP[1], align_perm); | 523 v = (vector signed char)vec_perm (vivP[0], vivP[1], align_perm); |
524 u = (vector signed char) | 524 u = (vector signed char) |
525 vec_sub (u,(vector signed char) | 525 vec_sub (u,(vector signed char) |
526 vec_splat((vector signed char)AVV(128),0)); | 526 vec_splat((vector signed char){128},0)); |
527 | 527 |
528 v = (vector signed char) | 528 v = (vector signed char) |
529 vec_sub (v, (vector signed char) | 529 vec_sub (v, (vector signed char) |
530 vec_splat((vector signed char)AVV(128),0)); | 530 vec_splat((vector signed char){128},0)); |
531 | 531 |
532 U = vec_unpackh (u); | 532 U = vec_unpackh (u); |
533 V = vec_unpackh (v); | 533 V = vec_unpackh (v); |
534 | 534 |
535 | 535 |
543 Y2 = vec_mradds (Y2, lCY, lOY); | 543 Y2 = vec_mradds (Y2, lCY, lOY); |
544 Y3 = vec_mradds (Y3, lCY, lOY); | 544 Y3 = vec_mradds (Y3, lCY, lOY); |
545 | 545 |
546 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */ | 546 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */ |
547 ux = vec_sl (U, lCSHIFT); | 547 ux = vec_sl (U, lCSHIFT); |
548 ux = vec_mradds (ux, lCBU, (vector signed short)AVV(0)); | 548 ux = vec_mradds (ux, lCBU, (vector signed short){0}); |
549 ux0 = vec_mergeh (ux,ux); | 549 ux0 = vec_mergeh (ux,ux); |
550 ux1 = vec_mergel (ux,ux); | 550 ux1 = vec_mergel (ux,ux); |
551 | 551 |
552 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */ | 552 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */ |
553 vx = vec_sl (V, lCSHIFT); | 553 vx = vec_sl (V, lCSHIFT); |
554 vx = vec_mradds (vx, lCRV, (vector signed short)AVV(0)); | 554 vx = vec_mradds (vx, lCRV, (vector signed short){0}); |
555 vx0 = vec_mergeh (vx,vx); | 555 vx0 = vec_mergeh (vx,vx); |
556 vx1 = vec_mergel (vx,vx); | 556 vx1 = vec_mergel (vx,vx); |
557 /* uvx = ((CGU*u) + (CGV*v))>>15 */ | 557 /* uvx = ((CGU*u) + (CGV*v))>>15 */ |
558 uvx = vec_mradds (U, lCGU, (vector signed short)AVV(0)); | 558 uvx = vec_mradds (U, lCGU, (vector signed short){0}); |
559 uvx = vec_mradds (V, lCGV, uvx); | 559 uvx = vec_mradds (V, lCGV, uvx); |
560 uvx0 = vec_mergeh (uvx,uvx); | 560 uvx0 = vec_mergeh (uvx,uvx); |
561 uvx1 = vec_mergel (uvx,uvx); | 561 uvx1 = vec_mergel (uvx,uvx); |
562 R0 = vec_add (Y0,vx0); | 562 R0 = vec_add (Y0,vx0); |
563 G0 = vec_add (Y0,uvx0); | 563 G0 = vec_add (Y0,uvx0); |
610 | 610 |
611 // uyvy|uyvy|uyvy|uyvy | 611 // uyvy|uyvy|uyvy|uyvy |
612 // 0123 4567 89ab cdef | 612 // 0123 4567 89ab cdef |
613 static | 613 static |
614 const vector unsigned char | 614 const vector unsigned char |
615 demux_u = AVV(0x10,0x00,0x10,0x00, | 615 demux_u = {0x10,0x00,0x10,0x00, |
616 0x10,0x04,0x10,0x04, | 616 0x10,0x04,0x10,0x04, |
617 0x10,0x08,0x10,0x08, | 617 0x10,0x08,0x10,0x08, |
618 0x10,0x0c,0x10,0x0c), | 618 0x10,0x0c,0x10,0x0c}, |
619 demux_v = AVV(0x10,0x02,0x10,0x02, | 619 demux_v = {0x10,0x02,0x10,0x02, |
620 0x10,0x06,0x10,0x06, | 620 0x10,0x06,0x10,0x06, |
621 0x10,0x0A,0x10,0x0A, | 621 0x10,0x0A,0x10,0x0A, |
622 0x10,0x0E,0x10,0x0E), | 622 0x10,0x0E,0x10,0x0E}, |
623 demux_y = AVV(0x10,0x01,0x10,0x03, | 623 demux_y = {0x10,0x01,0x10,0x03, |
624 0x10,0x05,0x10,0x07, | 624 0x10,0x05,0x10,0x07, |
625 0x10,0x09,0x10,0x0B, | 625 0x10,0x09,0x10,0x0B, |
626 0x10,0x0D,0x10,0x0F); | 626 0x10,0x0D,0x10,0x0F}; |
627 | 627 |
628 /* | 628 /* |
629 this is so I can play live CCIR raw video | 629 this is so I can play live CCIR raw video |
630 */ | 630 */ |
631 static int altivec_uyvy_rgb32 (SwsContext *c, | 631 static int altivec_uyvy_rgb32 (SwsContext *c, |
648 | 648 |
649 for (i=0;i<h;i++) { | 649 for (i=0;i<h;i++) { |
650 for (j=0;j<w/16;j++) { | 650 for (j=0;j<w/16;j++) { |
651 uyvy = vec_ld (0, img); | 651 uyvy = vec_ld (0, img); |
652 U = (vector signed short) | 652 U = (vector signed short) |
653 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u); | 653 vec_perm (uyvy, (vector unsigned char){0}, demux_u); |
654 | 654 |
655 V = (vector signed short) | 655 V = (vector signed short) |
656 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v); | 656 vec_perm (uyvy, (vector unsigned char){0}, demux_v); |
657 | 657 |
658 Y = (vector signed short) | 658 Y = (vector signed short) |
659 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y); | 659 vec_perm (uyvy, (vector unsigned char){0}, demux_y); |
660 | 660 |
661 cvtyuvtoRGB (c, Y,U,V,&R0,&G0,&B0); | 661 cvtyuvtoRGB (c, Y,U,V,&R0,&G0,&B0); |
662 | 662 |
663 uyvy = vec_ld (16, img); | 663 uyvy = vec_ld (16, img); |
664 U = (vector signed short) | 664 U = (vector signed short) |
665 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u); | 665 vec_perm (uyvy, (vector unsigned char){0}, demux_u); |
666 | 666 |
667 V = (vector signed short) | 667 V = (vector signed short) |
668 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v); | 668 vec_perm (uyvy, (vector unsigned char){0}, demux_v); |
669 | 669 |
670 Y = (vector signed short) | 670 Y = (vector signed short) |
671 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y); | 671 vec_perm (uyvy, (vector unsigned char){0}, demux_y); |
672 | 672 |
673 cvtyuvtoRGB (c, Y,U,V,&R1,&G1,&B1); | 673 cvtyuvtoRGB (c, Y,U,V,&R1,&G1,&B1); |
674 | 674 |
675 R = vec_packclp (R0,R1); | 675 R = vec_packclp (R0,R1); |
676 G = vec_packclp (G0,G1); | 676 G = vec_packclp (G0,G1); |