| 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" |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 int diff = yuv_reference_bytes[i] - yuv_converted_bytes[i]; | 650 int diff = yuv_reference_bytes[i] - yuv_converted_bytes[i]; |
| 651 if (diff < 0) | 651 if (diff < 0) |
| 652 diff = -diff; | 652 diff = -diff; |
| 653 error += diff; | 653 error += diff; |
| 654 } | 654 } |
| 655 | 655 |
| 656 // Make sure there's no difference from the reference. | 656 // Make sure there's no difference from the reference. |
| 657 EXPECT_EQ(0, error); | 657 EXPECT_EQ(0, error); |
| 658 } | 658 } |
| 659 | 659 |
| 660 TEST(YUVConvertTest, ConvertYUVToRGB32Row_MMX) { | |
| 661 base::CPU cpu; | |
| 662 if (!cpu.has_mmx()) { | |
| 663 LOG(WARNING) << "System not supported. Test skipped."; | |
| 664 return; | |
| 665 } | |
| 666 | |
| 667 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | |
| 668 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | |
| 669 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | |
| 670 ReadYV12Data(&yuv_bytes); | |
| 671 | |
| 672 const int kWidth = 167; | |
| 673 ConvertYUVToRGB32Row_C(yuv_bytes.get(), | |
| 674 yuv_bytes.get() + kSourceUOffset, | |
| 675 yuv_bytes.get() + kSourceVOffset, | |
| 676 rgb_bytes_reference.get(), | |
| 677 kWidth, | |
| 678 GetLookupTable(YV12)); | |
| 679 ConvertYUVToRGB32Row_MMX(yuv_bytes.get(), | |
| 680 yuv_bytes.get() + kSourceUOffset, | |
| 681 yuv_bytes.get() + kSourceVOffset, | |
| 682 rgb_bytes_converted.get(), | |
| 683 kWidth, | |
| 684 GetLookupTable(YV12)); | |
| 685 media::EmptyRegisterState(); | |
| 686 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | |
| 687 rgb_bytes_converted.get(), | |
| 688 kWidth * kBpp)); | |
| 689 } | |
| 690 | |
| 691 TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { | 660 TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { |
| 692 base::CPU cpu; | 661 base::CPU cpu; |
| 693 if (!cpu.has_sse()) { | 662 if (!cpu.has_sse()) { |
| 694 LOG(WARNING) << "System not supported. Test skipped."; | 663 LOG(WARNING) << "System not supported. Test skipped."; |
| 695 return; | 664 return; |
| 696 } | 665 } |
| 697 | 666 |
| 698 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 667 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 699 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 668 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 700 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 669 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 712 yuv_bytes.get() + kSourceVOffset, | 681 yuv_bytes.get() + kSourceVOffset, |
| 713 rgb_bytes_converted.get(), | 682 rgb_bytes_converted.get(), |
| 714 kWidth, | 683 kWidth, |
| 715 GetLookupTable(YV12)); | 684 GetLookupTable(YV12)); |
| 716 media::EmptyRegisterState(); | 685 media::EmptyRegisterState(); |
| 717 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 686 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 718 rgb_bytes_converted.get(), | 687 rgb_bytes_converted.get(), |
| 719 kWidth * kBpp)); | 688 kWidth * kBpp)); |
| 720 } | 689 } |
| 721 | 690 |
| 722 TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) { | |
| 723 base::CPU cpu; | |
| 724 if (!cpu.has_mmx()) { | |
| 725 LOG(WARNING) << "System not supported. Test skipped."; | |
| 726 return; | |
| 727 } | |
| 728 | |
| 729 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | |
| 730 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | |
| 731 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | |
| 732 ReadYV12Data(&yuv_bytes); | |
| 733 | |
| 734 const int kWidth = 167; | |
| 735 const int kSourceDx = 80000; // This value means a scale down. | |
| 736 ScaleYUVToRGB32Row_C(yuv_bytes.get(), | |
| 737 yuv_bytes.get() + kSourceUOffset, | |
| 738 yuv_bytes.get() + kSourceVOffset, | |
| 739 rgb_bytes_reference.get(), | |
| 740 kWidth, | |
| 741 kSourceDx, | |
| 742 GetLookupTable(YV12)); | |
| 743 ScaleYUVToRGB32Row_MMX(yuv_bytes.get(), | |
| 744 yuv_bytes.get() + kSourceUOffset, | |
| 745 yuv_bytes.get() + kSourceVOffset, | |
| 746 rgb_bytes_converted.get(), | |
| 747 kWidth, | |
| 748 kSourceDx, | |
| 749 GetLookupTable(YV12)); | |
| 750 media::EmptyRegisterState(); | |
| 751 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | |
| 752 rgb_bytes_converted.get(), | |
| 753 kWidth * kBpp)); | |
| 754 } | |
| 755 | |
| 756 TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { | 691 TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { |
| 757 base::CPU cpu; | 692 base::CPU cpu; |
| 758 if (!cpu.has_sse()) { | 693 if (!cpu.has_sse()) { |
| 759 LOG(WARNING) << "System not supported. Test skipped."; | 694 LOG(WARNING) << "System not supported. Test skipped."; |
| 760 return; | 695 return; |
| 761 } | 696 } |
| 762 | 697 |
| 763 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 698 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 764 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 699 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 765 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 700 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 780 rgb_bytes_converted.get(), | 715 rgb_bytes_converted.get(), |
| 781 kWidth, | 716 kWidth, |
| 782 kSourceDx, | 717 kSourceDx, |
| 783 GetLookupTable(YV12)); | 718 GetLookupTable(YV12)); |
| 784 media::EmptyRegisterState(); | 719 media::EmptyRegisterState(); |
| 785 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 720 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 786 rgb_bytes_converted.get(), | 721 rgb_bytes_converted.get(), |
| 787 kWidth * kBpp)); | 722 kWidth * kBpp)); |
| 788 } | 723 } |
| 789 | 724 |
| 790 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) { | |
| 791 base::CPU cpu; | |
| 792 if (!cpu.has_mmx()) { | |
| 793 LOG(WARNING) << "System not supported. Test skipped."; | |
| 794 return; | |
| 795 } | |
| 796 | |
| 797 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | |
| 798 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | |
| 799 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | |
| 800 ReadYV12Data(&yuv_bytes); | |
| 801 | |
| 802 const int kWidth = 167; | |
| 803 const int kSourceDx = 80000; // This value means a scale down. | |
| 804 LinearScaleYUVToRGB32Row_C(yuv_bytes.get(), | |
| 805 yuv_bytes.get() + kSourceUOffset, | |
| 806 yuv_bytes.get() + kSourceVOffset, | |
| 807 rgb_bytes_reference.get(), | |
| 808 kWidth, | |
| 809 kSourceDx, | |
| 810 GetLookupTable(YV12)); | |
| 811 LinearScaleYUVToRGB32Row_MMX(yuv_bytes.get(), | |
| 812 yuv_bytes.get() + kSourceUOffset, | |
| 813 yuv_bytes.get() + kSourceVOffset, | |
| 814 rgb_bytes_converted.get(), | |
| 815 kWidth, | |
| 816 kSourceDx, | |
| 817 GetLookupTable(YV12)); | |
| 818 media::EmptyRegisterState(); | |
| 819 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | |
| 820 rgb_bytes_converted.get(), | |
| 821 kWidth * kBpp)); | |
| 822 } | |
| 823 | |
| 824 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) { | 725 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) { |
| 825 base::CPU cpu; | 726 base::CPU cpu; |
| 826 if (!cpu.has_sse()) { | 727 if (!cpu.has_sse()) { |
| 827 LOG(WARNING) << "System not supported. Test skipped."; | 728 LOG(WARNING) << "System not supported. Test skipped."; |
| 828 return; | 729 return; |
| 829 } | 730 } |
| 830 | 731 |
| 831 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); | 732 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); |
| 832 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); | 733 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); |
| 833 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); | 734 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 934 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 1034 rgb_bytes_converted.get(), | 935 rgb_bytes_converted.get(), |
| 1035 kWidth * kBpp)); | 936 kWidth * kBpp)); |
| 1036 } | 937 } |
| 1037 | 938 |
| 1038 #endif // defined(ARCH_CPU_X86_64) | 939 #endif // defined(ARCH_CPU_X86_64) |
| 1039 | 940 |
| 1040 #endif // defined(ARCH_CPU_X86_FAMILY) | 941 #endif // defined(ARCH_CPU_X86_FAMILY) |
| 1041 | 942 |
| 1042 } // namespace media | 943 } // namespace media |
| OLD | NEW |