| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 CHECK_EQ(bytes_read, kYUV12Size); | 57 CHECK_EQ(bytes_read, kYUV12Size); |
| 58 } | 58 } |
| 59 | 59 |
| 60 scoped_ptr<uint8[]> yuv_bytes_; | 60 scoped_ptr<uint8[]> yuv_bytes_; |
| 61 scoped_ptr<uint8[]> rgb_bytes_converted_; | 61 scoped_ptr<uint8[]> rgb_bytes_converted_; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest); | 64 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_MMX) { | |
| 68 ASSERT_TRUE(base::CPU().has_mmx()); | |
| 69 | |
| 70 base::TimeTicks start = base::TimeTicks::HighResNow(); | |
| 71 for (int i = 0; i < kPerfTestIterations; ++i) { | |
| 72 for (int row = 0; row < kSourceHeight; ++row) { | |
| 73 int chroma_row = row / 2; | |
| 74 ConvertYUVToRGB32Row_MMX( | |
| 75 yuv_bytes_.get() + row * kSourceWidth, | |
| 76 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | |
| 77 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | |
| 78 rgb_bytes_converted_.get(), | |
| 79 kWidth, | |
| 80 GetLookupTable(YV12)); | |
| 81 } | |
| 82 } | |
| 83 double total_time_seconds = | |
| 84 (base::TimeTicks::HighResNow() - start).InSecondsF(); | |
| 85 perf_test::PrintResult( | |
| 86 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_MMX", | |
| 87 kPerfTestIterations / total_time_seconds, "runs/s", true); | |
| 88 | |
| 89 media::EmptyRegisterState(); | |
| 90 } | |
| 91 | |
| 92 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { | 67 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { |
| 93 ASSERT_TRUE(base::CPU().has_sse()); | 68 ASSERT_TRUE(base::CPU().has_sse()); |
| 94 | 69 |
| 95 base::TimeTicks start = base::TimeTicks::HighResNow(); | 70 base::TimeTicks start = base::TimeTicks::HighResNow(); |
| 96 for (int i = 0; i < kPerfTestIterations; ++i) { | 71 for (int i = 0; i < kPerfTestIterations; ++i) { |
| 97 for (int row = 0; row < kSourceHeight; ++row) { | 72 for (int row = 0; row < kSourceHeight; ++row) { |
| 98 int chroma_row = row / 2; | 73 int chroma_row = row / 2; |
| 99 ConvertYUVToRGB32Row_SSE( | 74 ConvertYUVToRGB32Row_SSE( |
| 100 yuv_bytes_.get() + row * kSourceWidth, | 75 yuv_bytes_.get() + row * kSourceWidth, |
| 101 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 76 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
| 102 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 77 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
| 103 rgb_bytes_converted_.get(), | 78 rgb_bytes_converted_.get(), |
| 104 kWidth, | 79 kWidth, |
| 105 GetLookupTable(YV12)); | 80 GetLookupTable(YV12)); |
| 106 } | 81 } |
| 107 } | 82 } |
| 108 double total_time_seconds = | 83 double total_time_seconds = |
| 109 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 84 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
| 110 perf_test::PrintResult( | 85 perf_test::PrintResult( |
| 111 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE", | 86 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE", |
| 112 kPerfTestIterations / total_time_seconds, "runs/s", true); | 87 kPerfTestIterations / total_time_seconds, "runs/s", true); |
| 113 media::EmptyRegisterState(); | 88 media::EmptyRegisterState(); |
| 114 } | 89 } |
| 115 | 90 |
| 116 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_MMX) { | 91 // 64-bit release + component builds on Windows are too smart and optimizes |
| 117 ASSERT_TRUE(base::CPU().has_mmx()); | 92 // away the function being tested. |
| 118 | 93 #if defined(OS_WIN) && (defined(ARCH_CPU_X86) || !defined(COMPONENT_BUILD)) |
| 119 const int kSourceDx = 80000; // This value means a scale down. | |
| 120 | |
| 121 base::TimeTicks start = base::TimeTicks::HighResNow(); | |
| 122 for (int i = 0; i < kPerfTestIterations; ++i) { | |
| 123 for (int row = 0; row < kSourceHeight; ++row) { | |
| 124 int chroma_row = row / 2; | |
| 125 ScaleYUVToRGB32Row_MMX( | |
| 126 yuv_bytes_.get() + row * kSourceWidth, | |
| 127 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | |
| 128 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | |
| 129 rgb_bytes_converted_.get(), | |
| 130 kWidth, | |
| 131 kSourceDx, | |
| 132 GetLookupTable(YV12)); | |
| 133 } | |
| 134 } | |
| 135 double total_time_seconds = | |
| 136 (base::TimeTicks::HighResNow() - start).InSecondsF(); | |
| 137 perf_test::PrintResult( | |
| 138 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_MMX", | |
| 139 kPerfTestIterations / total_time_seconds, "runs/s", true); | |
| 140 media::EmptyRegisterState(); | |
| 141 } | |
| 142 | |
| 143 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) { | 94 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) { |
| 144 ASSERT_TRUE(base::CPU().has_sse()); | 95 ASSERT_TRUE(base::CPU().has_sse()); |
| 145 | 96 |
| 146 const int kSourceDx = 80000; // This value means a scale down. | 97 const int kSourceDx = 80000; // This value means a scale down. |
| 147 | 98 |
| 148 base::TimeTicks start = base::TimeTicks::HighResNow(); | 99 base::TimeTicks start = base::TimeTicks::HighResNow(); |
| 149 for (int i = 0; i < kPerfTestIterations; ++i) { | 100 for (int i = 0; i < kPerfTestIterations; ++i) { |
| 150 for (int row = 0; row < kSourceHeight; ++row) { | 101 for (int row = 0; row < kSourceHeight; ++row) { |
| 151 int chroma_row = row / 2; | 102 int chroma_row = row / 2; |
| 152 ScaleYUVToRGB32Row_SSE( | 103 ScaleYUVToRGB32Row_SSE( |
| 153 yuv_bytes_.get() + row * kSourceWidth, | 104 yuv_bytes_.get() + row * kSourceWidth, |
| 154 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 105 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
| 155 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 106 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
| 156 rgb_bytes_converted_.get(), | 107 rgb_bytes_converted_.get(), |
| 157 kWidth, | 108 kWidth, |
| 158 kSourceDx, | 109 kSourceDx, |
| 159 GetLookupTable(YV12)); | 110 GetLookupTable(YV12)); |
| 160 } | 111 } |
| 161 } | 112 } |
| 162 double total_time_seconds = | 113 double total_time_seconds = |
| 163 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 114 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
| 164 perf_test::PrintResult( | 115 perf_test::PrintResult( |
| 165 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", | 116 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", |
| 166 kPerfTestIterations / total_time_seconds, "runs/s", true); | 117 kPerfTestIterations / total_time_seconds, "runs/s", true); |
| 167 media::EmptyRegisterState(); | 118 media::EmptyRegisterState(); |
| 168 } | 119 } |
| 169 | 120 |
| 170 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_MMX) { | |
| 171 ASSERT_TRUE(base::CPU().has_mmx()); | |
| 172 | |
| 173 const int kSourceDx = 80000; // This value means a scale down. | |
| 174 | |
| 175 base::TimeTicks start = base::TimeTicks::HighResNow(); | |
| 176 for (int i = 0; i < kPerfTestIterations; ++i) { | |
| 177 for (int row = 0; row < kSourceHeight; ++row) { | |
| 178 int chroma_row = row / 2; | |
| 179 LinearScaleYUVToRGB32Row_MMX( | |
| 180 yuv_bytes_.get() + row * kSourceWidth, | |
| 181 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | |
| 182 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | |
| 183 rgb_bytes_converted_.get(), | |
| 184 kWidth, | |
| 185 kSourceDx, | |
| 186 GetLookupTable(YV12)); | |
| 187 } | |
| 188 } | |
| 189 double total_time_seconds = | |
| 190 (base::TimeTicks::HighResNow() - start).InSecondsF(); | |
| 191 perf_test::PrintResult( | |
| 192 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_MMX", | |
| 193 kPerfTestIterations / total_time_seconds, "runs/s", true); | |
| 194 media::EmptyRegisterState(); | |
| 195 } | |
| 196 | |
| 197 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) { | 121 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) { |
| 198 ASSERT_TRUE(base::CPU().has_sse()); | 122 ASSERT_TRUE(base::CPU().has_sse()); |
| 199 | 123 |
| 200 const int kSourceDx = 80000; // This value means a scale down. | 124 const int kSourceDx = 80000; // This value means a scale down. |
| 201 | 125 |
| 202 base::TimeTicks start = base::TimeTicks::HighResNow(); | 126 base::TimeTicks start = base::TimeTicks::HighResNow(); |
| 203 for (int i = 0; i < kPerfTestIterations; ++i) { | 127 for (int i = 0; i < kPerfTestIterations; ++i) { |
| 204 for (int row = 0; row < kSourceHeight; ++row) { | 128 for (int row = 0; row < kSourceHeight; ++row) { |
| 205 int chroma_row = row / 2; | 129 int chroma_row = row / 2; |
| 206 LinearScaleYUVToRGB32Row_SSE( | 130 LinearScaleYUVToRGB32Row_SSE( |
| 207 yuv_bytes_.get() + row * kSourceWidth, | 131 yuv_bytes_.get() + row * kSourceWidth, |
| 208 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 132 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
| 209 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 133 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
| 210 rgb_bytes_converted_.get(), | 134 rgb_bytes_converted_.get(), |
| 211 kWidth, | 135 kWidth, |
| 212 kSourceDx, | 136 kSourceDx, |
| 213 GetLookupTable(YV12)); | 137 GetLookupTable(YV12)); |
| 214 } | 138 } |
| 215 } | 139 } |
| 216 double total_time_seconds = | 140 double total_time_seconds = |
| 217 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 141 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
| 218 perf_test::PrintResult( | 142 perf_test::PrintResult( |
| 219 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", | 143 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", |
| 220 kPerfTestIterations / total_time_seconds, "runs/s", true); | 144 kPerfTestIterations / total_time_seconds, "runs/s", true); |
| 221 media::EmptyRegisterState(); | 145 media::EmptyRegisterState(); |
| 222 } | 146 } |
| 147 #endif // defined(OS_WIN) && (ARCH_CPU_X86 || COMPONENT_BUILD) |
| 223 | 148 |
| 224 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) | 149 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) |
| 225 | 150 |
| 226 } // namespace media | 151 } // namespace media |
| OLD | NEW |