| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/cpu.h" | 6 #include "base/cpu.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "media/base/djb2.h" | 10 #include "media/base/djb2.h" |
| 11 #include "media/base/simd/convert_rgb_to_yuv.h" | 11 #include "media/base/simd/convert_rgb_to_yuv.h" |
| 12 #include "media/base/simd/convert_yuv_to_rgb.h" | 12 #include "media/base/simd/convert_yuv_to_rgb.h" |
| 13 #include "media/base/simd/filter_yuv.h" | 13 #include "media/base/simd/filter_yuv.h" |
| 14 #include "media/base/simd/yuv_to_rgb_table.h" | |
| 15 #include "media/base/yuv_convert.h" | 14 #include "media/base/yuv_convert.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 18 | 17 |
| 19 // Size of raw image. | 18 // Size of raw image. |
| 20 static const int kSourceWidth = 640; | 19 static const int kSourceWidth = 640; |
| 21 static const int kSourceHeight = 360; | 20 static const int kSourceHeight = 360; |
| 22 static const int kSourceYSize = kSourceWidth * kSourceHeight; | 21 static const int kSourceYSize = kSourceWidth * kSourceHeight; |
| 23 static const int kSourceUOffset = kSourceYSize; | 22 static const int kSourceUOffset = kSourceYSize; |
| 24 static const int kSourceVOffset = kSourceYSize * 5 / 4; | 23 static const int kSourceVOffset = kSourceYSize * 5 / 4; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 media::YUVType yuv_type; | 155 media::YUVType yuv_type; |
| 157 media::ScaleFilter scale_filter; | 156 media::ScaleFilter scale_filter; |
| 158 uint32 rgb_hash; | 157 uint32 rgb_hash; |
| 159 }; | 158 }; |
| 160 | 159 |
| 161 class YUVScaleTest : public ::testing::TestWithParam<YUVScaleTestData> { | 160 class YUVScaleTest : public ::testing::TestWithParam<YUVScaleTestData> { |
| 162 public: | 161 public: |
| 163 YUVScaleTest() { | 162 YUVScaleTest() { |
| 164 switch (GetParam().yuv_type) { | 163 switch (GetParam().yuv_type) { |
| 165 case media::YV12: | 164 case media::YV12: |
| 166 case media::YV12J: | |
| 167 ReadYV12Data(&yuv_bytes_); | 165 ReadYV12Data(&yuv_bytes_); |
| 168 break; | 166 break; |
| 169 case media::YV16: | 167 case media::YV16: |
| 170 ReadYV16Data(&yuv_bytes_); | 168 ReadYV16Data(&yuv_bytes_); |
| 171 break; | 169 break; |
| 172 } | 170 } |
| 173 | 171 |
| 174 rgb_bytes_.reset(new uint8[kRGBSizeScaled]); | 172 rgb_bytes_.reset(new uint8[kRGBSizeScaled]); |
| 175 } | 173 } |
| 176 | 174 |
| 177 // Helpers for getting the proper Y, U and V plane offsets. | 175 // Helpers for getting the proper Y, U and V plane offsets. |
| 178 uint8* y_plane() { return yuv_bytes_.get(); } | 176 uint8* y_plane() { return yuv_bytes_.get(); } |
| 179 uint8* u_plane() { return yuv_bytes_.get() + kSourceYSize; } | 177 uint8* u_plane() { return yuv_bytes_.get() + kSourceYSize; } |
| 180 uint8* v_plane() { | 178 uint8* v_plane() { |
| 181 switch (GetParam().yuv_type) { | 179 switch (GetParam().yuv_type) { |
| 182 case media::YV12: | 180 case media::YV12: |
| 183 case media::YV12J: | |
| 184 return yuv_bytes_.get() + kSourceVOffset; | 181 return yuv_bytes_.get() + kSourceVOffset; |
| 185 case media::YV16: | 182 case media::YV16: |
| 186 return yuv_bytes_.get() + kSourceYSize * 3 / 2; | 183 return yuv_bytes_.get() + kSourceYSize * 3 / 2; |
| 187 } | 184 } |
| 188 return NULL; | 185 return NULL; |
| 189 } | 186 } |
| 190 | 187 |
| 191 scoped_ptr<uint8[]> yuv_bytes_; | 188 scoped_ptr<uint8[]> yuv_bytes_; |
| 192 scoped_ptr<uint8[]> rgb_bytes_; | 189 scoped_ptr<uint8[]> rgb_bytes_; |
| 193 }; | 190 }; |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 611 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 615 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 612 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 616 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 613 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 617 ReadYV12Data(&yuv_bytes); | 614 ReadYV12Data(&yuv_bytes); |
| 618 | 615 |
| 619 const int kWidth = 167; | 616 const int kWidth = 167; |
| 620 ConvertYUVToRGB32Row_C(yuv_bytes.get(), | 617 ConvertYUVToRGB32Row_C(yuv_bytes.get(), |
| 621 yuv_bytes.get() + kSourceUOffset, | 618 yuv_bytes.get() + kSourceUOffset, |
| 622 yuv_bytes.get() + kSourceVOffset, | 619 yuv_bytes.get() + kSourceVOffset, |
| 623 rgb_bytes_reference.get(), | 620 rgb_bytes_reference.get(), |
| 624 kWidth, | 621 kWidth); |
| 625 GetLookupTable(YV12)); | |
| 626 ConvertYUVToRGB32Row_MMX(yuv_bytes.get(), | 622 ConvertYUVToRGB32Row_MMX(yuv_bytes.get(), |
| 627 yuv_bytes.get() + kSourceUOffset, | 623 yuv_bytes.get() + kSourceUOffset, |
| 628 yuv_bytes.get() + kSourceVOffset, | 624 yuv_bytes.get() + kSourceVOffset, |
| 629 rgb_bytes_converted.get(), | 625 rgb_bytes_converted.get(), |
| 630 kWidth, | 626 kWidth); |
| 631 GetLookupTable(YV12)); | |
| 632 media::EmptyRegisterState(); | 627 media::EmptyRegisterState(); |
| 633 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 628 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 634 rgb_bytes_converted.get(), | 629 rgb_bytes_converted.get(), |
| 635 kWidth * kBpp)); | 630 kWidth * kBpp)); |
| 636 } | 631 } |
| 637 | 632 |
| 638 TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { | 633 TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { |
| 639 base::CPU cpu; | 634 base::CPU cpu; |
| 640 if (!cpu.has_sse()) { | 635 if (!cpu.has_sse()) { |
| 641 LOG(WARNING) << "System not supported. Test skipped."; | 636 LOG(WARNING) << "System not supported. Test skipped."; |
| 642 return; | 637 return; |
| 643 } | 638 } |
| 644 | 639 |
| 645 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 640 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 646 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 641 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 647 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 642 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 648 ReadYV12Data(&yuv_bytes); | 643 ReadYV12Data(&yuv_bytes); |
| 649 | 644 |
| 650 const int kWidth = 167; | 645 const int kWidth = 167; |
| 651 ConvertYUVToRGB32Row_C(yuv_bytes.get(), | 646 ConvertYUVToRGB32Row_C(yuv_bytes.get(), |
| 652 yuv_bytes.get() + kSourceUOffset, | 647 yuv_bytes.get() + kSourceUOffset, |
| 653 yuv_bytes.get() + kSourceVOffset, | 648 yuv_bytes.get() + kSourceVOffset, |
| 654 rgb_bytes_reference.get(), | 649 rgb_bytes_reference.get(), |
| 655 kWidth, | 650 kWidth); |
| 656 GetLookupTable(YV12)); | |
| 657 ConvertYUVToRGB32Row_SSE(yuv_bytes.get(), | 651 ConvertYUVToRGB32Row_SSE(yuv_bytes.get(), |
| 658 yuv_bytes.get() + kSourceUOffset, | 652 yuv_bytes.get() + kSourceUOffset, |
| 659 yuv_bytes.get() + kSourceVOffset, | 653 yuv_bytes.get() + kSourceVOffset, |
| 660 rgb_bytes_converted.get(), | 654 rgb_bytes_converted.get(), |
| 661 kWidth, | 655 kWidth); |
| 662 GetLookupTable(YV12)); | |
| 663 media::EmptyRegisterState(); | 656 media::EmptyRegisterState(); |
| 664 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 657 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 665 rgb_bytes_converted.get(), | 658 rgb_bytes_converted.get(), |
| 666 kWidth * kBpp)); | 659 kWidth * kBpp)); |
| 667 } | 660 } |
| 668 | 661 |
| 669 TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) { | 662 TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) { |
| 670 base::CPU cpu; | 663 base::CPU cpu; |
| 671 if (!cpu.has_mmx()) { | 664 if (!cpu.has_mmx()) { |
| 672 LOG(WARNING) << "System not supported. Test skipped."; | 665 LOG(WARNING) << "System not supported. Test skipped."; |
| 673 return; | 666 return; |
| 674 } | 667 } |
| 675 | 668 |
| 676 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 669 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 677 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 670 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 678 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 671 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 679 ReadYV12Data(&yuv_bytes); | 672 ReadYV12Data(&yuv_bytes); |
| 680 | 673 |
| 681 const int kWidth = 167; | 674 const int kWidth = 167; |
| 682 const int kSourceDx = 80000; // This value means a scale down. | 675 const int kSourceDx = 80000; // This value means a scale down. |
| 683 ScaleYUVToRGB32Row_C(yuv_bytes.get(), | 676 ScaleYUVToRGB32Row_C(yuv_bytes.get(), |
| 684 yuv_bytes.get() + kSourceUOffset, | 677 yuv_bytes.get() + kSourceUOffset, |
| 685 yuv_bytes.get() + kSourceVOffset, | 678 yuv_bytes.get() + kSourceVOffset, |
| 686 rgb_bytes_reference.get(), | 679 rgb_bytes_reference.get(), |
| 687 kWidth, | 680 kWidth, |
| 688 kSourceDx, | 681 kSourceDx); |
| 689 GetLookupTable(YV12)); | |
| 690 ScaleYUVToRGB32Row_MMX(yuv_bytes.get(), | 682 ScaleYUVToRGB32Row_MMX(yuv_bytes.get(), |
| 691 yuv_bytes.get() + kSourceUOffset, | 683 yuv_bytes.get() + kSourceUOffset, |
| 692 yuv_bytes.get() + kSourceVOffset, | 684 yuv_bytes.get() + kSourceVOffset, |
| 693 rgb_bytes_converted.get(), | 685 rgb_bytes_converted.get(), |
| 694 kWidth, | 686 kWidth, |
| 695 kSourceDx, | 687 kSourceDx); |
| 696 GetLookupTable(YV12)); | |
| 697 media::EmptyRegisterState(); | 688 media::EmptyRegisterState(); |
| 698 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 689 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 699 rgb_bytes_converted.get(), | 690 rgb_bytes_converted.get(), |
| 700 kWidth * kBpp)); | 691 kWidth * kBpp)); |
| 701 } | 692 } |
| 702 | 693 |
| 703 TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { | 694 TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { |
| 704 base::CPU cpu; | 695 base::CPU cpu; |
| 705 if (!cpu.has_sse()) { | 696 if (!cpu.has_sse()) { |
| 706 LOG(WARNING) << "System not supported. Test skipped."; | 697 LOG(WARNING) << "System not supported. Test skipped."; |
| 707 return; | 698 return; |
| 708 } | 699 } |
| 709 | 700 |
| 710 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 701 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 711 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 702 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 712 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 703 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 713 ReadYV12Data(&yuv_bytes); | 704 ReadYV12Data(&yuv_bytes); |
| 714 | 705 |
| 715 const int kWidth = 167; | 706 const int kWidth = 167; |
| 716 const int kSourceDx = 80000; // This value means a scale down. | 707 const int kSourceDx = 80000; // This value means a scale down. |
| 717 ScaleYUVToRGB32Row_C(yuv_bytes.get(), | 708 ScaleYUVToRGB32Row_C(yuv_bytes.get(), |
| 718 yuv_bytes.get() + kSourceUOffset, | 709 yuv_bytes.get() + kSourceUOffset, |
| 719 yuv_bytes.get() + kSourceVOffset, | 710 yuv_bytes.get() + kSourceVOffset, |
| 720 rgb_bytes_reference.get(), | 711 rgb_bytes_reference.get(), |
| 721 kWidth, | 712 kWidth, |
| 722 kSourceDx, | 713 kSourceDx); |
| 723 GetLookupTable(YV12)); | |
| 724 ScaleYUVToRGB32Row_SSE(yuv_bytes.get(), | 714 ScaleYUVToRGB32Row_SSE(yuv_bytes.get(), |
| 725 yuv_bytes.get() + kSourceUOffset, | 715 yuv_bytes.get() + kSourceUOffset, |
| 726 yuv_bytes.get() + kSourceVOffset, | 716 yuv_bytes.get() + kSourceVOffset, |
| 727 rgb_bytes_converted.get(), | 717 rgb_bytes_converted.get(), |
| 728 kWidth, | 718 kWidth, |
| 729 kSourceDx, | 719 kSourceDx); |
| 730 GetLookupTable(YV12)); | |
| 731 media::EmptyRegisterState(); | 720 media::EmptyRegisterState(); |
| 732 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 721 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 733 rgb_bytes_converted.get(), | 722 rgb_bytes_converted.get(), |
| 734 kWidth * kBpp)); | 723 kWidth * kBpp)); |
| 735 } | 724 } |
| 736 | 725 |
| 737 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) { | 726 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) { |
| 738 base::CPU cpu; | 727 base::CPU cpu; |
| 739 if (!cpu.has_mmx()) { | 728 if (!cpu.has_mmx()) { |
| 740 LOG(WARNING) << "System not supported. Test skipped."; | 729 LOG(WARNING) << "System not supported. Test skipped."; |
| 741 return; | 730 return; |
| 742 } | 731 } |
| 743 | 732 |
| 744 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 733 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 745 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 734 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 746 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 735 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 747 ReadYV12Data(&yuv_bytes); | 736 ReadYV12Data(&yuv_bytes); |
| 748 | 737 |
| 749 const int kWidth = 167; | 738 const int kWidth = 167; |
| 750 const int kSourceDx = 80000; // This value means a scale down. | 739 const int kSourceDx = 80000; // This value means a scale down. |
| 751 LinearScaleYUVToRGB32Row_C(yuv_bytes.get(), | 740 LinearScaleYUVToRGB32Row_C(yuv_bytes.get(), |
| 752 yuv_bytes.get() + kSourceUOffset, | 741 yuv_bytes.get() + kSourceUOffset, |
| 753 yuv_bytes.get() + kSourceVOffset, | 742 yuv_bytes.get() + kSourceVOffset, |
| 754 rgb_bytes_reference.get(), | 743 rgb_bytes_reference.get(), |
| 755 kWidth, | 744 kWidth, |
| 756 kSourceDx, | 745 kSourceDx); |
| 757 GetLookupTable(YV12)); | |
| 758 LinearScaleYUVToRGB32Row_MMX(yuv_bytes.get(), | 746 LinearScaleYUVToRGB32Row_MMX(yuv_bytes.get(), |
| 759 yuv_bytes.get() + kSourceUOffset, | 747 yuv_bytes.get() + kSourceUOffset, |
| 760 yuv_bytes.get() + kSourceVOffset, | 748 yuv_bytes.get() + kSourceVOffset, |
| 761 rgb_bytes_converted.get(), | 749 rgb_bytes_converted.get(), |
| 762 kWidth, | 750 kWidth, |
| 763 kSourceDx, | 751 kSourceDx); |
| 764 GetLookupTable(YV12)); | |
| 765 media::EmptyRegisterState(); | 752 media::EmptyRegisterState(); |
| 766 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 753 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 767 rgb_bytes_converted.get(), | 754 rgb_bytes_converted.get(), |
| 768 kWidth * kBpp)); | 755 kWidth * kBpp)); |
| 769 } | 756 } |
| 770 | 757 |
| 771 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) { | 758 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) { |
| 772 base::CPU cpu; | 759 base::CPU cpu; |
| 773 if (!cpu.has_sse()) { | 760 if (!cpu.has_sse()) { |
| 774 LOG(WARNING) << "System not supported. Test skipped."; | 761 LOG(WARNING) << "System not supported. Test skipped."; |
| 775 return; | 762 return; |
| 776 } | 763 } |
| 777 | 764 |
| 778 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 765 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 779 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 766 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 780 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 767 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 781 ReadYV12Data(&yuv_bytes); | 768 ReadYV12Data(&yuv_bytes); |
| 782 | 769 |
| 783 const int kWidth = 167; | 770 const int kWidth = 167; |
| 784 const int kSourceDx = 80000; // This value means a scale down. | 771 const int kSourceDx = 80000; // This value means a scale down. |
| 785 LinearScaleYUVToRGB32Row_C(yuv_bytes.get(), | 772 LinearScaleYUVToRGB32Row_C(yuv_bytes.get(), |
| 786 yuv_bytes.get() + kSourceUOffset, | 773 yuv_bytes.get() + kSourceUOffset, |
| 787 yuv_bytes.get() + kSourceVOffset, | 774 yuv_bytes.get() + kSourceVOffset, |
| 788 rgb_bytes_reference.get(), | 775 rgb_bytes_reference.get(), |
| 789 kWidth, | 776 kWidth, |
| 790 kSourceDx, | 777 kSourceDx); |
| 791 GetLookupTable(YV12)); | |
| 792 LinearScaleYUVToRGB32Row_SSE(yuv_bytes.get(), | 778 LinearScaleYUVToRGB32Row_SSE(yuv_bytes.get(), |
| 793 yuv_bytes.get() + kSourceUOffset, | 779 yuv_bytes.get() + kSourceUOffset, |
| 794 yuv_bytes.get() + kSourceVOffset, | 780 yuv_bytes.get() + kSourceVOffset, |
| 795 rgb_bytes_converted.get(), | 781 rgb_bytes_converted.get(), |
| 796 kWidth, | 782 kWidth, |
| 797 kSourceDx, | 783 kSourceDx); |
| 798 GetLookupTable(YV12)); | |
| 799 media::EmptyRegisterState(); | 784 media::EmptyRegisterState(); |
| 800 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 785 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 801 rgb_bytes_converted.get(), | 786 rgb_bytes_converted.get(), |
| 802 kWidth * kBpp)); | 787 kWidth * kBpp)); |
| 803 } | 788 } |
| 804 | 789 |
| 805 TEST(YUVConvertTest, FilterYUVRows_C_OutOfBounds) { | 790 TEST(YUVConvertTest, FilterYUVRows_C_OutOfBounds) { |
| 806 scoped_ptr<uint8[]> src(new uint8[16]); | 791 scoped_ptr<uint8[]> src(new uint8[16]); |
| 807 scoped_ptr<uint8[]> dst(new uint8[16]); | 792 scoped_ptr<uint8[]> dst(new uint8[16]); |
| 808 | 793 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 917 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 933 ReadYV12Data(&yuv_bytes); | 918 ReadYV12Data(&yuv_bytes); |
| 934 | 919 |
| 935 const int kWidth = 167; | 920 const int kWidth = 167; |
| 936 const int kSourceDx = 80000; // This value means a scale down. | 921 const int kSourceDx = 80000; // This value means a scale down. |
| 937 ScaleYUVToRGB32Row_C(yuv_bytes.get(), | 922 ScaleYUVToRGB32Row_C(yuv_bytes.get(), |
| 938 yuv_bytes.get() + kSourceUOffset, | 923 yuv_bytes.get() + kSourceUOffset, |
| 939 yuv_bytes.get() + kSourceVOffset, | 924 yuv_bytes.get() + kSourceVOffset, |
| 940 rgb_bytes_reference.get(), | 925 rgb_bytes_reference.get(), |
| 941 kWidth, | 926 kWidth, |
| 942 kSourceDx, | 927 kSourceDx); |
| 943 GetLookupTable(YV12)); | |
| 944 ScaleYUVToRGB32Row_SSE2_X64(yuv_bytes.get(), | 928 ScaleYUVToRGB32Row_SSE2_X64(yuv_bytes.get(), |
| 945 yuv_bytes.get() + kSourceUOffset, | 929 yuv_bytes.get() + kSourceUOffset, |
| 946 yuv_bytes.get() + kSourceVOffset, | 930 yuv_bytes.get() + kSourceVOffset, |
| 947 rgb_bytes_converted.get(), | 931 rgb_bytes_converted.get(), |
| 948 kWidth, | 932 kWidth, |
| 949 kSourceDx, | 933 kSourceDx); |
| 950 GetLookupTable(YV12)); | |
| 951 media::EmptyRegisterState(); | 934 media::EmptyRegisterState(); |
| 952 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 935 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 953 rgb_bytes_converted.get(), | 936 rgb_bytes_converted.get(), |
| 954 kWidth * kBpp)); | 937 kWidth * kBpp)); |
| 955 } | 938 } |
| 956 | 939 |
| 957 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX_X64) { | 940 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX_X64) { |
| 958 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 941 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 959 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 942 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 960 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 943 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| 961 ReadYV12Data(&yuv_bytes); | 944 ReadYV12Data(&yuv_bytes); |
| 962 | 945 |
| 963 const int kWidth = 167; | 946 const int kWidth = 167; |
| 964 const int kSourceDx = 80000; // This value means a scale down. | 947 const int kSourceDx = 80000; // This value means a scale down. |
| 965 LinearScaleYUVToRGB32Row_C(yuv_bytes.get(), | 948 LinearScaleYUVToRGB32Row_C(yuv_bytes.get(), |
| 966 yuv_bytes.get() + kSourceUOffset, | 949 yuv_bytes.get() + kSourceUOffset, |
| 967 yuv_bytes.get() + kSourceVOffset, | 950 yuv_bytes.get() + kSourceVOffset, |
| 968 rgb_bytes_reference.get(), | 951 rgb_bytes_reference.get(), |
| 969 kWidth, | 952 kWidth, |
| 970 kSourceDx, | 953 kSourceDx); |
| 971 GetLookupTable(YV12)); | |
| 972 LinearScaleYUVToRGB32Row_MMX_X64(yuv_bytes.get(), | 954 LinearScaleYUVToRGB32Row_MMX_X64(yuv_bytes.get(), |
| 973 yuv_bytes.get() + kSourceUOffset, | 955 yuv_bytes.get() + kSourceUOffset, |
| 974 yuv_bytes.get() + kSourceVOffset, | 956 yuv_bytes.get() + kSourceVOffset, |
| 975 rgb_bytes_converted.get(), | 957 rgb_bytes_converted.get(), |
| 976 kWidth, | 958 kWidth, |
| 977 kSourceDx, | 959 kSourceDx); |
| 978 GetLookupTable(YV12)); | |
| 979 media::EmptyRegisterState(); | 960 media::EmptyRegisterState(); |
| 980 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 961 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 981 rgb_bytes_converted.get(), | 962 rgb_bytes_converted.get(), |
| 982 kWidth * kBpp)); | 963 kWidth * kBpp)); |
| 983 } | 964 } |
| 984 | 965 |
| 985 #endif // defined(ARCH_CPU_X86_64) | 966 #endif // defined(ARCH_CPU_X86_64) |
| 986 | 967 |
| 987 #endif // defined(ARCH_CPU_X86_FAMILY) | 968 #endif // defined(ARCH_CPU_X86_FAMILY) |
| 988 | 969 |
| 989 } // namespace media | 970 } // namespace media |
| OLD | NEW |