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/cpu.h" | 5 #include "base/cpu.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "media/base/simd/convert_rgb_to_yuv.h" | 7 #include "media/base/simd/convert_rgb_to_yuv.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 int ConvertRGBToV(const uint8* rgb, int size) { | 25 int ConvertRGBToV(const uint8* rgb, int size) { |
26 int v = -18 * rgb[0] - 94 * rgb[1] + 112 * rgb[2]; | 26 int v = -18 * rgb[0] - 94 * rgb[1] + 112 * rgb[2]; |
27 v = ((v + 128) >> 8) + 128; | 27 v = ((v + 128) >> 8) + 128; |
28 return std::max(0, std::min(255, v)); | 28 return std::max(0, std::min(255, v)); |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
| 33 // Assembly code confuses MemorySanitizer. Do not run it in MSan builds. |
| 34 #if defined(MEMORY_SANITIZER) |
| 35 #define MAYBE_SideBySideRGB DISABLED_SideBySideRGB |
| 36 #else |
| 37 #define MAYBE_SideBySideRGB SideBySideRGB |
| 38 #endif |
| 39 |
33 // A side-by-side test that verifies our ASM functions that convert RGB pixels | 40 // A side-by-side test that verifies our ASM functions that convert RGB pixels |
34 // to YUV pixels can output the expected results. This test converts RGB pixels | 41 // to YUV pixels can output the expected results. This test converts RGB pixels |
35 // to YUV pixels with our ASM functions (which use SSE, SSE2, SSE3, and SSSE3) | 42 // to YUV pixels with our ASM functions (which use SSE, SSE2, SSE3, and SSSE3) |
36 // and compare the output YUV pixels with the ones calculated with out reference | 43 // and compare the output YUV pixels with the ones calculated with out reference |
37 // functions implemented in C++. | 44 // functions implemented in C++. |
38 TEST(YUVConvertTest, SideBySideRGB) { | 45 TEST(YUVConvertTest, MAYBE_SideBySideRGB) { |
39 // We skip this test on PCs which does not support SSE3 because this test | 46 // We skip this test on PCs which does not support SSE3 because this test |
40 // needs it. | 47 // needs it. |
41 base::CPU cpu; | 48 base::CPU cpu; |
42 if (!cpu.has_ssse3()) | 49 if (!cpu.has_ssse3()) |
43 return; | 50 return; |
44 | 51 |
45 // This test checks a subset of all RGB values so this test does not take so | 52 // This test checks a subset of all RGB values so this test does not take so |
46 // long time. | 53 // long time. |
47 const int kStep = 8; | 54 const int kStep = 8; |
48 const int kWidth = 256 / kStep; | 55 const int kWidth = 256 / kStep; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 const uint8* p = &rgb[i * 2 * size]; | 105 const uint8* p = &rgb[i * 2 * size]; |
99 int error = ConvertRGBToV(p, size) - v[i]; | 106 int error = ConvertRGBToV(p, size) - v[i]; |
100 total_error += error > 0 ? error : -error; | 107 total_error += error > 0 ? error : -error; |
101 } | 108 } |
102 } | 109 } |
103 } | 110 } |
104 | 111 |
105 EXPECT_EQ(0, total_error); | 112 EXPECT_EQ(0, total_error); |
106 } | 113 } |
107 } | 114 } |
OLD | NEW |