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

Side by Side Diff: media/base/yuv_convert_unittest.cc

Issue 513663002: Revert of Cleanup: Remove unneeded SSE2 checks and unused code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « media/base/yuv_convert_perftest.cc ('k') | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
660 TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { 691 TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) {
661 base::CPU cpu; 692 base::CPU cpu;
662 if (!cpu.has_sse()) { 693 if (!cpu.has_sse()) {
663 LOG(WARNING) << "System not supported. Test skipped."; 694 LOG(WARNING) << "System not supported. Test skipped.";
664 return; 695 return;
665 } 696 }
666 697
667 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); 698 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]);
668 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); 699 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]);
669 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); 700 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]);
670 ReadYV12Data(&yuv_bytes); 701 ReadYV12Data(&yuv_bytes);
671 702
672 const int kWidth = 167; 703 const int kWidth = 167;
673 ConvertYUVToRGB32Row_C(yuv_bytes.get(), 704 ConvertYUVToRGB32Row_C(yuv_bytes.get(),
674 yuv_bytes.get() + kSourceUOffset, 705 yuv_bytes.get() + kSourceUOffset,
675 yuv_bytes.get() + kSourceVOffset, 706 yuv_bytes.get() + kSourceVOffset,
676 rgb_bytes_reference.get(), 707 rgb_bytes_reference.get(),
677 kWidth, 708 kWidth,
678 GetLookupTable(YV12)); 709 GetLookupTable(YV12));
679 ConvertYUVToRGB32Row_SSE(yuv_bytes.get(), 710 ConvertYUVToRGB32Row_SSE(yuv_bytes.get(),
680 yuv_bytes.get() + kSourceUOffset, 711 yuv_bytes.get() + kSourceUOffset,
681 yuv_bytes.get() + kSourceVOffset, 712 yuv_bytes.get() + kSourceVOffset,
682 rgb_bytes_converted.get(), 713 rgb_bytes_converted.get(),
683 kWidth, 714 kWidth,
684 GetLookupTable(YV12)); 715 GetLookupTable(YV12));
685 media::EmptyRegisterState(); 716 media::EmptyRegisterState();
686 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), 717 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(),
687 rgb_bytes_converted.get(), 718 rgb_bytes_converted.get(),
719 kWidth * kBpp));
720 }
721
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(),
688 kWidth * kBpp)); 753 kWidth * kBpp));
689 } 754 }
690 755
691 TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { 756 TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) {
692 base::CPU cpu; 757 base::CPU cpu;
693 if (!cpu.has_sse()) { 758 if (!cpu.has_sse()) {
694 LOG(WARNING) << "System not supported. Test skipped."; 759 LOG(WARNING) << "System not supported. Test skipped.";
695 return; 760 return;
696 } 761 }
697 762
(...skipping 17 matching lines...) Expand all
715 rgb_bytes_converted.get(), 780 rgb_bytes_converted.get(),
716 kWidth, 781 kWidth,
717 kSourceDx, 782 kSourceDx,
718 GetLookupTable(YV12)); 783 GetLookupTable(YV12));
719 media::EmptyRegisterState(); 784 media::EmptyRegisterState();
720 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), 785 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(),
721 rgb_bytes_converted.get(), 786 rgb_bytes_converted.get(),
722 kWidth * kBpp)); 787 kWidth * kBpp));
723 } 788 }
724 789
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
725 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) { 824 TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) {
726 base::CPU cpu; 825 base::CPU cpu;
727 if (!cpu.has_sse()) { 826 if (!cpu.has_sse()) {
728 LOG(WARNING) << "System not supported. Test skipped."; 827 LOG(WARNING) << "System not supported. Test skipped.";
729 return; 828 return;
730 } 829 }
731 830
732 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]); 831 scoped_ptr<uint8[]> yuv_bytes(new uint8[kYUV12Size]);
733 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]); 832 scoped_ptr<uint8[]> rgb_bytes_reference(new uint8[kRGBSize]);
734 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]); 833 scoped_ptr<uint8[]> rgb_bytes_converted(new uint8[kRGBSize]);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), 1033 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(),
935 rgb_bytes_converted.get(), 1034 rgb_bytes_converted.get(),
936 kWidth * kBpp)); 1035 kWidth * kBpp));
937 } 1036 }
938 1037
939 #endif // defined(ARCH_CPU_X86_64) 1038 #endif // defined(ARCH_CPU_X86_64)
940 1039
941 #endif // defined(ARCH_CPU_X86_FAMILY) 1040 #endif // defined(ARCH_CPU_X86_FAMILY)
942 1041
943 } // namespace media 1042 } // namespace media
OLDNEW
« no previous file with comments | « media/base/yuv_convert_perftest.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698