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" |
11 #include "media/base/simd/convert_yuv_to_rgb.h" | 11 #include "media/base/simd/convert_yuv_to_rgb.h" |
| 12 #include "media/base/simd/yuv_to_rgb_table.h" |
12 #include "media/base/yuv_convert.h" | 13 #include "media/base/yuv_convert.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "testing/perf/perf_test.h" | 15 #include "testing/perf/perf_test.h" |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 #if !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) | 18 #if !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) |
18 // Size of raw image. | 19 // Size of raw image. |
19 static const int kSourceWidth = 640; | 20 static const int kSourceWidth = 640; |
20 static const int kSourceHeight = 360; | 21 static const int kSourceHeight = 360; |
21 static const int kSourceYSize = kSourceWidth * kSourceHeight; | 22 static const int kSourceYSize = kSourceWidth * kSourceHeight; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 70 |
70 base::TimeTicks start = base::TimeTicks::HighResNow(); | 71 base::TimeTicks start = base::TimeTicks::HighResNow(); |
71 for (int i = 0; i < kPerfTestIterations; ++i) { | 72 for (int i = 0; i < kPerfTestIterations; ++i) { |
72 for (int row = 0; row < kSourceHeight; ++row) { | 73 for (int row = 0; row < kSourceHeight; ++row) { |
73 int chroma_row = row / 2; | 74 int chroma_row = row / 2; |
74 ConvertYUVToRGB32Row_MMX( | 75 ConvertYUVToRGB32Row_MMX( |
75 yuv_bytes_.get() + row * kSourceWidth, | 76 yuv_bytes_.get() + row * kSourceWidth, |
76 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 77 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
77 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 78 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
78 rgb_bytes_converted_.get(), | 79 rgb_bytes_converted_.get(), |
79 kWidth); | 80 kWidth, |
| 81 kCoefficientsRgbY); |
80 } | 82 } |
81 } | 83 } |
82 double total_time_seconds = | 84 double total_time_seconds = |
83 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 85 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
84 perf_test::PrintResult( | 86 perf_test::PrintResult( |
85 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_MMX", | 87 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_MMX", |
86 kPerfTestIterations / total_time_seconds, "runs/s", true); | 88 kPerfTestIterations / total_time_seconds, "runs/s", true); |
87 | 89 |
88 media::EmptyRegisterState(); | 90 media::EmptyRegisterState(); |
89 } | 91 } |
90 | 92 |
91 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { | 93 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { |
92 ASSERT_TRUE(base::CPU().has_sse()); | 94 ASSERT_TRUE(base::CPU().has_sse()); |
93 | 95 |
94 base::TimeTicks start = base::TimeTicks::HighResNow(); | 96 base::TimeTicks start = base::TimeTicks::HighResNow(); |
95 for (int i = 0; i < kPerfTestIterations; ++i) { | 97 for (int i = 0; i < kPerfTestIterations; ++i) { |
96 for (int row = 0; row < kSourceHeight; ++row) { | 98 for (int row = 0; row < kSourceHeight; ++row) { |
97 int chroma_row = row / 2; | 99 int chroma_row = row / 2; |
98 ConvertYUVToRGB32Row_SSE( | 100 ConvertYUVToRGB32Row_SSE( |
99 yuv_bytes_.get() + row * kSourceWidth, | 101 yuv_bytes_.get() + row * kSourceWidth, |
100 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 102 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
101 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 103 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
102 rgb_bytes_converted_.get(), | 104 rgb_bytes_converted_.get(), |
103 kWidth); | 105 kWidth, |
| 106 kCoefficientsRgbY); |
104 } | 107 } |
105 } | 108 } |
106 double total_time_seconds = | 109 double total_time_seconds = |
107 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 110 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
108 perf_test::PrintResult( | 111 perf_test::PrintResult( |
109 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE", | 112 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE", |
110 kPerfTestIterations / total_time_seconds, "runs/s", true); | 113 kPerfTestIterations / total_time_seconds, "runs/s", true); |
111 media::EmptyRegisterState(); | 114 media::EmptyRegisterState(); |
112 } | 115 } |
113 | 116 |
114 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_MMX) { | 117 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_MMX) { |
115 ASSERT_TRUE(base::CPU().has_mmx()); | 118 ASSERT_TRUE(base::CPU().has_mmx()); |
116 | 119 |
117 const int kSourceDx = 80000; // This value means a scale down. | 120 const int kSourceDx = 80000; // This value means a scale down. |
118 | 121 |
119 base::TimeTicks start = base::TimeTicks::HighResNow(); | 122 base::TimeTicks start = base::TimeTicks::HighResNow(); |
120 for (int i = 0; i < kPerfTestIterations; ++i) { | 123 for (int i = 0; i < kPerfTestIterations; ++i) { |
121 for (int row = 0; row < kSourceHeight; ++row) { | 124 for (int row = 0; row < kSourceHeight; ++row) { |
122 int chroma_row = row / 2; | 125 int chroma_row = row / 2; |
123 ScaleYUVToRGB32Row_MMX( | 126 ScaleYUVToRGB32Row_MMX( |
124 yuv_bytes_.get() + row * kSourceWidth, | 127 yuv_bytes_.get() + row * kSourceWidth, |
125 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 128 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
126 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 129 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
127 rgb_bytes_converted_.get(), | 130 rgb_bytes_converted_.get(), |
128 kWidth, | 131 kWidth, |
129 kSourceDx); | 132 kSourceDx, |
| 133 kCoefficientsRgbY); |
130 } | 134 } |
131 } | 135 } |
132 double total_time_seconds = | 136 double total_time_seconds = |
133 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 137 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
134 perf_test::PrintResult( | 138 perf_test::PrintResult( |
135 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_MMX", | 139 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_MMX", |
136 kPerfTestIterations / total_time_seconds, "runs/s", true); | 140 kPerfTestIterations / total_time_seconds, "runs/s", true); |
137 media::EmptyRegisterState(); | 141 media::EmptyRegisterState(); |
138 } | 142 } |
139 | 143 |
140 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) { | 144 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) { |
141 ASSERT_TRUE(base::CPU().has_sse()); | 145 ASSERT_TRUE(base::CPU().has_sse()); |
142 | 146 |
143 const int kSourceDx = 80000; // This value means a scale down. | 147 const int kSourceDx = 80000; // This value means a scale down. |
144 | 148 |
145 base::TimeTicks start = base::TimeTicks::HighResNow(); | 149 base::TimeTicks start = base::TimeTicks::HighResNow(); |
146 for (int i = 0; i < kPerfTestIterations; ++i) { | 150 for (int i = 0; i < kPerfTestIterations; ++i) { |
147 for (int row = 0; row < kSourceHeight; ++row) { | 151 for (int row = 0; row < kSourceHeight; ++row) { |
148 int chroma_row = row / 2; | 152 int chroma_row = row / 2; |
149 ScaleYUVToRGB32Row_SSE( | 153 ScaleYUVToRGB32Row_SSE( |
150 yuv_bytes_.get() + row * kSourceWidth, | 154 yuv_bytes_.get() + row * kSourceWidth, |
151 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 155 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
152 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 156 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
153 rgb_bytes_converted_.get(), | 157 rgb_bytes_converted_.get(), |
154 kWidth, | 158 kWidth, |
155 kSourceDx); | 159 kSourceDx, |
| 160 kCoefficientsRgbY); |
156 } | 161 } |
157 } | 162 } |
158 double total_time_seconds = | 163 double total_time_seconds = |
159 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 164 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
160 perf_test::PrintResult( | 165 perf_test::PrintResult( |
161 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", | 166 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", |
162 kPerfTestIterations / total_time_seconds, "runs/s", true); | 167 kPerfTestIterations / total_time_seconds, "runs/s", true); |
163 media::EmptyRegisterState(); | 168 media::EmptyRegisterState(); |
164 } | 169 } |
165 | 170 |
166 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_MMX) { | 171 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_MMX) { |
167 ASSERT_TRUE(base::CPU().has_mmx()); | 172 ASSERT_TRUE(base::CPU().has_mmx()); |
168 | 173 |
169 const int kSourceDx = 80000; // This value means a scale down. | 174 const int kSourceDx = 80000; // This value means a scale down. |
170 | 175 |
171 base::TimeTicks start = base::TimeTicks::HighResNow(); | 176 base::TimeTicks start = base::TimeTicks::HighResNow(); |
172 for (int i = 0; i < kPerfTestIterations; ++i) { | 177 for (int i = 0; i < kPerfTestIterations; ++i) { |
173 for (int row = 0; row < kSourceHeight; ++row) { | 178 for (int row = 0; row < kSourceHeight; ++row) { |
174 int chroma_row = row / 2; | 179 int chroma_row = row / 2; |
175 LinearScaleYUVToRGB32Row_MMX( | 180 LinearScaleYUVToRGB32Row_MMX( |
176 yuv_bytes_.get() + row * kSourceWidth, | 181 yuv_bytes_.get() + row * kSourceWidth, |
177 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 182 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
178 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 183 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
179 rgb_bytes_converted_.get(), | 184 rgb_bytes_converted_.get(), |
180 kWidth, | 185 kWidth, |
181 kSourceDx); | 186 kSourceDx, |
| 187 kCoefficientsRgbY); |
182 } | 188 } |
183 } | 189 } |
184 double total_time_seconds = | 190 double total_time_seconds = |
185 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 191 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
186 perf_test::PrintResult( | 192 perf_test::PrintResult( |
187 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_MMX", | 193 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_MMX", |
188 kPerfTestIterations / total_time_seconds, "runs/s", true); | 194 kPerfTestIterations / total_time_seconds, "runs/s", true); |
189 media::EmptyRegisterState(); | 195 media::EmptyRegisterState(); |
190 } | 196 } |
191 | 197 |
192 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) { | 198 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) { |
193 ASSERT_TRUE(base::CPU().has_sse()); | 199 ASSERT_TRUE(base::CPU().has_sse()); |
194 | 200 |
195 const int kSourceDx = 80000; // This value means a scale down. | 201 const int kSourceDx = 80000; // This value means a scale down. |
196 | 202 |
197 base::TimeTicks start = base::TimeTicks::HighResNow(); | 203 base::TimeTicks start = base::TimeTicks::HighResNow(); |
198 for (int i = 0; i < kPerfTestIterations; ++i) { | 204 for (int i = 0; i < kPerfTestIterations; ++i) { |
199 for (int row = 0; row < kSourceHeight; ++row) { | 205 for (int row = 0; row < kSourceHeight; ++row) { |
200 int chroma_row = row / 2; | 206 int chroma_row = row / 2; |
201 LinearScaleYUVToRGB32Row_SSE( | 207 LinearScaleYUVToRGB32Row_SSE( |
202 yuv_bytes_.get() + row * kSourceWidth, | 208 yuv_bytes_.get() + row * kSourceWidth, |
203 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), | 209 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), |
204 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), | 210 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), |
205 rgb_bytes_converted_.get(), | 211 rgb_bytes_converted_.get(), |
206 kWidth, | 212 kWidth, |
207 kSourceDx); | 213 kSourceDx, |
| 214 kCoefficientsRgbY); |
208 } | 215 } |
209 } | 216 } |
210 double total_time_seconds = | 217 double total_time_seconds = |
211 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 218 (base::TimeTicks::HighResNow() - start).InSecondsF(); |
212 perf_test::PrintResult( | 219 perf_test::PrintResult( |
213 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", | 220 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", |
214 kPerfTestIterations / total_time_seconds, "runs/s", true); | 221 kPerfTestIterations / total_time_seconds, "runs/s", true); |
215 media::EmptyRegisterState(); | 222 media::EmptyRegisterState(); |
216 } | 223 } |
217 | 224 |
218 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) | 225 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) |
219 | 226 |
220 } // namespace media | 227 } // namespace media |
OLD | NEW |