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 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 free_aligned_buffer_64(orig_v); \ | 1684 free_aligned_buffer_64(orig_v); \ |
1685 free_aligned_buffer_64(dst_y_orig); \ | 1685 free_aligned_buffer_64(dst_y_orig); \ |
1686 free_aligned_buffer_64(dst_uv_orig); \ | 1686 free_aligned_buffer_64(dst_uv_orig); \ |
1687 free_aligned_buffer_64(dst_y); \ | 1687 free_aligned_buffer_64(dst_y); \ |
1688 free_aligned_buffer_64(dst_uv); \ | 1688 free_aligned_buffer_64(dst_uv); \ |
1689 } | 1689 } |
1690 | 1690 |
1691 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) | 1691 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) |
1692 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) | 1692 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) |
1693 | 1693 |
1694 TEST_F(LibYUVConvertTest, TestI444ToABGRvsARGB) { | 1694 #define TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
1695 align_buffer_64(src_y, benchmark_width_ * benchmark_height_); | 1695 W1280, N, NEG, OFF, FMT_C, BPP_C) \ |
1696 align_buffer_64(src_u, benchmark_width_ * benchmark_height_); | 1696 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##_##FMT_C##N) { \ |
1697 align_buffer_64(src_v, benchmark_width_ * benchmark_height_); | 1697 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1698 align_buffer_64(dst_argb, benchmark_width_ * benchmark_height_ * 4); | 1698 const int kHeight = benchmark_height_; \ |
1699 align_buffer_64(dst_abgr, benchmark_width_ * benchmark_height_ * 4); | 1699 const int kStrideB = kWidth * BPP_B; \ |
1700 MemRandomize(src_y, benchmark_width_ * benchmark_height_); | 1700 const int kSizeUV = \ |
1701 MemRandomize(src_u, benchmark_width_ * benchmark_height_); | 1701 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
1702 MemRandomize(src_v, benchmark_width_ * benchmark_height_); | 1702 align_buffer_64(src_y, kWidth * kHeight + OFF); \ |
1703 MemRandomize(dst_argb, benchmark_width_ * benchmark_height_ * 4); | 1703 align_buffer_64(src_u, kSizeUV + OFF); \ |
1704 MemRandomize(dst_abgr, benchmark_width_ * benchmark_height_ * 4); | 1704 align_buffer_64(src_v, kSizeUV + OFF); \ |
1705 libyuv::I444ToARGB(src_y, benchmark_width_, | 1705 align_buffer_64(dst_argb_b, kStrideB * kHeight + OFF); \ |
1706 src_u, benchmark_width_, | 1706 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1707 src_v, benchmark_width_, | 1707 src_y[i + OFF] = (fastrand() & 0xff); \ |
1708 dst_argb, benchmark_width_ * 4, | 1708 } \ |
1709 benchmark_width_, benchmark_height_); | 1709 for (int i = 0; i < kSizeUV; ++i) { \ |
1710 libyuv::I444ToABGR(src_y, benchmark_width_, | 1710 src_u[i + OFF] = (fastrand() & 0xff); \ |
1711 src_u, benchmark_width_, | 1711 src_v[i + OFF] = (fastrand() & 0xff); \ |
1712 src_v, benchmark_width_, | 1712 } \ |
1713 dst_abgr, benchmark_width_ * 4, | 1713 memset(dst_argb_b + OFF, 1, kStrideB * kHeight); \ |
1714 benchmark_width_, benchmark_height_); | 1714 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1715 // swap in place. | 1715 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
1716 libyuv::ABGRToARGB(dst_abgr, benchmark_width_ * 4, | 1716 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
1717 dst_abgr, benchmark_width_ * 4, | 1717 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
1718 benchmark_width_, benchmark_height_); | 1718 dst_argb_b + OFF, kStrideB, \ |
1719 for (int i = 0; i < benchmark_width_ * benchmark_height_ * 4; ++i) { | 1719 kWidth, NEG kHeight); \ |
1720 EXPECT_EQ(dst_abgr[i], dst_argb[i]); | 1720 } \ |
1721 } | 1721 int max_diff = 0; \ |
1722 free_aligned_buffer_64(src_y); | 1722 /* Convert to a 3rd format in 1 step and 2 steps and compare */ \ |
1723 free_aligned_buffer_64(src_u); | 1723 const int kStrideC = kWidth * BPP_C; \ |
1724 free_aligned_buffer_64(src_v); | 1724 align_buffer_64(dst_argb_c, kStrideC * kHeight + OFF); \ |
1725 free_aligned_buffer_64(dst_argb); | 1725 align_buffer_64(dst_argb_bc, kStrideC * kHeight + OFF); \ |
1726 free_aligned_buffer_64(dst_abgr); | 1726 memset(dst_argb_c + OFF, 2, kStrideC * kHeight); \ |
| 1727 memset(dst_argb_bc + OFF, 3, kStrideC * kHeight); \ |
| 1728 FMT_PLANAR##To##FMT_C(src_y + OFF, kWidth, \ |
| 1729 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
| 1730 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
| 1731 dst_argb_c + OFF, kStrideC, \ |
| 1732 kWidth, NEG kHeight); \ |
| 1733 /* Convert B to C */ \ |
| 1734 FMT_B##To##FMT_C(dst_argb_b + OFF, kStrideB, \ |
| 1735 dst_argb_bc + OFF, kStrideC, \ |
| 1736 kWidth, kHeight); \ |
| 1737 for (int i = 0; i < kStrideC * kHeight; ++i) { \ |
| 1738 EXPECT_EQ(dst_argb_c[i + OFF], dst_argb_bc[i + OFF]); \ |
| 1739 } \ |
| 1740 free_aligned_buffer_64(src_y); \ |
| 1741 free_aligned_buffer_64(src_u); \ |
| 1742 free_aligned_buffer_64(src_v); \ |
| 1743 free_aligned_buffer_64(dst_argb_b); \ |
| 1744 free_aligned_buffer_64(dst_argb_c); \ |
| 1745 free_aligned_buffer_64(dst_argb_bc); \ |
1727 } | 1746 } |
1728 | 1747 |
| 1748 #define TESTPLANARTOE(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
| 1749 FMT_C, BPP_C) \ |
| 1750 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
| 1751 benchmark_width_ - 4, _Any, +, 0, FMT_C, BPP_C) \ |
| 1752 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
| 1753 benchmark_width_, _Unaligned, +, 1, FMT_C, BPP_C) \ |
| 1754 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
| 1755 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C) \ |
| 1756 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
| 1757 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C) |
| 1758 |
| 1759 TESTPLANARTOE(I420, 2, 2, ARGB, 4, ABGR, 4) |
| 1760 TESTPLANARTOE(J420, 2, 2, ARGB, 4, ARGB, 4) |
| 1761 TESTPLANARTOE(J420, 2, 2, ABGR, 4, ARGB, 4) |
| 1762 TESTPLANARTOE(H420, 2, 2, ARGB, 4, ARGB, 4) |
| 1763 TESTPLANARTOE(H420, 2, 2, ABGR, 4, ARGB, 4) |
| 1764 TESTPLANARTOE(I420, 2, 2, BGRA, 4, ARGB, 4) |
| 1765 TESTPLANARTOE(I420, 2, 2, ABGR, 4, ARGB, 4) |
| 1766 TESTPLANARTOE(I420, 2, 2, RGBA, 4, ARGB, 4) |
| 1767 TESTPLANARTOE(I420, 2, 2, RGB24, 3, ARGB, 4) |
| 1768 // TESTPLANARTOE(I420, 2, 2, RGB24, 3, RAW, 3) |
| 1769 TESTPLANARTOE(I420, 2, 2, ARGB, 4, RAW, 3) |
| 1770 TESTPLANARTOE(I420, 2, 2, RAW, 3, ARGB, 4) |
| 1771 TESTPLANARTOE(I420, 2, 2, ARGB, 4, RGB565, 2) |
| 1772 TESTPLANARTOE(I420, 2, 2, ARGB, 4, ARGB1555, 2) |
| 1773 TESTPLANARTOE(I420, 2, 2, ARGB, 4, ARGB4444, 2) |
| 1774 TESTPLANARTOE(I422, 2, 1, ARGB, 4, ARGB, 4) |
| 1775 TESTPLANARTOE(J422, 2, 1, ARGB, 4, ARGB, 4) |
| 1776 TESTPLANARTOE(J422, 2, 1, ABGR, 4, ARGB, 4) |
| 1777 TESTPLANARTOE(H422, 2, 1, ARGB, 4, ARGB, 4) |
| 1778 TESTPLANARTOE(H422, 2, 1, ABGR, 4, ARGB, 4) |
| 1779 TESTPLANARTOE(I422, 2, 1, BGRA, 4, ARGB, 4) |
| 1780 TESTPLANARTOE(I422, 2, 1, ABGR, 4, ARGB, 4) |
| 1781 TESTPLANARTOE(I422, 2, 1, RGBA, 4, ARGB, 4) |
| 1782 TESTPLANARTOE(I411, 4, 1, ARGB, 4, ARGB, 4) |
| 1783 TESTPLANARTOE(I444, 1, 1, ARGB, 4, ARGB, 4) |
| 1784 TESTPLANARTOE(J444, 1, 1, ARGB, 4, ARGB, 4) |
| 1785 TESTPLANARTOE(I444, 1, 1, ABGR, 4, ARGB, 4) |
| 1786 // TESTPLANARTOE(I420, 2, 2, YUY2, 2, ARGB, 4) |
| 1787 // TESTPLANARTOE(I420, 2, 2, UYVY, 2, ARGB, 4) |
| 1788 TESTPLANARTOE(I422, 2, 1, YUY2, 2, ARGB, 4) |
| 1789 TESTPLANARTOE(I422, 2, 1, UYVY, 2, ARGB, 4) |
| 1790 // TESTPLANARTOE(I420, 2, 2, ARGB, 4, I400, 1) |
| 1791 // TESTPLANARTOE(J420, 2, 2, ARGB, 4, J400, 1) |
| 1792 |
1729 } // namespace libyuv | 1793 } // namespace libyuv |
OLD | NEW |