OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2014 The WebRTC 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 |
| 11 #include <memory> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "libyuv/convert.h" | 14 #include "libyuv/convert.h" |
14 #include "libyuv/convert_from.h" | 15 #include "libyuv/convert_from.h" |
15 #include "libyuv/convert_from_argb.h" | 16 #include "libyuv/convert_from_argb.h" |
16 #include "libyuv/mjpeg_decoder.h" | 17 #include "libyuv/mjpeg_decoder.h" |
17 #include "libyuv/planar_functions.h" | 18 #include "libyuv/planar_functions.h" |
18 #include "webrtc/base/flags.h" | 19 #include "webrtc/base/flags.h" |
19 #include "webrtc/base/gunit.h" | 20 #include "webrtc/base/gunit.h" |
20 #include "webrtc/base/scoped_ptr.h" | |
21 #include "webrtc/media/base/testutils.h" | 21 #include "webrtc/media/base/testutils.h" |
22 #include "webrtc/media/base/videocommon.h" | 22 #include "webrtc/media/base/videocommon.h" |
23 | 23 |
24 // Undefine macros for the windows build. | 24 // Undefine macros for the windows build. |
25 #undef max | 25 #undef max |
26 #undef min | 26 #undef min |
27 | 27 |
28 using cricket::DumpPlanarYuvTestImage; | 28 using cricket::DumpPlanarYuvTestImage; |
29 | 29 |
30 DEFINE_bool(planarfunctions_dump, false, | 30 DEFINE_bool(planarfunctions_dump, false, |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 const testing::TestInfo* const test_info = | 462 const testing::TestInfo* const test_info = |
463 testing::UnitTest::GetInstance()->current_test_info(); | 463 testing::UnitTest::GetInstance()->current_test_info(); |
464 std::string test_name(test_info->name()); | 464 std::string test_name(test_info->name()); |
465 return test_name; | 465 return test_name; |
466 } | 466 } |
467 | 467 |
468 bool dump_; | 468 bool dump_; |
469 int repeat_; | 469 int repeat_; |
470 | 470 |
471 // Y, U, V and R, G, B channels of testing colors. | 471 // Y, U, V and R, G, B channels of testing colors. |
472 rtc::scoped_ptr<uint8_t[]> testing_color_y_; | 472 std::unique_ptr<uint8_t[]> testing_color_y_; |
473 rtc::scoped_ptr<uint8_t[]> testing_color_u_; | 473 std::unique_ptr<uint8_t[]> testing_color_u_; |
474 rtc::scoped_ptr<uint8_t[]> testing_color_v_; | 474 std::unique_ptr<uint8_t[]> testing_color_v_; |
475 rtc::scoped_ptr<uint8_t[]> testing_color_r_; | 475 std::unique_ptr<uint8_t[]> testing_color_r_; |
476 rtc::scoped_ptr<uint8_t[]> testing_color_g_; | 476 std::unique_ptr<uint8_t[]> testing_color_g_; |
477 rtc::scoped_ptr<uint8_t[]> testing_color_b_; | 477 std::unique_ptr<uint8_t[]> testing_color_b_; |
478 }; | 478 }; |
479 | 479 |
480 TEST_F(PlanarFunctionsTest, I420Copy) { | 480 TEST_F(PlanarFunctionsTest, I420Copy) { |
481 uint8_t* y_pointer = nullptr; | 481 uint8_t* y_pointer = nullptr; |
482 uint8_t* u_pointer = nullptr; | 482 uint8_t* u_pointer = nullptr; |
483 uint8_t* v_pointer = nullptr; | 483 uint8_t* v_pointer = nullptr; |
484 int y_pitch = kWidth; | 484 int y_pitch = kWidth; |
485 int u_pitch = (kWidth + 1) >> 1; | 485 int u_pitch = (kWidth + 1) >> 1; |
486 int v_pitch = (kWidth + 1) >> 1; | 486 int v_pitch = (kWidth + 1) >> 1; |
487 int y_size = kHeight * kWidth; | 487 int y_size = kHeight * kWidth; |
488 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); | 488 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
489 int block_size = 3; | 489 int block_size = 3; |
490 // Generate a fake input image. | 490 // Generate a fake input image. |
491 rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( | 491 std::unique_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
492 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, | 492 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
493 v_pointer)); | 493 v_pointer)); |
494 // Allocate space for the output image. | 494 // Allocate space for the output image. |
495 rtc::scoped_ptr<uint8_t[]> yuv_output( | 495 std::unique_ptr<uint8_t[]> yuv_output( |
496 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); | 496 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); |
497 uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); | 497 uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); |
498 uint8_t* u_output_pointer = y_output_pointer + y_size; | 498 uint8_t* u_output_pointer = y_output_pointer + y_size; |
499 uint8_t* v_output_pointer = u_output_pointer + uv_size; | 499 uint8_t* v_output_pointer = u_output_pointer + uv_size; |
500 | 500 |
501 for (int i = 0; i < repeat_; ++i) { | 501 for (int i = 0; i < repeat_; ++i) { |
502 libyuv::I420Copy(y_pointer, y_pitch, | 502 libyuv::I420Copy(y_pointer, y_pitch, |
503 u_pointer, u_pitch, | 503 u_pointer, u_pitch, |
504 v_pointer, v_pitch, | 504 v_pointer, v_pitch, |
505 y_output_pointer, y_pitch, | 505 y_output_pointer, y_pitch, |
(...skipping 13 matching lines...) Expand all Loading... |
519 uint8_t* y_pointer = nullptr; | 519 uint8_t* y_pointer = nullptr; |
520 uint8_t* u_pointer = nullptr; | 520 uint8_t* u_pointer = nullptr; |
521 uint8_t* v_pointer = nullptr; | 521 uint8_t* v_pointer = nullptr; |
522 int y_pitch = kWidth; | 522 int y_pitch = kWidth; |
523 int u_pitch = (kWidth + 1) >> 1; | 523 int u_pitch = (kWidth + 1) >> 1; |
524 int v_pitch = (kWidth + 1) >> 1; | 524 int v_pitch = (kWidth + 1) >> 1; |
525 int y_size = kHeight * kWidth; | 525 int y_size = kHeight * kWidth; |
526 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); | 526 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
527 int block_size = 2; | 527 int block_size = 2; |
528 // Generate a fake input image. | 528 // Generate a fake input image. |
529 rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( | 529 std::unique_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
530 kHeight, kWidth, block_size, libyuv::kJpegYuv422, y_pointer, u_pointer, | 530 kHeight, kWidth, block_size, libyuv::kJpegYuv422, y_pointer, u_pointer, |
531 v_pointer)); | 531 v_pointer)); |
532 // Allocate space for the output image. | 532 // Allocate space for the output image. |
533 rtc::scoped_ptr<uint8_t[]> yuv_output( | 533 std::unique_ptr<uint8_t[]> yuv_output( |
534 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); | 534 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); |
535 uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); | 535 uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); |
536 uint8_t* u_output_pointer = y_output_pointer + y_size; | 536 uint8_t* u_output_pointer = y_output_pointer + y_size; |
537 uint8_t* v_output_pointer = u_output_pointer + uv_size; | 537 uint8_t* v_output_pointer = u_output_pointer + uv_size; |
538 // Generate the expected output. | 538 // Generate the expected output. |
539 uint8_t* y_expected_pointer = nullptr; | 539 uint8_t* y_expected_pointer = nullptr; |
540 uint8_t* u_expected_pointer = nullptr; | 540 uint8_t* u_expected_pointer = nullptr; |
541 uint8_t* v_expected_pointer = nullptr; | 541 uint8_t* v_expected_pointer = nullptr; |
542 rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( | 542 std::unique_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( |
543 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, | 543 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, |
544 u_expected_pointer, v_expected_pointer)); | 544 u_expected_pointer, v_expected_pointer)); |
545 | 545 |
546 for (int i = 0; i < repeat_; ++i) { | 546 for (int i = 0; i < repeat_; ++i) { |
547 libyuv::I422ToI420(y_pointer, y_pitch, | 547 libyuv::I422ToI420(y_pointer, y_pitch, |
548 u_pointer, u_pitch, | 548 u_pointer, u_pitch, |
549 v_pointer, v_pitch, | 549 v_pointer, v_pitch, |
550 y_output_pointer, y_pitch, | 550 y_output_pointer, y_pitch, |
551 u_output_pointer, u_pitch, | 551 u_output_pointer, u_pitch, |
552 v_output_pointer, v_pitch, | 552 v_output_pointer, v_pitch, |
(...skipping 14 matching lines...) Expand all Loading... |
567 int unalignment = GetParam(); | 567 int unalignment = GetParam(); |
568 uint8_t* m420_pointer = NULL; | 568 uint8_t* m420_pointer = NULL; |
569 int y_pitch = kWidth; | 569 int y_pitch = kWidth; |
570 int m420_pitch = kWidth; | 570 int m420_pitch = kWidth; |
571 int u_pitch = (kWidth + 1) >> 1; | 571 int u_pitch = (kWidth + 1) >> 1; |
572 int v_pitch = (kWidth + 1) >> 1; | 572 int v_pitch = (kWidth + 1) >> 1; |
573 int y_size = kHeight * kWidth; | 573 int y_size = kHeight * kWidth; |
574 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); | 574 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
575 int block_size = 2; | 575 int block_size = 2; |
576 // Generate a fake input image. | 576 // Generate a fake input image. |
577 rtc::scoped_ptr<uint8_t[]> yuv_input( | 577 std::unique_ptr<uint8_t[]> yuv_input( |
578 CreateFakeM420TestingImage(kHeight, kWidth, block_size, m420_pointer)); | 578 CreateFakeM420TestingImage(kHeight, kWidth, block_size, m420_pointer)); |
579 // Allocate space for the output image. | 579 // Allocate space for the output image. |
580 rtc::scoped_ptr<uint8_t[]> yuv_output( | 580 std::unique_ptr<uint8_t[]> yuv_output( |
581 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); | 581 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); |
582 uint8_t* y_output_pointer = | 582 uint8_t* y_output_pointer = |
583 ALIGNP(yuv_output.get(), kAlignment) + unalignment; | 583 ALIGNP(yuv_output.get(), kAlignment) + unalignment; |
584 uint8_t* u_output_pointer = y_output_pointer + y_size; | 584 uint8_t* u_output_pointer = y_output_pointer + y_size; |
585 uint8_t* v_output_pointer = u_output_pointer + uv_size; | 585 uint8_t* v_output_pointer = u_output_pointer + uv_size; |
586 // Generate the expected output. | 586 // Generate the expected output. |
587 uint8_t* y_expected_pointer = nullptr; | 587 uint8_t* y_expected_pointer = nullptr; |
588 uint8_t* u_expected_pointer = nullptr; | 588 uint8_t* u_expected_pointer = nullptr; |
589 uint8_t* v_expected_pointer = nullptr; | 589 uint8_t* v_expected_pointer = nullptr; |
590 rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( | 590 std::unique_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( |
591 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, | 591 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, |
592 u_expected_pointer, v_expected_pointer)); | 592 u_expected_pointer, v_expected_pointer)); |
593 | 593 |
594 for (int i = 0; i < repeat_; ++i) { | 594 for (int i = 0; i < repeat_; ++i) { |
595 libyuv::M420ToI420(m420_pointer, m420_pitch, | 595 libyuv::M420ToI420(m420_pointer, m420_pitch, |
596 y_output_pointer, y_pitch, | 596 y_output_pointer, y_pitch, |
597 u_output_pointer, u_pitch, | 597 u_output_pointer, u_pitch, |
598 v_output_pointer, v_pitch, | 598 v_output_pointer, v_pitch, |
599 kWidth, kHeight); | 599 kWidth, kHeight); |
600 } | 600 } |
(...skipping 12 matching lines...) Expand all Loading... |
613 uint8_t* y_pointer = nullptr; | 613 uint8_t* y_pointer = nullptr; |
614 uint8_t* uv_pointer = nullptr; | 614 uint8_t* uv_pointer = nullptr; |
615 int y_pitch = kWidth; | 615 int y_pitch = kWidth; |
616 int uv_pitch = 2 * ((kWidth + 1) >> 1); | 616 int uv_pitch = 2 * ((kWidth + 1) >> 1); |
617 int u_pitch = (kWidth + 1) >> 1; | 617 int u_pitch = (kWidth + 1) >> 1; |
618 int v_pitch = (kWidth + 1) >> 1; | 618 int v_pitch = (kWidth + 1) >> 1; |
619 int y_size = kHeight * kWidth; | 619 int y_size = kHeight * kWidth; |
620 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); | 620 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
621 int block_size = 2; | 621 int block_size = 2; |
622 // Generate a fake input image. | 622 // Generate a fake input image. |
623 rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeNV12TestingImage( | 623 std::unique_ptr<uint8_t[]> yuv_input(CreateFakeNV12TestingImage( |
624 kHeight, kWidth, block_size, y_pointer, uv_pointer)); | 624 kHeight, kWidth, block_size, y_pointer, uv_pointer)); |
625 // Allocate space for the output image. | 625 // Allocate space for the output image. |
626 rtc::scoped_ptr<uint8_t[]> yuv_output( | 626 std::unique_ptr<uint8_t[]> yuv_output( |
627 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); | 627 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); |
628 uint8_t* y_output_pointer = | 628 uint8_t* y_output_pointer = |
629 ALIGNP(yuv_output.get(), kAlignment) + unalignment; | 629 ALIGNP(yuv_output.get(), kAlignment) + unalignment; |
630 uint8_t* u_output_pointer = y_output_pointer + y_size; | 630 uint8_t* u_output_pointer = y_output_pointer + y_size; |
631 uint8_t* v_output_pointer = u_output_pointer + uv_size; | 631 uint8_t* v_output_pointer = u_output_pointer + uv_size; |
632 // Generate the expected output. | 632 // Generate the expected output. |
633 uint8_t* y_expected_pointer = nullptr; | 633 uint8_t* y_expected_pointer = nullptr; |
634 uint8_t* u_expected_pointer = nullptr; | 634 uint8_t* u_expected_pointer = nullptr; |
635 uint8_t* v_expected_pointer = nullptr; | 635 uint8_t* v_expected_pointer = nullptr; |
636 rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( | 636 std::unique_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( |
637 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, | 637 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, |
638 u_expected_pointer, v_expected_pointer)); | 638 u_expected_pointer, v_expected_pointer)); |
639 | 639 |
640 for (int i = 0; i < repeat_; ++i) { | 640 for (int i = 0; i < repeat_; ++i) { |
641 libyuv::NV12ToI420(y_pointer, y_pitch, | 641 libyuv::NV12ToI420(y_pointer, y_pitch, |
642 uv_pointer, uv_pitch, | 642 uv_pointer, uv_pitch, |
643 y_output_pointer, y_pitch, | 643 y_output_pointer, y_pitch, |
644 u_output_pointer, u_pitch, | 644 u_output_pointer, u_pitch, |
645 v_output_pointer, v_pitch, | 645 v_output_pointer, v_pitch, |
646 kWidth, kHeight); | 646 kWidth, kHeight); |
(...skipping 14 matching lines...) Expand all Loading... |
661 int unalignment = GetParam(); \ | 661 int unalignment = GetParam(); \ |
662 uint8_t* yuv_pointer = nullptr; \ | 662 uint8_t* yuv_pointer = nullptr; \ |
663 int yuv_pitch = 2 * ((kWidth + 1) & ~1); \ | 663 int yuv_pitch = 2 * ((kWidth + 1) & ~1); \ |
664 int y_pitch = kWidth; \ | 664 int y_pitch = kWidth; \ |
665 int u_pitch = (kWidth + 1) >> 1; \ | 665 int u_pitch = (kWidth + 1) >> 1; \ |
666 int v_pitch = (kWidth + 1) >> 1; \ | 666 int v_pitch = (kWidth + 1) >> 1; \ |
667 int y_size = kHeight * kWidth; \ | 667 int y_size = kHeight * kWidth; \ |
668 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); \ | 668 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); \ |
669 int block_size = 2; \ | 669 int block_size = 2; \ |
670 /* Generate a fake input image.*/ \ | 670 /* Generate a fake input image.*/ \ |
671 rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeInterleaveYuvTestingImage( \ | 671 std::unique_ptr<uint8_t[]> yuv_input(CreateFakeInterleaveYuvTestingImage( \ |
672 kHeight, kWidth, BLOCK_SIZE, yuv_pointer, FOURCC_##SRC_NAME)); \ | 672 kHeight, kWidth, BLOCK_SIZE, yuv_pointer, FOURCC_##SRC_NAME)); \ |
673 /* Allocate space for the output image.*/ \ | 673 /* Allocate space for the output image.*/ \ |
674 rtc::scoped_ptr<uint8_t[]> yuv_output( \ | 674 std::unique_ptr<uint8_t[]> yuv_output( \ |
675 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); \ | 675 new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); \ |
676 uint8_t* y_output_pointer = \ | 676 uint8_t* y_output_pointer = \ |
677 ALIGNP(yuv_output.get(), kAlignment) + unalignment; \ | 677 ALIGNP(yuv_output.get(), kAlignment) + unalignment; \ |
678 uint8_t* u_output_pointer = y_output_pointer + y_size; \ | 678 uint8_t* u_output_pointer = y_output_pointer + y_size; \ |
679 uint8_t* v_output_pointer = u_output_pointer + uv_size; \ | 679 uint8_t* v_output_pointer = u_output_pointer + uv_size; \ |
680 /* Generate the expected output.*/ \ | 680 /* Generate the expected output.*/ \ |
681 uint8_t* y_expected_pointer = nullptr; \ | 681 uint8_t* y_expected_pointer = nullptr; \ |
682 uint8_t* u_expected_pointer = nullptr; \ | 682 uint8_t* u_expected_pointer = nullptr; \ |
683 uint8_t* v_expected_pointer = nullptr; \ | 683 uint8_t* v_expected_pointer = nullptr; \ |
684 rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( \ | 684 std::unique_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( \ |
685 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, \ | 685 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, \ |
686 u_expected_pointer, v_expected_pointer)); \ | 686 u_expected_pointer, v_expected_pointer)); \ |
687 for (int i = 0; i < repeat_; ++i) { \ | 687 for (int i = 0; i < repeat_; ++i) { \ |
688 libyuv::SRC_NAME##ToI420(yuv_pointer, yuv_pitch, y_output_pointer, \ | 688 libyuv::SRC_NAME##ToI420(yuv_pointer, yuv_pitch, y_output_pointer, \ |
689 y_pitch, u_output_pointer, u_pitch, \ | 689 y_pitch, u_output_pointer, u_pitch, \ |
690 v_output_pointer, v_pitch, kWidth, kHeight); \ | 690 v_output_pointer, v_pitch, kWidth, kHeight); \ |
691 } \ | 691 } \ |
692 /* Compare the output frame with what is expected.*/ \ | 692 /* Compare the output frame with what is expected.*/ \ |
693 /* Note: MSE should be set to a larger threshold if an odd block width*/ \ | 693 /* Note: MSE should be set to a larger threshold if an odd block width*/ \ |
694 /* is used, since the conversion will be lossy.*/ \ | 694 /* is used, since the conversion will be lossy.*/ \ |
(...skipping 13 matching lines...) Expand all Loading... |
708 #define TEST_YUVTORGB(SRC_NAME, DST_NAME, JPG_TYPE, MSE, BLOCK_SIZE) \ | 708 #define TEST_YUVTORGB(SRC_NAME, DST_NAME, JPG_TYPE, MSE, BLOCK_SIZE) \ |
709 TEST_F(PlanarFunctionsTest, SRC_NAME##To##DST_NAME) { \ | 709 TEST_F(PlanarFunctionsTest, SRC_NAME##To##DST_NAME) { \ |
710 uint8_t* y_pointer = nullptr; \ | 710 uint8_t* y_pointer = nullptr; \ |
711 uint8_t* u_pointer = nullptr; \ | 711 uint8_t* u_pointer = nullptr; \ |
712 uint8_t* v_pointer = nullptr; \ | 712 uint8_t* v_pointer = nullptr; \ |
713 uint8_t* argb_expected_pointer = NULL; \ | 713 uint8_t* argb_expected_pointer = NULL; \ |
714 int y_pitch = kWidth; \ | 714 int y_pitch = kWidth; \ |
715 int u_pitch = (kWidth + 1) >> 1; \ | 715 int u_pitch = (kWidth + 1) >> 1; \ |
716 int v_pitch = (kWidth + 1) >> 1; \ | 716 int v_pitch = (kWidth + 1) >> 1; \ |
717 /* Generate a fake input image.*/ \ | 717 /* Generate a fake input image.*/ \ |
718 rtc::scoped_ptr<uint8_t[]> yuv_input( \ | 718 std::unique_ptr<uint8_t[]> yuv_input( \ |
719 CreateFakeYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, JPG_TYPE, \ | 719 CreateFakeYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, JPG_TYPE, \ |
720 y_pointer, u_pointer, v_pointer)); \ | 720 y_pointer, u_pointer, v_pointer)); \ |
721 /* Generate the expected output.*/ \ | 721 /* Generate the expected output.*/ \ |
722 rtc::scoped_ptr<uint8_t[]> argb_expected( \ | 722 std::unique_ptr<uint8_t[]> argb_expected( \ |
723 CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ | 723 CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ |
724 argb_expected_pointer, FOURCC_##DST_NAME)); \ | 724 argb_expected_pointer, FOURCC_##DST_NAME)); \ |
725 /* Allocate space for the output.*/ \ | 725 /* Allocate space for the output.*/ \ |
726 rtc::scoped_ptr<uint8_t[]> argb_output( \ | 726 std::unique_ptr<uint8_t[]> argb_output( \ |
727 new uint8_t[kHeight * kWidth * 4 + kAlignment]); \ | 727 new uint8_t[kHeight * kWidth * 4 + kAlignment]); \ |
728 uint8_t* argb_pointer = ALIGNP(argb_expected.get(), kAlignment); \ | 728 uint8_t* argb_pointer = ALIGNP(argb_expected.get(), kAlignment); \ |
729 for (int i = 0; i < repeat_; ++i) { \ | 729 for (int i = 0; i < repeat_; ++i) { \ |
730 libyuv::SRC_NAME##To##DST_NAME(y_pointer, y_pitch, u_pointer, u_pitch, \ | 730 libyuv::SRC_NAME##To##DST_NAME(y_pointer, y_pitch, u_pointer, u_pitch, \ |
731 v_pointer, v_pitch, argb_pointer, \ | 731 v_pointer, v_pitch, argb_pointer, \ |
732 kWidth * 4, kWidth, kHeight); \ | 732 kWidth * 4, kWidth, kHeight); \ |
733 } \ | 733 } \ |
734 EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ | 734 EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ |
735 kHeight* kWidth * 4, MSE)); \ | 735 kHeight* kWidth * 4, MSE)); \ |
736 if (dump_) { \ | 736 if (dump_) { \ |
(...skipping 16 matching lines...) Expand all Loading... |
753 | 753 |
754 TEST_F(PlanarFunctionsTest, I400ToARGB_Reference) { | 754 TEST_F(PlanarFunctionsTest, I400ToARGB_Reference) { |
755 uint8_t* y_pointer = nullptr; | 755 uint8_t* y_pointer = nullptr; |
756 uint8_t* u_pointer = nullptr; | 756 uint8_t* u_pointer = nullptr; |
757 uint8_t* v_pointer = nullptr; | 757 uint8_t* v_pointer = nullptr; |
758 int y_pitch = kWidth; | 758 int y_pitch = kWidth; |
759 int u_pitch = (kWidth + 1) >> 1; | 759 int u_pitch = (kWidth + 1) >> 1; |
760 int v_pitch = (kWidth + 1) >> 1; | 760 int v_pitch = (kWidth + 1) >> 1; |
761 int block_size = 3; | 761 int block_size = 3; |
762 // Generate a fake input image. | 762 // Generate a fake input image. |
763 rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( | 763 std::unique_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
764 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, | 764 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
765 v_pointer)); | 765 v_pointer)); |
766 // As the comparison standard, we convert a grayscale image (by setting both | 766 // As the comparison standard, we convert a grayscale image (by setting both |
767 // U and V channels to be 128) using an I420 converter. | 767 // U and V channels to be 128) using an I420 converter. |
768 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); | 768 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
769 | 769 |
770 rtc::scoped_ptr<uint8_t[]> uv(new uint8_t[uv_size + kAlignment]); | 770 std::unique_ptr<uint8_t[]> uv(new uint8_t[uv_size + kAlignment]); |
771 u_pointer = v_pointer = ALIGNP(uv.get(), kAlignment); | 771 u_pointer = v_pointer = ALIGNP(uv.get(), kAlignment); |
772 memset(u_pointer, 128, uv_size); | 772 memset(u_pointer, 128, uv_size); |
773 | 773 |
774 // Allocate space for the output image and generate the expected output. | 774 // Allocate space for the output image and generate the expected output. |
775 rtc::scoped_ptr<uint8_t[]> argb_expected( | 775 std::unique_ptr<uint8_t[]> argb_expected( |
776 new uint8_t[kHeight * kWidth * 4 + kAlignment]); | 776 new uint8_t[kHeight * kWidth * 4 + kAlignment]); |
777 rtc::scoped_ptr<uint8_t[]> argb_output( | 777 std::unique_ptr<uint8_t[]> argb_output( |
778 new uint8_t[kHeight * kWidth * 4 + kAlignment]); | 778 new uint8_t[kHeight * kWidth * 4 + kAlignment]); |
779 uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); | 779 uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); |
780 uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment); | 780 uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment); |
781 | 781 |
782 libyuv::I420ToARGB(y_pointer, y_pitch, | 782 libyuv::I420ToARGB(y_pointer, y_pitch, |
783 u_pointer, u_pitch, | 783 u_pointer, u_pitch, |
784 v_pointer, v_pitch, | 784 v_pointer, v_pitch, |
785 argb_expected_pointer, kWidth * 4, | 785 argb_expected_pointer, kWidth * 4, |
786 kWidth, kHeight); | 786 kWidth, kHeight); |
787 for (int i = 0; i < repeat_; ++i) { | 787 for (int i = 0; i < repeat_; ++i) { |
(...skipping 12 matching lines...) Expand all Loading... |
800 // Get the unalignment offset | 800 // Get the unalignment offset |
801 int unalignment = GetParam(); | 801 int unalignment = GetParam(); |
802 uint8_t* y_pointer = nullptr; | 802 uint8_t* y_pointer = nullptr; |
803 uint8_t* u_pointer = nullptr; | 803 uint8_t* u_pointer = nullptr; |
804 uint8_t* v_pointer = nullptr; | 804 uint8_t* v_pointer = nullptr; |
805 int y_pitch = kWidth; | 805 int y_pitch = kWidth; |
806 int u_pitch = (kWidth + 1) >> 1; | 806 int u_pitch = (kWidth + 1) >> 1; |
807 int v_pitch = (kWidth + 1) >> 1; | 807 int v_pitch = (kWidth + 1) >> 1; |
808 int block_size = 3; | 808 int block_size = 3; |
809 // Generate a fake input image. | 809 // Generate a fake input image. |
810 rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( | 810 std::unique_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
811 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, | 811 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
812 v_pointer)); | 812 v_pointer)); |
813 // As the comparison standard, we convert a grayscale image (by setting both | 813 // As the comparison standard, we convert a grayscale image (by setting both |
814 // U and V channels to be 128) using an I420 converter. | 814 // U and V channels to be 128) using an I420 converter. |
815 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); | 815 int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
816 | 816 |
817 // 1 byte extra if in the unaligned mode. | 817 // 1 byte extra if in the unaligned mode. |
818 rtc::scoped_ptr<uint8_t[]> uv(new uint8_t[uv_size * 2 + kAlignment]); | 818 std::unique_ptr<uint8_t[]> uv(new uint8_t[uv_size * 2 + kAlignment]); |
819 u_pointer = ALIGNP(uv.get(), kAlignment); | 819 u_pointer = ALIGNP(uv.get(), kAlignment); |
820 v_pointer = u_pointer + uv_size; | 820 v_pointer = u_pointer + uv_size; |
821 memset(u_pointer, 128, uv_size); | 821 memset(u_pointer, 128, uv_size); |
822 memset(v_pointer, 128, uv_size); | 822 memset(v_pointer, 128, uv_size); |
823 | 823 |
824 // Allocate space for the output image and generate the expected output. | 824 // Allocate space for the output image and generate the expected output. |
825 rtc::scoped_ptr<uint8_t[]> argb_expected( | 825 std::unique_ptr<uint8_t[]> argb_expected( |
826 new uint8_t[kHeight * kWidth * 4 + kAlignment]); | 826 new uint8_t[kHeight * kWidth * 4 + kAlignment]); |
827 // 1 byte extra if in the misalinged mode. | 827 // 1 byte extra if in the misalinged mode. |
828 rtc::scoped_ptr<uint8_t[]> argb_output( | 828 std::unique_ptr<uint8_t[]> argb_output( |
829 new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); | 829 new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); |
830 uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); | 830 uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); |
831 uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; | 831 uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; |
832 | 832 |
833 libyuv::I420ToARGB(y_pointer, y_pitch, | 833 libyuv::I420ToARGB(y_pointer, y_pitch, |
834 u_pointer, u_pitch, | 834 u_pointer, u_pitch, |
835 v_pointer, v_pitch, | 835 v_pointer, v_pitch, |
836 argb_expected_pointer, kWidth * 4, | 836 argb_expected_pointer, kWidth * 4, |
837 kWidth, kHeight); | 837 kWidth, kHeight); |
838 for (int i = 0; i < repeat_; ++i) { | 838 for (int i = 0; i < repeat_; ++i) { |
(...skipping 10 matching lines...) Expand all Loading... |
849 } | 849 } |
850 | 850 |
851 TEST_P(PlanarFunctionsTest, ARGBToI400) { | 851 TEST_P(PlanarFunctionsTest, ARGBToI400) { |
852 // Get the unalignment offset | 852 // Get the unalignment offset |
853 int unalignment = GetParam(); | 853 int unalignment = GetParam(); |
854 // Create a fake ARGB input image. | 854 // Create a fake ARGB input image. |
855 uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; | 855 uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; |
856 uint8_t* argb_pointer = NULL; | 856 uint8_t* argb_pointer = NULL; |
857 int block_size = 3; | 857 int block_size = 3; |
858 // Generate a fake input image. | 858 // Generate a fake input image. |
859 rtc::scoped_ptr<uint8_t[]> argb_input(CreateFakeArgbTestingImage( | 859 std::unique_ptr<uint8_t[]> argb_input(CreateFakeArgbTestingImage( |
860 kHeight, kWidth, block_size, argb_pointer, FOURCC_ARGB)); | 860 kHeight, kWidth, block_size, argb_pointer, FOURCC_ARGB)); |
861 // Generate the expected output. Only Y channel is used | 861 // Generate the expected output. Only Y channel is used |
862 rtc::scoped_ptr<uint8_t[]> yuv_expected(CreateFakeYuvTestingImage( | 862 std::unique_ptr<uint8_t[]> yuv_expected(CreateFakeYuvTestingImage( |
863 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, | 863 kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
864 v_pointer)); | 864 v_pointer)); |
865 // Allocate space for the Y output. | 865 // Allocate space for the Y output. |
866 rtc::scoped_ptr<uint8_t[]> y_output( | 866 std::unique_ptr<uint8_t[]> y_output( |
867 new uint8_t[kHeight * kWidth + kAlignment + unalignment]); | 867 new uint8_t[kHeight * kWidth + kAlignment + unalignment]); |
868 uint8_t* y_output_pointer = ALIGNP(y_output.get(), kAlignment) + unalignment; | 868 uint8_t* y_output_pointer = ALIGNP(y_output.get(), kAlignment) + unalignment; |
869 | 869 |
870 for (int i = 0; i < repeat_; ++i) { | 870 for (int i = 0; i < repeat_; ++i) { |
871 libyuv::ARGBToI400(argb_pointer, kWidth * 4, y_output_pointer, kWidth, | 871 libyuv::ARGBToI400(argb_pointer, kWidth * 4, y_output_pointer, kWidth, |
872 kWidth, kHeight); | 872 kWidth, kHeight); |
873 } | 873 } |
874 // Check if the output matches the input Y channel. | 874 // Check if the output matches the input Y channel. |
875 // Note: an empirical MSE tolerance 2.0 is used here for the probable | 875 // Note: an empirical MSE tolerance 2.0 is used here for the probable |
876 // error from float-to-uint8_t type conversion. | 876 // error from float-to-uint8_t type conversion. |
877 EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_pointer, | 877 EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_pointer, |
878 kHeight * kWidth, 2.)); | 878 kHeight * kWidth, 2.)); |
879 if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } | 879 if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } |
880 } | 880 } |
881 | 881 |
882 // A common macro for testing converting RAW, BG24, BGRA, and ABGR | 882 // A common macro for testing converting RAW, BG24, BGRA, and ABGR |
883 // to ARGB. | 883 // to ARGB. |
884 #define TEST_ARGB(SRC_NAME, FC_ID, BPP, BLOCK_SIZE) \ | 884 #define TEST_ARGB(SRC_NAME, FC_ID, BPP, BLOCK_SIZE) \ |
885 TEST_P(PlanarFunctionsTest, SRC_NAME##ToARGB) { \ | 885 TEST_P(PlanarFunctionsTest, SRC_NAME##ToARGB) { \ |
886 int unalignment = GetParam(); /* Get the unalignment offset.*/ \ | 886 int unalignment = GetParam(); /* Get the unalignment offset.*/ \ |
887 uint8_t* argb_expected_pointer = NULL, * src_pointer = NULL; \ | 887 uint8_t *argb_expected_pointer = NULL, *src_pointer = NULL; \ |
888 /* Generate a fake input image.*/ \ | 888 /* Generate a fake input image.*/ \ |
889 rtc::scoped_ptr<uint8_t[]> src_input(CreateFakeArgbTestingImage( \ | 889 std::unique_ptr<uint8_t[]> src_input(CreateFakeArgbTestingImage( \ |
890 kHeight, kWidth, BLOCK_SIZE, src_pointer, FOURCC_##FC_ID)); \ | 890 kHeight, kWidth, BLOCK_SIZE, src_pointer, FOURCC_##FC_ID)); \ |
891 /* Generate the expected output.*/ \ | 891 /* Generate the expected output.*/ \ |
892 rtc::scoped_ptr<uint8_t[]> argb_expected(CreateFakeArgbTestingImage( \ | 892 std::unique_ptr<uint8_t[]> argb_expected(CreateFakeArgbTestingImage( \ |
893 kHeight, kWidth, BLOCK_SIZE, argb_expected_pointer, FOURCC_ARGB)); \ | 893 kHeight, kWidth, BLOCK_SIZE, argb_expected_pointer, FOURCC_ARGB)); \ |
894 /* Allocate space for the output; 1 byte extra if in the unaligned mode.*/ \ | 894 /* Allocate space for the output; 1 byte extra if in the unaligned mode.*/ \ |
895 rtc::scoped_ptr<uint8_t[]> argb_output( \ | 895 std::unique_ptr<uint8_t[]> argb_output( \ |
896 new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); \ | 896 new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); \ |
897 uint8_t* argb_pointer = \ | 897 uint8_t* argb_pointer = \ |
898 ALIGNP(argb_output.get(), kAlignment) + unalignment; \ | 898 ALIGNP(argb_output.get(), kAlignment) + unalignment; \ |
899 for (int i = 0; i < repeat_; ++i) { \ | 899 for (int i = 0; i < repeat_; ++i) { \ |
900 libyuv::SRC_NAME##ToARGB(src_pointer, kWidth*(BPP), argb_pointer, \ | 900 libyuv::SRC_NAME##ToARGB(src_pointer, kWidth*(BPP), argb_pointer, \ |
901 kWidth * 4, kWidth, kHeight); \ | 901 kWidth * 4, kWidth, kHeight); \ |
902 } \ | 902 } \ |
903 /* Compare the result; expect identical.*/ \ | 903 /* Compare the result; expect identical.*/ \ |
904 EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ | 904 EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ |
905 kHeight* kWidth * 4, 1.e-6)); \ | 905 kHeight* kWidth * 4, 1.e-6)); \ |
(...skipping 10 matching lines...) Expand all Loading... |
916 // Parameter Test: The parameter is the unalignment offset. | 916 // Parameter Test: The parameter is the unalignment offset. |
917 // Aligned data for testing assembly versions. | 917 // Aligned data for testing assembly versions. |
918 INSTANTIATE_TEST_CASE_P(PlanarFunctionsAligned, PlanarFunctionsTest, | 918 INSTANTIATE_TEST_CASE_P(PlanarFunctionsAligned, PlanarFunctionsTest, |
919 ::testing::Values(0)); | 919 ::testing::Values(0)); |
920 | 920 |
921 // Purposely unalign the output argb pointer to test slow path (C version). | 921 // Purposely unalign the output argb pointer to test slow path (C version). |
922 INSTANTIATE_TEST_CASE_P(PlanarFunctionsMisaligned, PlanarFunctionsTest, | 922 INSTANTIATE_TEST_CASE_P(PlanarFunctionsMisaligned, PlanarFunctionsTest, |
923 ::testing::Values(1)); | 923 ::testing::Values(1)); |
924 | 924 |
925 } // namespace cricket | 925 } // namespace cricket |
OLD | NEW |