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

Side by Side Diff: unit_test/convert_test.cc

Issue 1361813002: replace random with fastrand (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: remove win32 version of random Created 5 years, 3 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/compare_test.cc ('k') | unit_test/math_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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 align_buffer_64(dst_v_c, \ 49 align_buffer_64(dst_v_c, \
50 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 50 SUBSAMPLE(kWidth, SUBSAMP_X) * \
51 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 51 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
52 align_buffer_64(dst_y_opt, kWidth * kHeight); \ 52 align_buffer_64(dst_y_opt, kWidth * kHeight); \
53 align_buffer_64(dst_u_opt, \ 53 align_buffer_64(dst_u_opt, \
54 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 54 SUBSAMPLE(kWidth, SUBSAMP_X) * \
55 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 55 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
56 align_buffer_64(dst_v_opt, \ 56 align_buffer_64(dst_v_opt, \
57 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 57 SUBSAMPLE(kWidth, SUBSAMP_X) * \
58 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 58 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
59 srandom(time(NULL)); \
60 for (int i = 0; i < kHeight; ++i) \ 59 for (int i = 0; i < kHeight; ++i) \
61 for (int j = 0; j < kWidth; ++j) \ 60 for (int j = 0; j < kWidth; ++j) \
62 src_y[i * kWidth + j + OFF] = (random() & 0xff); \ 61 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
63 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ 62 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \
64 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ 63 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \
65 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ 64 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \
66 (random() & 0xff); \ 65 (fastrand() & 0xff); \
67 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ 66 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \
68 (random() & 0xff); \ 67 (fastrand() & 0xff); \
69 } \ 68 } \
70 } \ 69 } \
71 memset(dst_y_c, 1, kWidth * kHeight); \ 70 memset(dst_y_c, 1, kWidth * kHeight); \
72 memset(dst_u_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 71 memset(dst_u_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * \
73 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 72 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
74 memset(dst_v_c, 3, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 73 memset(dst_v_c, 3, SUBSAMPLE(kWidth, SUBSAMP_X) * \
75 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 74 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
76 memset(dst_y_opt, 101, kWidth * kHeight); \ 75 memset(dst_y_opt, 101, kWidth * kHeight); \
77 memset(dst_u_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 76 memset(dst_u_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * \
78 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 77 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ 185 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \
187 align_buffer_64(src_v, \ 186 align_buffer_64(src_v, \
188 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ 187 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \
189 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ 188 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \
190 align_buffer_64(dst_y_c, kWidth * kHeight); \ 189 align_buffer_64(dst_y_c, kWidth * kHeight); \
191 align_buffer_64(dst_uv_c, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ 190 align_buffer_64(dst_uv_c, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \
192 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 191 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
193 align_buffer_64(dst_y_opt, kWidth * kHeight); \ 192 align_buffer_64(dst_y_opt, kWidth * kHeight); \
194 align_buffer_64(dst_uv_opt, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ 193 align_buffer_64(dst_uv_opt, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \
195 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 194 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
196 srandom(time(NULL)); \
197 for (int i = 0; i < kHeight; ++i) \ 195 for (int i = 0; i < kHeight; ++i) \
198 for (int j = 0; j < kWidth; ++j) \ 196 for (int j = 0; j < kWidth; ++j) \
199 src_y[i * kWidth + j + OFF] = (random() & 0xff); \ 197 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
200 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ 198 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \
201 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ 199 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \
202 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ 200 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \
203 (random() & 0xff); \ 201 (fastrand() & 0xff); \
204 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ 202 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \
205 (random() & 0xff); \ 203 (fastrand() & 0xff); \
206 } \ 204 } \
207 } \ 205 } \
208 memset(dst_y_c, 1, kWidth * kHeight); \ 206 memset(dst_y_c, 1, kWidth * kHeight); \
209 memset(dst_uv_c, 2, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ 207 memset(dst_uv_c, 2, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \
210 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 208 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
211 memset(dst_y_opt, 101, kWidth * kHeight); \ 209 memset(dst_y_opt, 101, kWidth * kHeight); \
212 memset(dst_uv_opt, 102, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ 210 memset(dst_uv_opt, 102, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \
213 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 211 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
214 MaskCpuFlags(disable_cpu_flags_); \ 212 MaskCpuFlags(disable_cpu_flags_); \
215 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ 213 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 align_buffer_64(dst_v_c, \ 297 align_buffer_64(dst_v_c, \
300 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 298 SUBSAMPLE(kWidth, SUBSAMP_X) * \
301 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 299 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
302 align_buffer_64(dst_y_opt, kWidth * kHeight); \ 300 align_buffer_64(dst_y_opt, kWidth * kHeight); \
303 align_buffer_64(dst_u_opt, \ 301 align_buffer_64(dst_u_opt, \
304 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 302 SUBSAMPLE(kWidth, SUBSAMP_X) * \
305 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 303 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
306 align_buffer_64(dst_v_opt, \ 304 align_buffer_64(dst_v_opt, \
307 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 305 SUBSAMPLE(kWidth, SUBSAMP_X) * \
308 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 306 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
309 srandom(time(NULL)); \
310 for (int i = 0; i < kHeight; ++i) \ 307 for (int i = 0; i < kHeight; ++i) \
311 for (int j = 0; j < kWidth; ++j) \ 308 for (int j = 0; j < kWidth; ++j) \
312 src_y[i * kWidth + j + OFF] = (random() & 0xff); \ 309 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
313 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ 310 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \
314 for (int j = 0; j < 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ 311 for (int j = 0; j < 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \
315 src_uv[(i * 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ 312 src_uv[(i * 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \
316 (random() & 0xff); \ 313 (fastrand() & 0xff); \
317 } \ 314 } \
318 } \ 315 } \
319 memset(dst_y_c, 1, kWidth * kHeight); \ 316 memset(dst_y_c, 1, kWidth * kHeight); \
320 memset(dst_u_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 317 memset(dst_u_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * \
321 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 318 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
322 memset(dst_v_c, 3, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 319 memset(dst_v_c, 3, SUBSAMPLE(kWidth, SUBSAMP_X) * \
323 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 320 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
324 memset(dst_y_opt, 101, kWidth * kHeight); \ 321 memset(dst_y_opt, 101, kWidth * kHeight); \
325 memset(dst_u_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 322 memset(dst_u_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * \
326 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 323 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 415 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
419 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ 416 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
420 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ 417 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \
421 const int kSizeUV = \ 418 const int kSizeUV = \
422 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ 419 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \
423 align_buffer_64(src_y, kWidth * kHeight + OFF); \ 420 align_buffer_64(src_y, kWidth * kHeight + OFF); \
424 align_buffer_64(src_u, kSizeUV + OFF); \ 421 align_buffer_64(src_u, kSizeUV + OFF); \
425 align_buffer_64(src_v, kSizeUV + OFF); \ 422 align_buffer_64(src_v, kSizeUV + OFF); \
426 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ 423 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \
427 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ 424 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \
428 srandom(time(NULL)); \
429 for (int i = 0; i < kWidth * kHeight; ++i) { \ 425 for (int i = 0; i < kWidth * kHeight; ++i) { \
430 src_y[i + OFF] = (random() & 0xff); \ 426 src_y[i + OFF] = (fastrand() & 0xff); \
431 } \ 427 } \
432 for (int i = 0; i < kSizeUV; ++i) { \ 428 for (int i = 0; i < kSizeUV; ++i) { \
433 src_u[i + OFF] = (random() & 0xff); \ 429 src_u[i + OFF] = (fastrand() & 0xff); \
434 src_v[i + OFF] = (random() & 0xff); \ 430 src_v[i + OFF] = (fastrand() & 0xff); \
435 } \ 431 } \
436 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ 432 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \
437 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ 433 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \
438 MaskCpuFlags(disable_cpu_flags_); \ 434 MaskCpuFlags(disable_cpu_flags_); \
439 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ 435 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
440 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 436 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
441 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 437 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
442 dst_argb_c + OFF, kStrideB, \ 438 dst_argb_c + OFF, kStrideB, \
443 kWidth, NEG kHeight); \ 439 kWidth, NEG kHeight); \
444 MaskCpuFlags(-1); \ 440 MaskCpuFlags(-1); \
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ 524 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
529 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ 525 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \
530 const int kSizeUV = \ 526 const int kSizeUV = \
531 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ 527 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \
532 align_buffer_64(src_y, kWidth * kHeight + OFF); \ 528 align_buffer_64(src_y, kWidth * kHeight + OFF); \
533 align_buffer_64(src_u, kSizeUV + OFF); \ 529 align_buffer_64(src_u, kSizeUV + OFF); \
534 align_buffer_64(src_v, kSizeUV + OFF); \ 530 align_buffer_64(src_v, kSizeUV + OFF); \
535 align_buffer_64(src_a, kWidth * kHeight + OFF); \ 531 align_buffer_64(src_a, kWidth * kHeight + OFF); \
536 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ 532 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \
537 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ 533 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \
538 srandom(time(NULL)); \
539 for (int i = 0; i < kWidth * kHeight; ++i) { \ 534 for (int i = 0; i < kWidth * kHeight; ++i) { \
540 src_y[i + OFF] = (random() & 0xff); \ 535 src_y[i + OFF] = (fastrand() & 0xff); \
541 src_a[i + OFF] = (random() & 0xff); \ 536 src_a[i + OFF] = (fastrand() & 0xff); \
542 } \ 537 } \
543 for (int i = 0; i < kSizeUV; ++i) { \ 538 for (int i = 0; i < kSizeUV; ++i) { \
544 src_u[i + OFF] = (random() & 0xff); \ 539 src_u[i + OFF] = (fastrand() & 0xff); \
545 src_v[i + OFF] = (random() & 0xff); \ 540 src_v[i + OFF] = (fastrand() & 0xff); \
546 } \ 541 } \
547 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ 542 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \
548 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ 543 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \
549 MaskCpuFlags(disable_cpu_flags_); \ 544 MaskCpuFlags(disable_cpu_flags_); \
550 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ 545 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
551 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 546 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
552 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 547 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
553 src_a + OFF, kWidth, \ 548 src_a + OFF, kWidth, \
554 dst_argb_c + OFF, kStrideB, \ 549 dst_argb_c + OFF, kStrideB, \
555 kWidth, NEG kHeight); \ 550 kWidth, NEG kHeight); \
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ 594 TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
600 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 595 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
601 const int kHeight = benchmark_height_; \ 596 const int kHeight = benchmark_height_; \
602 const int kStrideB = kWidth * BPP_B; \ 597 const int kStrideB = kWidth * BPP_B; \
603 align_buffer_64(src_y, kWidth * kHeight + OFF); \ 598 align_buffer_64(src_y, kWidth * kHeight + OFF); \
604 align_buffer_64(src_uv, \ 599 align_buffer_64(src_uv, \
605 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 600 SUBSAMPLE(kWidth, SUBSAMP_X) * \
606 SUBSAMPLE(kHeight, SUBSAMP_Y) * 2 + OFF); \ 601 SUBSAMPLE(kHeight, SUBSAMP_Y) * 2 + OFF); \
607 align_buffer_64(dst_argb_c, kStrideB * kHeight); \ 602 align_buffer_64(dst_argb_c, kStrideB * kHeight); \
608 align_buffer_64(dst_argb_opt, kStrideB * kHeight); \ 603 align_buffer_64(dst_argb_opt, kStrideB * kHeight); \
609 srandom(time(NULL)); \
610 for (int i = 0; i < kHeight; ++i) \ 604 for (int i = 0; i < kHeight; ++i) \
611 for (int j = 0; j < kWidth; ++j) \ 605 for (int j = 0; j < kWidth; ++j) \
612 src_y[i * kWidth + j + OFF] = (random() & 0xff); \ 606 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
613 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ 607 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
614 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X) * 2; ++j) { \ 608 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X) * 2; ++j) { \
615 src_uv[i * SUBSAMPLE(kWidth, SUBSAMP_X) * 2 + j + OFF] = \ 609 src_uv[i * SUBSAMPLE(kWidth, SUBSAMP_X) * 2 + j + OFF] = \
616 (random() & 0xff); \ 610 (fastrand() & 0xff); \
617 } \ 611 } \
618 } \ 612 } \
619 memset(dst_argb_c, 1, kStrideB * kHeight); \ 613 memset(dst_argb_c, 1, kStrideB * kHeight); \
620 memset(dst_argb_opt, 101, kStrideB * kHeight); \ 614 memset(dst_argb_opt, 101, kStrideB * kHeight); \
621 MaskCpuFlags(disable_cpu_flags_); \ 615 MaskCpuFlags(disable_cpu_flags_); \
622 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ 616 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
623 src_uv + OFF, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ 617 src_uv + OFF, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \
624 dst_argb_c, kWidth * BPP_B, \ 618 dst_argb_c, kWidth * BPP_B, \
625 kWidth, NEG kHeight); \ 619 kWidth, NEG kHeight); \
626 MaskCpuFlags(-1); \ 620 MaskCpuFlags(-1); \
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 memset(dst_y_c, 1, kWidth * kHeight); \ 695 memset(dst_y_c, 1, kWidth * kHeight); \
702 memset(dst_u_c, 2, \ 696 memset(dst_u_c, 2, \
703 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 697 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
704 memset(dst_v_c, 3, \ 698 memset(dst_v_c, 3, \
705 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 699 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
706 memset(dst_y_opt, 101, kWidth * kHeight); \ 700 memset(dst_y_opt, 101, kWidth * kHeight); \
707 memset(dst_u_opt, 102, \ 701 memset(dst_u_opt, 102, \
708 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 702 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
709 memset(dst_v_opt, 103, \ 703 memset(dst_v_opt, 103, \
710 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 704 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
711 srandom(time(NULL)); \
712 for (int i = 0; i < kHeight; ++i) \ 705 for (int i = 0; i < kHeight; ++i) \
713 for (int j = 0; j < kStride; ++j) \ 706 for (int j = 0; j < kStride; ++j) \
714 src_argb[(i * kStride) + j + OFF] = (random() & 0xff); \ 707 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \
715 MaskCpuFlags(disable_cpu_flags_); \ 708 MaskCpuFlags(disable_cpu_flags_); \
716 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ 709 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \
717 dst_y_c, kWidth, \ 710 dst_y_c, kWidth, \
718 dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ 711 dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \
719 dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ 712 dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X), \
720 kWidth, NEG kHeight); \ 713 kWidth, NEG kHeight); \
721 MaskCpuFlags(-1); \ 714 MaskCpuFlags(-1); \
722 for (int i = 0; i < benchmark_iterations_; ++i) { \ 715 for (int i = 0; i < benchmark_iterations_; ++i) { \
723 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ 716 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \
724 dst_y_opt, kWidth, \ 717 dst_y_opt, kWidth, \
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \ 796 const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \
804 align_buffer_64(src_argb, kStride * kHeight + OFF); \ 797 align_buffer_64(src_argb, kStride * kHeight + OFF); \
805 align_buffer_64(dst_y_c, kWidth * kHeight); \ 798 align_buffer_64(dst_y_c, kWidth * kHeight); \
806 align_buffer_64(dst_uv_c, \ 799 align_buffer_64(dst_uv_c, \
807 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ 800 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \
808 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 801 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
809 align_buffer_64(dst_y_opt, kWidth * kHeight); \ 802 align_buffer_64(dst_y_opt, kWidth * kHeight); \
810 align_buffer_64(dst_uv_opt, \ 803 align_buffer_64(dst_uv_opt, \
811 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ 804 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \
812 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 805 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
813 srandom(time(NULL)); \
814 for (int i = 0; i < kHeight; ++i) \ 806 for (int i = 0; i < kHeight; ++i) \
815 for (int j = 0; j < kStride; ++j) \ 807 for (int j = 0; j < kStride; ++j) \
816 src_argb[(i * kStride) + j + OFF] = (random() & 0xff); \ 808 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \
817 memset(dst_y_c, 1, kWidth * kHeight); \ 809 memset(dst_y_c, 1, kWidth * kHeight); \
818 memset(dst_uv_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ 810 memset(dst_uv_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \
819 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 811 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
820 memset(dst_y_opt, 101, kWidth * kHeight); \ 812 memset(dst_y_opt, 101, kWidth * kHeight); \
821 memset(dst_uv_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ 813 memset(dst_uv_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \
822 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 814 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
823 MaskCpuFlags(disable_cpu_flags_); \ 815 MaskCpuFlags(disable_cpu_flags_); \
824 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ 816 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \
825 dst_y_c, kWidth, \ 817 dst_y_c, kWidth, \
826 dst_uv_c, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ 818 dst_uv_c, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 TEST_F(libyuvTest, FMT_A##To##FMT_B##N) { \ 877 TEST_F(libyuvTest, FMT_A##To##FMT_B##N) { \
886 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 878 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
887 const int kHeight = benchmark_height_; \ 879 const int kHeight = benchmark_height_; \
888 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ 880 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \
889 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ 881 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \
890 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ 882 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \
891 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ 883 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \
892 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \ 884 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \
893 align_buffer_64(dst_argb_c, kStrideB * kHeightB); \ 885 align_buffer_64(dst_argb_c, kStrideB * kHeightB); \
894 align_buffer_64(dst_argb_opt, kStrideB * kHeightB); \ 886 align_buffer_64(dst_argb_opt, kStrideB * kHeightB); \
895 srandom(time(NULL)); \
896 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ 887 for (int i = 0; i < kStrideA * kHeightA; ++i) { \
897 src_argb[i + OFF] = (random() & 0xff); \ 888 src_argb[i + OFF] = (fastrand() & 0xff); \
898 } \ 889 } \
899 memset(dst_argb_c, 1, kStrideB * kHeightB); \ 890 memset(dst_argb_c, 1, kStrideB * kHeightB); \
900 memset(dst_argb_opt, 101, kStrideB * kHeightB); \ 891 memset(dst_argb_opt, 101, kStrideB * kHeightB); \
901 MaskCpuFlags(disable_cpu_flags_); \ 892 MaskCpuFlags(disable_cpu_flags_); \
902 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \ 893 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \
903 dst_argb_c, kStrideB, \ 894 dst_argb_c, kStrideB, \
904 kWidth, NEG kHeight); \ 895 kWidth, NEG kHeight); \
905 MaskCpuFlags(-1); \ 896 MaskCpuFlags(-1); \
906 for (int i = 0; i < benchmark_iterations_; ++i) { \ 897 for (int i = 0; i < benchmark_iterations_; ++i) { \
907 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \ 898 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \
(...skipping 11 matching lines...) Expand all
919 } \ 910 } \
920 EXPECT_LE(max_diff, DIFF); \ 911 EXPECT_LE(max_diff, DIFF); \
921 free_aligned_buffer_64(src_argb); \ 912 free_aligned_buffer_64(src_argb); \
922 free_aligned_buffer_64(dst_argb_c); \ 913 free_aligned_buffer_64(dst_argb_c); \
923 free_aligned_buffer_64(dst_argb_opt); \ 914 free_aligned_buffer_64(dst_argb_opt); \
924 } 915 }
925 916
926 #define TESTATOBRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ 917 #define TESTATOBRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \
927 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \ 918 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \
928 TEST_F(libyuvTest, FMT_A##To##FMT_B##_Random) { \ 919 TEST_F(libyuvTest, FMT_A##To##FMT_B##_Random) { \
929 srandom(time(NULL)); \
930 for (int times = 0; times < benchmark_iterations_; ++times) { \ 920 for (int times = 0; times < benchmark_iterations_; ++times) { \
931 const int kWidth = (random() & 63) + 1; \ 921 const int kWidth = (fastrand() & 63) + 1; \
932 const int kHeight = (random() & 31) + 1; \ 922 const int kHeight = (fastrand() & 31) + 1; \
933 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ 923 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \
934 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ 924 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \
935 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A;\ 925 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A;\
936 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B;\ 926 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B;\
937 align_buffer_page_end(src_argb, kStrideA * kHeightA); \ 927 align_buffer_page_end(src_argb, kStrideA * kHeightA); \
938 align_buffer_page_end(dst_argb_c, kStrideB * kHeightB); \ 928 align_buffer_page_end(dst_argb_c, kStrideB * kHeightB); \
939 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ 929 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \
940 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ 930 for (int i = 0; i < kStrideA * kHeightA; ++i) { \
941 src_argb[i] = (random() & 0xff); \ 931 src_argb[i] = (fastrand() & 0xff); \
942 } \ 932 } \
943 memset(dst_argb_c, 123, kStrideB * kHeightB); \ 933 memset(dst_argb_c, 123, kStrideB * kHeightB); \
944 memset(dst_argb_opt, 123, kStrideB * kHeightB); \ 934 memset(dst_argb_opt, 123, kStrideB * kHeightB); \
945 MaskCpuFlags(disable_cpu_flags_); \ 935 MaskCpuFlags(disable_cpu_flags_); \
946 FMT_A##To##FMT_B(src_argb, kStrideA, \ 936 FMT_A##To##FMT_B(src_argb, kStrideA, \
947 dst_argb_c, kStrideB, \ 937 dst_argb_c, kStrideB, \
948 kWidth, kHeight); \ 938 kWidth, kHeight); \
949 MaskCpuFlags(-1); \ 939 MaskCpuFlags(-1); \
950 FMT_A##To##FMT_B(src_argb, kStrideA, \ 940 FMT_A##To##FMT_B(src_argb, kStrideA, \
951 dst_argb_opt, kStrideB, \ 941 dst_argb_opt, kStrideB, \
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither##N) { \ 1009 TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither##N) { \
1020 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 1010 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
1021 const int kHeight = benchmark_height_; \ 1011 const int kHeight = benchmark_height_; \
1022 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ 1012 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \
1023 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ 1013 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \
1024 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ 1014 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \
1025 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ 1015 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \
1026 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \ 1016 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \
1027 align_buffer_64(dst_argb_c, kStrideB * kHeightB); \ 1017 align_buffer_64(dst_argb_c, kStrideB * kHeightB); \
1028 align_buffer_64(dst_argb_opt, kStrideB * kHeightB); \ 1018 align_buffer_64(dst_argb_opt, kStrideB * kHeightB); \
1029 srandom(time(NULL)); \
1030 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ 1019 for (int i = 0; i < kStrideA * kHeightA; ++i) { \
1031 src_argb[i + OFF] = (random() & 0xff); \ 1020 src_argb[i + OFF] = (fastrand() & 0xff); \
1032 } \ 1021 } \
1033 memset(dst_argb_c, 1, kStrideB * kHeightB); \ 1022 memset(dst_argb_c, 1, kStrideB * kHeightB); \
1034 memset(dst_argb_opt, 101, kStrideB * kHeightB); \ 1023 memset(dst_argb_opt, 101, kStrideB * kHeightB); \
1035 MaskCpuFlags(disable_cpu_flags_); \ 1024 MaskCpuFlags(disable_cpu_flags_); \
1036 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \ 1025 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \
1037 dst_argb_c, kStrideB, \ 1026 dst_argb_c, kStrideB, \
1038 NULL, kWidth, NEG kHeight); \ 1027 NULL, kWidth, NEG kHeight); \
1039 MaskCpuFlags(-1); \ 1028 MaskCpuFlags(-1); \
1040 for (int i = 0; i < benchmark_iterations_; ++i) { \ 1029 for (int i = 0; i < benchmark_iterations_; ++i) { \
1041 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \ 1030 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \
(...skipping 11 matching lines...) Expand all
1053 } \ 1042 } \
1054 EXPECT_LE(max_diff, DIFF); \ 1043 EXPECT_LE(max_diff, DIFF); \
1055 free_aligned_buffer_64(src_argb); \ 1044 free_aligned_buffer_64(src_argb); \
1056 free_aligned_buffer_64(dst_argb_c); \ 1045 free_aligned_buffer_64(dst_argb_c); \
1057 free_aligned_buffer_64(dst_argb_opt); \ 1046 free_aligned_buffer_64(dst_argb_opt); \
1058 } 1047 }
1059 1048
1060 #define TESTATOBDRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ 1049 #define TESTATOBDRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \
1061 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \ 1050 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \
1062 TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither_Random) { \ 1051 TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither_Random) { \
1063 srandom(time(NULL)); \
1064 for (int times = 0; times < benchmark_iterations_; ++times) { \ 1052 for (int times = 0; times < benchmark_iterations_; ++times) { \
1065 const int kWidth = (random() & 63) + 1; \ 1053 const int kWidth = (fastrand() & 63) + 1; \
1066 const int kHeight = (random() & 31) + 1; \ 1054 const int kHeight = (fastrand() & 31) + 1; \
1067 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ 1055 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \
1068 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ 1056 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \
1069 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A;\ 1057 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A;\
1070 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B;\ 1058 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B;\
1071 align_buffer_page_end(src_argb, kStrideA * kHeightA); \ 1059 align_buffer_page_end(src_argb, kStrideA * kHeightA); \
1072 align_buffer_page_end(dst_argb_c, kStrideB * kHeightB); \ 1060 align_buffer_page_end(dst_argb_c, kStrideB * kHeightB); \
1073 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ 1061 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \
1074 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ 1062 for (int i = 0; i < kStrideA * kHeightA; ++i) { \
1075 src_argb[i] = (random() & 0xff); \ 1063 src_argb[i] = (fastrand() & 0xff); \
1076 } \ 1064 } \
1077 memset(dst_argb_c, 123, kStrideB * kHeightB); \ 1065 memset(dst_argb_c, 123, kStrideB * kHeightB); \
1078 memset(dst_argb_opt, 123, kStrideB * kHeightB); \ 1066 memset(dst_argb_opt, 123, kStrideB * kHeightB); \
1079 MaskCpuFlags(disable_cpu_flags_); \ 1067 MaskCpuFlags(disable_cpu_flags_); \
1080 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \ 1068 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \
1081 dst_argb_c, kStrideB, \ 1069 dst_argb_c, kStrideB, \
1082 NULL, kWidth, kHeight); \ 1070 NULL, kWidth, kHeight); \
1083 MaskCpuFlags(-1); \ 1071 MaskCpuFlags(-1); \
1084 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \ 1072 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \
1085 dst_argb_opt, kStrideB, \ 1073 dst_argb_opt, kStrideB, \
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 #define TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ 1110 #define TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \
1123 W1280, N, NEG, OFF) \ 1111 W1280, N, NEG, OFF) \
1124 TEST_F(libyuvTest, FMT_ATOB##_Symetric##N) { \ 1112 TEST_F(libyuvTest, FMT_ATOB##_Symetric##N) { \
1125 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 1113 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
1126 const int kHeight = benchmark_height_; \ 1114 const int kHeight = benchmark_height_; \
1127 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ 1115 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \
1128 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ 1116 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \
1129 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \ 1117 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \
1130 align_buffer_64(dst_argb_c, kStrideA * kHeightA); \ 1118 align_buffer_64(dst_argb_c, kStrideA * kHeightA); \
1131 align_buffer_64(dst_argb_opt, kStrideA * kHeightA); \ 1119 align_buffer_64(dst_argb_opt, kStrideA * kHeightA); \
1132 srandom(time(NULL)); \
1133 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ 1120 for (int i = 0; i < kStrideA * kHeightA; ++i) { \
1134 src_argb[i + OFF] = (random() & 0xff); \ 1121 src_argb[i + OFF] = (fastrand() & 0xff); \
1135 } \ 1122 } \
1136 memset(dst_argb_c, 1, kStrideA * kHeightA); \ 1123 memset(dst_argb_c, 1, kStrideA * kHeightA); \
1137 memset(dst_argb_opt, 101, kStrideA * kHeightA); \ 1124 memset(dst_argb_opt, 101, kStrideA * kHeightA); \
1138 MaskCpuFlags(disable_cpu_flags_); \ 1125 MaskCpuFlags(disable_cpu_flags_); \
1139 FMT_ATOB(src_argb + OFF, kStrideA, \ 1126 FMT_ATOB(src_argb + OFF, kStrideA, \
1140 dst_argb_c, kStrideA, \ 1127 dst_argb_c, kStrideA, \
1141 kWidth, NEG kHeight); \ 1128 kWidth, NEG kHeight); \
1142 MaskCpuFlags(-1); \ 1129 MaskCpuFlags(-1); \
1143 for (int i = 0; i < benchmark_iterations_; ++i) { \ 1130 for (int i = 0; i < benchmark_iterations_; ++i) { \
1144 FMT_ATOB(src_argb + OFF, kStrideA, \ 1131 FMT_ATOB(src_argb + OFF, kStrideA, \
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 orig_pixels[0] = 0; 1262 orig_pixels[0] = 0;
1276 orig_pixels[1] = 0; 1263 orig_pixels[1] = 0;
1277 orig_pixels[kSize - kOff + 0] = 0xff; 1264 orig_pixels[kSize - kOff + 0] = 0xff;
1278 orig_pixels[kSize - kOff + 1] = 0xd9; // EOI. 1265 orig_pixels[kSize - kOff + 1] = 0xd9; // EOI.
1279 EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize)); 1266 EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
1280 1267
1281 free_aligned_buffer_page_end(orig_pixels); 1268 free_aligned_buffer_page_end(orig_pixels);
1282 } 1269 }
1283 1270
1284 TEST_F(libyuvTest, FuzzJpeg) { 1271 TEST_F(libyuvTest, FuzzJpeg) {
1285 srandom(time(NULL));
1286 // SOI but no EOI. Expect fail. 1272 // SOI but no EOI. Expect fail.
1287 for (int times = 0; times < benchmark_iterations_; ++times) { 1273 for (int times = 0; times < benchmark_iterations_; ++times) {
1288 const int kSize = random() % 5000 + 2; 1274 const int kSize = fastrand() % 5000 + 2;
1289 align_buffer_page_end(orig_pixels, kSize); 1275 align_buffer_page_end(orig_pixels, kSize);
1290 MemRandomize(orig_pixels, kSize); 1276 MemRandomize(orig_pixels, kSize);
1291 1277
1292 // Add SOI so frame will be scanned. 1278 // Add SOI so frame will be scanned.
1293 orig_pixels[0] = 0xff; 1279 orig_pixels[0] = 0xff;
1294 orig_pixels[1] = 0xd8; // SOI. 1280 orig_pixels[1] = 0xd8; // SOI.
1295 orig_pixels[kSize - 1] = 0xff; 1281 orig_pixels[kSize - 1] = 0xff;
1296 ValidateJpeg(orig_pixels, kSize); // Failure normally expected. 1282 ValidateJpeg(orig_pixels, kSize); // Failure normally expected.
1297 free_aligned_buffer_page_end(orig_pixels); 1283 free_aligned_buffer_page_end(orig_pixels);
1298 } 1284 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); 1378 SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1393 1379
1394 align_buffer_64(dst_y_2, kDestWidth * kDestHeight); 1380 align_buffer_64(dst_y_2, kDestWidth * kDestHeight);
1395 align_buffer_64(dst_u_2, 1381 align_buffer_64(dst_u_2,
1396 SUBSAMPLE(kDestWidth, SUBSAMP_X) * 1382 SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1397 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); 1383 SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1398 align_buffer_64(dst_v_2, 1384 align_buffer_64(dst_v_2,
1399 SUBSAMPLE(kDestWidth, SUBSAMP_X) * 1385 SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1400 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); 1386 SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1401 1387
1402 srandom(time(NULL));
1403 for (int i = 0; i < kHeight * kWidth; ++i) { 1388 for (int i = 0; i < kHeight * kWidth; ++i) {
1404 src_y[i] = (random() & 0xff); 1389 src_y[i] = (fastrand() & 0xff);
1405 } 1390 }
1406 for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) * 1391 for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) *
1407 SUBSAMPLE(kWidth, SUBSAMP_X)) * 2; ++i) { 1392 SUBSAMPLE(kWidth, SUBSAMP_X)) * 2; ++i) {
1408 src_uv[i] = (random() & 0xff); 1393 src_uv[i] = (fastrand() & 0xff);
1409 } 1394 }
1410 memset(dst_y, 1, kDestWidth * kDestHeight); 1395 memset(dst_y, 1, kDestWidth * kDestHeight);
1411 memset(dst_u, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) * 1396 memset(dst_u, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1412 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); 1397 SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1413 memset(dst_v, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) * 1398 memset(dst_v, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1414 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); 1399 SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1415 memset(dst_y_2, 1, kDestWidth * kDestHeight); 1400 memset(dst_y_2, 1, kDestWidth * kDestHeight);
1416 memset(dst_u_2, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) * 1401 memset(dst_u_2, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1417 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); 1402 SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1418 memset(dst_v_2, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) * 1403 memset(dst_v_2, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 1553 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
1569 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ 1554 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
1570 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ 1555 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \
1571 const int kSizeUV = \ 1556 const int kSizeUV = \
1572 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ 1557 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \
1573 align_buffer_64(src_y, kWidth * kHeight + OFF); \ 1558 align_buffer_64(src_y, kWidth * kHeight + OFF); \
1574 align_buffer_64(src_u, kSizeUV + OFF); \ 1559 align_buffer_64(src_u, kSizeUV + OFF); \
1575 align_buffer_64(src_v, kSizeUV + OFF); \ 1560 align_buffer_64(src_v, kSizeUV + OFF); \
1576 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ 1561 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \
1577 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ 1562 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \
1578 srandom(time(NULL)); \
1579 for (int i = 0; i < kWidth * kHeight; ++i) { \ 1563 for (int i = 0; i < kWidth * kHeight; ++i) { \
1580 src_y[i + OFF] = (random() & 0xff); \ 1564 src_y[i + OFF] = (fastrand() & 0xff); \
1581 } \ 1565 } \
1582 for (int i = 0; i < kSizeUV; ++i) { \ 1566 for (int i = 0; i < kSizeUV; ++i) { \
1583 src_u[i + OFF] = (random() & 0xff); \ 1567 src_u[i + OFF] = (fastrand() & 0xff); \
1584 src_v[i + OFF] = (random() & 0xff); \ 1568 src_v[i + OFF] = (fastrand() & 0xff); \
1585 } \ 1569 } \
1586 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ 1570 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \
1587 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ 1571 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \
1588 MaskCpuFlags(disable_cpu_flags_); \ 1572 MaskCpuFlags(disable_cpu_flags_); \
1589 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ 1573 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \
1590 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 1574 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
1591 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 1575 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
1592 dst_argb_c + OFF, kStrideB, \ 1576 dst_argb_c + OFF, kStrideB, \
1593 NULL, kWidth, NEG kHeight); \ 1577 NULL, kWidth, NEG kHeight); \
1594 MaskCpuFlags(-1); \ 1578 MaskCpuFlags(-1); \
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 align_buffer_64(dst_y_orig, kWidth * kHeight); \ 1644 align_buffer_64(dst_y_orig, kWidth * kHeight); \
1661 align_buffer_64(dst_uv_orig, 2 * \ 1645 align_buffer_64(dst_uv_orig, 2 * \
1662 SUBSAMPLE(kWidth, 2) * \ 1646 SUBSAMPLE(kWidth, 2) * \
1663 SUBSAMPLE(kHeight, 2)); \ 1647 SUBSAMPLE(kHeight, 2)); \
1664 \ 1648 \
1665 align_buffer_64(dst_y, kWidth * kHeight); \ 1649 align_buffer_64(dst_y, kWidth * kHeight); \
1666 align_buffer_64(dst_uv, 2 * \ 1650 align_buffer_64(dst_uv, 2 * \
1667 SUBSAMPLE(kWidth, 2) * \ 1651 SUBSAMPLE(kWidth, 2) * \
1668 SUBSAMPLE(kHeight, 2)); \ 1652 SUBSAMPLE(kHeight, 2)); \
1669 \ 1653 \
1670 srandom(time(NULL)); \
1671 MemRandomize(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2) * kHeight); \ 1654 MemRandomize(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2) * kHeight); \
1672 \ 1655 \
1673 /* Convert UYVY to NV12 in 2 steps for reference */ \ 1656 /* Convert UYVY to NV12 in 2 steps for reference */ \
1674 libyuv::UYVYTOI420(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2), \ 1657 libyuv::UYVYTOI420(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2), \
1675 orig_y, kWidth, \ 1658 orig_y, kWidth, \
1676 orig_u, SUBSAMPLE(kWidth, 2), \ 1659 orig_u, SUBSAMPLE(kWidth, 2), \
1677 orig_v, SUBSAMPLE(kWidth, 2), \ 1660 orig_v, SUBSAMPLE(kWidth, 2), \
1678 kWidth, kHeight); \ 1661 kWidth, kHeight); \
1679 libyuv::I420ToNV12(orig_y, kWidth, \ 1662 libyuv::I420ToNV12(orig_y, kWidth, \
1680 orig_u, SUBSAMPLE(kWidth, 2), \ 1663 orig_u, SUBSAMPLE(kWidth, 2), \
(...skipping 27 matching lines...) Expand all
1708 free_aligned_buffer_64(dst_y_orig); \ 1691 free_aligned_buffer_64(dst_y_orig); \
1709 free_aligned_buffer_64(dst_uv_orig); \ 1692 free_aligned_buffer_64(dst_uv_orig); \
1710 free_aligned_buffer_64(dst_y); \ 1693 free_aligned_buffer_64(dst_y); \
1711 free_aligned_buffer_64(dst_uv); \ 1694 free_aligned_buffer_64(dst_uv); \
1712 } 1695 }
1713 1696
1714 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) 1697 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12)
1715 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) 1698 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12)
1716 1699
1717 } // namespace libyuv 1700 } // namespace libyuv
OLDNEW
« no previous file with comments | « unit_test/compare_test.cc ('k') | unit_test/math_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698