OLD | NEW |
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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 TESTBIPLANARTOP(NV21, 2, 2, I420, 2, 2) | 408 TESTBIPLANARTOP(NV21, 2, 2, I420, 2, 2) |
409 | 409 |
410 #define ALIGNINT(V, ALIGN) (((V) + (ALIGN) - 1) / (ALIGN) * (ALIGN)) | 410 #define ALIGNINT(V, ALIGN) (((V) + (ALIGN) - 1) / (ALIGN) * (ALIGN)) |
411 | 411 |
412 #define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 412 #define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
413 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ | 413 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ |
414 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ | 414 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ |
415 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 415 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
416 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 416 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
417 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ | 417 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ |
418 const int kSizeUV = \ | 418 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
419 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 419 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
420 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 420 align_buffer_64(src_y, kWidth * kHeight + OFF); \ |
421 align_buffer_64(src_u, kSizeUV + OFF); \ | 421 align_buffer_64(src_u, kSizeUV + OFF); \ |
422 align_buffer_64(src_v, kSizeUV + OFF); \ | 422 align_buffer_64(src_v, kSizeUV + OFF); \ |
423 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ | 423 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ |
424 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ | 424 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ |
425 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 425 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
426 src_y[i + OFF] = (fastrand() & 0xff); \ | 426 src_y[i + OFF] = (fastrand() & 0xff); \ |
427 } \ | 427 } \ |
428 for (int i = 0; i < kSizeUV; ++i) { \ | 428 for (int i = 0; i < kSizeUV; ++i) { \ |
429 src_u[i + OFF] = (fastrand() & 0xff); \ | 429 src_u[i + OFF] = (fastrand() & 0xff); \ |
430 src_v[i + OFF] = (fastrand() & 0xff); \ | 430 src_v[i + OFF] = (fastrand() & 0xff); \ |
431 } \ | 431 } \ |
432 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ | 432 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ |
433 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ | 433 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ |
434 MaskCpuFlags(disable_cpu_flags_); \ | 434 MaskCpuFlags(disable_cpu_flags_); \ |
435 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 435 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
436 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 436 src_u + OFF, kStrideUV, \ |
437 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 437 src_v + OFF, kStrideUV, \ |
438 dst_argb_c + OFF, kStrideB, \ | 438 dst_argb_c + OFF, kStrideB, \ |
439 kWidth, NEG kHeight); \ | 439 kWidth, NEG kHeight); \ |
440 MaskCpuFlags(benchmark_cpu_info_); \ | 440 MaskCpuFlags(benchmark_cpu_info_); \ |
441 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 441 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
442 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 442 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
443 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 443 src_u + OFF, kStrideUV, \ |
444 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 444 src_v + OFF, kStrideUV, \ |
445 dst_argb_opt + OFF, kStrideB, \ | 445 dst_argb_opt + OFF, kStrideB, \ |
446 kWidth, NEG kHeight); \ | 446 kWidth, NEG kHeight); \ |
447 } \ | 447 } \ |
448 int max_diff = 0; \ | 448 int max_diff = 0; \ |
449 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ | 449 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ |
450 align_buffer_64(dst_argb32_c, kWidth * BPP_C * kHeight); \ | 450 align_buffer_64(dst_argb32_c, kWidth * BPP_C * kHeight); \ |
451 align_buffer_64(dst_argb32_opt, kWidth * BPP_C * kHeight); \ | 451 align_buffer_64(dst_argb32_opt, kWidth * BPP_C * kHeight); \ |
452 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ | 452 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ |
453 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ | 453 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ |
454 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ | 454 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4, 1, 0, ARGB, 4) | 517 TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4, 1, 0, ARGB, 4) |
518 TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 1, 0, ARGB, 4) | 518 TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 1, 0, ARGB, 4) |
519 TESTPLANARTOB(J420, 2, 2, J400, 1, 1, 1, 0, ARGB, 4) | 519 TESTPLANARTOB(J420, 2, 2, J400, 1, 1, 1, 0, ARGB, 4) |
520 | 520 |
521 #define TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 521 #define TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
522 YALIGN, W1280, DIFF, N, NEG, OFF, ATTEN) \ | 522 YALIGN, W1280, DIFF, N, NEG, OFF, ATTEN) \ |
523 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ | 523 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ |
524 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 524 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
525 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 525 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
526 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ | 526 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ |
527 const int kSizeUV = \ | 527 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
528 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 528 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
529 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 529 align_buffer_64(src_y, kWidth * kHeight + OFF); \ |
530 align_buffer_64(src_u, kSizeUV + OFF); \ | 530 align_buffer_64(src_u, kSizeUV + OFF); \ |
531 align_buffer_64(src_v, kSizeUV + OFF); \ | 531 align_buffer_64(src_v, kSizeUV + OFF); \ |
532 align_buffer_64(src_a, kWidth * kHeight + OFF); \ | 532 align_buffer_64(src_a, kWidth * kHeight + OFF); \ |
533 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ | 533 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ |
534 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ | 534 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ |
535 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 535 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
536 src_y[i + OFF] = (fastrand() & 0xff); \ | 536 src_y[i + OFF] = (fastrand() & 0xff); \ |
537 src_a[i + OFF] = (fastrand() & 0xff); \ | 537 src_a[i + OFF] = (fastrand() & 0xff); \ |
538 } \ | 538 } \ |
539 for (int i = 0; i < kSizeUV; ++i) { \ | 539 for (int i = 0; i < kSizeUV; ++i) { \ |
540 src_u[i + OFF] = (fastrand() & 0xff); \ | 540 src_u[i + OFF] = (fastrand() & 0xff); \ |
541 src_v[i + OFF] = (fastrand() & 0xff); \ | 541 src_v[i + OFF] = (fastrand() & 0xff); \ |
542 } \ | 542 } \ |
543 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ | 543 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ |
544 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ | 544 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ |
545 MaskCpuFlags(disable_cpu_flags_); \ | 545 MaskCpuFlags(disable_cpu_flags_); \ |
546 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 546 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
547 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 547 src_u + OFF, kStrideUV, \ |
548 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 548 src_v + OFF, kStrideUV, \ |
549 src_a + OFF, kWidth, \ | 549 src_a + OFF, kWidth, \ |
550 dst_argb_c + OFF, kStrideB, \ | 550 dst_argb_c + OFF, kStrideB, \ |
551 kWidth, NEG kHeight, ATTEN); \ | 551 kWidth, NEG kHeight, ATTEN); \ |
552 MaskCpuFlags(benchmark_cpu_info_); \ | 552 MaskCpuFlags(benchmark_cpu_info_); \ |
553 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 553 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
554 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 554 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
555 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 555 src_u + OFF, kStrideUV, \ |
556 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 556 src_v + OFF, kStrideUV, \ |
557 src_a + OFF, kWidth, \ | 557 src_a + OFF, kWidth, \ |
558 dst_argb_opt + OFF, kStrideB, \ | 558 dst_argb_opt + OFF, kStrideB, \ |
559 kWidth, NEG kHeight, ATTEN); \ | 559 kWidth, NEG kHeight, ATTEN); \ |
560 } \ | 560 } \ |
561 int max_diff = 0; \ | 561 int max_diff = 0; \ |
562 for (int i = 0; i < kWidth * BPP_B * kHeight; ++i) { \ | 562 for (int i = 0; i < kWidth * BPP_B * kHeight; ++i) { \ |
563 int abs_diff = \ | 563 int abs_diff = \ |
564 abs(static_cast<int>(dst_argb_c[i + OFF]) - \ | 564 abs(static_cast<int>(dst_argb_c[i + OFF]) - \ |
565 static_cast<int>(dst_argb_opt[i + OFF])); \ | 565 static_cast<int>(dst_argb_opt[i + OFF])); \ |
566 if (abs_diff > max_diff) { \ | 566 if (abs_diff > max_diff) { \ |
(...skipping 24 matching lines...) Expand all Loading... |
591 | 591 |
592 TESTQPLANARTOB(I420Alpha, 2, 2, ARGB, 4, 4, 1, 2) | 592 TESTQPLANARTOB(I420Alpha, 2, 2, ARGB, 4, 4, 1, 2) |
593 TESTQPLANARTOB(I420Alpha, 2, 2, ABGR, 4, 4, 1, 2) | 593 TESTQPLANARTOB(I420Alpha, 2, 2, ABGR, 4, 4, 1, 2) |
594 | 594 |
595 #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 595 #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
596 W1280, DIFF, N, NEG, OFF) \ | 596 W1280, DIFF, N, NEG, OFF) \ |
597 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ | 597 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ |
598 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 598 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
599 const int kHeight = benchmark_height_; \ | 599 const int kHeight = benchmark_height_; \ |
600 const int kStrideB = kWidth * BPP_B; \ | 600 const int kStrideB = kWidth * BPP_B; \ |
| 601 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
601 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 602 align_buffer_64(src_y, kWidth * kHeight + OFF); \ |
602 align_buffer_64(src_uv, \ | 603 align_buffer_64(src_uv, \ |
603 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 604 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y) * 2 + OFF); \ |
604 SUBSAMPLE(kHeight, SUBSAMP_Y) * 2 + OFF); \ | |
605 align_buffer_64(dst_argb_c, kStrideB * kHeight); \ | 605 align_buffer_64(dst_argb_c, kStrideB * kHeight); \ |
606 align_buffer_64(dst_argb_opt, kStrideB * kHeight); \ | 606 align_buffer_64(dst_argb_opt, kStrideB * kHeight); \ |
607 for (int i = 0; i < kHeight; ++i) \ | 607 for (int i = 0; i < kHeight; ++i) \ |
608 for (int j = 0; j < kWidth; ++j) \ | 608 for (int j = 0; j < kWidth; ++j) \ |
609 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ | 609 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ |
610 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ | 610 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
611 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X) * 2; ++j) { \ | 611 for (int j = 0; j < kStrideUV * 2; ++j) { \ |
612 src_uv[i * SUBSAMPLE(kWidth, SUBSAMP_X) * 2 + j + OFF] = \ | 612 src_uv[i * kStrideUV * 2 + j + OFF] = (fastrand() & 0xff); \ |
613 (fastrand() & 0xff); \ | |
614 } \ | 613 } \ |
615 } \ | 614 } \ |
616 memset(dst_argb_c, 1, kStrideB * kHeight); \ | 615 memset(dst_argb_c, 1, kStrideB * kHeight); \ |
617 memset(dst_argb_opt, 101, kStrideB * kHeight); \ | 616 memset(dst_argb_opt, 101, kStrideB * kHeight); \ |
618 MaskCpuFlags(disable_cpu_flags_); \ | 617 MaskCpuFlags(disable_cpu_flags_); \ |
619 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 618 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
620 src_uv + OFF, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ | 619 src_uv + OFF, kStrideUV * 2, \ |
621 dst_argb_c, kWidth * BPP_B, \ | 620 dst_argb_c, kWidth * BPP_B, \ |
622 kWidth, NEG kHeight); \ | 621 kWidth, NEG kHeight); \ |
623 MaskCpuFlags(benchmark_cpu_info_); \ | 622 MaskCpuFlags(benchmark_cpu_info_); \ |
624 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 623 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
625 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 624 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
626 src_uv + OFF, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ | 625 src_uv + OFF, kStrideUV * 2, \ |
627 dst_argb_opt, kWidth * BPP_B, \ | 626 dst_argb_opt, kWidth * BPP_B, \ |
628 kWidth, NEG kHeight); \ | 627 kWidth, NEG kHeight); \ |
629 } \ | 628 } \ |
630 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ | 629 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ |
631 align_buffer_64(dst_argb32_c, kWidth * 4 * kHeight); \ | 630 align_buffer_64(dst_argb32_c, kWidth * 4 * kHeight); \ |
632 align_buffer_64(dst_argb32_opt, kWidth * 4 * kHeight); \ | 631 align_buffer_64(dst_argb32_opt, kWidth * 4 * kHeight); \ |
633 memset(dst_argb32_c, 2, kWidth * 4 * kHeight); \ | 632 memset(dst_argb32_c, 2, kWidth * 4 * kHeight); \ |
634 memset(dst_argb32_opt, 102, kWidth * 4 * kHeight); \ | 633 memset(dst_argb32_opt, 102, kWidth * 4 * kHeight); \ |
635 FMT_B##ToARGB(dst_argb_c, kStrideB, \ | 634 FMT_B##ToARGB(dst_argb_c, kStrideB, \ |
636 dst_argb32_c, kWidth * 4, \ | 635 dst_argb32_c, kWidth * 4, \ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 669 |
671 TESTBIPLANARTOB(NV12, 2, 2, ARGB, 4, 2) | 670 TESTBIPLANARTOB(NV12, 2, 2, ARGB, 4, 2) |
672 TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4, 2) | 671 TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4, 2) |
673 TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2, 9) | 672 TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2, 9) |
674 | 673 |
675 #define TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 674 #define TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
676 W1280, DIFF, N, NEG, OFF) \ | 675 W1280, DIFF, N, NEG, OFF) \ |
677 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ | 676 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ |
678 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 677 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
679 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 678 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
| 679 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
680 const int kStride = \ | 680 const int kStride = \ |
681 (SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMP_X * 8 * BPP_A + 7) / 8; \ | 681 (kStrideUV * SUBSAMP_X * 8 * BPP_A + 7) / 8; \ |
682 align_buffer_64(src_argb, kStride * kHeight + OFF); \ | 682 align_buffer_64(src_argb, kStride * kHeight + OFF); \ |
683 align_buffer_64(dst_y_c, kWidth * kHeight); \ | 683 align_buffer_64(dst_y_c, kWidth * kHeight); \ |
684 align_buffer_64(dst_u_c, \ | 684 align_buffer_64(dst_u_c, \ |
685 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 685 kStrideUV * \ |
686 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 686 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
687 align_buffer_64(dst_v_c, \ | 687 align_buffer_64(dst_v_c, \ |
688 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 688 kStrideUV * \ |
689 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 689 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
690 align_buffer_64(dst_y_opt, kWidth * kHeight); \ | 690 align_buffer_64(dst_y_opt, kWidth * kHeight); \ |
691 align_buffer_64(dst_u_opt, \ | 691 align_buffer_64(dst_u_opt, \ |
692 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 692 kStrideUV * \ |
693 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 693 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
694 align_buffer_64(dst_v_opt, \ | 694 align_buffer_64(dst_v_opt, \ |
695 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 695 kStrideUV * \ |
696 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 696 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
697 memset(dst_y_c, 1, kWidth * kHeight); \ | 697 memset(dst_y_c, 1, kWidth * kHeight); \ |
698 memset(dst_u_c, 2, \ | 698 memset(dst_u_c, 2, \ |
699 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 699 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
700 memset(dst_v_c, 3, \ | 700 memset(dst_v_c, 3, \ |
701 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 701 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
702 memset(dst_y_opt, 101, kWidth * kHeight); \ | 702 memset(dst_y_opt, 101, kWidth * kHeight); \ |
703 memset(dst_u_opt, 102, \ | 703 memset(dst_u_opt, 102, \ |
704 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 704 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
705 memset(dst_v_opt, 103, \ | 705 memset(dst_v_opt, 103, \ |
706 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 706 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
707 for (int i = 0; i < kHeight; ++i) \ | 707 for (int i = 0; i < kHeight; ++i) \ |
708 for (int j = 0; j < kStride; ++j) \ | 708 for (int j = 0; j < kStride; ++j) \ |
709 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \ | 709 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \ |
710 MaskCpuFlags(disable_cpu_flags_); \ | 710 MaskCpuFlags(disable_cpu_flags_); \ |
711 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ | 711 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ |
712 dst_y_c, kWidth, \ | 712 dst_y_c, kWidth, \ |
713 dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 713 dst_u_c, kStrideUV, \ |
714 dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 714 dst_v_c, kStrideUV, \ |
715 kWidth, NEG kHeight); \ | 715 kWidth, NEG kHeight); \ |
716 MaskCpuFlags(benchmark_cpu_info_); \ | 716 MaskCpuFlags(benchmark_cpu_info_); \ |
717 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 717 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
718 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ | 718 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ |
719 dst_y_opt, kWidth, \ | 719 dst_y_opt, kWidth, \ |
720 dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 720 dst_u_opt, kStrideUV, \ |
721 dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 721 dst_v_opt, kStrideUV, \ |
722 kWidth, NEG kHeight); \ | 722 kWidth, NEG kHeight); \ |
723 } \ | 723 } \ |
724 for (int i = 0; i < kHeight; ++i) { \ | 724 for (int i = 0; i < kHeight; ++i) { \ |
725 for (int j = 0; j < kWidth; ++j) { \ | 725 for (int j = 0; j < kWidth; ++j) { \ |
726 EXPECT_NEAR(static_cast<int>(dst_y_c[i * kWidth + j]), \ | 726 EXPECT_NEAR(static_cast<int>(dst_y_c[i * kWidth + j]), \ |
727 static_cast<int>(dst_y_opt[i * kWidth + j]), DIFF); \ | 727 static_cast<int>(dst_y_opt[i * kWidth + j]), DIFF); \ |
728 } \ | 728 } \ |
729 } \ | 729 } \ |
730 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ | 730 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
731 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \ | 731 for (int j = 0; j < kStrideUV; ++j) { \ |
732 EXPECT_NEAR(static_cast<int>(dst_u_c[i * \ | 732 EXPECT_NEAR(static_cast<int>(dst_u_c[i * kStrideUV + j]), \ |
733 SUBSAMPLE(kWidth, SUBSAMP_X) + j]), \ | 733 static_cast<int>(dst_u_opt[i * kStrideUV + j]), DIFF); \ |
734 static_cast<int>(dst_u_opt[i * \ | |
735 SUBSAMPLE(kWidth, SUBSAMP_X) + j]), DIFF); \ | |
736 } \ | 734 } \ |
737 } \ | 735 } \ |
738 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ | 736 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
739 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \ | 737 for (int j = 0; j < kStrideUV; ++j) { \ |
740 EXPECT_NEAR(static_cast<int>(dst_v_c[i * \ | 738 EXPECT_NEAR(static_cast<int>(dst_v_c[i * \ |
741 SUBSAMPLE(kWidth, SUBSAMP_X) + j]), \ | 739 kStrideUV + j]), \ |
742 static_cast<int>(dst_v_opt[i * \ | 740 static_cast<int>(dst_v_opt[i * \ |
743 SUBSAMPLE(kWidth, SUBSAMP_X) + j]), DIFF); \ | 741 kStrideUV + j]), DIFF); \ |
744 } \ | 742 } \ |
745 } \ | 743 } \ |
746 free_aligned_buffer_64(dst_y_c); \ | 744 free_aligned_buffer_64(dst_y_c); \ |
747 free_aligned_buffer_64(dst_u_c); \ | 745 free_aligned_buffer_64(dst_u_c); \ |
748 free_aligned_buffer_64(dst_v_c); \ | 746 free_aligned_buffer_64(dst_v_c); \ |
749 free_aligned_buffer_64(dst_y_opt); \ | 747 free_aligned_buffer_64(dst_y_opt); \ |
750 free_aligned_buffer_64(dst_u_opt); \ | 748 free_aligned_buffer_64(dst_u_opt); \ |
751 free_aligned_buffer_64(dst_v_opt); \ | 749 free_aligned_buffer_64(dst_v_opt); \ |
752 free_aligned_buffer_64(src_argb); \ | 750 free_aligned_buffer_64(src_argb); \ |
753 } | 751 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 TESTATOPLANAR(UYVY, 2, 1, I422, 2, 1, 2) | 787 TESTATOPLANAR(UYVY, 2, 1, I422, 2, 1, 2) |
790 TESTATOPLANAR(I400, 1, 1, I420, 2, 2, 2) | 788 TESTATOPLANAR(I400, 1, 1, I420, 2, 2, 2) |
791 TESTATOPLANAR(J400, 1, 1, J420, 2, 2, 2) | 789 TESTATOPLANAR(J400, 1, 1, J420, 2, 2, 2) |
792 | 790 |
793 #define TESTATOBIPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 791 #define TESTATOBIPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
794 W1280, N, NEG, OFF) \ | 792 W1280, N, NEG, OFF) \ |
795 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ | 793 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ |
796 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 794 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
797 const int kHeight = benchmark_height_; \ | 795 const int kHeight = benchmark_height_; \ |
798 const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \ | 796 const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \ |
| 797 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
799 align_buffer_64(src_argb, kStride * kHeight + OFF); \ | 798 align_buffer_64(src_argb, kStride * kHeight + OFF); \ |
800 align_buffer_64(dst_y_c, kWidth * kHeight); \ | 799 align_buffer_64(dst_y_c, kWidth * kHeight); \ |
801 align_buffer_64(dst_uv_c, \ | 800 align_buffer_64(dst_uv_c, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
802 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ | |
803 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | |
804 align_buffer_64(dst_y_opt, kWidth * kHeight); \ | 801 align_buffer_64(dst_y_opt, kWidth * kHeight); \ |
805 align_buffer_64(dst_uv_opt, \ | 802 align_buffer_64(dst_uv_opt, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
806 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ | |
807 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | |
808 for (int i = 0; i < kHeight; ++i) \ | 803 for (int i = 0; i < kHeight; ++i) \ |
809 for (int j = 0; j < kStride; ++j) \ | 804 for (int j = 0; j < kStride; ++j) \ |
810 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \ | 805 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \ |
811 memset(dst_y_c, 1, kWidth * kHeight); \ | 806 memset(dst_y_c, 1, kWidth * kHeight); \ |
812 memset(dst_uv_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ | 807 memset(dst_uv_c, 2, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
813 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | |
814 memset(dst_y_opt, 101, kWidth * kHeight); \ | 808 memset(dst_y_opt, 101, kWidth * kHeight); \ |
815 memset(dst_uv_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ | 809 memset(dst_uv_opt, 102, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
816 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | |
817 MaskCpuFlags(disable_cpu_flags_); \ | 810 MaskCpuFlags(disable_cpu_flags_); \ |
818 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ | 811 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ |
819 dst_y_c, kWidth, \ | 812 dst_y_c, kWidth, dst_uv_c, kStrideUV * 2, \ |
820 dst_uv_c, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ | |
821 kWidth, NEG kHeight); \ | 813 kWidth, NEG kHeight); \ |
822 MaskCpuFlags(benchmark_cpu_info_); \ | 814 MaskCpuFlags(benchmark_cpu_info_); \ |
823 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 815 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
824 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ | 816 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ |
825 dst_y_opt, kWidth, \ | 817 dst_y_opt, kWidth, \ |
826 dst_uv_opt, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ | 818 dst_uv_opt, kStrideUV * 2, kWidth, NEG kHeight); \ |
827 kWidth, NEG kHeight); \ | |
828 } \ | 819 } \ |
829 int max_diff = 0; \ | 820 int max_diff = 0; \ |
830 for (int i = 0; i < kHeight; ++i) { \ | 821 for (int i = 0; i < kHeight; ++i) { \ |
831 for (int j = 0; j < kWidth; ++j) { \ | 822 for (int j = 0; j < kWidth; ++j) { \ |
832 int abs_diff = \ | 823 int abs_diff = \ |
833 abs(static_cast<int>(dst_y_c[i * kWidth + j]) - \ | 824 abs(static_cast<int>(dst_y_c[i * kWidth + j]) - \ |
834 static_cast<int>(dst_y_opt[i * kWidth + j])); \ | 825 static_cast<int>(dst_y_opt[i * kWidth + j])); \ |
835 if (abs_diff > max_diff) { \ | 826 if (abs_diff > max_diff) { \ |
836 max_diff = abs_diff; \ | 827 max_diff = abs_diff; \ |
837 } \ | 828 } \ |
838 } \ | 829 } \ |
839 } \ | 830 } \ |
840 EXPECT_LE(max_diff, 4); \ | 831 EXPECT_LE(max_diff, 4); \ |
841 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ | 832 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
842 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X) * 2; ++j) { \ | 833 for (int j = 0; j < kStrideUV * 2; ++j) { \ |
843 int abs_diff = \ | 834 int abs_diff = \ |
844 abs(static_cast<int>(dst_uv_c[i * \ | 835 abs(static_cast<int>(dst_uv_c[i * kStrideUV * 2 + j]) - \ |
845 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 + j]) - \ | 836 static_cast<int>(dst_uv_opt[i * kStrideUV * 2 + j])); \ |
846 static_cast<int>(dst_uv_opt[i * \ | |
847 SUBSAMPLE(kWidth, SUBSAMP_X) * 2 + j])); \ | |
848 if (abs_diff > max_diff) { \ | 837 if (abs_diff > max_diff) { \ |
849 max_diff = abs_diff; \ | 838 max_diff = abs_diff; \ |
850 } \ | 839 } \ |
851 } \ | 840 } \ |
852 } \ | 841 } \ |
853 EXPECT_LE(max_diff, 4); \ | 842 EXPECT_LE(max_diff, 4); \ |
854 free_aligned_buffer_64(dst_y_c); \ | 843 free_aligned_buffer_64(dst_y_c); \ |
855 free_aligned_buffer_64(dst_uv_c); \ | 844 free_aligned_buffer_64(dst_uv_c); \ |
856 free_aligned_buffer_64(dst_y_opt); \ | 845 free_aligned_buffer_64(dst_y_opt); \ |
857 free_aligned_buffer_64(dst_uv_opt); \ | 846 free_aligned_buffer_64(dst_uv_opt); \ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ | 920 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ |
932 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ | 921 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ |
933 src_argb[i] = (fastrand() & 0xff); \ | 922 src_argb[i] = (fastrand() & 0xff); \ |
934 } \ | 923 } \ |
935 memset(dst_argb_c, 123, kStrideB * kHeightB); \ | 924 memset(dst_argb_c, 123, kStrideB * kHeightB); \ |
936 memset(dst_argb_opt, 123, kStrideB * kHeightB); \ | 925 memset(dst_argb_opt, 123, kStrideB * kHeightB); \ |
937 MaskCpuFlags(disable_cpu_flags_); \ | 926 MaskCpuFlags(disable_cpu_flags_); \ |
938 FMT_A##To##FMT_B(src_argb, kStrideA, \ | 927 FMT_A##To##FMT_B(src_argb, kStrideA, \ |
939 dst_argb_c, kStrideB, \ | 928 dst_argb_c, kStrideB, \ |
940 kWidth, kHeight); \ | 929 kWidth, kHeight); \ |
941 MaskCpuFlags(benchmark_cpu_info_);
\ | 930 MaskCpuFlags(benchmark_cpu_info_); \ |
942 FMT_A##To##FMT_B(src_argb, kStrideA, \ | 931 FMT_A##To##FMT_B(src_argb, kStrideA, \ |
943 dst_argb_opt, kStrideB, \ | 932 dst_argb_opt, kStrideB, \ |
944 kWidth, kHeight); \ | 933 kWidth, kHeight); \ |
945 int max_diff = 0; \ | 934 int max_diff = 0; \ |
946 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ | 935 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ |
947 int abs_diff = \ | 936 int abs_diff = \ |
948 abs(static_cast<int>(dst_argb_c[i]) - \ | 937 abs(static_cast<int>(dst_argb_c[i]) - \ |
949 static_cast<int>(dst_argb_opt[i])); \ | 938 static_cast<int>(dst_argb_opt[i])); \ |
950 if (abs_diff > max_diff) { \ | 939 if (abs_diff > max_diff) { \ |
951 max_diff = abs_diff; \ | 940 max_diff = abs_diff; \ |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ | 1053 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ |
1065 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ | 1054 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ |
1066 src_argb[i] = (fastrand() & 0xff); \ | 1055 src_argb[i] = (fastrand() & 0xff); \ |
1067 } \ | 1056 } \ |
1068 memset(dst_argb_c, 123, kStrideB * kHeightB); \ | 1057 memset(dst_argb_c, 123, kStrideB * kHeightB); \ |
1069 memset(dst_argb_opt, 123, kStrideB * kHeightB); \ | 1058 memset(dst_argb_opt, 123, kStrideB * kHeightB); \ |
1070 MaskCpuFlags(disable_cpu_flags_); \ | 1059 MaskCpuFlags(disable_cpu_flags_); \ |
1071 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \ | 1060 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \ |
1072 dst_argb_c, kStrideB, \ | 1061 dst_argb_c, kStrideB, \ |
1073 NULL, kWidth, kHeight); \ | 1062 NULL, kWidth, kHeight); \ |
1074 MaskCpuFlags(benchmark_cpu_info_);
\ | 1063 MaskCpuFlags(benchmark_cpu_info_); \ |
1075 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \ | 1064 FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \ |
1076 dst_argb_opt, kStrideB, \ | 1065 dst_argb_opt, kStrideB, \ |
1077 NULL, kWidth, kHeight); \ | 1066 NULL, kWidth, kHeight); \ |
1078 int max_diff = 0; \ | 1067 int max_diff = 0; \ |
1079 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ | 1068 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ |
1080 int abs_diff = \ | 1069 int abs_diff = \ |
1081 abs(static_cast<int>(dst_argb_c[i]) - \ | 1070 abs(static_cast<int>(dst_argb_c[i]) - \ |
1082 static_cast<int>(dst_argb_opt[i])); \ | 1071 static_cast<int>(dst_argb_opt[i])); \ |
1083 if (abs_diff > max_diff) { \ | 1072 if (abs_diff > max_diff) { \ |
1084 max_diff = abs_diff; \ | 1073 max_diff = abs_diff; \ |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 | 1348 |
1360 TEST_F(LibYUVConvertTest, CropNV12) { | 1349 TEST_F(LibYUVConvertTest, CropNV12) { |
1361 const int SUBSAMP_X = 2; | 1350 const int SUBSAMP_X = 2; |
1362 const int SUBSAMP_Y = 2; | 1351 const int SUBSAMP_Y = 2; |
1363 const int kWidth = benchmark_width_; | 1352 const int kWidth = benchmark_width_; |
1364 const int kHeight = benchmark_height_; | 1353 const int kHeight = benchmark_height_; |
1365 const int crop_y = | 1354 const int crop_y = |
1366 ((benchmark_height_ - (benchmark_height_ * 360 / 480)) / 2 + 1) & ~1; | 1355 ((benchmark_height_ - (benchmark_height_ * 360 / 480)) / 2 + 1) & ~1; |
1367 const int kDestWidth = benchmark_width_; | 1356 const int kDestWidth = benchmark_width_; |
1368 const int kDestHeight = benchmark_height_ - crop_y * 2; | 1357 const int kDestHeight = benchmark_height_ - crop_y * 2; |
| 1358 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); |
1369 const int sample_size = kWidth * kHeight + | 1359 const int sample_size = kWidth * kHeight + |
1370 SUBSAMPLE(kWidth, SUBSAMP_X) * | 1360 kStrideUV * |
1371 SUBSAMPLE(kHeight, SUBSAMP_Y) * 2; | 1361 SUBSAMPLE(kHeight, SUBSAMP_Y) * 2; |
1372 align_buffer_64(src_y, sample_size); | 1362 align_buffer_64(src_y, sample_size); |
1373 uint8* src_uv = src_y + kWidth * kHeight; | 1363 uint8* src_uv = src_y + kWidth * kHeight; |
1374 | 1364 |
1375 align_buffer_64(dst_y, kDestWidth * kDestHeight); | 1365 align_buffer_64(dst_y, kDestWidth * kDestHeight); |
1376 align_buffer_64(dst_u, | 1366 align_buffer_64(dst_u, |
1377 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1367 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1378 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1368 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1379 align_buffer_64(dst_v, | 1369 align_buffer_64(dst_v, |
1380 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1370 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1381 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1371 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1382 | 1372 |
1383 align_buffer_64(dst_y_2, kDestWidth * kDestHeight); | 1373 align_buffer_64(dst_y_2, kDestWidth * kDestHeight); |
1384 align_buffer_64(dst_u_2, | 1374 align_buffer_64(dst_u_2, |
1385 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1375 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1386 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1376 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1387 align_buffer_64(dst_v_2, | 1377 align_buffer_64(dst_v_2, |
1388 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1378 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1389 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1379 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1390 | 1380 |
1391 for (int i = 0; i < kHeight * kWidth; ++i) { | 1381 for (int i = 0; i < kHeight * kWidth; ++i) { |
1392 src_y[i] = (fastrand() & 0xff); | 1382 src_y[i] = (fastrand() & 0xff); |
1393 } | 1383 } |
1394 for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) * | 1384 for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) * |
1395 SUBSAMPLE(kWidth, SUBSAMP_X)) * 2; ++i) { | 1385 kStrideUV) * 2; ++i) { |
1396 src_uv[i] = (fastrand() & 0xff); | 1386 src_uv[i] = (fastrand() & 0xff); |
1397 } | 1387 } |
1398 memset(dst_y, 1, kDestWidth * kDestHeight); | 1388 memset(dst_y, 1, kDestWidth * kDestHeight); |
1399 memset(dst_u, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1389 memset(dst_u, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1400 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1390 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1401 memset(dst_v, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1391 memset(dst_v, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1402 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1392 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1403 memset(dst_y_2, 1, kDestWidth * kDestHeight); | 1393 memset(dst_y_2, 1, kDestWidth * kDestHeight); |
1404 memset(dst_u_2, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1394 memset(dst_u_2, 2, SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1405 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1395 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1406 memset(dst_v_2, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1396 memset(dst_v_2, 3, SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1407 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1397 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1408 | 1398 |
1409 ConvertToI420(src_y, sample_size, | 1399 ConvertToI420(src_y, sample_size, |
1410 dst_y_2, kDestWidth, | 1400 dst_y_2, kDestWidth, |
1411 dst_u_2, SUBSAMPLE(kDestWidth, SUBSAMP_X), | 1401 dst_u_2, SUBSAMPLE(kDestWidth, SUBSAMP_X), |
1412 dst_v_2, SUBSAMPLE(kDestWidth, SUBSAMP_X), | 1402 dst_v_2, SUBSAMPLE(kDestWidth, SUBSAMP_X), |
1413 0, crop_y, | 1403 0, crop_y, |
1414 kWidth, kHeight, | 1404 kWidth, kHeight, |
1415 kDestWidth, kDestHeight, | 1405 kDestWidth, kDestHeight, |
1416 libyuv::kRotate0, libyuv::FOURCC_NV12); | 1406 libyuv::kRotate0, libyuv::FOURCC_NV12); |
1417 | 1407 |
1418 NV12ToI420(src_y + crop_y * kWidth, kWidth, | 1408 NV12ToI420(src_y + crop_y * kWidth, kWidth, |
1419 src_uv + (crop_y / 2) * SUBSAMPLE(kWidth, SUBSAMP_X) * 2, | 1409 src_uv + (crop_y / 2) * kStrideUV * 2, |
1420 SUBSAMPLE(kWidth, SUBSAMP_X) * 2, | 1410 kStrideUV * 2, |
1421 dst_y, kDestWidth, | 1411 dst_y, kDestWidth, |
1422 dst_u, SUBSAMPLE(kDestWidth, SUBSAMP_X), | 1412 dst_u, SUBSAMPLE(kDestWidth, SUBSAMP_X), |
1423 dst_v, SUBSAMPLE(kDestWidth, SUBSAMP_X), | 1413 dst_v, SUBSAMPLE(kDestWidth, SUBSAMP_X), |
1424 kDestWidth, kDestHeight); | 1414 kDestWidth, kDestHeight); |
1425 | 1415 |
1426 for (int i = 0; i < kDestHeight; ++i) { | 1416 for (int i = 0; i < kDestHeight; ++i) { |
1427 for (int j = 0; j < kDestWidth; ++j) { | 1417 for (int j = 0; j < kDestWidth; ++j) { |
1428 EXPECT_EQ(dst_y[i * kWidth + j], dst_y_2[i * kWidth + j]); | 1418 EXPECT_EQ(dst_y[i * kWidth + j], dst_y_2[i * kWidth + j]); |
1429 } | 1419 } |
1430 } | 1420 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 free_aligned_buffer_64(dst_argb); | 1531 free_aligned_buffer_64(dst_argb); |
1542 free_aligned_buffer_64(dst_argbdither); | 1532 free_aligned_buffer_64(dst_argbdither); |
1543 } | 1533 } |
1544 | 1534 |
1545 #define TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 1535 #define TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
1546 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ | 1536 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ |
1547 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##Dither##N) { \ | 1537 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##Dither##N) { \ |
1548 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1538 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1549 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 1539 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
1550 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ | 1540 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ |
1551 const int kSizeUV = \ | 1541 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
1552 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 1542 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
1553 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 1543 align_buffer_64(src_y, kWidth * kHeight + OFF); \ |
1554 align_buffer_64(src_u, kSizeUV + OFF); \ | 1544 align_buffer_64(src_u, kSizeUV + OFF); \ |
1555 align_buffer_64(src_v, kSizeUV + OFF); \ | 1545 align_buffer_64(src_v, kSizeUV + OFF); \ |
1556 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ | 1546 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ |
1557 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ | 1547 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ |
1558 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 1548 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1559 src_y[i + OFF] = (fastrand() & 0xff); \ | 1549 src_y[i + OFF] = (fastrand() & 0xff); \ |
1560 } \ | 1550 } \ |
1561 for (int i = 0; i < kSizeUV; ++i) { \ | 1551 for (int i = 0; i < kSizeUV; ++i) { \ |
1562 src_u[i + OFF] = (fastrand() & 0xff); \ | 1552 src_u[i + OFF] = (fastrand() & 0xff); \ |
1563 src_v[i + OFF] = (fastrand() & 0xff); \ | 1553 src_v[i + OFF] = (fastrand() & 0xff); \ |
1564 } \ | 1554 } \ |
1565 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ | 1555 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ |
1566 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ | 1556 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ |
1567 MaskCpuFlags(disable_cpu_flags_); \ | 1557 MaskCpuFlags(disable_cpu_flags_); \ |
1568 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ | 1558 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ |
1569 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1559 src_u + OFF, kStrideUV, \ |
1570 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1560 src_v + OFF, kStrideUV, \ |
1571 dst_argb_c + OFF, kStrideB, \ | 1561 dst_argb_c + OFF, kStrideB, \ |
1572 NULL, kWidth, NEG kHeight); \ | 1562 NULL, kWidth, NEG kHeight); \ |
1573 MaskCpuFlags(benchmark_cpu_info_); \ | 1563 MaskCpuFlags(benchmark_cpu_info_); \ |
1574 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1564 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1575 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ | 1565 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ |
1576 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1566 src_u + OFF, kStrideUV, \ |
1577 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1567 src_v + OFF, kStrideUV, \ |
1578 dst_argb_opt + OFF, kStrideB, \ | 1568 dst_argb_opt + OFF, kStrideB, \ |
1579 NULL, kWidth, NEG kHeight); \ | 1569 NULL, kWidth, NEG kHeight); \ |
1580 } \ | 1570 } \ |
1581 int max_diff = 0; \ | 1571 int max_diff = 0; \ |
1582 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ | 1572 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ |
1583 align_buffer_64(dst_argb32_c, kWidth * BPP_C * kHeight); \ | 1573 align_buffer_64(dst_argb32_c, kWidth * BPP_C * kHeight); \ |
1584 align_buffer_64(dst_argb32_opt, kWidth * BPP_C * kHeight); \ | 1574 align_buffer_64(dst_argb32_opt, kWidth * BPP_C * kHeight); \ |
1585 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ | 1575 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ |
1586 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ | 1576 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ |
1587 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ | 1577 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 | 1681 |
1692 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) | 1682 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) |
1693 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) | 1683 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) |
1694 | 1684 |
1695 #define TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 1685 #define TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
1696 W1280, N, NEG, OFF, FMT_C, BPP_C) \ | 1686 W1280, N, NEG, OFF, FMT_C, BPP_C) \ |
1697 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##_##FMT_C##N) { \ | 1687 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##_##FMT_C##N) { \ |
1698 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1688 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1699 const int kHeight = benchmark_height_; \ | 1689 const int kHeight = benchmark_height_; \ |
1700 const int kStrideB = kWidth * BPP_B; \ | 1690 const int kStrideB = kWidth * BPP_B; \ |
1701 const int kSizeUV = \ | 1691 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
1702 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 1692 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
1703 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 1693 align_buffer_64(src_y, kWidth * kHeight + OFF); \ |
1704 align_buffer_64(src_u, kSizeUV + OFF); \ | 1694 align_buffer_64(src_u, kSizeUV + OFF); \ |
1705 align_buffer_64(src_v, kSizeUV + OFF); \ | 1695 align_buffer_64(src_v, kSizeUV + OFF); \ |
1706 align_buffer_64(dst_argb_b, kStrideB * kHeight + OFF); \ | 1696 align_buffer_64(dst_argb_b, kStrideB * kHeight + OFF); \ |
1707 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 1697 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1708 src_y[i + OFF] = (fastrand() & 0xff); \ | 1698 src_y[i + OFF] = (fastrand() & 0xff); \ |
1709 } \ | 1699 } \ |
1710 for (int i = 0; i < kSizeUV; ++i) { \ | 1700 for (int i = 0; i < kSizeUV; ++i) { \ |
1711 src_u[i + OFF] = (fastrand() & 0xff); \ | 1701 src_u[i + OFF] = (fastrand() & 0xff); \ |
1712 src_v[i + OFF] = (fastrand() & 0xff); \ | 1702 src_v[i + OFF] = (fastrand() & 0xff); \ |
1713 } \ | 1703 } \ |
1714 memset(dst_argb_b + OFF, 1, kStrideB * kHeight); \ | 1704 memset(dst_argb_b + OFF, 1, kStrideB * kHeight); \ |
1715 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1705 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1716 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 1706 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
1717 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1707 src_u + OFF, kStrideUV, \ |
1718 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1708 src_v + OFF, kStrideUV, \ |
1719 dst_argb_b + OFF, kStrideB, \ | 1709 dst_argb_b + OFF, kStrideB, \ |
1720 kWidth, NEG kHeight); \ | 1710 kWidth, NEG kHeight); \ |
1721 } \ | 1711 } \ |
1722 int max_diff = 0; \ | 1712 int max_diff = 0; \ |
1723 /* Convert to a 3rd format in 1 step and 2 steps and compare */ \ | 1713 /* Convert to a 3rd format in 1 step and 2 steps and compare */ \ |
1724 const int kStrideC = kWidth * BPP_C; \ | 1714 const int kStrideC = kWidth * BPP_C; \ |
1725 align_buffer_64(dst_argb_c, kStrideC * kHeight + OFF); \ | 1715 align_buffer_64(dst_argb_c, kStrideC * kHeight + OFF); \ |
1726 align_buffer_64(dst_argb_bc, kStrideC * kHeight + OFF); \ | 1716 align_buffer_64(dst_argb_bc, kStrideC * kHeight + OFF); \ |
1727 memset(dst_argb_c + OFF, 2, kStrideC * kHeight); \ | 1717 memset(dst_argb_c + OFF, 2, kStrideC * kHeight); \ |
1728 memset(dst_argb_bc + OFF, 3, kStrideC * kHeight); \ | 1718 memset(dst_argb_bc + OFF, 3, kStrideC * kHeight); \ |
1729 FMT_PLANAR##To##FMT_C(src_y + OFF, kWidth, \ | 1719 FMT_PLANAR##To##FMT_C(src_y + OFF, kWidth, \ |
1730 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1720 src_u + OFF, kStrideUV, \ |
1731 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1721 src_v + OFF, kStrideUV, \ |
1732 dst_argb_c + OFF, kStrideC, \ | 1722 dst_argb_c + OFF, kStrideC, \ |
1733 kWidth, NEG kHeight); \ | 1723 kWidth, NEG kHeight); \ |
1734 /* Convert B to C */ \ | 1724 /* Convert B to C */ \ |
1735 FMT_B##To##FMT_C(dst_argb_b + OFF, kStrideB, \ | 1725 FMT_B##To##FMT_C(dst_argb_b + OFF, kStrideB, \ |
1736 dst_argb_bc + OFF, kStrideC, \ | 1726 dst_argb_bc + OFF, kStrideC, \ |
1737 kWidth, kHeight); \ | 1727 kWidth, kHeight); \ |
1738 for (int i = 0; i < kStrideC * kHeight; ++i) { \ | 1728 for (int i = 0; i < kStrideC * kHeight; ++i) { \ |
1739 EXPECT_EQ(dst_argb_c[i + OFF], dst_argb_bc[i + OFF]); \ | 1729 EXPECT_EQ(dst_argb_c[i + OFF], dst_argb_bc[i + OFF]); \ |
1740 } \ | 1730 } \ |
1741 free_aligned_buffer_64(src_y); \ | 1731 free_aligned_buffer_64(src_y); \ |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \ | 1851 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \ |
1862 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 1852 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
1863 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \ | 1853 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \ |
1864 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 1854 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
1865 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1) | 1855 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1) |
1866 | 1856 |
1867 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 4, ABGR, 4) | 1857 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 4, ABGR, 4) |
1868 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 4, ARGB, 4) | 1858 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 4, ARGB, 4) |
1869 | 1859 |
1870 } // namespace libyuv | 1860 } // namespace libyuv |
OLD | NEW |