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