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

Side by Side Diff: unit_test/scale_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/scale_color_test.cc ('k') | unit_test/unit_test.h » ('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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 free_aligned_buffer_page_end(src_y_16) 267 free_aligned_buffer_page_end(src_y_16)
268 free_aligned_buffer_page_end(src_u_16) 268 free_aligned_buffer_page_end(src_u_16)
269 free_aligned_buffer_page_end(src_v_16) 269 free_aligned_buffer_page_end(src_v_16)
270 270
271 return max_diff; 271 return max_diff;
272 } 272 }
273 273
274 // The following adjustments in dimensions ensure the scale factor will be 274 // The following adjustments in dimensions ensure the scale factor will be
275 // exactly achieved. 275 // exactly achieved.
276 // 2 is chroma subsample 276 // 2 is chroma subsample
277 #define DX(x, nom, denom) ((int)(Abs(x) / nom / 2) * nom * 2) 277 #define DX(x, nom, denom) static_cast<int>((Abs(x) / nom / 2) * nom * 2)
278 #define SX(x, nom, denom) ((int)(x / nom / 2) * denom * 2) 278 #define SX(x, nom, denom) static_cast<int>((x / nom / 2) * denom * 2)
279 279
280 #define TEST_FACTOR1(name, filter, nom, denom, max_diff) \ 280 #define TEST_FACTOR1(name, filter, nom, denom, max_diff) \
281 TEST_F(libyuvTest, ScaleDownBy##name##_##filter) { \ 281 TEST_F(LibYUVScaleTest, ScaleDownBy##name##_##filter) { \
282 int diff = TestFilter(SX(benchmark_width_, nom, denom), \ 282 int diff = TestFilter(SX(benchmark_width_, nom, denom), \
283 SX(benchmark_height_, nom, denom), \ 283 SX(benchmark_height_, nom, denom), \
284 DX(benchmark_width_, nom, denom), \ 284 DX(benchmark_width_, nom, denom), \
285 DX(benchmark_height_, nom, denom), \ 285 DX(benchmark_height_, nom, denom), \
286 kFilter##filter, benchmark_iterations_, \ 286 kFilter##filter, benchmark_iterations_, \
287 disable_cpu_flags_); \ 287 disable_cpu_flags_); \
288 EXPECT_LE(diff, max_diff); \ 288 EXPECT_LE(diff, max_diff); \
289 } \ 289 } \
290 TEST_F(libyuvTest, DISABLED_ScaleDownBy##name##_##filter##_16) { \ 290 TEST_F(LibYUVScaleTest, DISABLED_ScaleDownBy##name##_##filter##_16) { \
291 int diff = TestFilter_16(SX(benchmark_width_, nom, denom), \ 291 int diff = TestFilter_16(SX(benchmark_width_, nom, denom), \
292 SX(benchmark_height_, nom, denom), \ 292 SX(benchmark_height_, nom, denom), \
293 DX(benchmark_width_, nom, denom), \ 293 DX(benchmark_width_, nom, denom), \
294 DX(benchmark_height_, nom, denom), \ 294 DX(benchmark_height_, nom, denom), \
295 kFilter##filter, benchmark_iterations_); \ 295 kFilter##filter, benchmark_iterations_); \
296 EXPECT_LE(diff, max_diff); \ 296 EXPECT_LE(diff, max_diff); \
297 } 297 }
298 298
299 // Test a scale factor with all 4 filters. Expect unfiltered to be exact, but 299 // Test a scale factor with all 4 filters. Expect unfiltered to be exact, but
300 // filtering is different fixed point implementations for SSSE3, Neon and C. 300 // filtering is different fixed point implementations for SSSE3, Neon and C.
301 #define TEST_FACTOR(name, nom, denom) \ 301 #define TEST_FACTOR(name, nom, denom) \
302 TEST_FACTOR1(name, None, nom, denom, 0) \ 302 TEST_FACTOR1(name, None, nom, denom, 0) \
303 TEST_FACTOR1(name, Linear, nom, denom, 3) \ 303 TEST_FACTOR1(name, Linear, nom, denom, 3) \
304 TEST_FACTOR1(name, Bilinear, nom, denom, 3) \ 304 TEST_FACTOR1(name, Bilinear, nom, denom, 3) \
305 TEST_FACTOR1(name, Box, nom, denom, 3) 305 TEST_FACTOR1(name, Box, nom, denom, 3)
306 306
307 TEST_FACTOR(2, 1, 2) 307 TEST_FACTOR(2, 1, 2)
308 TEST_FACTOR(4, 1, 4) 308 TEST_FACTOR(4, 1, 4)
309 TEST_FACTOR(8, 1, 8) 309 TEST_FACTOR(8, 1, 8)
310 TEST_FACTOR(3by4, 3, 4) 310 TEST_FACTOR(3by4, 3, 4)
311 TEST_FACTOR(3by8, 3, 8) 311 TEST_FACTOR(3by8, 3, 8)
312 TEST_FACTOR(3, 1, 3) 312 TEST_FACTOR(3, 1, 3)
313 #undef TEST_FACTOR1 313 #undef TEST_FACTOR1
314 #undef TEST_FACTOR 314 #undef TEST_FACTOR
315 #undef SX 315 #undef SX
316 #undef DX 316 #undef DX
317 317
318 #define TEST_SCALETO1(name, width, height, filter, max_diff) \ 318 #define TEST_SCALETO1(name, width, height, filter, max_diff) \
319 TEST_F(libyuvTest, name##To##width##x##height##_##filter) { \ 319 TEST_F(LibYUVScaleTest, name##To##width##x##height##_##filter) { \
320 int diff = TestFilter(benchmark_width_, benchmark_height_, \ 320 int diff = TestFilter(benchmark_width_, benchmark_height_, \
321 width, height, \ 321 width, height, \
322 kFilter##filter, benchmark_iterations_, \ 322 kFilter##filter, benchmark_iterations_, \
323 disable_cpu_flags_); \ 323 disable_cpu_flags_); \
324 EXPECT_LE(diff, max_diff); \ 324 EXPECT_LE(diff, max_diff); \
325 } \ 325 } \
326 TEST_F(libyuvTest, name##From##width##x##height##_##filter) { \ 326 TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) { \
327 int diff = TestFilter(width, height, \ 327 int diff = TestFilter(width, height, \
328 Abs(benchmark_width_), Abs(benchmark_height_), \ 328 Abs(benchmark_width_), Abs(benchmark_height_), \
329 kFilter##filter, benchmark_iterations_, \ 329 kFilter##filter, benchmark_iterations_, \
330 disable_cpu_flags_); \ 330 disable_cpu_flags_); \
331 EXPECT_LE(diff, max_diff); \ 331 EXPECT_LE(diff, max_diff); \
332 } \ 332 } \
333 TEST_F(libyuvTest, \ 333 TEST_F(LibYUVScaleTest, \
334 DISABLED_##name##To##width##x##height##_##filter##_16) { \ 334 DISABLED_##name##To##width##x##height##_##filter##_16) { \
335 int diff = TestFilter_16(benchmark_width_, benchmark_height_, \ 335 int diff = TestFilter_16(benchmark_width_, benchmark_height_, \
336 width, height, \ 336 width, height, \
337 kFilter##filter, benchmark_iterations_); \ 337 kFilter##filter, benchmark_iterations_); \
338 EXPECT_LE(diff, max_diff); \ 338 EXPECT_LE(diff, max_diff); \
339 } \ 339 } \
340 TEST_F(libyuvTest, \ 340 TEST_F(LibYUVScaleTest, \
341 DISABLED_##name##From##width##x##height##_##filter##_16) { \ 341 DISABLED_##name##From##width##x##height##_##filter##_16) { \
342 int diff = TestFilter_16(width, height, \ 342 int diff = TestFilter_16(width, height, \
343 Abs(benchmark_width_), Abs(benchmark_height_), \ 343 Abs(benchmark_width_), Abs(benchmark_height_), \
344 kFilter##filter, benchmark_iterations_); \ 344 kFilter##filter, benchmark_iterations_); \
345 EXPECT_LE(diff, max_diff); \ 345 EXPECT_LE(diff, max_diff); \
346 } 346 }
347 347
348 // Test scale to a specified size with all 4 filters. 348 // Test scale to a specified size with all 4 filters.
349 #define TEST_SCALETO(name, width, height) \ 349 #define TEST_SCALETO(name, width, height) \
350 TEST_SCALETO1(name, width, height, None, 0) \ 350 TEST_SCALETO1(name, width, height, None, 0) \
351 TEST_SCALETO1(name, width, height, Linear, 3) \ 351 TEST_SCALETO1(name, width, height, Linear, 3) \
352 TEST_SCALETO1(name, width, height, Bilinear, 3) \ 352 TEST_SCALETO1(name, width, height, Bilinear, 3) \
353 TEST_SCALETO1(name, width, height, Box, 3) 353 TEST_SCALETO1(name, width, height, Box, 3)
354 354
355 TEST_SCALETO(Scale, 1, 1) 355 TEST_SCALETO(Scale, 1, 1)
356 TEST_SCALETO(Scale, 320, 240) 356 TEST_SCALETO(Scale, 320, 240)
357 TEST_SCALETO(Scale, 352, 288) 357 TEST_SCALETO(Scale, 352, 288)
358 TEST_SCALETO(Scale, 569, 480) 358 TEST_SCALETO(Scale, 569, 480)
359 TEST_SCALETO(Scale, 640, 360) 359 TEST_SCALETO(Scale, 640, 360)
360 TEST_SCALETO(Scale, 1280, 720) 360 TEST_SCALETO(Scale, 1280, 720)
361 #undef TEST_SCALETO1 361 #undef TEST_SCALETO1
362 #undef TEST_SCALETO 362 #undef TEST_SCALETO
363 363
364 } // namespace libyuv 364 } // namespace libyuv
OLDNEW
« no previous file with comments | « unit_test/scale_color_test.cc ('k') | unit_test/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698