| OLD | NEW |
| 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 Loading... |
| 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 int width) = I422ToARGBRow_C; | 466 int width) = I422ToARGBRow_C; |
| 466 if (!src_y || !src_u || !src_v || !dst_argb || | 467 if (!src_y || !src_u || !src_v || !dst_argb || |
| 467 width <= 0 || height == 0) { | 468 width <= 0 || height == 0) { |
| 468 return -1; | 469 return -1; |
| 469 } | 470 } |
| 470 // Negative height means invert the image. | 471 // Negative height means invert the image. |
| 471 if (height < 0) { | 472 if (height < 0) { |
| 472 height = -height; | 473 height = -height; |
| 473 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | 474 dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| 474 dst_stride_argb = -dst_stride_argb; | 475 dst_stride_argb = -dst_stride_argb; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 501 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | 502 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
| 502 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | 503 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
| 503 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | 504 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
| 504 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | 505 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
| 505 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { | 506 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { |
| 506 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; | 507 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; |
| 507 } | 508 } |
| 508 #endif | 509 #endif |
| 509 | 510 |
| 510 for (y = 0; y < height; ++y) { | 511 for (y = 0; y < height; ++y) { |
| 511 I422ToARGBRow(src_y, src_u, src_v, dst_argb, width); | 512 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvConstants, width); |
| 512 dst_argb += dst_stride_argb; | 513 dst_argb += dst_stride_argb; |
| 513 src_y += src_stride_y; | 514 src_y += src_stride_y; |
| 514 if (y & 1) { | 515 if (y & 1) { |
| 515 src_u += src_stride_u; | 516 src_u += src_stride_u; |
| 516 src_v += src_stride_v; | 517 src_v += src_stride_v; |
| 517 } | 518 } |
| 518 } | 519 } |
| 519 return 0; | 520 return 0; |
| 520 } | 521 } |
| 521 | 522 |
| 522 // Convert I420 to BGRA. | 523 // Convert I420 to BGRA. |
| 523 LIBYUV_API | 524 LIBYUV_API |
| 524 int I420ToBGRA(const uint8* src_y, int src_stride_y, | 525 int I420ToBGRA(const uint8* src_y, int src_stride_y, |
| 525 const uint8* src_u, int src_stride_u, | 526 const uint8* src_u, int src_stride_u, |
| 526 const uint8* src_v, int src_stride_v, | 527 const uint8* src_v, int src_stride_v, |
| 527 uint8* dst_bgra, int dst_stride_bgra, | 528 uint8* dst_bgra, int dst_stride_bgra, |
| 528 int width, int height) { | 529 int width, int height) { |
| 529 int y; | 530 int y; |
| 530 void (*I422ToBGRARow)(const uint8* y_buf, | 531 void (*I422ToBGRARow)(const uint8* y_buf, |
| 531 const uint8* u_buf, | 532 const uint8* u_buf, |
| 532 const uint8* v_buf, | 533 const uint8* v_buf, |
| 533 uint8* rgb_buf, | 534 uint8* rgb_buf, |
| 535 struct YuvConstants* yuvconstants, |
| 534 int width) = I422ToBGRARow_C; | 536 int width) = I422ToBGRARow_C; |
| 535 if (!src_y || !src_u || !src_v || !dst_bgra || | 537 if (!src_y || !src_u || !src_v || !dst_bgra || |
| 536 width <= 0 || height == 0) { | 538 width <= 0 || height == 0) { |
| 537 return -1; | 539 return -1; |
| 538 } | 540 } |
| 539 // Negative height means invert the image. | 541 // Negative height means invert the image. |
| 540 if (height < 0) { | 542 if (height < 0) { |
| 541 height = -height; | 543 height = -height; |
| 542 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; | 544 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; |
| 543 dst_stride_bgra = -dst_stride_bgra; | 545 dst_stride_bgra = -dst_stride_bgra; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 570 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | 572 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
| 571 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | 573 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
| 572 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | 574 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
| 573 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | 575 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
| 574 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { | 576 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { |
| 575 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; | 577 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; |
| 576 } | 578 } |
| 577 #endif | 579 #endif |
| 578 | 580 |
| 579 for (y = 0; y < height; ++y) { | 581 for (y = 0; y < height; ++y) { |
| 580 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, width); | 582 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, &kYuvConstants, width); |
| 581 dst_bgra += dst_stride_bgra; | 583 dst_bgra += dst_stride_bgra; |
| 582 src_y += src_stride_y; | 584 src_y += src_stride_y; |
| 583 if (y & 1) { | 585 if (y & 1) { |
| 584 src_u += src_stride_u; | 586 src_u += src_stride_u; |
| 585 src_v += src_stride_v; | 587 src_v += src_stride_v; |
| 586 } | 588 } |
| 587 } | 589 } |
| 588 return 0; | 590 return 0; |
| 589 } | 591 } |
| 590 | 592 |
| 591 // Convert I420 to ABGR. | 593 // Convert I420 to ABGR. |
| 592 LIBYUV_API | 594 LIBYUV_API |
| 593 int I420ToABGR(const uint8* src_y, int src_stride_y, | 595 int I420ToABGR(const uint8* src_y, int src_stride_y, |
| 594 const uint8* src_u, int src_stride_u, | 596 const uint8* src_u, int src_stride_u, |
| 595 const uint8* src_v, int src_stride_v, | 597 const uint8* src_v, int src_stride_v, |
| 596 uint8* dst_abgr, int dst_stride_abgr, | 598 uint8* dst_abgr, int dst_stride_abgr, |
| 597 int width, int height) { | 599 int width, int height) { |
| 598 int y; | 600 int y; |
| 599 void (*I422ToABGRRow)(const uint8* y_buf, | 601 void (*I422ToABGRRow)(const uint8* y_buf, |
| 600 const uint8* u_buf, | 602 const uint8* u_buf, |
| 601 const uint8* v_buf, | 603 const uint8* v_buf, |
| 602 uint8* rgb_buf, | 604 uint8* rgb_buf, |
| 605 struct YuvConstants* yuvconstants, |
| 603 int width) = I422ToABGRRow_C; | 606 int width) = I422ToABGRRow_C; |
| 604 if (!src_y || !src_u || !src_v || !dst_abgr || | 607 if (!src_y || !src_u || !src_v || !dst_abgr || |
| 605 width <= 0 || height == 0) { | 608 width <= 0 || height == 0) { |
| 606 return -1; | 609 return -1; |
| 607 } | 610 } |
| 608 // Negative height means invert the image. | 611 // Negative height means invert the image. |
| 609 if (height < 0) { | 612 if (height < 0) { |
| 610 height = -height; | 613 height = -height; |
| 611 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | 614 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; |
| 612 dst_stride_abgr = -dst_stride_abgr; | 615 dst_stride_abgr = -dst_stride_abgr; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 630 #if defined(HAS_I422TOABGRROW_NEON) | 633 #if defined(HAS_I422TOABGRROW_NEON) |
| 631 if (TestCpuFlag(kCpuHasNEON)) { | 634 if (TestCpuFlag(kCpuHasNEON)) { |
| 632 I422ToABGRRow = I422ToABGRRow_Any_NEON; | 635 I422ToABGRRow = I422ToABGRRow_Any_NEON; |
| 633 if (IS_ALIGNED(width, 8)) { | 636 if (IS_ALIGNED(width, 8)) { |
| 634 I422ToABGRRow = I422ToABGRRow_NEON; | 637 I422ToABGRRow = I422ToABGRRow_NEON; |
| 635 } | 638 } |
| 636 } | 639 } |
| 637 #endif | 640 #endif |
| 638 | 641 |
| 639 for (y = 0; y < height; ++y) { | 642 for (y = 0; y < height; ++y) { |
| 640 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); | 643 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvConstants, width); |
| 641 dst_abgr += dst_stride_abgr; | 644 dst_abgr += dst_stride_abgr; |
| 642 src_y += src_stride_y; | 645 src_y += src_stride_y; |
| 643 if (y & 1) { | 646 if (y & 1) { |
| 644 src_u += src_stride_u; | 647 src_u += src_stride_u; |
| 645 src_v += src_stride_v; | 648 src_v += src_stride_v; |
| 646 } | 649 } |
| 647 } | 650 } |
| 648 return 0; | 651 return 0; |
| 649 } | 652 } |
| 650 | 653 |
| 651 // Convert I420 to RGBA. | 654 // Convert I420 to RGBA. |
| 652 LIBYUV_API | 655 LIBYUV_API |
| 653 int I420ToRGBA(const uint8* src_y, int src_stride_y, | 656 int I420ToRGBA(const uint8* src_y, int src_stride_y, |
| 654 const uint8* src_u, int src_stride_u, | 657 const uint8* src_u, int src_stride_u, |
| 655 const uint8* src_v, int src_stride_v, | 658 const uint8* src_v, int src_stride_v, |
| 656 uint8* dst_rgba, int dst_stride_rgba, | 659 uint8* dst_rgba, int dst_stride_rgba, |
| 657 int width, int height) { | 660 int width, int height) { |
| 658 int y; | 661 int y; |
| 659 void (*I422ToRGBARow)(const uint8* y_buf, | 662 void (*I422ToRGBARow)(const uint8* y_buf, |
| 660 const uint8* u_buf, | 663 const uint8* u_buf, |
| 661 const uint8* v_buf, | 664 const uint8* v_buf, |
| 662 uint8* rgb_buf, | 665 uint8* rgb_buf, |
| 666 struct YuvConstants* yuvconstants, |
| 663 int width) = I422ToRGBARow_C; | 667 int width) = I422ToRGBARow_C; |
| 664 if (!src_y || !src_u || !src_v || !dst_rgba || | 668 if (!src_y || !src_u || !src_v || !dst_rgba || |
| 665 width <= 0 || height == 0) { | 669 width <= 0 || height == 0) { |
| 666 return -1; | 670 return -1; |
| 667 } | 671 } |
| 668 // Negative height means invert the image. | 672 // Negative height means invert the image. |
| 669 if (height < 0) { | 673 if (height < 0) { |
| 670 height = -height; | 674 height = -height; |
| 671 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; | 675 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; |
| 672 dst_stride_rgba = -dst_stride_rgba; | 676 dst_stride_rgba = -dst_stride_rgba; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 690 #if defined(HAS_I422TORGBAROW_NEON) | 694 #if defined(HAS_I422TORGBAROW_NEON) |
| 691 if (TestCpuFlag(kCpuHasNEON)) { | 695 if (TestCpuFlag(kCpuHasNEON)) { |
| 692 I422ToRGBARow = I422ToRGBARow_Any_NEON; | 696 I422ToRGBARow = I422ToRGBARow_Any_NEON; |
| 693 if (IS_ALIGNED(width, 8)) { | 697 if (IS_ALIGNED(width, 8)) { |
| 694 I422ToRGBARow = I422ToRGBARow_NEON; | 698 I422ToRGBARow = I422ToRGBARow_NEON; |
| 695 } | 699 } |
| 696 } | 700 } |
| 697 #endif | 701 #endif |
| 698 | 702 |
| 699 for (y = 0; y < height; ++y) { | 703 for (y = 0; y < height; ++y) { |
| 700 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, width); | 704 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, &kYuvConstants, width); |
| 701 dst_rgba += dst_stride_rgba; | 705 dst_rgba += dst_stride_rgba; |
| 702 src_y += src_stride_y; | 706 src_y += src_stride_y; |
| 703 if (y & 1) { | 707 if (y & 1) { |
| 704 src_u += src_stride_u; | 708 src_u += src_stride_u; |
| 705 src_v += src_stride_v; | 709 src_v += src_stride_v; |
| 706 } | 710 } |
| 707 } | 711 } |
| 708 return 0; | 712 return 0; |
| 709 } | 713 } |
| 710 | 714 |
| 711 // Convert I420 to RGB24. | 715 // Convert I420 to RGB24. |
| 712 LIBYUV_API | 716 LIBYUV_API |
| 713 int I420ToRGB24(const uint8* src_y, int src_stride_y, | 717 int I420ToRGB24(const uint8* src_y, int src_stride_y, |
| 714 const uint8* src_u, int src_stride_u, | 718 const uint8* src_u, int src_stride_u, |
| 715 const uint8* src_v, int src_stride_v, | 719 const uint8* src_v, int src_stride_v, |
| 716 uint8* dst_rgb24, int dst_stride_rgb24, | 720 uint8* dst_rgb24, int dst_stride_rgb24, |
| 717 int width, int height) { | 721 int width, int height) { |
| 718 int y; | 722 int y; |
| 719 void (*I422ToRGB24Row)(const uint8* y_buf, | 723 void (*I422ToRGB24Row)(const uint8* y_buf, |
| 720 const uint8* u_buf, | 724 const uint8* u_buf, |
| 721 const uint8* v_buf, | 725 const uint8* v_buf, |
| 722 uint8* rgb_buf, | 726 uint8* rgb_buf, |
| 727 struct YuvConstants* yuvconstants, |
| 723 int width) = I422ToRGB24Row_C; | 728 int width) = I422ToRGB24Row_C; |
| 724 if (!src_y || !src_u || !src_v || !dst_rgb24 || | 729 if (!src_y || !src_u || !src_v || !dst_rgb24 || |
| 725 width <= 0 || height == 0) { | 730 width <= 0 || height == 0) { |
| 726 return -1; | 731 return -1; |
| 727 } | 732 } |
| 728 // Negative height means invert the image. | 733 // Negative height means invert the image. |
| 729 if (height < 0) { | 734 if (height < 0) { |
| 730 height = -height; | 735 height = -height; |
| 731 dst_rgb24 = dst_rgb24 + (height - 1) * dst_stride_rgb24; | 736 dst_rgb24 = dst_rgb24 + (height - 1) * dst_stride_rgb24; |
| 732 dst_stride_rgb24 = -dst_stride_rgb24; | 737 dst_stride_rgb24 = -dst_stride_rgb24; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 750 #if defined(HAS_I422TORGB24ROW_NEON) | 755 #if defined(HAS_I422TORGB24ROW_NEON) |
| 751 if (TestCpuFlag(kCpuHasNEON)) { | 756 if (TestCpuFlag(kCpuHasNEON)) { |
| 752 I422ToRGB24Row = I422ToRGB24Row_Any_NEON; | 757 I422ToRGB24Row = I422ToRGB24Row_Any_NEON; |
| 753 if (IS_ALIGNED(width, 8)) { | 758 if (IS_ALIGNED(width, 8)) { |
| 754 I422ToRGB24Row = I422ToRGB24Row_NEON; | 759 I422ToRGB24Row = I422ToRGB24Row_NEON; |
| 755 } | 760 } |
| 756 } | 761 } |
| 757 #endif | 762 #endif |
| 758 | 763 |
| 759 for (y = 0; y < height; ++y) { | 764 for (y = 0; y < height; ++y) { |
| 760 I422ToRGB24Row(src_y, src_u, src_v, dst_rgb24, width); | 765 I422ToRGB24Row(src_y, src_u, src_v, dst_rgb24, &kYuvConstants, width); |
| 761 dst_rgb24 += dst_stride_rgb24; | 766 dst_rgb24 += dst_stride_rgb24; |
| 762 src_y += src_stride_y; | 767 src_y += src_stride_y; |
| 763 if (y & 1) { | 768 if (y & 1) { |
| 764 src_u += src_stride_u; | 769 src_u += src_stride_u; |
| 765 src_v += src_stride_v; | 770 src_v += src_stride_v; |
| 766 } | 771 } |
| 767 } | 772 } |
| 768 return 0; | 773 return 0; |
| 769 } | 774 } |
| 770 | 775 |
| 771 // Convert I420 to RAW. | 776 // Convert I420 to RAW. |
| 772 LIBYUV_API | 777 LIBYUV_API |
| 773 int I420ToRAW(const uint8* src_y, int src_stride_y, | 778 int I420ToRAW(const uint8* src_y, int src_stride_y, |
| 774 const uint8* src_u, int src_stride_u, | 779 const uint8* src_u, int src_stride_u, |
| 775 const uint8* src_v, int src_stride_v, | 780 const uint8* src_v, int src_stride_v, |
| 776 uint8* dst_raw, int dst_stride_raw, | 781 uint8* dst_raw, int dst_stride_raw, |
| 777 int width, int height) { | 782 int width, int height) { |
| 778 int y; | 783 int y; |
| 779 void (*I422ToRAWRow)(const uint8* y_buf, | 784 void (*I422ToRAWRow)(const uint8* y_buf, |
| 780 const uint8* u_buf, | 785 const uint8* u_buf, |
| 781 const uint8* v_buf, | 786 const uint8* v_buf, |
| 782 uint8* rgb_buf, | 787 uint8* rgb_buf, |
| 788 struct YuvConstants* yuvconstants, |
| 783 int width) = I422ToRAWRow_C; | 789 int width) = I422ToRAWRow_C; |
| 784 if (!src_y || !src_u || !src_v || !dst_raw || | 790 if (!src_y || !src_u || !src_v || !dst_raw || |
| 785 width <= 0 || height == 0) { | 791 width <= 0 || height == 0) { |
| 786 return -1; | 792 return -1; |
| 787 } | 793 } |
| 788 // Negative height means invert the image. | 794 // Negative height means invert the image. |
| 789 if (height < 0) { | 795 if (height < 0) { |
| 790 height = -height; | 796 height = -height; |
| 791 dst_raw = dst_raw + (height - 1) * dst_stride_raw; | 797 dst_raw = dst_raw + (height - 1) * dst_stride_raw; |
| 792 dst_stride_raw = -dst_stride_raw; | 798 dst_stride_raw = -dst_stride_raw; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 810 #if defined(HAS_I422TORAWROW_NEON) | 816 #if defined(HAS_I422TORAWROW_NEON) |
| 811 if (TestCpuFlag(kCpuHasNEON)) { | 817 if (TestCpuFlag(kCpuHasNEON)) { |
| 812 I422ToRAWRow = I422ToRAWRow_Any_NEON; | 818 I422ToRAWRow = I422ToRAWRow_Any_NEON; |
| 813 if (IS_ALIGNED(width, 8)) { | 819 if (IS_ALIGNED(width, 8)) { |
| 814 I422ToRAWRow = I422ToRAWRow_NEON; | 820 I422ToRAWRow = I422ToRAWRow_NEON; |
| 815 } | 821 } |
| 816 } | 822 } |
| 817 #endif | 823 #endif |
| 818 | 824 |
| 819 for (y = 0; y < height; ++y) { | 825 for (y = 0; y < height; ++y) { |
| 820 I422ToRAWRow(src_y, src_u, src_v, dst_raw, width); | 826 I422ToRAWRow(src_y, src_u, src_v, dst_raw, &kYuvConstants, width); |
| 821 dst_raw += dst_stride_raw; | 827 dst_raw += dst_stride_raw; |
| 822 src_y += src_stride_y; | 828 src_y += src_stride_y; |
| 823 if (y & 1) { | 829 if (y & 1) { |
| 824 src_u += src_stride_u; | 830 src_u += src_stride_u; |
| 825 src_v += src_stride_v; | 831 src_v += src_stride_v; |
| 826 } | 832 } |
| 827 } | 833 } |
| 828 return 0; | 834 return 0; |
| 829 } | 835 } |
| 830 | 836 |
| 831 // Convert I420 to ARGB1555. | 837 // Convert I420 to ARGB1555. |
| 832 LIBYUV_API | 838 LIBYUV_API |
| 833 int I420ToARGB1555(const uint8* src_y, int src_stride_y, | 839 int I420ToARGB1555(const uint8* src_y, int src_stride_y, |
| 834 const uint8* src_u, int src_stride_u, | 840 const uint8* src_u, int src_stride_u, |
| 835 const uint8* src_v, int src_stride_v, | 841 const uint8* src_v, int src_stride_v, |
| 836 uint8* dst_argb1555, int dst_stride_argb1555, | 842 uint8* dst_argb1555, int dst_stride_argb1555, |
| 837 int width, int height) { | 843 int width, int height) { |
| 838 int y; | 844 int y; |
| 839 void (*I422ToARGB1555Row)(const uint8* y_buf, | 845 void (*I422ToARGB1555Row)(const uint8* y_buf, |
| 840 const uint8* u_buf, | 846 const uint8* u_buf, |
| 841 const uint8* v_buf, | 847 const uint8* v_buf, |
| 842 uint8* rgb_buf, | 848 uint8* rgb_buf, |
| 849 struct YuvConstants* yuvconstants, |
| 843 int width) = I422ToARGB1555Row_C; | 850 int width) = I422ToARGB1555Row_C; |
| 844 if (!src_y || !src_u || !src_v || !dst_argb1555 || | 851 if (!src_y || !src_u || !src_v || !dst_argb1555 || |
| 845 width <= 0 || height == 0) { | 852 width <= 0 || height == 0) { |
| 846 return -1; | 853 return -1; |
| 847 } | 854 } |
| 848 // Negative height means invert the image. | 855 // Negative height means invert the image. |
| 849 if (height < 0) { | 856 if (height < 0) { |
| 850 height = -height; | 857 height = -height; |
| 851 dst_argb1555 = dst_argb1555 + (height - 1) * dst_stride_argb1555; | 858 dst_argb1555 = dst_argb1555 + (height - 1) * dst_stride_argb1555; |
| 852 dst_stride_argb1555 = -dst_stride_argb1555; | 859 dst_stride_argb1555 = -dst_stride_argb1555; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 870 #if defined(HAS_I422TOARGB1555ROW_NEON) | 877 #if defined(HAS_I422TOARGB1555ROW_NEON) |
| 871 if (TestCpuFlag(kCpuHasNEON)) { | 878 if (TestCpuFlag(kCpuHasNEON)) { |
| 872 I422ToARGB1555Row = I422ToARGB1555Row_Any_NEON; | 879 I422ToARGB1555Row = I422ToARGB1555Row_Any_NEON; |
| 873 if (IS_ALIGNED(width, 8)) { | 880 if (IS_ALIGNED(width, 8)) { |
| 874 I422ToARGB1555Row = I422ToARGB1555Row_NEON; | 881 I422ToARGB1555Row = I422ToARGB1555Row_NEON; |
| 875 } | 882 } |
| 876 } | 883 } |
| 877 #endif | 884 #endif |
| 878 | 885 |
| 879 for (y = 0; y < height; ++y) { | 886 for (y = 0; y < height; ++y) { |
| 880 I422ToARGB1555Row(src_y, src_u, src_v, dst_argb1555, width); | 887 I422ToARGB1555Row(src_y, src_u, src_v, dst_argb1555, &kYuvConstants, width); |
| 881 dst_argb1555 += dst_stride_argb1555; | 888 dst_argb1555 += dst_stride_argb1555; |
| 882 src_y += src_stride_y; | 889 src_y += src_stride_y; |
| 883 if (y & 1) { | 890 if (y & 1) { |
| 884 src_u += src_stride_u; | 891 src_u += src_stride_u; |
| 885 src_v += src_stride_v; | 892 src_v += src_stride_v; |
| 886 } | 893 } |
| 887 } | 894 } |
| 888 return 0; | 895 return 0; |
| 889 } | 896 } |
| 890 | 897 |
| 891 | 898 |
| 892 // Convert I420 to ARGB4444. | 899 // Convert I420 to ARGB4444. |
| 893 LIBYUV_API | 900 LIBYUV_API |
| 894 int I420ToARGB4444(const uint8* src_y, int src_stride_y, | 901 int I420ToARGB4444(const uint8* src_y, int src_stride_y, |
| 895 const uint8* src_u, int src_stride_u, | 902 const uint8* src_u, int src_stride_u, |
| 896 const uint8* src_v, int src_stride_v, | 903 const uint8* src_v, int src_stride_v, |
| 897 uint8* dst_argb4444, int dst_stride_argb4444, | 904 uint8* dst_argb4444, int dst_stride_argb4444, |
| 898 int width, int height) { | 905 int width, int height) { |
| 899 int y; | 906 int y; |
| 900 void (*I422ToARGB4444Row)(const uint8* y_buf, | 907 void (*I422ToARGB4444Row)(const uint8* y_buf, |
| 901 const uint8* u_buf, | 908 const uint8* u_buf, |
| 902 const uint8* v_buf, | 909 const uint8* v_buf, |
| 903 uint8* rgb_buf, | 910 uint8* rgb_buf, |
| 911 struct YuvConstants* yuvconstants, |
| 904 int width) = I422ToARGB4444Row_C; | 912 int width) = I422ToARGB4444Row_C; |
| 905 if (!src_y || !src_u || !src_v || !dst_argb4444 || | 913 if (!src_y || !src_u || !src_v || !dst_argb4444 || |
| 906 width <= 0 || height == 0) { | 914 width <= 0 || height == 0) { |
| 907 return -1; | 915 return -1; |
| 908 } | 916 } |
| 909 // Negative height means invert the image. | 917 // Negative height means invert the image. |
| 910 if (height < 0) { | 918 if (height < 0) { |
| 911 height = -height; | 919 height = -height; |
| 912 dst_argb4444 = dst_argb4444 + (height - 1) * dst_stride_argb4444; | 920 dst_argb4444 = dst_argb4444 + (height - 1) * dst_stride_argb4444; |
| 913 dst_stride_argb4444 = -dst_stride_argb4444; | 921 dst_stride_argb4444 = -dst_stride_argb4444; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 931 #if defined(HAS_I422TOARGB4444ROW_NEON) | 939 #if defined(HAS_I422TOARGB4444ROW_NEON) |
| 932 if (TestCpuFlag(kCpuHasNEON)) { | 940 if (TestCpuFlag(kCpuHasNEON)) { |
| 933 I422ToARGB4444Row = I422ToARGB4444Row_Any_NEON; | 941 I422ToARGB4444Row = I422ToARGB4444Row_Any_NEON; |
| 934 if (IS_ALIGNED(width, 8)) { | 942 if (IS_ALIGNED(width, 8)) { |
| 935 I422ToARGB4444Row = I422ToARGB4444Row_NEON; | 943 I422ToARGB4444Row = I422ToARGB4444Row_NEON; |
| 936 } | 944 } |
| 937 } | 945 } |
| 938 #endif | 946 #endif |
| 939 | 947 |
| 940 for (y = 0; y < height; ++y) { | 948 for (y = 0; y < height; ++y) { |
| 941 I422ToARGB4444Row(src_y, src_u, src_v, dst_argb4444, width); | 949 I422ToARGB4444Row(src_y, src_u, src_v, dst_argb4444, &kYuvConstants, width); |
| 942 dst_argb4444 += dst_stride_argb4444; | 950 dst_argb4444 += dst_stride_argb4444; |
| 943 src_y += src_stride_y; | 951 src_y += src_stride_y; |
| 944 if (y & 1) { | 952 if (y & 1) { |
| 945 src_u += src_stride_u; | 953 src_u += src_stride_u; |
| 946 src_v += src_stride_v; | 954 src_v += src_stride_v; |
| 947 } | 955 } |
| 948 } | 956 } |
| 949 return 0; | 957 return 0; |
| 950 } | 958 } |
| 951 | 959 |
| 952 // Convert I420 to RGB565. | 960 // Convert I420 to RGB565. |
| 953 LIBYUV_API | 961 LIBYUV_API |
| 954 int I420ToRGB565(const uint8* src_y, int src_stride_y, | 962 int I420ToRGB565(const uint8* src_y, int src_stride_y, |
| 955 const uint8* src_u, int src_stride_u, | 963 const uint8* src_u, int src_stride_u, |
| 956 const uint8* src_v, int src_stride_v, | 964 const uint8* src_v, int src_stride_v, |
| 957 uint8* dst_rgb565, int dst_stride_rgb565, | 965 uint8* dst_rgb565, int dst_stride_rgb565, |
| 958 int width, int height) { | 966 int width, int height) { |
| 959 int y; | 967 int y; |
| 960 void (*I422ToRGB565Row)(const uint8* y_buf, | 968 void (*I422ToRGB565Row)(const uint8* y_buf, |
| 961 const uint8* u_buf, | 969 const uint8* u_buf, |
| 962 const uint8* v_buf, | 970 const uint8* v_buf, |
| 963 uint8* rgb_buf, | 971 uint8* rgb_buf, |
| 972 struct YuvConstants* yuvconstants, |
| 964 int width) = I422ToRGB565Row_C; | 973 int width) = I422ToRGB565Row_C; |
| 965 if (!src_y || !src_u || !src_v || !dst_rgb565 || | 974 if (!src_y || !src_u || !src_v || !dst_rgb565 || |
| 966 width <= 0 || height == 0) { | 975 width <= 0 || height == 0) { |
| 967 return -1; | 976 return -1; |
| 968 } | 977 } |
| 969 // Negative height means invert the image. | 978 // Negative height means invert the image. |
| 970 if (height < 0) { | 979 if (height < 0) { |
| 971 height = -height; | 980 height = -height; |
| 972 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; | 981 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; |
| 973 dst_stride_rgb565 = -dst_stride_rgb565; | 982 dst_stride_rgb565 = -dst_stride_rgb565; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 991 #if defined(HAS_I422TORGB565ROW_NEON) | 1000 #if defined(HAS_I422TORGB565ROW_NEON) |
| 992 if (TestCpuFlag(kCpuHasNEON)) { | 1001 if (TestCpuFlag(kCpuHasNEON)) { |
| 993 I422ToRGB565Row = I422ToRGB565Row_Any_NEON; | 1002 I422ToRGB565Row = I422ToRGB565Row_Any_NEON; |
| 994 if (IS_ALIGNED(width, 8)) { | 1003 if (IS_ALIGNED(width, 8)) { |
| 995 I422ToRGB565Row = I422ToRGB565Row_NEON; | 1004 I422ToRGB565Row = I422ToRGB565Row_NEON; |
| 996 } | 1005 } |
| 997 } | 1006 } |
| 998 #endif | 1007 #endif |
| 999 | 1008 |
| 1000 for (y = 0; y < height; ++y) { | 1009 for (y = 0; y < height; ++y) { |
| 1001 I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, width); | 1010 I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, &kYuvConstants, width); |
| 1002 dst_rgb565 += dst_stride_rgb565; | 1011 dst_rgb565 += dst_stride_rgb565; |
| 1003 src_y += src_stride_y; | 1012 src_y += src_stride_y; |
| 1004 if (y & 1) { | 1013 if (y & 1) { |
| 1005 src_u += src_stride_u; | 1014 src_u += src_stride_u; |
| 1006 src_v += src_stride_v; | 1015 src_v += src_stride_v; |
| 1007 } | 1016 } |
| 1008 } | 1017 } |
| 1009 return 0; | 1018 return 0; |
| 1010 } | 1019 } |
| 1011 | 1020 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1022 int I420ToRGB565Dither(const uint8* src_y, int src_stride_y, | 1031 int I420ToRGB565Dither(const uint8* src_y, int src_stride_y, |
| 1023 const uint8* src_u, int src_stride_u, | 1032 const uint8* src_u, int src_stride_u, |
| 1024 const uint8* src_v, int src_stride_v, | 1033 const uint8* src_v, int src_stride_v, |
| 1025 uint8* dst_rgb565, int dst_stride_rgb565, | 1034 uint8* dst_rgb565, int dst_stride_rgb565, |
| 1026 const uint8* dither4x4, int width, int height) { | 1035 const uint8* dither4x4, int width, int height) { |
| 1027 int y; | 1036 int y; |
| 1028 void (*I422ToARGBRow)(const uint8* y_buf, | 1037 void (*I422ToARGBRow)(const uint8* y_buf, |
| 1029 const uint8* u_buf, | 1038 const uint8* u_buf, |
| 1030 const uint8* v_buf, | 1039 const uint8* v_buf, |
| 1031 uint8* rgb_buf, | 1040 uint8* rgb_buf, |
| 1041 struct YuvConstants* yuvconstants, |
| 1032 int width) = I422ToARGBRow_C; | 1042 int width) = I422ToARGBRow_C; |
| 1033 void (*ARGBToRGB565DitherRow)(const uint8* src_argb, uint8* dst_rgb, | 1043 void (*ARGBToRGB565DitherRow)(const uint8* src_argb, uint8* dst_rgb, |
| 1034 const uint32 dither4, int pix) = ARGBToRGB565DitherRow_C; | 1044 const uint32 dither4, int pix) = ARGBToRGB565DitherRow_C; |
| 1035 if (!src_y || !src_u || !src_v || !dst_rgb565 || | 1045 if (!src_y || !src_u || !src_v || !dst_rgb565 || |
| 1036 width <= 0 || height == 0) { | 1046 width <= 0 || height == 0) { |
| 1037 return -1; | 1047 return -1; |
| 1038 } | 1048 } |
| 1039 // Negative height means invert the image. | 1049 // Negative height means invert the image. |
| 1040 if (height < 0) { | 1050 if (height < 0) { |
| 1041 height = -height; | 1051 height = -height; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_Any_NEON; | 1108 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_Any_NEON; |
| 1099 if (IS_ALIGNED(width, 8)) { | 1109 if (IS_ALIGNED(width, 8)) { |
| 1100 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; | 1110 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; |
| 1101 } | 1111 } |
| 1102 } | 1112 } |
| 1103 #endif | 1113 #endif |
| 1104 { | 1114 { |
| 1105 // Allocate a row of argb. | 1115 // Allocate a row of argb. |
| 1106 align_buffer_64(row_argb, width * 4); | 1116 align_buffer_64(row_argb, width * 4); |
| 1107 for (y = 0; y < height; ++y) { | 1117 for (y = 0; y < height; ++y) { |
| 1108 I422ToARGBRow(src_y, src_u, src_v, row_argb, width); | 1118 I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvConstants, width); |
| 1109 ARGBToRGB565DitherRow(row_argb, dst_rgb565, | 1119 ARGBToRGB565DitherRow(row_argb, dst_rgb565, |
| 1110 *(uint32*)(dither4x4 + ((y & 3) << 2)), width); | 1120 *(uint32*)(dither4x4 + ((y & 3) << 2)), width); |
| 1111 dst_rgb565 += dst_stride_rgb565; | 1121 dst_rgb565 += dst_stride_rgb565; |
| 1112 src_y += src_stride_y; | 1122 src_y += src_stride_y; |
| 1113 if (y & 1) { | 1123 if (y & 1) { |
| 1114 src_u += src_stride_u; | 1124 src_u += src_stride_u; |
| 1115 src_v += src_stride_v; | 1125 src_v += src_stride_v; |
| 1116 } | 1126 } |
| 1117 } | 1127 } |
| 1118 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 Loading... |
| 1339 default: | 1349 default: |
| 1340 return -1; // unknown fourcc - return failure code. | 1350 return -1; // unknown fourcc - return failure code. |
| 1341 } | 1351 } |
| 1342 return r; | 1352 return r; |
| 1343 } | 1353 } |
| 1344 | 1354 |
| 1345 #ifdef __cplusplus | 1355 #ifdef __cplusplus |
| 1346 } // extern "C" | 1356 } // extern "C" |
| 1347 } // namespace libyuv | 1357 } // namespace libyuv |
| 1348 #endif | 1358 #endif |
| OLD | NEW |