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

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

Issue 12213029: Lift MEDIA_MMX_INTRINSICS_AVAILABLE definition to header and use it to condition media_unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix lint errors Created 7 years, 10 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.cc ('k') | no next file » | 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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 memset(dst.get(), 0, 16); 768 memset(dst.get(), 0, 16);
769 769
770 media::FilterYUVRows_C(dst.get(), src.get(), src.get(), 1, 255); 770 media::FilterYUVRows_C(dst.get(), src.get(), src.get(), 1, 255);
771 771
772 EXPECT_EQ(255u, dst[0]); 772 EXPECT_EQ(255u, dst[0]);
773 for (int i = 1; i < 16; ++i) { 773 for (int i = 1; i < 16; ++i) {
774 EXPECT_EQ(0u, dst[i]) << " not equal at " << i; 774 EXPECT_EQ(0u, dst[i]) << " not equal at " << i;
775 } 775 }
776 } 776 }
777 777
778 TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) { 778 TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) {
scherkus (not reviewing) 2013/02/06 08:09:01 gtest supports disabling tests by prepending the t
wolenetz 2013/02/06 19:03:10 Sorry about being pedantic here. Please help me u
779 #if defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
779 base::CPU cpu; 780 base::CPU cpu;
780 if (!cpu.has_mmx()) { 781 if (!cpu.has_mmx()) {
781 LOG(WARNING) << "System not supported. Test skipped."; 782 LOG(WARNING) << "System not supported. Test skipped.";
782 return; 783 return;
783 } 784 }
784 785
785 scoped_array<uint8> src(new uint8[16]); 786 scoped_array<uint8> src(new uint8[16]);
786 scoped_array<uint8> dst(new uint8[16]); 787 scoped_array<uint8> dst(new uint8[16]);
787 788
788 memset(src.get(), 0xff, 16); 789 memset(src.get(), 0xff, 16);
789 memset(dst.get(), 0, 16); 790 memset(dst.get(), 0, 16);
790 791
791 media::FilterYUVRows_MMX(dst.get(), src.get(), src.get(), 1, 255); 792 media::FilterYUVRows_MMX(dst.get(), src.get(), src.get(), 1, 255);
792 media::EmptyRegisterState(); 793 media::EmptyRegisterState();
793 794
794 EXPECT_EQ(255u, dst[0]); 795 EXPECT_EQ(255u, dst[0]);
795 for (int i = 1; i < 16; ++i) { 796 for (int i = 1; i < 16; ++i) {
796 EXPECT_EQ(0u, dst[i]); 797 EXPECT_EQ(0u, dst[i]);
797 } 798 }
799 #else
800 LOG(WARNING) << "System not supported. Test skipped.";
801 return;
802 #endif // defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
798 } 803 }
799 804
800 TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) { 805 TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) {
801 base::CPU cpu; 806 base::CPU cpu;
802 if (!cpu.has_sse2()) { 807 if (!cpu.has_sse2()) {
803 LOG(WARNING) << "System not supported. Test skipped."; 808 LOG(WARNING) << "System not supported. Test skipped.";
804 return; 809 return;
805 } 810 }
806 811
807 scoped_array<uint8> src(new uint8[16]); 812 scoped_array<uint8> src(new uint8[16]);
808 scoped_array<uint8> dst(new uint8[16]); 813 scoped_array<uint8> dst(new uint8[16]);
809 814
810 memset(src.get(), 0xff, 16); 815 memset(src.get(), 0xff, 16);
811 memset(dst.get(), 0, 16); 816 memset(dst.get(), 0, 16);
812 817
813 media::FilterYUVRows_SSE2(dst.get(), src.get(), src.get(), 1, 255); 818 media::FilterYUVRows_SSE2(dst.get(), src.get(), src.get(), 1, 255);
814 819
815 EXPECT_EQ(255u, dst[0]); 820 EXPECT_EQ(255u, dst[0]);
816 for (int i = 1; i < 16; ++i) { 821 for (int i = 1; i < 16; ++i) {
817 EXPECT_EQ(0u, dst[i]); 822 EXPECT_EQ(0u, dst[i]);
818 } 823 }
819 } 824 }
820 825
821 TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) { 826 TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) {
827 #if defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
scherkus (not reviewing) 2013/02/06 08:09:01 ditto
wolenetz 2013/02/06 19:03:10 See reply for similar comment, above.
822 base::CPU cpu; 828 base::CPU cpu;
823 if (!cpu.has_mmx()) { 829 if (!cpu.has_mmx()) {
824 LOG(WARNING) << "System not supported. Test skipped."; 830 LOG(WARNING) << "System not supported. Test skipped.";
825 return; 831 return;
826 } 832 }
827 833
828 const int kSize = 32; 834 const int kSize = 32;
829 scoped_array<uint8> src(new uint8[kSize]); 835 scoped_array<uint8> src(new uint8[kSize]);
830 scoped_array<uint8> dst_sample(new uint8[kSize]); 836 scoped_array<uint8> dst_sample(new uint8[kSize]);
831 scoped_array<uint8> dst(new uint8[kSize]); 837 scoped_array<uint8> dst(new uint8[kSize]);
832 838
833 memset(dst_sample.get(), 0, kSize); 839 memset(dst_sample.get(), 0, kSize);
834 memset(dst.get(), 0, kSize); 840 memset(dst.get(), 0, kSize);
835 for (int i = 0; i < kSize; ++i) 841 for (int i = 0; i < kSize; ++i)
836 src[i] = 100 + i; 842 src[i] = 100 + i;
837 843
838 media::FilterYUVRows_C(dst_sample.get(), 844 media::FilterYUVRows_C(dst_sample.get(),
839 src.get(), src.get(), 17, 128); 845 src.get(), src.get(), 17, 128);
840 846
841 // Generate an unaligned output address. 847 // Generate an unaligned output address.
842 uint8* dst_ptr = 848 uint8* dst_ptr =
843 reinterpret_cast<uint8*>( 849 reinterpret_cast<uint8*>(
844 (reinterpret_cast<uintptr_t>(dst.get() + 8) & ~7) + 1); 850 (reinterpret_cast<uintptr_t>(dst.get() + 8) & ~7) + 1);
845 media::FilterYUVRows_MMX(dst_ptr, src.get(), src.get(), 17, 128); 851 media::FilterYUVRows_MMX(dst_ptr, src.get(), src.get(), 17, 128);
846 media::EmptyRegisterState(); 852 media::EmptyRegisterState();
847 853
848 EXPECT_EQ(0, memcmp(dst_sample.get(), dst_ptr, 17)); 854 EXPECT_EQ(0, memcmp(dst_sample.get(), dst_ptr, 17));
855 #else
856 LOG(WARNING) << "System not supported. Test skipped.";
857 return;
858 #endif // defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
849 } 859 }
850 860
851 TEST(YUVConvertTest, FilterYUVRows_SSE2_UnalignedDestination) { 861 TEST(YUVConvertTest, FilterYUVRows_SSE2_UnalignedDestination) {
852 base::CPU cpu; 862 base::CPU cpu;
853 if (!cpu.has_sse2()) { 863 if (!cpu.has_sse2()) {
854 LOG(WARNING) << "System not supported. Test skipped."; 864 LOG(WARNING) << "System not supported. Test skipped.";
855 return; 865 return;
856 } 866 }
857 867
858 const int kSize = 64; 868 const int kSize = 64;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 kSourceDx); 938 kSourceDx);
929 media::EmptyRegisterState(); 939 media::EmptyRegisterState();
930 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), 940 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(),
931 rgb_bytes_converted.get(), 941 rgb_bytes_converted.get(),
932 kWidth * kBpp)); 942 kWidth * kBpp));
933 } 943 }
934 944
935 #endif // defined(ARCH_CPU_X86_64) 945 #endif // defined(ARCH_CPU_X86_64)
936 946
937 #endif // defined(ARCH_CPU_X86_FAMILY) 947 #endif // defined(ARCH_CPU_X86_FAMILY)
OLDNEW
« no previous file with comments | « media/base/yuv_convert.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698