OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Rotation should be exact. | 75 // Rotation should be exact. |
76 for (int i = 0; i < dst_i420_size; ++i) { | 76 for (int i = 0; i < dst_i420_size; ++i) { |
77 EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]); | 77 EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]); |
78 } | 78 } |
79 | 79 |
80 free_aligned_buffer_64(dst_i420_c); | 80 free_aligned_buffer_64(dst_i420_c); |
81 free_aligned_buffer_64(dst_i420_opt); | 81 free_aligned_buffer_64(dst_i420_opt); |
82 free_aligned_buffer_64(src_i420); | 82 free_aligned_buffer_64(src_i420); |
83 } | 83 } |
84 | 84 |
85 TEST_F(libyuvTest, I420Rotate0) { | 85 TEST_F(LibYUVRotateTest, I420Rotate0) { |
86 I420TestRotate(benchmark_width_, benchmark_height_, | 86 I420TestRotate(benchmark_width_, benchmark_height_, |
87 benchmark_width_, benchmark_height_, | 87 benchmark_width_, benchmark_height_, |
88 kRotate0, benchmark_iterations_, disable_cpu_flags_); | 88 kRotate0, benchmark_iterations_, disable_cpu_flags_); |
89 } | 89 } |
90 | 90 |
91 TEST_F(libyuvTest, I420Rotate90) { | 91 TEST_F(LibYUVRotateTest, I420Rotate90) { |
92 I420TestRotate(benchmark_width_, benchmark_height_, | 92 I420TestRotate(benchmark_width_, benchmark_height_, |
93 benchmark_height_, benchmark_width_, | 93 benchmark_height_, benchmark_width_, |
94 kRotate90, benchmark_iterations_, disable_cpu_flags_); | 94 kRotate90, benchmark_iterations_, disable_cpu_flags_); |
95 } | 95 } |
96 | 96 |
97 TEST_F(libyuvTest, I420Rotate180) { | 97 TEST_F(LibYUVRotateTest, I420Rotate180) { |
98 I420TestRotate(benchmark_width_, benchmark_height_, | 98 I420TestRotate(benchmark_width_, benchmark_height_, |
99 benchmark_width_, benchmark_height_, | 99 benchmark_width_, benchmark_height_, |
100 kRotate180, benchmark_iterations_, disable_cpu_flags_); | 100 kRotate180, benchmark_iterations_, disable_cpu_flags_); |
101 } | 101 } |
102 | 102 |
103 TEST_F(libyuvTest, I420Rotate270) { | 103 TEST_F(LibYUVRotateTest, I420Rotate270) { |
104 I420TestRotate(benchmark_width_, benchmark_height_, | 104 I420TestRotate(benchmark_width_, benchmark_height_, |
105 benchmark_height_, benchmark_width_, | 105 benchmark_height_, benchmark_width_, |
106 kRotate270, benchmark_iterations_, disable_cpu_flags_); | 106 kRotate270, benchmark_iterations_, disable_cpu_flags_); |
107 } | 107 } |
108 | 108 |
109 TEST_F(libyuvTest, I420Rotate0_Odd) { | 109 TEST_F(LibYUVRotateTest, I420Rotate0_Odd) { |
110 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 110 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
111 benchmark_width_ - 3, benchmark_height_ - 1, | 111 benchmark_width_ - 3, benchmark_height_ - 1, |
112 kRotate0, benchmark_iterations_, disable_cpu_flags_); | 112 kRotate0, benchmark_iterations_, disable_cpu_flags_); |
113 } | 113 } |
114 | 114 |
115 TEST_F(libyuvTest, I420Rotate90_Odd) { | 115 TEST_F(LibYUVRotateTest, I420Rotate90_Odd) { |
116 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 116 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
117 benchmark_height_ - 1, benchmark_width_ - 3, | 117 benchmark_height_ - 1, benchmark_width_ - 3, |
118 kRotate90, benchmark_iterations_, disable_cpu_flags_); | 118 kRotate90, benchmark_iterations_, disable_cpu_flags_); |
119 } | 119 } |
120 | 120 |
121 TEST_F(libyuvTest, I420Rotate180_Odd) { | 121 TEST_F(LibYUVRotateTest, I420Rotate180_Odd) { |
122 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 122 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
123 benchmark_width_ - 3, benchmark_height_ - 1, | 123 benchmark_width_ - 3, benchmark_height_ - 1, |
124 kRotate180, benchmark_iterations_, disable_cpu_flags_); | 124 kRotate180, benchmark_iterations_, disable_cpu_flags_); |
125 } | 125 } |
126 | 126 |
127 TEST_F(libyuvTest, I420Rotate270_Odd) { | 127 TEST_F(LibYUVRotateTest, I420Rotate270_Odd) { |
128 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 128 I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
129 benchmark_height_ - 1, benchmark_width_ - 3, | 129 benchmark_height_ - 1, benchmark_width_ - 3, |
130 kRotate270, benchmark_iterations_, disable_cpu_flags_); | 130 kRotate270, benchmark_iterations_, disable_cpu_flags_); |
131 } | 131 } |
132 | 132 |
133 static void NV12TestRotate(int src_width, int src_height, | 133 static void NV12TestRotate(int src_width, int src_height, |
134 int dst_width, int dst_height, | 134 int dst_width, int dst_height, |
135 libyuv::RotationMode mode, | 135 libyuv::RotationMode mode, |
136 int benchmark_iterations, int disable_cpu_flags) { | 136 int benchmark_iterations, int disable_cpu_flags) { |
137 if (src_width < 1) { | 137 if (src_width < 1) { |
138 src_width = 1; | 138 src_width = 1; |
139 } | 139 } |
140 if (src_height == 0) { // allow negative for inversion test. | 140 if (src_height == 0) { // allow negative for inversion test. |
141 src_height = 1; | 141 src_height = 1; |
142 } | 142 } |
143 if (dst_width < 1) { | 143 if (dst_width < 1) { |
144 dst_width = 1; | 144 dst_width = 1; |
145 } | 145 } |
146 if (dst_height < 1) { | 146 if (dst_height < 1) { |
147 dst_height = 1; | 147 dst_height = 1; |
148 } | 148 } |
149 int src_nv12_y_size = src_width * Abs(src_height); | 149 int src_nv12_y_size = src_width * Abs(src_height); |
150 int src_nv12_uv_size = ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2) * 2
; | 150 int src_nv12_uv_size = |
| 151 ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2) * 2; |
151 int src_nv12_size = src_nv12_y_size + src_nv12_uv_size; | 152 int src_nv12_size = src_nv12_y_size + src_nv12_uv_size; |
152 align_buffer_64(src_nv12, src_nv12_size); | 153 align_buffer_64(src_nv12, src_nv12_size); |
153 for (int i = 0; i < src_nv12_size; ++i) { | 154 for (int i = 0; i < src_nv12_size; ++i) { |
154 src_nv12[i] = fastrand() & 0xff; | 155 src_nv12[i] = fastrand() & 0xff; |
155 } | 156 } |
156 | 157 |
157 int dst_i420_y_size = dst_width * dst_height; | 158 int dst_i420_y_size = dst_width * dst_height; |
158 int dst_i420_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2); | 159 int dst_i420_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2); |
159 int dst_i420_size = dst_i420_y_size + dst_i420_uv_size * 2; | 160 int dst_i420_size = dst_i420_y_size + dst_i420_uv_size * 2; |
160 align_buffer_64(dst_i420_c, dst_i420_size); | 161 align_buffer_64(dst_i420_c, dst_i420_size); |
(...skipping 24 matching lines...) Expand all Loading... |
185 // Rotation should be exact. | 186 // Rotation should be exact. |
186 for (int i = 0; i < dst_i420_size; ++i) { | 187 for (int i = 0; i < dst_i420_size; ++i) { |
187 EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]); | 188 EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]); |
188 } | 189 } |
189 | 190 |
190 free_aligned_buffer_64(dst_i420_c); | 191 free_aligned_buffer_64(dst_i420_c); |
191 free_aligned_buffer_64(dst_i420_opt); | 192 free_aligned_buffer_64(dst_i420_opt); |
192 free_aligned_buffer_64(src_nv12); | 193 free_aligned_buffer_64(src_nv12); |
193 } | 194 } |
194 | 195 |
195 TEST_F(libyuvTest, NV12Rotate0) { | 196 TEST_F(LibYUVRotateTest, NV12Rotate0) { |
196 NV12TestRotate(benchmark_width_, benchmark_height_, | 197 NV12TestRotate(benchmark_width_, benchmark_height_, |
197 benchmark_width_, benchmark_height_, | 198 benchmark_width_, benchmark_height_, |
198 kRotate0, benchmark_iterations_, disable_cpu_flags_); | 199 kRotate0, benchmark_iterations_, disable_cpu_flags_); |
199 } | 200 } |
200 | 201 |
201 TEST_F(libyuvTest, NV12Rotate90) { | 202 TEST_F(LibYUVRotateTest, NV12Rotate90) { |
202 NV12TestRotate(benchmark_width_, benchmark_height_, | 203 NV12TestRotate(benchmark_width_, benchmark_height_, |
203 benchmark_height_, benchmark_width_, | 204 benchmark_height_, benchmark_width_, |
204 kRotate90, benchmark_iterations_, disable_cpu_flags_); | 205 kRotate90, benchmark_iterations_, disable_cpu_flags_); |
205 } | 206 } |
206 | 207 |
207 TEST_F(libyuvTest, NV12Rotate180) { | 208 TEST_F(LibYUVRotateTest, NV12Rotate180) { |
208 NV12TestRotate(benchmark_width_, benchmark_height_, | 209 NV12TestRotate(benchmark_width_, benchmark_height_, |
209 benchmark_width_, benchmark_height_, | 210 benchmark_width_, benchmark_height_, |
210 kRotate180, benchmark_iterations_, disable_cpu_flags_); | 211 kRotate180, benchmark_iterations_, disable_cpu_flags_); |
211 } | 212 } |
212 | 213 |
213 TEST_F(libyuvTest, NV12Rotate270) { | 214 TEST_F(LibYUVRotateTest, NV12Rotate270) { |
214 NV12TestRotate(benchmark_width_, benchmark_height_, | 215 NV12TestRotate(benchmark_width_, benchmark_height_, |
215 benchmark_height_, benchmark_width_, | 216 benchmark_height_, benchmark_width_, |
216 kRotate270, benchmark_iterations_, disable_cpu_flags_); | 217 kRotate270, benchmark_iterations_, disable_cpu_flags_); |
217 } | 218 } |
218 | 219 |
219 TEST_F(libyuvTest, NV12Rotate0_Odd) { | 220 TEST_F(LibYUVRotateTest, NV12Rotate0_Odd) { |
220 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 221 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
221 benchmark_width_ - 3, benchmark_height_ - 1, | 222 benchmark_width_ - 3, benchmark_height_ - 1, |
222 kRotate0, benchmark_iterations_, disable_cpu_flags_); | 223 kRotate0, benchmark_iterations_, disable_cpu_flags_); |
223 } | 224 } |
224 | 225 |
225 TEST_F(libyuvTest, NV12Rotate90_Odd) { | 226 TEST_F(LibYUVRotateTest, NV12Rotate90_Odd) { |
226 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 227 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
227 benchmark_height_ - 1, benchmark_width_ - 3, | 228 benchmark_height_ - 1, benchmark_width_ - 3, |
228 kRotate90, benchmark_iterations_, disable_cpu_flags_); | 229 kRotate90, benchmark_iterations_, disable_cpu_flags_); |
229 } | 230 } |
230 | 231 |
231 TEST_F(libyuvTest, NV12Rotate180_Odd) { | 232 TEST_F(LibYUVRotateTest, NV12Rotate180_Odd) { |
232 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 233 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
233 benchmark_width_ - 3, benchmark_height_ - 1, | 234 benchmark_width_ - 3, benchmark_height_ - 1, |
234 kRotate180, benchmark_iterations_, disable_cpu_flags_); | 235 kRotate180, benchmark_iterations_, disable_cpu_flags_); |
235 } | 236 } |
236 | 237 |
237 TEST_F(libyuvTest, NV12Rotate270_Odd) { | 238 TEST_F(LibYUVRotateTest, NV12Rotate270_Odd) { |
238 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, | 239 NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, |
239 benchmark_height_ - 1, benchmark_width_ - 3, | 240 benchmark_height_ - 1, benchmark_width_ - 3, |
240 kRotate270, benchmark_iterations_, disable_cpu_flags_); | 241 kRotate270, benchmark_iterations_, disable_cpu_flags_); |
241 } | 242 } |
242 | 243 |
243 TEST_F(libyuvTest, NV12Rotate0_Inverted) { | 244 TEST_F(LibYUVRotateTest, NV12Rotate0_Inverted) { |
244 NV12TestRotate(benchmark_width_, -benchmark_height_, | 245 NV12TestRotate(benchmark_width_, -benchmark_height_, |
245 benchmark_width_, benchmark_height_, | 246 benchmark_width_, benchmark_height_, |
246 kRotate0, benchmark_iterations_, disable_cpu_flags_); | 247 kRotate0, benchmark_iterations_, disable_cpu_flags_); |
247 } | 248 } |
248 | 249 |
249 TEST_F(libyuvTest, NV12Rotate90_Inverted) { | 250 TEST_F(LibYUVRotateTest, NV12Rotate90_Inverted) { |
250 NV12TestRotate(benchmark_width_, -benchmark_height_, | 251 NV12TestRotate(benchmark_width_, -benchmark_height_, |
251 benchmark_height_, benchmark_width_, | 252 benchmark_height_, benchmark_width_, |
252 kRotate90, benchmark_iterations_, disable_cpu_flags_); | 253 kRotate90, benchmark_iterations_, disable_cpu_flags_); |
253 } | 254 } |
254 | 255 |
255 TEST_F(libyuvTest, NV12Rotate180_Inverted) { | 256 TEST_F(LibYUVRotateTest, NV12Rotate180_Inverted) { |
256 NV12TestRotate(benchmark_width_, -benchmark_height_, | 257 NV12TestRotate(benchmark_width_, -benchmark_height_, |
257 benchmark_width_, benchmark_height_, | 258 benchmark_width_, benchmark_height_, |
258 kRotate180, benchmark_iterations_, disable_cpu_flags_); | 259 kRotate180, benchmark_iterations_, disable_cpu_flags_); |
259 } | 260 } |
260 | 261 |
261 TEST_F(libyuvTest, NV12Rotate270_Inverted) { | 262 TEST_F(LibYUVRotateTest, NV12Rotate270_Inverted) { |
262 NV12TestRotate(benchmark_width_, -benchmark_height_, | 263 NV12TestRotate(benchmark_width_, -benchmark_height_, |
263 benchmark_height_, benchmark_width_, | 264 benchmark_height_, benchmark_width_, |
264 kRotate270, benchmark_iterations_, disable_cpu_flags_); | 265 kRotate270, benchmark_iterations_, disable_cpu_flags_); |
265 } | 266 } |
266 | 267 |
267 | 268 |
268 | 269 |
269 | 270 |
270 | 271 |
271 } // namespace libyuv | 272 } // namespace libyuv |
OLD | NEW |