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

Side by Side Diff: unit_test/convert_test.cc

Issue 1367093002: I420Alpha row function in 1 pass (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 | « source/row_win.cc ('k') | no next file » | 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 TESTPLANARTOB(I444, 1, 1, ARGB, 4, 4, 1, 2, ARGB, 4) 511 TESTPLANARTOB(I444, 1, 1, ARGB, 4, 4, 1, 2, ARGB, 4)
512 TESTPLANARTOB(I444, 1, 1, ABGR, 4, 4, 1, 2, ARGB, 4) 512 TESTPLANARTOB(I444, 1, 1, ABGR, 4, 4, 1, 2, ARGB, 4)
513 TESTPLANARTOB(I420, 2, 2, YUY2, 2, 4, 1, 1, ARGB, 4) 513 TESTPLANARTOB(I420, 2, 2, YUY2, 2, 4, 1, 1, ARGB, 4)
514 TESTPLANARTOB(I420, 2, 2, UYVY, 2, 4, 1, 1, ARGB, 4) 514 TESTPLANARTOB(I420, 2, 2, UYVY, 2, 4, 1, 1, ARGB, 4)
515 TESTPLANARTOB(I422, 2, 1, YUY2, 2, 4, 1, 0, ARGB, 4) 515 TESTPLANARTOB(I422, 2, 1, YUY2, 2, 4, 1, 0, ARGB, 4)
516 TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4, 1, 0, ARGB, 4) 516 TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4, 1, 0, ARGB, 4)
517 TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 1, 0, ARGB, 4) 517 TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 1, 0, ARGB, 4)
518 TESTPLANARTOB(J420, 2, 2, J400, 1, 1, 1, 0, ARGB, 4) 518 TESTPLANARTOB(J420, 2, 2, J400, 1, 1, 1, 0, ARGB, 4)
519 519
520 #define TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ 520 #define TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
521 YALIGN, W1280, DIFF, N, NEG, OFF) \ 521 YALIGN, W1280, DIFF, N, NEG, OFF, ATTEN) \
522 TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ 522 TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
523 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 523 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
524 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ 524 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
525 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ 525 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \
526 const int kSizeUV = \ 526 const int kSizeUV = \
527 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ 527 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \
528 align_buffer_64(src_y, kWidth * kHeight + OFF); \ 528 align_buffer_64(src_y, kWidth * kHeight + OFF); \
529 align_buffer_64(src_u, kSizeUV + OFF); \ 529 align_buffer_64(src_u, kSizeUV + OFF); \
530 align_buffer_64(src_v, kSizeUV + OFF); \ 530 align_buffer_64(src_v, kSizeUV + OFF); \
531 align_buffer_64(src_a, kWidth * kHeight + OFF); \ 531 align_buffer_64(src_a, kWidth * kHeight + OFF); \
532 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ 532 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \
533 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ 533 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \
534 for (int i = 0; i < kWidth * kHeight; ++i) { \ 534 for (int i = 0; i < kWidth * kHeight; ++i) { \
535 src_y[i + OFF] = (fastrand() & 0xff); \ 535 src_y[i + OFF] = (fastrand() & 0xff); \
536 src_a[i + OFF] = (fastrand() & 0xff); \ 536 src_a[i + OFF] = (fastrand() & 0xff); \
537 } \ 537 } \
538 for (int i = 0; i < kSizeUV; ++i) { \ 538 for (int i = 0; i < kSizeUV; ++i) { \
539 src_u[i + OFF] = (fastrand() & 0xff); \ 539 src_u[i + OFF] = (fastrand() & 0xff); \
540 src_v[i + OFF] = (fastrand() & 0xff); \ 540 src_v[i + OFF] = (fastrand() & 0xff); \
541 } \ 541 } \
542 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ 542 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \
543 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ 543 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \
544 MaskCpuFlags(disable_cpu_flags_); \ 544 MaskCpuFlags(disable_cpu_flags_); \
545 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ 545 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
546 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 546 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
547 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 547 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
548 src_a + OFF, kWidth, \ 548 src_a + OFF, kWidth, \
549 dst_argb_c + OFF, kStrideB, \ 549 dst_argb_c + OFF, kStrideB, \
550 kWidth, NEG kHeight); \ 550 kWidth, NEG kHeight, ATTEN); \
551 MaskCpuFlags(-1); \ 551 MaskCpuFlags(-1); \
552 for (int i = 0; i < benchmark_iterations_; ++i) { \ 552 for (int i = 0; i < benchmark_iterations_; ++i) { \
553 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ 553 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
554 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 554 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
555 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ 555 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
556 src_a + OFF, kWidth, \ 556 src_a + OFF, kWidth, \
557 dst_argb_opt + OFF, kStrideB, \ 557 dst_argb_opt + OFF, kStrideB, \
558 kWidth, NEG kHeight); \ 558 kWidth, NEG kHeight, ATTEN); \
559 } \ 559 } \
560 int max_diff = 0; \ 560 int max_diff = 0; \
561 for (int i = 0; i < kWidth * BPP_B * kHeight; ++i) { \ 561 for (int i = 0; i < kWidth * BPP_B * kHeight; ++i) { \
562 int abs_diff = \ 562 int abs_diff = \
563 abs(static_cast<int>(dst_argb_c[i + OFF]) - \ 563 abs(static_cast<int>(dst_argb_c[i + OFF]) - \
564 static_cast<int>(dst_argb_opt[i + OFF])); \ 564 static_cast<int>(dst_argb_opt[i + OFF])); \
565 if (abs_diff > max_diff) { \ 565 if (abs_diff > max_diff) { \
566 max_diff = abs_diff; \ 566 max_diff = abs_diff; \
567 } \ 567 } \
568 } \ 568 } \
569 EXPECT_LE(max_diff, DIFF); \ 569 EXPECT_LE(max_diff, DIFF); \
570 free_aligned_buffer_64(src_y); \ 570 free_aligned_buffer_64(src_y); \
571 free_aligned_buffer_64(src_u); \ 571 free_aligned_buffer_64(src_u); \
572 free_aligned_buffer_64(src_v); \ 572 free_aligned_buffer_64(src_v); \
573 free_aligned_buffer_64(src_a); \ 573 free_aligned_buffer_64(src_a); \
574 free_aligned_buffer_64(dst_argb_c); \ 574 free_aligned_buffer_64(dst_argb_c); \
575 free_aligned_buffer_64(dst_argb_opt); \ 575 free_aligned_buffer_64(dst_argb_opt); \
576 } 576 }
577 577
578 #define TESTQPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ 578 #define TESTQPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
579 YALIGN, DIFF) \ 579 YALIGN, DIFF) \
580 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ 580 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
581 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0) \ 581 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, 0) \
582 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ 582 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
583 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1) \ 583 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, 0) \
584 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ 584 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
585 YALIGN, benchmark_width_, DIFF, _Invert, -, 0) \ 585 YALIGN, benchmark_width_, DIFF, _Invert, -, 0, 0) \
586 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ 586 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
587 YALIGN, benchmark_width_, DIFF, _Opt, +, 0) 587 YALIGN, benchmark_width_, DIFF, _Opt, +, 0, 0) \
588 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
589 YALIGN, benchmark_width_, DIFF, _Premult, +, 0, 1)
588 590
589 TESTQPLANARTOB(I420Alpha, 2, 2, ARGB, 4, 4, 1, 2) 591 TESTQPLANARTOB(I420Alpha, 2, 2, ARGB, 4, 4, 1, 2)
590 TESTQPLANARTOB(I420Alpha, 2, 2, ABGR, 4, 4, 1, 2) 592 TESTQPLANARTOB(I420Alpha, 2, 2, ABGR, 4, 4, 1, 2)
591 593
592 #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ 594 #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \
593 W1280, DIFF, N, NEG, OFF) \ 595 W1280, DIFF, N, NEG, OFF) \
594 TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ 596 TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
595 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 597 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
596 const int kHeight = benchmark_height_; \ 598 const int kHeight = benchmark_height_; \
597 const int kStrideB = kWidth * BPP_B; \ 599 const int kStrideB = kWidth * BPP_B; \
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 free_aligned_buffer_64(dst_y_orig); \ 1693 free_aligned_buffer_64(dst_y_orig); \
1692 free_aligned_buffer_64(dst_uv_orig); \ 1694 free_aligned_buffer_64(dst_uv_orig); \
1693 free_aligned_buffer_64(dst_y); \ 1695 free_aligned_buffer_64(dst_y); \
1694 free_aligned_buffer_64(dst_uv); \ 1696 free_aligned_buffer_64(dst_uv); \
1695 } 1697 }
1696 1698
1697 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) 1699 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12)
1698 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) 1700 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12)
1699 1701
1700 } // namespace libyuv 1702 } // namespace libyuv
OLDNEW
« no previous file with comments | « source/row_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698