Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: unit_test/scale_argb_test.cc

Issue 1399523004: break up unittests into categories (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: bump version Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « unit_test/rotate_test.cc ('k') | unit_test/scale_color_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 free_aligned_buffer_64(dst_argb_c); 209 free_aligned_buffer_64(dst_argb_c);
210 free_aligned_buffer_64(dst_argb_opt); 210 free_aligned_buffer_64(dst_argb_opt);
211 free_aligned_buffer_64(src_argb); 211 free_aligned_buffer_64(src_argb);
212 return max_diff; 212 return max_diff;
213 } 213 }
214 214
215 // The following adjustments in dimensions ensure the scale factor will be 215 // The following adjustments in dimensions ensure the scale factor will be
216 // exactly achieved. 216 // exactly achieved.
217 #define DX(x, nom, denom) ((int)(Abs(x) / nom) * nom) 217 #define DX(x, nom, denom) static_cast<int>((Abs(x) / nom) * nom)
218 #define SX(x, nom, denom) ((int)(x / nom) * denom) 218 #define SX(x, nom, denom) static_cast<int>((x / nom) * denom)
219 219
220 #define TEST_FACTOR1(name, filter, nom, denom, max_diff) \ 220 #define TEST_FACTOR1(name, filter, nom, denom, max_diff) \
221 TEST_F(libyuvTest, ARGBScaleDownBy##name##_##filter) { \ 221 TEST_F(LibYUVScaleTest, ARGBScaleDownBy##name##_##filter) { \
222 int diff = ARGBTestFilter(SX(benchmark_width_, nom, denom), \ 222 int diff = ARGBTestFilter(SX(benchmark_width_, nom, denom), \
223 SX(benchmark_height_, nom, denom), \ 223 SX(benchmark_height_, nom, denom), \
224 DX(benchmark_width_, nom, denom), \ 224 DX(benchmark_width_, nom, denom), \
225 DX(benchmark_height_, nom, denom), \ 225 DX(benchmark_height_, nom, denom), \
226 kFilter##filter, benchmark_iterations_, \ 226 kFilter##filter, benchmark_iterations_, \
227 disable_cpu_flags_); \ 227 disable_cpu_flags_); \
228 EXPECT_LE(diff, max_diff); \ 228 EXPECT_LE(diff, max_diff); \
229 } \ 229 } \
230 TEST_F(libyuvTest, ARGBScaleDownClipBy##name##_##filter) { \ 230 TEST_F(LibYUVScaleTest, ARGBScaleDownClipBy##name##_##filter) { \
231 int diff = ARGBClipTestFilter(SX(benchmark_width_, nom, denom), \ 231 int diff = ARGBClipTestFilter(SX(benchmark_width_, nom, denom), \
232 SX(benchmark_height_, nom, denom), \ 232 SX(benchmark_height_, nom, denom), \
233 DX(benchmark_width_, nom, denom), \ 233 DX(benchmark_width_, nom, denom), \
234 DX(benchmark_height_, nom, denom), \ 234 DX(benchmark_height_, nom, denom), \
235 kFilter##filter, benchmark_iterations_); \ 235 kFilter##filter, benchmark_iterations_); \
236 EXPECT_LE(diff, max_diff); \ 236 EXPECT_LE(diff, max_diff); \
237 } 237 }
238 238
239 // Test a scale factor with all 4 filters. Expect unfiltered to be exact, but 239 // Test a scale factor with all 4 filters. Expect unfiltered to be exact, but
240 // filtering is different fixed point implementations for SSSE3, Neon and C. 240 // filtering is different fixed point implementations for SSSE3, Neon and C.
241 #define TEST_FACTOR(name, nom, denom) \ 241 #define TEST_FACTOR(name, nom, denom) \
242 TEST_FACTOR1(name, None, nom, denom, 0) \ 242 TEST_FACTOR1(name, None, nom, denom, 0) \
243 TEST_FACTOR1(name, Linear, nom, denom, 3) \ 243 TEST_FACTOR1(name, Linear, nom, denom, 3) \
244 TEST_FACTOR1(name, Bilinear, nom, denom, 3) \ 244 TEST_FACTOR1(name, Bilinear, nom, denom, 3) \
245 TEST_FACTOR1(name, Box, nom, denom, 3) 245 TEST_FACTOR1(name, Box, nom, denom, 3)
246 246
247 TEST_FACTOR(2, 1, 2) 247 TEST_FACTOR(2, 1, 2)
248 TEST_FACTOR(4, 1, 4) 248 TEST_FACTOR(4, 1, 4)
249 TEST_FACTOR(8, 1, 8) 249 TEST_FACTOR(8, 1, 8)
250 TEST_FACTOR(3by4, 3, 4) 250 TEST_FACTOR(3by4, 3, 4)
251 TEST_FACTOR(3by8, 3, 8) 251 TEST_FACTOR(3by8, 3, 8)
252 TEST_FACTOR(3, 1, 3) 252 TEST_FACTOR(3, 1, 3)
253 #undef TEST_FACTOR1 253 #undef TEST_FACTOR1
254 #undef TEST_FACTOR 254 #undef TEST_FACTOR
255 #undef SX 255 #undef SX
256 #undef DX 256 #undef DX
257 257
258 #define TEST_SCALETO1(name, width, height, filter, max_diff) \ 258 #define TEST_SCALETO1(name, width, height, filter, max_diff) \
259 TEST_F(libyuvTest, name##To##width##x##height##_##filter) { \ 259 TEST_F(LibYUVScaleTest, name##To##width##x##height##_##filter) { \
260 int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \ 260 int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \
261 width, height, \ 261 width, height, \
262 kFilter##filter, benchmark_iterations_, \ 262 kFilter##filter, benchmark_iterations_, \
263 disable_cpu_flags_); \ 263 disable_cpu_flags_); \
264 EXPECT_LE(diff, max_diff); \ 264 EXPECT_LE(diff, max_diff); \
265 } \ 265 } \
266 TEST_F(libyuvTest, name##From##width##x##height##_##filter) { \ 266 TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) { \
267 int diff = ARGBTestFilter(width, height, \ 267 int diff = ARGBTestFilter(width, height, \
268 Abs(benchmark_width_), Abs(benchmark_height_), \ 268 Abs(benchmark_width_), Abs(benchmark_height_), \
269 kFilter##filter, benchmark_iterations_, \ 269 kFilter##filter, benchmark_iterations_, \
270 disable_cpu_flags_); \ 270 disable_cpu_flags_); \
271 EXPECT_LE(diff, max_diff); \ 271 EXPECT_LE(diff, max_diff); \
272 } \ 272 } \
273 TEST_F(libyuvTest, name##ClipTo##width##x##height##_##filter) { \ 273 TEST_F(LibYUVScaleTest, name##ClipTo##width##x##height##_##filter) { \
274 int diff = ARGBClipTestFilter(benchmark_width_, benchmark_height_, \ 274 int diff = ARGBClipTestFilter(benchmark_width_, benchmark_height_, \
275 width, height, \ 275 width, height, \
276 kFilter##filter, benchmark_iterations_); \ 276 kFilter##filter, benchmark_iterations_); \
277 EXPECT_LE(diff, max_diff); \ 277 EXPECT_LE(diff, max_diff); \
278 } \ 278 } \
279 TEST_F(libyuvTest, name##ClipFrom##width##x##height##_##filter) { \ 279 TEST_F(LibYUVScaleTest, name##ClipFrom##width##x##height##_##filter) { \
280 int diff = ARGBClipTestFilter(width, height, \ 280 int diff = ARGBClipTestFilter(width, height, \
281 Abs(benchmark_width_), \ 281 Abs(benchmark_width_), \
282 Abs(benchmark_height_), \ 282 Abs(benchmark_height_), \
283 kFilter##filter, benchmark_iterations_); \ 283 kFilter##filter, benchmark_iterations_); \
284 EXPECT_LE(diff, max_diff); \ 284 EXPECT_LE(diff, max_diff); \
285 } 285 }
286 286
287 /// Test scale to a specified size with all 4 filters. 287 /// Test scale to a specified size with all 4 filters.
288 #define TEST_SCALETO(name, width, height) \ 288 #define TEST_SCALETO(name, width, height) \
289 TEST_SCALETO1(name, width, height, None, 0) \ 289 TEST_SCALETO1(name, width, height, None, 0) \
290 TEST_SCALETO1(name, width, height, Linear, 3) \ 290 TEST_SCALETO1(name, width, height, Linear, 3) \
291 TEST_SCALETO1(name, width, height, Bilinear, 3) 291 TEST_SCALETO1(name, width, height, Bilinear, 3)
292 292
293 TEST_SCALETO(ARGBScale, 1, 1) 293 TEST_SCALETO(ARGBScale, 1, 1)
294 TEST_SCALETO(ARGBScale, 320, 240) 294 TEST_SCALETO(ARGBScale, 320, 240)
295 TEST_SCALETO(ARGBScale, 352, 288) 295 TEST_SCALETO(ARGBScale, 352, 288)
296 TEST_SCALETO(ARGBScale, 569, 480) 296 TEST_SCALETO(ARGBScale, 569, 480)
297 TEST_SCALETO(ARGBScale, 640, 360) 297 TEST_SCALETO(ARGBScale, 640, 360)
298 TEST_SCALETO(ARGBScale, 1280, 720) 298 TEST_SCALETO(ARGBScale, 1280, 720)
299 #undef TEST_SCALETO1 299 #undef TEST_SCALETO1
300 #undef TEST_SCALETO 300 #undef TEST_SCALETO
301 301
302 } // namespace libyuv 302 } // namespace libyuv
OLDNEW
« no previous file with comments | « unit_test/rotate_test.cc ('k') | unit_test/scale_color_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698