comparison libswscale/yuv2rgb_altivec.c @ 23129:9528d1ebe68f

cosmetics: Remove trailing whitespace.
author diego
date Thu, 26 Apr 2007 23:07:11 +0000
parents a14ddab18acd
children ebc55c913d73
comparison
equal deleted inserted replaced
23128:0c4b9bc10494 23129:9528d1ebe68f
57 57
58 GL2 libraries work now with patch for RGB32 58 GL2 libraries work now with patch for RGB32
59 59
60 NOTE quartz vo driver ARGB32_to_RGB24 consumes 30% of the processor 60 NOTE quartz vo driver ARGB32_to_RGB24 consumes 30% of the processor
61 61
62 Integrated luma prescaling adjustment for saturation/contrast/brightness adjustment. 62 Integrated luma prescaling adjustment for saturation/contrast/brightness adjustment.
63 */ 63 */
64 64
65 /* 65 /*
66 * This file is part of FFmpeg. 66 * This file is part of FFmpeg.
67 * 67 *
441 441
442 DEFCSP420_CVT (yuv2_abgr, out_abgr) 442 DEFCSP420_CVT (yuv2_abgr, out_abgr)
443 #if 1 443 #if 1
444 DEFCSP420_CVT (yuv2_bgra, out_bgra) 444 DEFCSP420_CVT (yuv2_bgra, out_bgra)
445 #else 445 #else
446 static int altivec_yuv2_bgra32 (SwsContext *c, 446 static int altivec_yuv2_bgra32 (SwsContext *c,
447 unsigned char **in, int *instrides, 447 unsigned char **in, int *instrides,
448 int srcSliceY, int srcSliceH, 448 int srcSliceY, int srcSliceH,
449 unsigned char **oplanes, int *outstrides) 449 unsigned char **oplanes, int *outstrides)
450 { 450 {
451 int w = c->srcW; 451 int w = c->srcW;
452 int h = srcSliceH; 452 int h = srcSliceH;
453 int i,j; 453 int i,j;
454 int instrides_scl[3]; 454 int instrides_scl[3];
455 vector unsigned char y0,y1; 455 vector unsigned char y0,y1;
456 456
457 vector signed char u,v; 457 vector signed char u,v;
458 458
459 vector signed short Y0,Y1,Y2,Y3; 459 vector signed short Y0,Y1,Y2,Y3;
460 vector signed short U,V; 460 vector signed short U,V;
461 vector signed short vx,ux,uvx; 461 vector signed short vx,ux,uvx;
462 vector signed short vx0,ux0,uvx0; 462 vector signed short vx0,ux0,uvx0;
463 vector signed short vx1,ux1,uvx1; 463 vector signed short vx1,ux1,uvx1;
464 vector signed short R0,G0,B0; 464 vector signed short R0,G0,B0;
465 vector signed short R1,G1,B1; 465 vector signed short R1,G1,B1;
466 vector unsigned char R,G,B; 466 vector unsigned char R,G,B;
467 467
468 vector unsigned char *uivP, *vivP; 468 vector unsigned char *uivP, *vivP;
469 vector unsigned char align_perm; 469 vector unsigned char align_perm;
470 470
471 vector signed short 471 vector signed short
472 lCY = c->CY, 472 lCY = c->CY,
473 lOY = c->OY, 473 lOY = c->OY,
474 lCRV = c->CRV, 474 lCRV = c->CRV,
475 lCBU = c->CBU, 475 lCBU = c->CBU,
476 lCGU = c->CGU, 476 lCGU = c->CGU,
477 lCGV = c->CGV; 477 lCGV = c->CGV;
478 478
479 vector unsigned short lCSHIFT = c->CSHIFT; 479 vector unsigned short lCSHIFT = c->CSHIFT;
480 480
481 ubyte *y1i = in[0]; 481 ubyte *y1i = in[0];
482 ubyte *y2i = in[0]+w; 482 ubyte *y2i = in[0]+w;
483 ubyte *ui = in[1]; 483 ubyte *ui = in[1];
484 ubyte *vi = in[2]; 484 ubyte *vi = in[2];
485 485
486 vector unsigned char *oute 486 vector unsigned char *oute
487 = (vector unsigned char *) 487 = (vector unsigned char *)
488 (oplanes[0]+srcSliceY*outstrides[0]); 488 (oplanes[0]+srcSliceY*outstrides[0]);
489 vector unsigned char *outo 489 vector unsigned char *outo
490 = (vector unsigned char *) 490 = (vector unsigned char *)
491 (oplanes[0]+srcSliceY*outstrides[0]+outstrides[0]); 491 (oplanes[0]+srcSliceY*outstrides[0]+outstrides[0]);
492 492
493 493
494 instrides_scl[0] = instrides[0]; 494 instrides_scl[0] = instrides[0];
495 instrides_scl[1] = instrides[1]-w/2; /* the loop moves ui by w/2 */ 495 instrides_scl[1] = instrides[1]-w/2; /* the loop moves ui by w/2 */
496 instrides_scl[2] = instrides[2]-w/2; /* the loop moves vi by w/2 */ 496 instrides_scl[2] = instrides[2]-w/2; /* the loop moves vi by w/2 */
497 497
498 498
499 for (i=0;i<h/2;i++) { 499 for (i=0;i<h/2;i++) {
500 vec_dstst (outo, (0x02000002|(((w*3+32)/32)<<16)), 0); 500 vec_dstst (outo, (0x02000002|(((w*3+32)/32)<<16)), 0);
501 vec_dstst (oute, (0x02000002|(((w*3+32)/32)<<16)), 1); 501 vec_dstst (oute, (0x02000002|(((w*3+32)/32)<<16)), 1);
502 502
503 for (j=0;j<w/16;j++) { 503 for (j=0;j<w/16;j++) {
504 504
505 y0 = vec_ldl (0,y1i); 505 y0 = vec_ldl (0,y1i);
506 y1 = vec_ldl (0,y2i); 506 y1 = vec_ldl (0,y2i);
507 uivP = (vector unsigned char *)ui; 507 uivP = (vector unsigned char *)ui;
508 vivP = (vector unsigned char *)vi; 508 vivP = (vector unsigned char *)vi;
509 509
510 align_perm = vec_lvsl (0, ui); 510 align_perm = vec_lvsl (0, ui);
511 u = (vector signed char)vec_perm (uivP[0], uivP[1], align_perm); 511 u = (vector signed char)vec_perm (uivP[0], uivP[1], align_perm);
512 512
513 align_perm = vec_lvsl (0, vi); 513 align_perm = vec_lvsl (0, vi);
514 v = (vector signed char)vec_perm (vivP[0], vivP[1], align_perm); 514 v = (vector signed char)vec_perm (vivP[0], vivP[1], align_perm);
515 u = (vector signed char) 515 u = (vector signed char)
516 vec_sub (u,(vector signed char) 516 vec_sub (u,(vector signed char)
517 vec_splat((vector signed char)AVV(128),0)); 517 vec_splat((vector signed char)AVV(128),0));
518 518
519 v = (vector signed char) 519 v = (vector signed char)
520 vec_sub (v, (vector signed char) 520 vec_sub (v, (vector signed char)
521 vec_splat((vector signed char)AVV(128),0)); 521 vec_splat((vector signed char)AVV(128),0));
522 522
523 U = vec_unpackh (u); 523 U = vec_unpackh (u);
524 V = vec_unpackh (v); 524 V = vec_unpackh (v);
525 525
526 526
527 Y0 = vec_unh (y0); 527 Y0 = vec_unh (y0);
528 Y1 = vec_unl (y0); 528 Y1 = vec_unl (y0);
529 Y2 = vec_unh (y1); 529 Y2 = vec_unh (y1);
530 Y3 = vec_unl (y1); 530 Y3 = vec_unl (y1);
531 531
532 Y0 = vec_mradds (Y0, lCY, lOY); 532 Y0 = vec_mradds (Y0, lCY, lOY);
533 Y1 = vec_mradds (Y1, lCY, lOY); 533 Y1 = vec_mradds (Y1, lCY, lOY);
534 Y2 = vec_mradds (Y2, lCY, lOY); 534 Y2 = vec_mradds (Y2, lCY, lOY);
535 Y3 = vec_mradds (Y3, lCY, lOY); 535 Y3 = vec_mradds (Y3, lCY, lOY);
536 536
537 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */ 537 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */
538 ux = vec_sl (U, lCSHIFT); 538 ux = vec_sl (U, lCSHIFT);
539 ux = vec_mradds (ux, lCBU, (vector signed short)AVV(0)); 539 ux = vec_mradds (ux, lCBU, (vector signed short)AVV(0));
540 ux0 = vec_mergeh (ux,ux); 540 ux0 = vec_mergeh (ux,ux);
541 ux1 = vec_mergel (ux,ux); 541 ux1 = vec_mergel (ux,ux);
542 542
543 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */ 543 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */
544 vx = vec_sl (V, lCSHIFT); 544 vx = vec_sl (V, lCSHIFT);
545 vx = vec_mradds (vx, lCRV, (vector signed short)AVV(0)); 545 vx = vec_mradds (vx, lCRV, (vector signed short)AVV(0));
546 vx0 = vec_mergeh (vx,vx); 546 vx0 = vec_mergeh (vx,vx);
547 vx1 = vec_mergel (vx,vx); 547 vx1 = vec_mergel (vx,vx);
548 /* uvx = ((CGU*u) + (CGV*v))>>15 */ 548 /* uvx = ((CGU*u) + (CGV*v))>>15 */
549 uvx = vec_mradds (U, lCGU, (vector signed short)AVV(0)); 549 uvx = vec_mradds (U, lCGU, (vector signed short)AVV(0));
557 G1 = vec_add (Y1,uvx1); 557 G1 = vec_add (Y1,uvx1);
558 B1 = vec_add (Y1,ux1); 558 B1 = vec_add (Y1,ux1);
559 R = vec_packclp (R0,R1); 559 R = vec_packclp (R0,R1);
560 G = vec_packclp (G0,G1); 560 G = vec_packclp (G0,G1);
561 B = vec_packclp (B0,B1); 561 B = vec_packclp (B0,B1);
562 562
563 out_argb(R,G,B,oute); 563 out_argb(R,G,B,oute);
564 R0 = vec_add (Y2,vx0); 564 R0 = vec_add (Y2,vx0);
565 G0 = vec_add (Y2,uvx0); 565 G0 = vec_add (Y2,uvx0);
566 B0 = vec_add (Y2,ux0); 566 B0 = vec_add (Y2,ux0);
567 R1 = vec_add (Y3,vx1); 567 R1 = vec_add (Y3,vx1);
568 G1 = vec_add (Y3,uvx1); 568 G1 = vec_add (Y3,uvx1);
569 B1 = vec_add (Y3,ux1); 569 B1 = vec_add (Y3,ux1);
570 R = vec_packclp (R0,R1); 570 R = vec_packclp (R0,R1);
571 G = vec_packclp (G0,G1); 571 G = vec_packclp (G0,G1);
572 B = vec_packclp (B0,B1); 572 B = vec_packclp (B0,B1);
573 573
574 out_argb(R,G,B,outo); 574 out_argb(R,G,B,outo);
575 y1i += 16; 575 y1i += 16;
576 y2i += 16; 576 y2i += 16;
577 ui += 8; 577 ui += 8;
578 vi += 8; 578 vi += 8;
579 579
580 } 580 }
581 581
582 outo += (outstrides[0])>>4; 582 outo += (outstrides[0])>>4;
583 oute += (outstrides[0])>>4; 583 oute += (outstrides[0])>>4;
584 584
585 ui += instrides_scl[1]; 585 ui += instrides_scl[1];
586 vi += instrides_scl[2]; 586 vi += instrides_scl[2];
587 y1i += instrides_scl[0]; 587 y1i += instrides_scl[0];
588 y2i += instrides_scl[0]; 588 y2i += instrides_scl[0];
589 } 589 }
590 return srcSliceH; 590 return srcSliceH;
591 } 591 }
592 592
593 #endif 593 #endif
594 594
595 595
684 684
685 So we just fall back to the C codes for this. 685 So we just fall back to the C codes for this.
686 */ 686 */
687 SwsFunc yuv2rgb_init_altivec (SwsContext *c) 687 SwsFunc yuv2rgb_init_altivec (SwsContext *c)
688 { 688 {
689 if (!(c->flags & SWS_CPU_CAPS_ALTIVEC)) 689 if (!(c->flags & SWS_CPU_CAPS_ALTIVEC))
690 return NULL; 690 return NULL;
691 691
692 /* 692 /*
693 and this seems not to matter too much I tried a bunch of 693 and this seems not to matter too much I tried a bunch of
694 videos with abnormal widths and mplayer crashes else where. 694 videos with abnormal widths and mplayer crashes else where.
695 mplayer -vo x11 -rawvideo on:w=350:h=240 raw-350x240.eyuv 695 mplayer -vo x11 -rawvideo on:w=350:h=240 raw-350x240.eyuv
696 boom with X11 bad match. 696 boom with X11 bad match.
697 697
698 */ 698 */
699 if ((c->srcW & 0xf) != 0) return NULL; 699 if ((c->srcW & 0xf) != 0) return NULL;
700 700
701 switch (c->srcFormat) { 701 switch (c->srcFormat) {
702 case PIX_FMT_YUV410P: 702 case PIX_FMT_YUV410P: