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