| 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) { | |
| 117 ASSERT_TRUE(base::CPU().has_mmx()); | |
| 118 | |
| 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) { | 91 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) { |
| 144 ASSERT_TRUE(base::CPU().has_sse()); | 92 ASSERT_TRUE(base::CPU().has_sse()); |
| 145 | 93 |
| 146 const int kSourceDx = 80000; // This value means a scale down. | 94 const int kSourceDx = 80000; // This value means a scale down. |
| 147 | 95 |
| 148 base::TimeTicks start = base::TimeTicks::HighResNow(); | 96 base::TimeTicks start = base::TimeTicks::HighResNow(); |
| 149 for (int i = 0; i < kPerfTestIterations; ++i) { | 97 for (int i = 0; i < kPerfTestIterations; ++i) { |
| 150 for (int row = 0; row < kSourceHeight; ++row) { | 98 for (int row = 0; row < kSourceHeight; ++row) { |
| 151 int chroma_row = row / 2; | 99 int chroma_row = row / 2; |
| 152 ScaleYUVToRGB32Row_SSE( | 100 ScaleYUVToRGB32Row_SSE( |
| 153 yuv_bytes_.get() + row * kSourceWidth, | 101 yuv_bytes_.get() + row * kSourceWidth, |
| 154 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 102 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
| 155 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 103 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
| 156 rgb_bytes_converted_.get(), | 104 rgb_bytes_converted_.get(), |
| 157 kWidth, | 105 kWidth, |
| 158 kSourceDx, | 106 kSourceDx, |
| 159 GetLookupTable(YV12)); | 107 GetLookupTable(YV12)); |
| 160 } | 108 } |
| 161 } | 109 } |
| 162 double total_time_seconds = | 110 double total_time_seconds = |
| 163 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 111 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
| 164 perf_test::PrintResult( | 112 perf_test::PrintResult( |
| 165 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", | 113 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", |
| 166 kPerfTestIterations / total_time_seconds, "runs/s", true); | 114 kPerfTestIterations / total_time_seconds, "runs/s", true); |
| 167 media::EmptyRegisterState(); | 115 media::EmptyRegisterState(); |
| 168 } | 116 } |
| 169 | 117 |
| 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) { | 118 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) { |
| 198 ASSERT_TRUE(base::CPU().has_sse()); | 119 ASSERT_TRUE(base::CPU().has_sse()); |
| 199 | 120 |
| 200 const int kSourceDx = 80000; // This value means a scale down. | 121 const int kSourceDx = 80000; // This value means a scale down. |
| 201 | 122 |
| 202 base::TimeTicks start = base::TimeTicks::HighResNow(); | 123 base::TimeTicks start = base::TimeTicks::HighResNow(); |
| 203 for (int i = 0; i < kPerfTestIterations; ++i) { | 124 for (int i = 0; i < kPerfTestIterations; ++i) { |
| 204 for (int row = 0; row < kSourceHeight; ++row) { | 125 for (int row = 0; row < kSourceHeight; ++row) { |
| 205 int chroma_row = row / 2; | 126 int chroma_row = row / 2; |
| 206 LinearScaleYUVToRGB32Row_SSE( | 127 LinearScaleYUVToRGB32Row_SSE( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 217 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 138 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
| 218 perf_test::PrintResult( | 139 perf_test::PrintResult( |
| 219 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", | 140 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", |
| 220 kPerfTestIterations / total_time_seconds, "runs/s", true); | 141 kPerfTestIterations / total_time_seconds, "runs/s", true); |
| 221 media::EmptyRegisterState(); | 142 media::EmptyRegisterState(); |
| 222 } | 143 } |
| 223 | 144 |
| 224 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) | 145 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) |
| 225 | 146 |
| 226 } // namespace media | 147 } // namespace media |
| OLD | NEW |