Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: source/convert_from.cc

Issue 1398623002: fix jpeg and bt.709 yuvconstants for neon64. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/convert_argb.cc ('k') | source/planar_functions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 int I420ToARGB(const uint8* src_y, int src_stride_y, 455 int I420ToARGB(const uint8* src_y, int src_stride_y,
456 const uint8* src_u, int src_stride_u, 456 const uint8* src_u, int src_stride_u,
457 const uint8* src_v, int src_stride_v, 457 const uint8* src_v, int src_stride_v,
458 uint8* dst_argb, int dst_stride_argb, 458 uint8* dst_argb, int dst_stride_argb,
459 int width, int height) { 459 int width, int height) {
460 int y; 460 int y;
461 void (*I422ToARGBRow)(const uint8* y_buf, 461 void (*I422ToARGBRow)(const uint8* y_buf,
462 const uint8* u_buf, 462 const uint8* u_buf,
463 const uint8* v_buf, 463 const uint8* v_buf,
464 uint8* rgb_buf, 464 uint8* rgb_buf,
465 struct YuvConstants* yuvconstants, 465 const struct YuvConstants* yuvconstants,
466 int width) = I422ToARGBRow_C; 466 int width) = I422ToARGBRow_C;
467 if (!src_y || !src_u || !src_v || !dst_argb || 467 if (!src_y || !src_u || !src_v || !dst_argb ||
468 width <= 0 || height == 0) { 468 width <= 0 || height == 0) {
469 return -1; 469 return -1;
470 } 470 }
471 // Negative height means invert the image. 471 // Negative height means invert the image.
472 if (height < 0) { 472 if (height < 0) {
473 height = -height; 473 height = -height;
474 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 474 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
475 dst_stride_argb = -dst_stride_argb; 475 dst_stride_argb = -dst_stride_argb;
(...skipping 26 matching lines...) Expand all
502 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 502 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
503 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 503 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
504 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 504 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
505 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 505 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
506 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 506 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {
507 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; 507 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
508 } 508 }
509 #endif 509 #endif
510 510
511 for (y = 0; y < height; ++y) { 511 for (y = 0; y < height; ++y) {
512 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvConstants, width); 512 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvIConstants, width);
513 dst_argb += dst_stride_argb; 513 dst_argb += dst_stride_argb;
514 src_y += src_stride_y; 514 src_y += src_stride_y;
515 if (y & 1) { 515 if (y & 1) {
516 src_u += src_stride_u; 516 src_u += src_stride_u;
517 src_v += src_stride_v; 517 src_v += src_stride_v;
518 } 518 }
519 } 519 }
520 return 0; 520 return 0;
521 } 521 }
522 522
523 // Convert I420 to BGRA. 523 // Convert I420 to BGRA.
524 LIBYUV_API 524 LIBYUV_API
525 int I420ToBGRA(const uint8* src_y, int src_stride_y, 525 int I420ToBGRA(const uint8* src_y, int src_stride_y,
526 const uint8* src_u, int src_stride_u, 526 const uint8* src_u, int src_stride_u,
527 const uint8* src_v, int src_stride_v, 527 const uint8* src_v, int src_stride_v,
528 uint8* dst_bgra, int dst_stride_bgra, 528 uint8* dst_bgra, int dst_stride_bgra,
529 int width, int height) { 529 int width, int height) {
530 int y; 530 int y;
531 void (*I422ToBGRARow)(const uint8* y_buf, 531 void (*I422ToBGRARow)(const uint8* y_buf,
532 const uint8* u_buf, 532 const uint8* u_buf,
533 const uint8* v_buf, 533 const uint8* v_buf,
534 uint8* rgb_buf, 534 uint8* rgb_buf,
535 struct YuvConstants* yuvconstants, 535 const struct YuvConstants* yuvconstants,
536 int width) = I422ToBGRARow_C; 536 int width) = I422ToBGRARow_C;
537 if (!src_y || !src_u || !src_v || !dst_bgra || 537 if (!src_y || !src_u || !src_v || !dst_bgra ||
538 width <= 0 || height == 0) { 538 width <= 0 || height == 0) {
539 return -1; 539 return -1;
540 } 540 }
541 // Negative height means invert the image. 541 // Negative height means invert the image.
542 if (height < 0) { 542 if (height < 0) {
543 height = -height; 543 height = -height;
544 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; 544 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra;
545 dst_stride_bgra = -dst_stride_bgra; 545 dst_stride_bgra = -dst_stride_bgra;
(...skipping 26 matching lines...) Expand all
572 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 572 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
573 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 573 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
574 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 574 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
575 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 575 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
576 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { 576 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) {
577 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; 577 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2;
578 } 578 }
579 #endif 579 #endif
580 580
581 for (y = 0; y < height; ++y) { 581 for (y = 0; y < height; ++y) {
582 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, &kYuvConstants, width); 582 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, &kYuvIConstants, width);
583 dst_bgra += dst_stride_bgra; 583 dst_bgra += dst_stride_bgra;
584 src_y += src_stride_y; 584 src_y += src_stride_y;
585 if (y & 1) { 585 if (y & 1) {
586 src_u += src_stride_u; 586 src_u += src_stride_u;
587 src_v += src_stride_v; 587 src_v += src_stride_v;
588 } 588 }
589 } 589 }
590 return 0; 590 return 0;
591 } 591 }
592 592
593 // Convert I420 to ABGR. 593 // Convert I420 to ABGR.
594 LIBYUV_API 594 LIBYUV_API
595 int I420ToABGR(const uint8* src_y, int src_stride_y, 595 int I420ToABGR(const uint8* src_y, int src_stride_y,
596 const uint8* src_u, int src_stride_u, 596 const uint8* src_u, int src_stride_u,
597 const uint8* src_v, int src_stride_v, 597 const uint8* src_v, int src_stride_v,
598 uint8* dst_abgr, int dst_stride_abgr, 598 uint8* dst_abgr, int dst_stride_abgr,
599 int width, int height) { 599 int width, int height) {
600 int y; 600 int y;
601 void (*I422ToABGRRow)(const uint8* y_buf, 601 void (*I422ToABGRRow)(const uint8* y_buf,
602 const uint8* u_buf, 602 const uint8* u_buf,
603 const uint8* v_buf, 603 const uint8* v_buf,
604 uint8* rgb_buf, 604 uint8* rgb_buf,
605 struct YuvConstants* yuvconstants, 605 const struct YuvConstants* yuvconstants,
606 int width) = I422ToABGRRow_C; 606 int width) = I422ToABGRRow_C;
607 if (!src_y || !src_u || !src_v || !dst_abgr || 607 if (!src_y || !src_u || !src_v || !dst_abgr ||
608 width <= 0 || height == 0) { 608 width <= 0 || height == 0) {
609 return -1; 609 return -1;
610 } 610 }
611 // Negative height means invert the image. 611 // Negative height means invert the image.
612 if (height < 0) { 612 if (height < 0) {
613 height = -height; 613 height = -height;
614 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; 614 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr;
615 dst_stride_abgr = -dst_stride_abgr; 615 dst_stride_abgr = -dst_stride_abgr;
(...skipping 17 matching lines...) Expand all
633 #if defined(HAS_I422TOABGRROW_NEON) 633 #if defined(HAS_I422TOABGRROW_NEON)
634 if (TestCpuFlag(kCpuHasNEON)) { 634 if (TestCpuFlag(kCpuHasNEON)) {
635 I422ToABGRRow = I422ToABGRRow_Any_NEON; 635 I422ToABGRRow = I422ToABGRRow_Any_NEON;
636 if (IS_ALIGNED(width, 8)) { 636 if (IS_ALIGNED(width, 8)) {
637 I422ToABGRRow = I422ToABGRRow_NEON; 637 I422ToABGRRow = I422ToABGRRow_NEON;
638 } 638 }
639 } 639 }
640 #endif 640 #endif
641 641
642 for (y = 0; y < height; ++y) { 642 for (y = 0; y < height; ++y) {
643 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvConstants, width); 643 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvIConstants, width);
644 dst_abgr += dst_stride_abgr; 644 dst_abgr += dst_stride_abgr;
645 src_y += src_stride_y; 645 src_y += src_stride_y;
646 if (y & 1) { 646 if (y & 1) {
647 src_u += src_stride_u; 647 src_u += src_stride_u;
648 src_v += src_stride_v; 648 src_v += src_stride_v;
649 } 649 }
650 } 650 }
651 return 0; 651 return 0;
652 } 652 }
653 653
654 // Convert I420 to RGBA. 654 // Convert I420 to RGBA.
655 LIBYUV_API 655 LIBYUV_API
656 int I420ToRGBA(const uint8* src_y, int src_stride_y, 656 int I420ToRGBA(const uint8* src_y, int src_stride_y,
657 const uint8* src_u, int src_stride_u, 657 const uint8* src_u, int src_stride_u,
658 const uint8* src_v, int src_stride_v, 658 const uint8* src_v, int src_stride_v,
659 uint8* dst_rgba, int dst_stride_rgba, 659 uint8* dst_rgba, int dst_stride_rgba,
660 int width, int height) { 660 int width, int height) {
661 int y; 661 int y;
662 void (*I422ToRGBARow)(const uint8* y_buf, 662 void (*I422ToRGBARow)(const uint8* y_buf,
663 const uint8* u_buf, 663 const uint8* u_buf,
664 const uint8* v_buf, 664 const uint8* v_buf,
665 uint8* rgb_buf, 665 uint8* rgb_buf,
666 struct YuvConstants* yuvconstants, 666 const struct YuvConstants* yuvconstants,
667 int width) = I422ToRGBARow_C; 667 int width) = I422ToRGBARow_C;
668 if (!src_y || !src_u || !src_v || !dst_rgba || 668 if (!src_y || !src_u || !src_v || !dst_rgba ||
669 width <= 0 || height == 0) { 669 width <= 0 || height == 0) {
670 return -1; 670 return -1;
671 } 671 }
672 // Negative height means invert the image. 672 // Negative height means invert the image.
673 if (height < 0) { 673 if (height < 0) {
674 height = -height; 674 height = -height;
675 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; 675 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba;
676 dst_stride_rgba = -dst_stride_rgba; 676 dst_stride_rgba = -dst_stride_rgba;
(...skipping 17 matching lines...) Expand all
694 #if defined(HAS_I422TORGBAROW_NEON) 694 #if defined(HAS_I422TORGBAROW_NEON)
695 if (TestCpuFlag(kCpuHasNEON)) { 695 if (TestCpuFlag(kCpuHasNEON)) {
696 I422ToRGBARow = I422ToRGBARow_Any_NEON; 696 I422ToRGBARow = I422ToRGBARow_Any_NEON;
697 if (IS_ALIGNED(width, 8)) { 697 if (IS_ALIGNED(width, 8)) {
698 I422ToRGBARow = I422ToRGBARow_NEON; 698 I422ToRGBARow = I422ToRGBARow_NEON;
699 } 699 }
700 } 700 }
701 #endif 701 #endif
702 702
703 for (y = 0; y < height; ++y) { 703 for (y = 0; y < height; ++y) {
704 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, &kYuvConstants, width); 704 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, &kYuvIConstants, width);
705 dst_rgba += dst_stride_rgba; 705 dst_rgba += dst_stride_rgba;
706 src_y += src_stride_y; 706 src_y += src_stride_y;
707 if (y & 1) { 707 if (y & 1) {
708 src_u += src_stride_u; 708 src_u += src_stride_u;
709 src_v += src_stride_v; 709 src_v += src_stride_v;
710 } 710 }
711 } 711 }
712 return 0; 712 return 0;
713 } 713 }
714 714
715 // Convert I420 to RGB24. 715 // Convert I420 to RGB24.
716 LIBYUV_API 716 LIBYUV_API
717 int I420ToRGB24(const uint8* src_y, int src_stride_y, 717 int I420ToRGB24(const uint8* src_y, int src_stride_y,
718 const uint8* src_u, int src_stride_u, 718 const uint8* src_u, int src_stride_u,
719 const uint8* src_v, int src_stride_v, 719 const uint8* src_v, int src_stride_v,
720 uint8* dst_rgb24, int dst_stride_rgb24, 720 uint8* dst_rgb24, int dst_stride_rgb24,
721 int width, int height) { 721 int width, int height) {
722 int y; 722 int y;
723 void (*I422ToRGB24Row)(const uint8* y_buf, 723 void (*I422ToRGB24Row)(const uint8* y_buf,
724 const uint8* u_buf, 724 const uint8* u_buf,
725 const uint8* v_buf, 725 const uint8* v_buf,
726 uint8* rgb_buf, 726 uint8* rgb_buf,
727 struct YuvConstants* yuvconstants, 727 const struct YuvConstants* yuvconstants,
728 int width) = I422ToRGB24Row_C; 728 int width) = I422ToRGB24Row_C;
729 if (!src_y || !src_u || !src_v || !dst_rgb24 || 729 if (!src_y || !src_u || !src_v || !dst_rgb24 ||
730 width <= 0 || height == 0) { 730 width <= 0 || height == 0) {
731 return -1; 731 return -1;
732 } 732 }
733 // Negative height means invert the image. 733 // Negative height means invert the image.
734 if (height < 0) { 734 if (height < 0) {
735 height = -height; 735 height = -height;
736 dst_rgb24 = dst_rgb24 + (height - 1) * dst_stride_rgb24; 736 dst_rgb24 = dst_rgb24 + (height - 1) * dst_stride_rgb24;
737 dst_stride_rgb24 = -dst_stride_rgb24; 737 dst_stride_rgb24 = -dst_stride_rgb24;
(...skipping 17 matching lines...) Expand all
755 #if defined(HAS_I422TORGB24ROW_NEON) 755 #if defined(HAS_I422TORGB24ROW_NEON)
756 if (TestCpuFlag(kCpuHasNEON)) { 756 if (TestCpuFlag(kCpuHasNEON)) {
757 I422ToRGB24Row = I422ToRGB24Row_Any_NEON; 757 I422ToRGB24Row = I422ToRGB24Row_Any_NEON;
758 if (IS_ALIGNED(width, 8)) { 758 if (IS_ALIGNED(width, 8)) {
759 I422ToRGB24Row = I422ToRGB24Row_NEON; 759 I422ToRGB24Row = I422ToRGB24Row_NEON;
760 } 760 }
761 } 761 }
762 #endif 762 #endif
763 763
764 for (y = 0; y < height; ++y) { 764 for (y = 0; y < height; ++y) {
765 I422ToRGB24Row(src_y, src_u, src_v, dst_rgb24, &kYuvConstants, width); 765 I422ToRGB24Row(src_y, src_u, src_v, dst_rgb24, &kYuvIConstants, width);
766 dst_rgb24 += dst_stride_rgb24; 766 dst_rgb24 += dst_stride_rgb24;
767 src_y += src_stride_y; 767 src_y += src_stride_y;
768 if (y & 1) { 768 if (y & 1) {
769 src_u += src_stride_u; 769 src_u += src_stride_u;
770 src_v += src_stride_v; 770 src_v += src_stride_v;
771 } 771 }
772 } 772 }
773 return 0; 773 return 0;
774 } 774 }
775 775
776 // Convert I420 to RAW. 776 // Convert I420 to RAW.
777 LIBYUV_API 777 LIBYUV_API
778 int I420ToRAW(const uint8* src_y, int src_stride_y, 778 int I420ToRAW(const uint8* src_y, int src_stride_y,
779 const uint8* src_u, int src_stride_u, 779 const uint8* src_u, int src_stride_u,
780 const uint8* src_v, int src_stride_v, 780 const uint8* src_v, int src_stride_v,
781 uint8* dst_raw, int dst_stride_raw, 781 uint8* dst_raw, int dst_stride_raw,
782 int width, int height) { 782 int width, int height) {
783 int y; 783 int y;
784 void (*I422ToRAWRow)(const uint8* y_buf, 784 void (*I422ToRAWRow)(const uint8* y_buf,
785 const uint8* u_buf, 785 const uint8* u_buf,
786 const uint8* v_buf, 786 const uint8* v_buf,
787 uint8* rgb_buf, 787 uint8* rgb_buf,
788 struct YuvConstants* yuvconstants, 788 const struct YuvConstants* yuvconstants,
789 int width) = I422ToRAWRow_C; 789 int width) = I422ToRAWRow_C;
790 if (!src_y || !src_u || !src_v || !dst_raw || 790 if (!src_y || !src_u || !src_v || !dst_raw ||
791 width <= 0 || height == 0) { 791 width <= 0 || height == 0) {
792 return -1; 792 return -1;
793 } 793 }
794 // Negative height means invert the image. 794 // Negative height means invert the image.
795 if (height < 0) { 795 if (height < 0) {
796 height = -height; 796 height = -height;
797 dst_raw = dst_raw + (height - 1) * dst_stride_raw; 797 dst_raw = dst_raw + (height - 1) * dst_stride_raw;
798 dst_stride_raw = -dst_stride_raw; 798 dst_stride_raw = -dst_stride_raw;
(...skipping 17 matching lines...) Expand all
816 #if defined(HAS_I422TORAWROW_NEON) 816 #if defined(HAS_I422TORAWROW_NEON)
817 if (TestCpuFlag(kCpuHasNEON)) { 817 if (TestCpuFlag(kCpuHasNEON)) {
818 I422ToRAWRow = I422ToRAWRow_Any_NEON; 818 I422ToRAWRow = I422ToRAWRow_Any_NEON;
819 if (IS_ALIGNED(width, 8)) { 819 if (IS_ALIGNED(width, 8)) {
820 I422ToRAWRow = I422ToRAWRow_NEON; 820 I422ToRAWRow = I422ToRAWRow_NEON;
821 } 821 }
822 } 822 }
823 #endif 823 #endif
824 824
825 for (y = 0; y < height; ++y) { 825 for (y = 0; y < height; ++y) {
826 I422ToRAWRow(src_y, src_u, src_v, dst_raw, &kYuvConstants, width); 826 I422ToRAWRow(src_y, src_u, src_v, dst_raw, &kYuvIConstants, width);
827 dst_raw += dst_stride_raw; 827 dst_raw += dst_stride_raw;
828 src_y += src_stride_y; 828 src_y += src_stride_y;
829 if (y & 1) { 829 if (y & 1) {
830 src_u += src_stride_u; 830 src_u += src_stride_u;
831 src_v += src_stride_v; 831 src_v += src_stride_v;
832 } 832 }
833 } 833 }
834 return 0; 834 return 0;
835 } 835 }
836 836
837 // Convert I420 to ARGB1555. 837 // Convert I420 to ARGB1555.
838 LIBYUV_API 838 LIBYUV_API
839 int I420ToARGB1555(const uint8* src_y, int src_stride_y, 839 int I420ToARGB1555(const uint8* src_y, int src_stride_y,
840 const uint8* src_u, int src_stride_u, 840 const uint8* src_u, int src_stride_u,
841 const uint8* src_v, int src_stride_v, 841 const uint8* src_v, int src_stride_v,
842 uint8* dst_argb1555, int dst_stride_argb1555, 842 uint8* dst_argb1555, int dst_stride_argb1555,
843 int width, int height) { 843 int width, int height) {
844 int y; 844 int y;
845 void (*I422ToARGB1555Row)(const uint8* y_buf, 845 void (*I422ToARGB1555Row)(const uint8* y_buf,
846 const uint8* u_buf, 846 const uint8* u_buf,
847 const uint8* v_buf, 847 const uint8* v_buf,
848 uint8* rgb_buf, 848 uint8* rgb_buf,
849 struct YuvConstants* yuvconstants, 849 const struct YuvConstants* yuvconstants,
850 int width) = I422ToARGB1555Row_C; 850 int width) = I422ToARGB1555Row_C;
851 if (!src_y || !src_u || !src_v || !dst_argb1555 || 851 if (!src_y || !src_u || !src_v || !dst_argb1555 ||
852 width <= 0 || height == 0) { 852 width <= 0 || height == 0) {
853 return -1; 853 return -1;
854 } 854 }
855 // Negative height means invert the image. 855 // Negative height means invert the image.
856 if (height < 0) { 856 if (height < 0) {
857 height = -height; 857 height = -height;
858 dst_argb1555 = dst_argb1555 + (height - 1) * dst_stride_argb1555; 858 dst_argb1555 = dst_argb1555 + (height - 1) * dst_stride_argb1555;
859 dst_stride_argb1555 = -dst_stride_argb1555; 859 dst_stride_argb1555 = -dst_stride_argb1555;
(...skipping 17 matching lines...) Expand all
877 #if defined(HAS_I422TOARGB1555ROW_NEON) 877 #if defined(HAS_I422TOARGB1555ROW_NEON)
878 if (TestCpuFlag(kCpuHasNEON)) { 878 if (TestCpuFlag(kCpuHasNEON)) {
879 I422ToARGB1555Row = I422ToARGB1555Row_Any_NEON; 879 I422ToARGB1555Row = I422ToARGB1555Row_Any_NEON;
880 if (IS_ALIGNED(width, 8)) { 880 if (IS_ALIGNED(width, 8)) {
881 I422ToARGB1555Row = I422ToARGB1555Row_NEON; 881 I422ToARGB1555Row = I422ToARGB1555Row_NEON;
882 } 882 }
883 } 883 }
884 #endif 884 #endif
885 885
886 for (y = 0; y < height; ++y) { 886 for (y = 0; y < height; ++y) {
887 I422ToARGB1555Row(src_y, src_u, src_v, dst_argb1555, &kYuvConstants, width); 887 I422ToARGB1555Row(src_y, src_u, src_v, dst_argb1555, &kYuvIConstants, width) ;
888 dst_argb1555 += dst_stride_argb1555; 888 dst_argb1555 += dst_stride_argb1555;
889 src_y += src_stride_y; 889 src_y += src_stride_y;
890 if (y & 1) { 890 if (y & 1) {
891 src_u += src_stride_u; 891 src_u += src_stride_u;
892 src_v += src_stride_v; 892 src_v += src_stride_v;
893 } 893 }
894 } 894 }
895 return 0; 895 return 0;
896 } 896 }
897 897
898 898
899 // Convert I420 to ARGB4444. 899 // Convert I420 to ARGB4444.
900 LIBYUV_API 900 LIBYUV_API
901 int I420ToARGB4444(const uint8* src_y, int src_stride_y, 901 int I420ToARGB4444(const uint8* src_y, int src_stride_y,
902 const uint8* src_u, int src_stride_u, 902 const uint8* src_u, int src_stride_u,
903 const uint8* src_v, int src_stride_v, 903 const uint8* src_v, int src_stride_v,
904 uint8* dst_argb4444, int dst_stride_argb4444, 904 uint8* dst_argb4444, int dst_stride_argb4444,
905 int width, int height) { 905 int width, int height) {
906 int y; 906 int y;
907 void (*I422ToARGB4444Row)(const uint8* y_buf, 907 void (*I422ToARGB4444Row)(const uint8* y_buf,
908 const uint8* u_buf, 908 const uint8* u_buf,
909 const uint8* v_buf, 909 const uint8* v_buf,
910 uint8* rgb_buf, 910 uint8* rgb_buf,
911 struct YuvConstants* yuvconstants, 911 const struct YuvConstants* yuvconstants,
912 int width) = I422ToARGB4444Row_C; 912 int width) = I422ToARGB4444Row_C;
913 if (!src_y || !src_u || !src_v || !dst_argb4444 || 913 if (!src_y || !src_u || !src_v || !dst_argb4444 ||
914 width <= 0 || height == 0) { 914 width <= 0 || height == 0) {
915 return -1; 915 return -1;
916 } 916 }
917 // Negative height means invert the image. 917 // Negative height means invert the image.
918 if (height < 0) { 918 if (height < 0) {
919 height = -height; 919 height = -height;
920 dst_argb4444 = dst_argb4444 + (height - 1) * dst_stride_argb4444; 920 dst_argb4444 = dst_argb4444 + (height - 1) * dst_stride_argb4444;
921 dst_stride_argb4444 = -dst_stride_argb4444; 921 dst_stride_argb4444 = -dst_stride_argb4444;
(...skipping 17 matching lines...) Expand all
939 #if defined(HAS_I422TOARGB4444ROW_NEON) 939 #if defined(HAS_I422TOARGB4444ROW_NEON)
940 if (TestCpuFlag(kCpuHasNEON)) { 940 if (TestCpuFlag(kCpuHasNEON)) {
941 I422ToARGB4444Row = I422ToARGB4444Row_Any_NEON; 941 I422ToARGB4444Row = I422ToARGB4444Row_Any_NEON;
942 if (IS_ALIGNED(width, 8)) { 942 if (IS_ALIGNED(width, 8)) {
943 I422ToARGB4444Row = I422ToARGB4444Row_NEON; 943 I422ToARGB4444Row = I422ToARGB4444Row_NEON;
944 } 944 }
945 } 945 }
946 #endif 946 #endif
947 947
948 for (y = 0; y < height; ++y) { 948 for (y = 0; y < height; ++y) {
949 I422ToARGB4444Row(src_y, src_u, src_v, dst_argb4444, &kYuvConstants, width); 949 I422ToARGB4444Row(src_y, src_u, src_v, dst_argb4444, &kYuvIConstants, width) ;
950 dst_argb4444 += dst_stride_argb4444; 950 dst_argb4444 += dst_stride_argb4444;
951 src_y += src_stride_y; 951 src_y += src_stride_y;
952 if (y & 1) { 952 if (y & 1) {
953 src_u += src_stride_u; 953 src_u += src_stride_u;
954 src_v += src_stride_v; 954 src_v += src_stride_v;
955 } 955 }
956 } 956 }
957 return 0; 957 return 0;
958 } 958 }
959 959
960 // Convert I420 to RGB565. 960 // Convert I420 to RGB565.
961 LIBYUV_API 961 LIBYUV_API
962 int I420ToRGB565(const uint8* src_y, int src_stride_y, 962 int I420ToRGB565(const uint8* src_y, int src_stride_y,
963 const uint8* src_u, int src_stride_u, 963 const uint8* src_u, int src_stride_u,
964 const uint8* src_v, int src_stride_v, 964 const uint8* src_v, int src_stride_v,
965 uint8* dst_rgb565, int dst_stride_rgb565, 965 uint8* dst_rgb565, int dst_stride_rgb565,
966 int width, int height) { 966 int width, int height) {
967 int y; 967 int y;
968 void (*I422ToRGB565Row)(const uint8* y_buf, 968 void (*I422ToRGB565Row)(const uint8* y_buf,
969 const uint8* u_buf, 969 const uint8* u_buf,
970 const uint8* v_buf, 970 const uint8* v_buf,
971 uint8* rgb_buf, 971 uint8* rgb_buf,
972 struct YuvConstants* yuvconstants, 972 const struct YuvConstants* yuvconstants,
973 int width) = I422ToRGB565Row_C; 973 int width) = I422ToRGB565Row_C;
974 if (!src_y || !src_u || !src_v || !dst_rgb565 || 974 if (!src_y || !src_u || !src_v || !dst_rgb565 ||
975 width <= 0 || height == 0) { 975 width <= 0 || height == 0) {
976 return -1; 976 return -1;
977 } 977 }
978 // Negative height means invert the image. 978 // Negative height means invert the image.
979 if (height < 0) { 979 if (height < 0) {
980 height = -height; 980 height = -height;
981 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; 981 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565;
982 dst_stride_rgb565 = -dst_stride_rgb565; 982 dst_stride_rgb565 = -dst_stride_rgb565;
(...skipping 17 matching lines...) Expand all
1000 #if defined(HAS_I422TORGB565ROW_NEON) 1000 #if defined(HAS_I422TORGB565ROW_NEON)
1001 if (TestCpuFlag(kCpuHasNEON)) { 1001 if (TestCpuFlag(kCpuHasNEON)) {
1002 I422ToRGB565Row = I422ToRGB565Row_Any_NEON; 1002 I422ToRGB565Row = I422ToRGB565Row_Any_NEON;
1003 if (IS_ALIGNED(width, 8)) { 1003 if (IS_ALIGNED(width, 8)) {
1004 I422ToRGB565Row = I422ToRGB565Row_NEON; 1004 I422ToRGB565Row = I422ToRGB565Row_NEON;
1005 } 1005 }
1006 } 1006 }
1007 #endif 1007 #endif
1008 1008
1009 for (y = 0; y < height; ++y) { 1009 for (y = 0; y < height; ++y) {
1010 I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, &kYuvConstants, width); 1010 I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, &kYuvIConstants, width);
1011 dst_rgb565 += dst_stride_rgb565; 1011 dst_rgb565 += dst_stride_rgb565;
1012 src_y += src_stride_y; 1012 src_y += src_stride_y;
1013 if (y & 1) { 1013 if (y & 1) {
1014 src_u += src_stride_u; 1014 src_u += src_stride_u;
1015 src_v += src_stride_v; 1015 src_v += src_stride_v;
1016 } 1016 }
1017 } 1017 }
1018 return 0; 1018 return 0;
1019 } 1019 }
1020 1020
(...skipping 10 matching lines...) Expand all
1031 int I420ToRGB565Dither(const uint8* src_y, int src_stride_y, 1031 int I420ToRGB565Dither(const uint8* src_y, int src_stride_y,
1032 const uint8* src_u, int src_stride_u, 1032 const uint8* src_u, int src_stride_u,
1033 const uint8* src_v, int src_stride_v, 1033 const uint8* src_v, int src_stride_v,
1034 uint8* dst_rgb565, int dst_stride_rgb565, 1034 uint8* dst_rgb565, int dst_stride_rgb565,
1035 const uint8* dither4x4, int width, int height) { 1035 const uint8* dither4x4, int width, int height) {
1036 int y; 1036 int y;
1037 void (*I422ToARGBRow)(const uint8* y_buf, 1037 void (*I422ToARGBRow)(const uint8* y_buf,
1038 const uint8* u_buf, 1038 const uint8* u_buf,
1039 const uint8* v_buf, 1039 const uint8* v_buf,
1040 uint8* rgb_buf, 1040 uint8* rgb_buf,
1041 struct YuvConstants* yuvconstants, 1041 const struct YuvConstants* yuvconstants,
1042 int width) = I422ToARGBRow_C; 1042 int width) = I422ToARGBRow_C;
1043 void (*ARGBToRGB565DitherRow)(const uint8* src_argb, uint8* dst_rgb, 1043 void (*ARGBToRGB565DitherRow)(const uint8* src_argb, uint8* dst_rgb,
1044 const uint32 dither4, int pix) = ARGBToRGB565DitherRow_C; 1044 const uint32 dither4, int pix) = ARGBToRGB565DitherRow_C;
1045 if (!src_y || !src_u || !src_v || !dst_rgb565 || 1045 if (!src_y || !src_u || !src_v || !dst_rgb565 ||
1046 width <= 0 || height == 0) { 1046 width <= 0 || height == 0) {
1047 return -1; 1047 return -1;
1048 } 1048 }
1049 // Negative height means invert the image. 1049 // Negative height means invert the image.
1050 if (height < 0) { 1050 if (height < 0) {
1051 height = -height; 1051 height = -height;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_Any_NEON; 1108 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_Any_NEON;
1109 if (IS_ALIGNED(width, 8)) { 1109 if (IS_ALIGNED(width, 8)) {
1110 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; 1110 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON;
1111 } 1111 }
1112 } 1112 }
1113 #endif 1113 #endif
1114 { 1114 {
1115 // Allocate a row of argb. 1115 // Allocate a row of argb.
1116 align_buffer_64(row_argb, width * 4); 1116 align_buffer_64(row_argb, width * 4);
1117 for (y = 0; y < height; ++y) { 1117 for (y = 0; y < height; ++y) {
1118 I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvConstants, width); 1118 I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvIConstants, width);
1119 ARGBToRGB565DitherRow(row_argb, dst_rgb565, 1119 ARGBToRGB565DitherRow(row_argb, dst_rgb565,
1120 *(uint32*)(dither4x4 + ((y & 3) << 2)), width); 1120 *(uint32*)(dither4x4 + ((y & 3) << 2)), width);
1121 dst_rgb565 += dst_stride_rgb565; 1121 dst_rgb565 += dst_stride_rgb565;
1122 src_y += src_stride_y; 1122 src_y += src_stride_y;
1123 if (y & 1) { 1123 if (y & 1) {
1124 src_u += src_stride_u; 1124 src_u += src_stride_u;
1125 src_v += src_stride_v; 1125 src_v += src_stride_v;
1126 } 1126 }
1127 } 1127 }
1128 free_aligned_buffer_64(row_argb); 1128 free_aligned_buffer_64(row_argb);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 default: 1349 default:
1350 return -1; // unknown fourcc - return failure code. 1350 return -1; // unknown fourcc - return failure code.
1351 } 1351 }
1352 return r; 1352 return r;
1353 } 1353 }
1354 1354
1355 #ifdef __cplusplus 1355 #ifdef __cplusplus
1356 } // extern "C" 1356 } // extern "C"
1357 } // namespace libyuv 1357 } // namespace libyuv
1358 #endif 1358 #endif
OLDNEW
« no previous file with comments | « source/convert_argb.cc ('k') | source/planar_functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698